mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-12 03:26:26 +00:00
clk: at91: usb: introduce num_parents in driver's structure
SAM9X60 USB clock may have up to 3 parents. Save the number of parents in driver's data structure and validate against it when setting parent. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lkml.kernel.org/r/1579261009-4573-5-git-send-email-claudiu.beznea@microchip.com Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
d7a83d67a1
commit
9962fb0d19
1 changed files with 3 additions and 1 deletions
|
@ -25,6 +25,7 @@ struct at91sam9x5_clk_usb {
|
||||||
struct clk_hw hw;
|
struct clk_hw hw;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
u32 usbs_mask;
|
u32 usbs_mask;
|
||||||
|
u8 num_parents;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define to_at91sam9x5_clk_usb(hw) \
|
#define to_at91sam9x5_clk_usb(hw) \
|
||||||
|
@ -110,7 +111,7 @@ static int at91sam9x5_clk_usb_set_parent(struct clk_hw *hw, u8 index)
|
||||||
{
|
{
|
||||||
struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw);
|
struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw);
|
||||||
|
|
||||||
if (index > 1)
|
if (index >= usb->num_parents)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
regmap_update_bits(usb->regmap, AT91_PMC_USB, usb->usbs_mask, index);
|
regmap_update_bits(usb->regmap, AT91_PMC_USB, usb->usbs_mask, index);
|
||||||
|
@ -215,6 +216,7 @@ _at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
|
||||||
usb->hw.init = &init;
|
usb->hw.init = &init;
|
||||||
usb->regmap = regmap;
|
usb->regmap = regmap;
|
||||||
usb->usbs_mask = usbs_mask;
|
usb->usbs_mask = usbs_mask;
|
||||||
|
usb->num_parents = num_parents;
|
||||||
|
|
||||||
hw = &usb->hw;
|
hw = &usb->hw;
|
||||||
ret = clk_hw_register(NULL, &usb->hw);
|
ret = clk_hw_register(NULL, &usb->hw);
|
||||||
|
|
Loading…
Reference in a new issue