@@ -35,8 +35,11 @@ struct raspberrypi_clk {
35
35
struct device * dev ;
36
36
struct rpi_firmware * firmware ;
37
37
struct platform_device * cpufreq ;
38
+ };
38
39
39
- struct clk_hw pllb ;
40
+ struct raspberrypi_clk_data {
41
+ struct clk_hw hw ;
42
+ struct raspberrypi_clk * rpi ;
40
43
};
41
44
42
45
/*
@@ -80,8 +83,9 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware, u32 tag,
80
83
81
84
static int raspberrypi_fw_pll_is_on (struct clk_hw * hw )
82
85
{
83
- struct raspberrypi_clk * rpi = container_of (hw , struct raspberrypi_clk ,
84
- pllb );
86
+ struct raspberrypi_clk_data * data =
87
+ container_of (hw , struct raspberrypi_clk_data , hw );
88
+ struct raspberrypi_clk * rpi = data -> rpi ;
85
89
u32 val = 0 ;
86
90
int ret ;
87
91
@@ -98,8 +102,9 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
98
102
static unsigned long raspberrypi_fw_pll_get_rate (struct clk_hw * hw ,
99
103
unsigned long parent_rate )
100
104
{
101
- struct raspberrypi_clk * rpi = container_of (hw , struct raspberrypi_clk ,
102
- pllb );
105
+ struct raspberrypi_clk_data * data =
106
+ container_of (hw , struct raspberrypi_clk_data , hw );
107
+ struct raspberrypi_clk * rpi = data -> rpi ;
103
108
u32 val = 0 ;
104
109
int ret ;
105
110
@@ -116,8 +121,9 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
116
121
static int raspberrypi_fw_pll_set_rate (struct clk_hw * hw , unsigned long rate ,
117
122
unsigned long parent_rate )
118
123
{
119
- struct raspberrypi_clk * rpi = container_of (hw , struct raspberrypi_clk ,
120
- pllb );
124
+ struct raspberrypi_clk_data * data =
125
+ container_of (hw , struct raspberrypi_clk_data , hw );
126
+ struct raspberrypi_clk * rpi = data -> rpi ;
121
127
u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE ;
122
128
int ret ;
123
129
@@ -168,10 +174,15 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
168
174
169
175
static int raspberrypi_register_pllb (struct raspberrypi_clk * rpi )
170
176
{
177
+ struct raspberrypi_clk_data * data ;
171
178
struct clk_init_data init = {};
172
179
u32 min_rate = 0 , max_rate = 0 ;
173
180
int ret ;
174
181
182
+ data = devm_kzalloc (rpi -> dev , sizeof (* data ), GFP_KERNEL );
183
+ if (!data )
184
+ return - ENOMEM ;
185
+ data -> rpi = rpi ;
175
186
176
187
/* All of the PLLs derive from the external oscillator. */
177
188
init .parent_names = (const char * []){ "osc" };
@@ -210,11 +221,11 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
210
221
dev_info (rpi -> dev , "CPU frequency range: min %u, max %u\n" ,
211
222
min_rate , max_rate );
212
223
213
- rpi -> pllb .init = & init ;
224
+ data -> hw .init = & init ;
214
225
215
- ret = devm_clk_hw_register (rpi -> dev , & rpi -> pllb );
226
+ ret = devm_clk_hw_register (rpi -> dev , & data -> hw );
216
227
if (!ret )
217
- clk_hw_set_rate_range (& rpi -> pllb ,
228
+ clk_hw_set_rate_range (& data -> hw ,
218
229
min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE ,
219
230
max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE );
220
231
0 commit comments