19
19
#include <linux/platform_device.h>
20
20
#include <linux/pm.h>
21
21
#include <linux/pm_runtime.h>
22
+ #include <linux/reset.h>
22
23
#include <linux/slab.h>
23
24
24
25
#define USB20_CLKSET0 0x00
@@ -35,6 +36,7 @@ struct usb2_clock_sel_priv {
35
36
void __iomem * base ;
36
37
struct clk_hw hw ;
37
38
struct clk_bulk_data clks [ARRAY_SIZE (rcar_usb2_clocks )];
39
+ struct reset_control * rsts ;
38
40
bool extal ;
39
41
bool xtal ;
40
42
};
@@ -62,10 +64,16 @@ static int usb2_clock_sel_enable(struct clk_hw *hw)
62
64
struct usb2_clock_sel_priv * priv = to_priv (hw );
63
65
int ret ;
64
66
65
- ret = clk_bulk_prepare_enable ( ARRAY_SIZE ( priv -> clks ), priv -> clks );
67
+ ret = reset_control_deassert ( priv -> rsts );
66
68
if (ret )
67
69
return ret ;
68
70
71
+ ret = clk_bulk_prepare_enable (ARRAY_SIZE (priv -> clks ), priv -> clks );
72
+ if (ret ) {
73
+ reset_control_assert (priv -> rsts );
74
+ return ret ;
75
+ }
76
+
69
77
usb2_clock_sel_enable_extal_only (priv );
70
78
71
79
return 0 ;
@@ -78,6 +86,7 @@ static void usb2_clock_sel_disable(struct clk_hw *hw)
78
86
usb2_clock_sel_disable_extal_only (priv );
79
87
80
88
clk_bulk_disable_unprepare (ARRAY_SIZE (priv -> clks ), priv -> clks );
89
+ reset_control_assert (priv -> rsts );
81
90
}
82
91
83
92
/*
@@ -151,6 +160,10 @@ static int rcar_usb2_clock_sel_probe(struct platform_device *pdev)
151
160
if (ret < 0 )
152
161
return ret ;
153
162
163
+ priv -> rsts = devm_reset_control_array_get (dev , true, false);
164
+ if (IS_ERR (priv -> rsts ))
165
+ return PTR_ERR (priv -> rsts );
166
+
154
167
pm_runtime_enable (dev );
155
168
pm_runtime_get_sync (dev );
156
169
0 commit comments