Skip to content

Commit 3ea59ac

Browse files
mripardbebarino
authored andcommitted
clk: bcm: rpi: Split pllb clock hooks
The driver only supports the pllb for now and all the clock framework hooks are a mix of the generic firmware interface and the specifics of the pllb. Since we will support more clocks in the future let's split the generic and specific hooks 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/fdc21962fdc7de5c46232f198672d5d5c868ec74.1592210452.git-series.maxime@cerno.tech Signed-off-by: Stephen Boyd <[email protected]>
1 parent c1ce350 commit 3ea59ac

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
102102
}
103103

104104

105-
static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
106-
unsigned long parent_rate)
105+
static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
106+
unsigned long parent_rate)
107107
{
108108
struct raspberrypi_clk_data *data =
109109
container_of(hw, struct raspberrypi_clk_data, hw);
@@ -116,28 +116,42 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
116116
if (ret)
117117
return ret;
118118

119-
return val * RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
119+
return val;
120120
}
121121

122-
static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
123-
unsigned long parent_rate)
122+
static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
123+
unsigned long parent_rate)
124+
{
125+
return raspberrypi_fw_get_rate(hw, parent_rate) *
126+
RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
127+
}
128+
129+
static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
130+
unsigned long parent_rate)
124131
{
125132
struct raspberrypi_clk_data *data =
126133
container_of(hw, struct raspberrypi_clk_data, hw);
127134
struct raspberrypi_clk *rpi = data->rpi;
128-
u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
135+
u32 _rate = rate;
129136
int ret;
130137

131138
ret = raspberrypi_clock_property(rpi->firmware, data,
132-
RPI_FIRMWARE_SET_CLOCK_RATE,
133-
&new_rate);
139+
RPI_FIRMWARE_SET_CLOCK_RATE, &_rate);
134140
if (ret)
135141
dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
136142
clk_hw_get_name(hw), ret);
137143

138144
return ret;
139145
}
140146

147+
static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
148+
unsigned long parent_rate)
149+
{
150+
u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
151+
152+
return raspberrypi_fw_set_rate(hw, new_rate, parent_rate);
153+
}
154+
141155
/*
142156
* Sadly there is no firmware rate rounding interface. We borrowed it from
143157
* clk-bcm2835.

0 commit comments

Comments
 (0)