@@ -680,10 +680,29 @@ static int usbhs_probe(struct platform_device *pdev)
680680 INIT_DELAYED_WORK (& priv -> notify_hotplug_work , usbhsc_notify_hotplug );
681681 spin_lock_init (usbhs_priv_to_lock (priv ));
682682
683+ /*
684+ * Acquire clocks and enable power management (PM) early in the
685+ * probe process, as the driver accesses registers during
686+ * initialization. Ensure the device is active before proceeding.
687+ */
688+ pm_runtime_enable (dev );
689+
690+ ret = usbhsc_clk_get (dev , priv );
691+ if (ret )
692+ goto probe_pm_disable ;
693+
694+ ret = pm_runtime_resume_and_get (dev );
695+ if (ret )
696+ goto probe_clk_put ;
697+
698+ ret = usbhsc_clk_prepare_enable (priv );
699+ if (ret )
700+ goto probe_pm_put ;
701+
683702 /* call pipe and module init */
684703 ret = usbhs_pipe_probe (priv );
685704 if (ret < 0 )
686- return ret ;
705+ goto probe_clk_dis_unprepare ;
687706
688707 ret = usbhs_fifo_probe (priv );
689708 if (ret < 0 )
@@ -700,10 +719,6 @@ static int usbhs_probe(struct platform_device *pdev)
700719 if (ret )
701720 goto probe_fail_rst ;
702721
703- ret = usbhsc_clk_get (dev , priv );
704- if (ret )
705- goto probe_fail_clks ;
706-
707722 /*
708723 * deviece reset here because
709724 * USB device might be used in boot loader.
@@ -719,7 +734,7 @@ static int usbhs_probe(struct platform_device *pdev)
719734 dev_warn (dev , "USB function not selected (GPIO %d)\n" ,
720735 priv -> dparam .enable_gpio );
721736 ret = - ENOTSUPP ;
722- goto probe_end_mod_exit ;
737+ goto probe_assert_rest ;
723738 }
724739 }
725740
@@ -733,14 +748,19 @@ static int usbhs_probe(struct platform_device *pdev)
733748 ret = usbhs_platform_call (priv , hardware_init , pdev );
734749 if (ret < 0 ) {
735750 dev_err (dev , "platform init failed.\n" );
736- goto probe_end_mod_exit ;
751+ goto probe_assert_rest ;
737752 }
738753
739754 /* reset phy for connection */
740755 usbhs_platform_call (priv , phy_reset , pdev );
741756
742- /* power control */
743- pm_runtime_enable (dev );
757+ /*
758+ * Disable the clocks that were enabled earlier in the probe path,
759+ * and let the driver handle the clocks beyond this point.
760+ */
761+ usbhsc_clk_disable_unprepare (priv );
762+ pm_runtime_put (dev );
763+
744764 if (!usbhs_get_dparam (priv , runtime_pwctrl )) {
745765 usbhsc_power_ctrl (priv , 1 );
746766 usbhs_mod_autonomy_mode (priv );
@@ -757,16 +777,22 @@ static int usbhs_probe(struct platform_device *pdev)
757777
758778 return ret ;
759779
760- probe_end_mod_exit :
761- usbhsc_clk_put (priv );
762- probe_fail_clks :
780+ probe_assert_rest :
763781 reset_control_assert (priv -> rsts );
764782probe_fail_rst :
765783 usbhs_mod_remove (priv );
766784probe_end_fifo_exit :
767785 usbhs_fifo_remove (priv );
768786probe_end_pipe_exit :
769787 usbhs_pipe_remove (priv );
788+ probe_clk_dis_unprepare :
789+ usbhsc_clk_disable_unprepare (priv );
790+ probe_pm_put :
791+ pm_runtime_put (dev );
792+ probe_clk_put :
793+ usbhsc_clk_put (priv );
794+ probe_pm_disable :
795+ pm_runtime_disable (dev );
770796
771797 dev_info (dev , "probe failed (%d)\n" , ret );
772798
0 commit comments