@@ -51,33 +51,19 @@ static int cs35l56_mbox_send(struct cs35l56_private *cs35l56, unsigned int comma
5151 return 0 ;
5252}
5353
54- static int cs35l56_wait_dsp_ready (struct cs35l56_private * cs35l56 )
54+ static void cs35l56_wait_dsp_ready (struct cs35l56_private * cs35l56 )
5555{
56- int ret ;
57-
58- if (!cs35l56 -> fw_patched ) {
59- /* block until firmware download completes */
60- ret = wait_for_completion_timeout (& cs35l56 -> dsp_ready_completion ,
61- msecs_to_jiffies (25000 ));
62- if (!ret ) {
63- dev_err (cs35l56 -> dev , "dsp_ready_completion timeout\n" );
64- return - ETIMEDOUT ;
65- }
66- }
67-
68- return 0 ;
56+ /* Wait for patching to complete */
57+ flush_work (& cs35l56 -> dsp_work );
6958}
7059
7160static int cs35l56_dspwait_get_volsw (struct snd_kcontrol * kcontrol ,
7261 struct snd_ctl_elem_value * ucontrol )
7362{
7463 struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
7564 struct cs35l56_private * cs35l56 = snd_soc_component_get_drvdata (component );
76- int ret = cs35l56_wait_dsp_ready (cs35l56 );
77-
78- if (ret )
79- return ret ;
8065
66+ cs35l56_wait_dsp_ready (cs35l56 );
8167 return snd_soc_get_volsw (kcontrol , ucontrol );
8268}
8369
@@ -86,11 +72,8 @@ static int cs35l56_dspwait_put_volsw(struct snd_kcontrol *kcontrol,
8672{
8773 struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
8874 struct cs35l56_private * cs35l56 = snd_soc_component_get_drvdata (component );
89- int ret = cs35l56_wait_dsp_ready (cs35l56 );
90-
91- if (ret )
92- return ret ;
9375
76+ cs35l56_wait_dsp_ready (cs35l56 );
9477 return snd_soc_put_volsw (kcontrol , ucontrol );
9578}
9679
@@ -423,18 +406,19 @@ irqreturn_t cs35l56_irq(int irq, void *data)
423406}
424407EXPORT_SYMBOL_NS_GPL (cs35l56_irq , SND_SOC_CS35L56_CORE );
425408
426- int cs35l56_irq_request (struct cs35l56_private * cs35l56 )
409+ int cs35l56_irq_request (struct cs35l56_private * cs35l56 , int irq )
427410{
428411 int ret ;
429412
430- if (!cs35l56 -> irq )
413+ if (!irq )
431414 return 0 ;
432415
433- ret = devm_request_threaded_irq (cs35l56 -> dev , cs35l56 -> irq , NULL ,
434- cs35l56_irq ,
416+ ret = devm_request_threaded_irq (cs35l56 -> dev , irq , NULL , cs35l56_irq ,
435417 IRQF_ONESHOT | IRQF_SHARED | IRQF_TRIGGER_LOW ,
436418 "cs35l56" , cs35l56 );
437- if (ret < 0 )
419+ if (!ret )
420+ cs35l56 -> irq = irq ;
421+ else
438422 dev_err (cs35l56 -> dev , "Failed to get IRQ: %d\n" , ret );
439423
440424 return ret ;
@@ -834,6 +818,12 @@ static int cs35l56_wait_for_firmware_boot(struct cs35l56_private *cs35l56)
834818 return 0 ;
835819}
836820
821+ static inline void cs35l56_wait_min_reset_pulse (void )
822+ {
823+ /* Satisfy minimum reset pulse width spec */
824+ usleep_range (CS35L56_RESET_PULSE_MIN_US , 2 * CS35L56_RESET_PULSE_MIN_US );
825+ }
826+
837827static const struct reg_sequence cs35l56_system_reset_seq [] = {
838828 REG_SEQ0 (CS35L56_DSP_VIRTUAL1_MBOX_1 , CS35L56_MBOX_CMD_SYSTEM_RESET ),
839829};
@@ -868,21 +858,14 @@ static void cs35l56_dsp_work(struct work_struct *work)
868858 unsigned int val ;
869859 int ret = 0 ;
870860
871- if (!cs35l56 -> init_done &&
872- !wait_for_completion_timeout (& cs35l56 -> init_completion ,
873- msecs_to_jiffies (5000 ))) {
874- dev_err (cs35l56 -> dev , "%s: init_completion timed out\n" , __func__ );
875- goto complete ;
876- }
877-
878861 if (!cs35l56 -> init_done )
879- goto complete ;
862+ return ;
880863
881864 cs35l56 -> dsp .part = devm_kasprintf (cs35l56 -> dev , GFP_KERNEL , "cs35l56%s-%02x" ,
882865 cs35l56 -> secured ? "s" : "" , cs35l56 -> rev );
883866
884867 if (!cs35l56 -> dsp .part )
885- goto complete ;
868+ return ;
886869
887870 pm_runtime_get_sync (cs35l56 -> dev );
888871
@@ -961,9 +944,6 @@ static void cs35l56_dsp_work(struct work_struct *work)
961944 sdw_write_no_pm (cs35l56 -> sdw_peripheral , CS35L56_SDW_GEN_INT_MASK_1 ,
962945 CS35L56_SDW_INT_MASK_CODEC_IRQ );
963946 }
964-
965- complete :
966- complete_all (& cs35l56 -> dsp_ready_completion );
967947}
968948
969949static int cs35l56_component_probe (struct snd_soc_component * component )
@@ -973,6 +953,12 @@ static int cs35l56_component_probe(struct snd_soc_component *component)
973953
974954 BUILD_BUG_ON (ARRAY_SIZE (cs35l56_tx_input_texts ) != ARRAY_SIZE (cs35l56_tx_input_values ));
975955
956+ if (!wait_for_completion_timeout (& cs35l56 -> init_completion ,
957+ msecs_to_jiffies (5000 ))) {
958+ dev_err (cs35l56 -> dev , "%s: init_completion timed out\n" , __func__ );
959+ return - ENODEV ;
960+ }
961+
976962 cs35l56 -> component = component ;
977963 wm_adsp2_component_probe (& cs35l56 -> dsp , component );
978964
@@ -996,7 +982,6 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component,
996982 enum snd_soc_bias_level level )
997983{
998984 struct cs35l56_private * cs35l56 = snd_soc_component_get_drvdata (component );
999- int ret = 0 ;
1000985
1001986 switch (level ) {
1002987 case SND_SOC_BIAS_STANDBY :
@@ -1005,14 +990,14 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component,
1005990 * BIAS_OFF to BIAS_STANDBY
1006991 */
1007992 if (snd_soc_component_get_bias_level (component ) == SND_SOC_BIAS_OFF )
1008- ret = cs35l56_wait_dsp_ready (cs35l56 );
993+ cs35l56_wait_dsp_ready (cs35l56 );
1009994
1010995 break ;
1011996 default :
1012997 break ;
1013998 }
1014999
1015- return ret ;
1000+ return 0 ;
10161001}
10171002
10181003static const struct snd_soc_component_driver soc_component_dev_cs35l56 = {
@@ -1235,7 +1220,7 @@ int cs35l56_system_suspend_late(struct device *dev)
12351220 */
12361221 if (cs35l56 -> reset_gpio ) {
12371222 gpiod_set_value_cansleep (cs35l56 -> reset_gpio , 0 );
1238- usleep_range ( CS35L56_RESET_PULSE_MIN_US , CS35L56_RESET_PULSE_MIN_US + 400 );
1223+ cs35l56_wait_min_reset_pulse ( );
12391224 }
12401225
12411226 regulator_bulk_disable (ARRAY_SIZE (cs35l56 -> supplies ), cs35l56 -> supplies );
@@ -1288,7 +1273,7 @@ int cs35l56_system_resume_early(struct device *dev)
12881273 /* Ensure a spec-compliant RESET pulse. */
12891274 if (cs35l56 -> reset_gpio ) {
12901275 gpiod_set_value_cansleep (cs35l56 -> reset_gpio , 0 );
1291- usleep_range ( CS35L56_RESET_PULSE_MIN_US , CS35L56_RESET_PULSE_MIN_US + 400 );
1276+ cs35l56_wait_min_reset_pulse ( );
12921277 }
12931278
12941279 /* Enable supplies before releasing RESET. */
@@ -1330,7 +1315,6 @@ int cs35l56_system_resume(struct device *dev)
13301315 return ret ;
13311316
13321317 cs35l56 -> fw_patched = false;
1333- init_completion (& cs35l56 -> dsp_ready_completion );
13341318 queue_work (cs35l56 -> dsp_wq , & cs35l56 -> dsp_work );
13351319
13361320 /*
@@ -1352,7 +1336,6 @@ static int cs35l56_dsp_init(struct cs35l56_private *cs35l56)
13521336 return - ENOMEM ;
13531337
13541338 INIT_WORK (& cs35l56 -> dsp_work , cs35l56_dsp_work );
1355- init_completion (& cs35l56 -> dsp_ready_completion );
13561339
13571340 dsp = & cs35l56 -> dsp ;
13581341 dsp -> part = "cs35l56" ;
@@ -1439,9 +1422,7 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56)
14391422 return dev_err_probe (cs35l56 -> dev , ret , "Failed to enable supplies\n" );
14401423
14411424 if (cs35l56 -> reset_gpio ) {
1442- /* satisfy minimum reset pulse width spec */
1443- usleep_range (CS35L56_RESET_PULSE_MIN_US ,
1444- CS35L56_RESET_PULSE_MIN_US + 400 );
1425+ cs35l56_wait_min_reset_pulse ();
14451426 gpiod_set_value_cansleep (cs35l56 -> reset_gpio , 1 );
14461427 }
14471428
@@ -1609,7 +1590,7 @@ int cs35l56_init(struct cs35l56_private *cs35l56)
16091590}
16101591EXPORT_SYMBOL_NS_GPL (cs35l56_init , SND_SOC_CS35L56_CORE );
16111592
1612- int cs35l56_remove (struct cs35l56_private * cs35l56 )
1593+ void cs35l56_remove (struct cs35l56_private * cs35l56 )
16131594{
16141595 cs35l56 -> init_done = false;
16151596
@@ -1632,8 +1613,6 @@ int cs35l56_remove(struct cs35l56_private *cs35l56)
16321613
16331614 gpiod_set_value_cansleep (cs35l56 -> reset_gpio , 0 );
16341615 regulator_bulk_disable (ARRAY_SIZE (cs35l56 -> supplies ), cs35l56 -> supplies );
1635-
1636- return 0 ;
16371616}
16381617EXPORT_SYMBOL_NS_GPL (cs35l56_remove , SND_SOC_CS35L56_CORE );
16391618
0 commit comments