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