@@ -678,10 +678,29 @@ static int usbhs_probe(struct platform_device *pdev)
678
678
INIT_DELAYED_WORK (& priv -> notify_hotplug_work , usbhsc_notify_hotplug );
679
679
spin_lock_init (usbhs_priv_to_lock (priv ));
680
680
681
+ /*
682
+ * Acquire clocks and enable power management (PM) early in the
683
+ * probe process, as the driver accesses registers during
684
+ * initialization. Ensure the device is active before proceeding.
685
+ */
686
+ pm_runtime_enable (dev );
687
+
688
+ ret = usbhsc_clk_get (dev , priv );
689
+ if (ret )
690
+ goto probe_pm_disable ;
691
+
692
+ ret = pm_runtime_resume_and_get (dev );
693
+ if (ret )
694
+ goto probe_clk_put ;
695
+
696
+ ret = usbhsc_clk_prepare_enable (priv );
697
+ if (ret )
698
+ goto probe_pm_put ;
699
+
681
700
/* call pipe and module init */
682
701
ret = usbhs_pipe_probe (priv );
683
702
if (ret < 0 )
684
- return ret ;
703
+ goto probe_clk_dis_unprepare ;
685
704
686
705
ret = usbhs_fifo_probe (priv );
687
706
if (ret < 0 )
@@ -698,10 +717,6 @@ static int usbhs_probe(struct platform_device *pdev)
698
717
if (ret )
699
718
goto probe_fail_rst ;
700
719
701
- ret = usbhsc_clk_get (dev , priv );
702
- if (ret )
703
- goto probe_fail_clks ;
704
-
705
720
/*
706
721
* deviece reset here because
707
722
* USB device might be used in boot loader.
@@ -714,7 +729,7 @@ static int usbhs_probe(struct platform_device *pdev)
714
729
if (ret ) {
715
730
dev_warn (dev , "USB function not selected (GPIO)\n" );
716
731
ret = - ENOTSUPP ;
717
- goto probe_end_mod_exit ;
732
+ goto probe_assert_rest ;
718
733
}
719
734
}
720
735
@@ -728,14 +743,19 @@ static int usbhs_probe(struct platform_device *pdev)
728
743
ret = usbhs_platform_call (priv , hardware_init , pdev );
729
744
if (ret < 0 ) {
730
745
dev_err (dev , "platform init failed.\n" );
731
- goto probe_end_mod_exit ;
746
+ goto probe_assert_rest ;
732
747
}
733
748
734
749
/* reset phy for connection */
735
750
usbhs_platform_call (priv , phy_reset , pdev );
736
751
737
- /* power control */
738
- pm_runtime_enable (dev );
752
+ /*
753
+ * Disable the clocks that were enabled earlier in the probe path,
754
+ * and let the driver handle the clocks beyond this point.
755
+ */
756
+ usbhsc_clk_disable_unprepare (priv );
757
+ pm_runtime_put (dev );
758
+
739
759
if (!usbhs_get_dparam (priv , runtime_pwctrl )) {
740
760
usbhsc_power_ctrl (priv , 1 );
741
761
usbhs_mod_autonomy_mode (priv );
@@ -752,16 +772,22 @@ static int usbhs_probe(struct platform_device *pdev)
752
772
753
773
return ret ;
754
774
755
- probe_end_mod_exit :
756
- usbhsc_clk_put (priv );
757
- probe_fail_clks :
775
+ probe_assert_rest :
758
776
reset_control_assert (priv -> rsts );
759
777
probe_fail_rst :
760
778
usbhs_mod_remove (priv );
761
779
probe_end_fifo_exit :
762
780
usbhs_fifo_remove (priv );
763
781
probe_end_pipe_exit :
764
782
usbhs_pipe_remove (priv );
783
+ probe_clk_dis_unprepare :
784
+ usbhsc_clk_disable_unprepare (priv );
785
+ probe_pm_put :
786
+ pm_runtime_put (dev );
787
+ probe_clk_put :
788
+ usbhsc_clk_put (priv );
789
+ probe_pm_disable :
790
+ pm_runtime_disable (dev );
765
791
766
792
dev_info (dev , "probe failed (%d)\n" , ret );
767
793
0 commit comments