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