Skip to content

Commit f922c56

Browse files
mripardbebarino
authored andcommitted
clk: bcm: rpi: Create a data structure for the clocks
So far the driver has really only been providing a single clock, and stored both the data associated to that clock in particular with the data associated to the "controller". Since we will change that in the future, let's decouple the clock data from the provider data. Cc: Michael Turquette <[email protected]> Cc: [email protected] Acked-by: Nicolas Saenz Julienne <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Tested-by: Nicolas Saenz Julienne <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/ee7f508db226214fab4add7f93a351f4137c86a1.1592210452.git-series.maxime@cerno.tech Signed-off-by: Stephen Boyd <[email protected]>
1 parent df4b6a4 commit f922c56

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ struct raspberrypi_clk {
3535
struct device *dev;
3636
struct rpi_firmware *firmware;
3737
struct platform_device *cpufreq;
38+
};
3839

39-
struct clk_hw pllb;
40+
struct raspberrypi_clk_data {
41+
struct clk_hw hw;
42+
struct raspberrypi_clk *rpi;
4043
};
4144

4245
/*
@@ -80,8 +83,9 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware, u32 tag,
8083

8184
static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
8285
{
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;
8589
u32 val = 0;
8690
int ret;
8791

@@ -98,8 +102,9 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
98102
static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
99103
unsigned long parent_rate)
100104
{
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;
103108
u32 val = 0;
104109
int ret;
105110

@@ -116,8 +121,9 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
116121
static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
117122
unsigned long parent_rate)
118123
{
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;
121127
u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
122128
int ret;
123129

@@ -168,10 +174,15 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
168174

169175
static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
170176
{
177+
struct raspberrypi_clk_data *data;
171178
struct clk_init_data init = {};
172179
u32 min_rate = 0, max_rate = 0;
173180
int ret;
174181

182+
data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
183+
if (!data)
184+
return -ENOMEM;
185+
data->rpi = rpi;
175186

176187
/* All of the PLLs derive from the external oscillator. */
177188
init.parent_names = (const char *[]){ "osc" };
@@ -210,11 +221,11 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
210221
dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
211222
min_rate, max_rate);
212223

213-
rpi->pllb.init = &init;
224+
data->hw.init = &init;
214225

215-
ret = devm_clk_hw_register(rpi->dev, &rpi->pllb);
226+
ret = devm_clk_hw_register(rpi->dev, &data->hw);
216227
if (!ret)
217-
clk_hw_set_rate_range(&rpi->pllb,
228+
clk_hw_set_rate_range(&data->hw,
218229
min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
219230
max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
220231

0 commit comments

Comments
 (0)