Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: at91: usb: Add sam9x60 support

The sam9x60 USB clock supports four different parents, ensure they can be
selected.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Alexandre Belloni and committed by
Stephen Boyd
2423eeae e4cfb823

+30 -6
+27 -6
drivers/clk/at91/clk-usb.c
··· 23 23 #define RM9200_USB_DIV_SHIFT 28 24 24 #define RM9200_USB_DIV_TAB_SIZE 4 25 25 26 + #define SAM9X5_USBS_MASK GENMASK(0, 0) 27 + #define SAM9X60_USBS_MASK GENMASK(1, 0) 28 + 26 29 struct at91sam9x5_clk_usb { 27 30 struct clk_hw hw; 28 31 struct regmap *regmap; 32 + u32 usbs_mask; 29 33 }; 30 34 31 35 #define to_at91sam9x5_clk_usb(hw) \ ··· 115 111 if (index > 1) 116 112 return -EINVAL; 117 113 118 - regmap_update_bits(usb->regmap, AT91_PMC_USB, AT91_PMC_USBS, 119 - index ? AT91_PMC_USBS : 0); 114 + regmap_update_bits(usb->regmap, AT91_PMC_USB, usb->usbs_mask, index); 120 115 121 116 return 0; 122 117 } ··· 127 124 128 125 regmap_read(usb->regmap, AT91_PMC_USB, &usbr); 129 126 130 - return usbr & AT91_PMC_USBS; 127 + return usbr & usb->usbs_mask; 131 128 } 132 129 133 130 static int at91sam9x5_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate, ··· 193 190 .set_rate = at91sam9x5_clk_usb_set_rate, 194 191 }; 195 192 196 - struct clk_hw * __init 197 - at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, 198 - const char **parent_names, u8 num_parents) 193 + static struct clk_hw * __init 194 + _at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, 195 + const char **parent_names, u8 num_parents, 196 + u32 usbs_mask) 199 197 { 200 198 struct at91sam9x5_clk_usb *usb; 201 199 struct clk_hw *hw; ··· 216 212 217 213 usb->hw.init = &init; 218 214 usb->regmap = regmap; 215 + usb->usbs_mask = SAM9X5_USBS_MASK; 219 216 220 217 hw = &usb->hw; 221 218 ret = clk_hw_register(NULL, &usb->hw); ··· 226 221 } 227 222 228 223 return hw; 224 + } 225 + 226 + struct clk_hw * __init 227 + at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, 228 + const char **parent_names, u8 num_parents) 229 + { 230 + return _at91sam9x5_clk_register_usb(regmap, name, parent_names, 231 + num_parents, SAM9X5_USBS_MASK); 232 + } 233 + 234 + struct clk_hw * __init 235 + sam9x60_clk_register_usb(struct regmap *regmap, const char *name, 236 + const char **parent_names, u8 num_parents) 237 + { 238 + return _at91sam9x5_clk_register_usb(regmap, name, parent_names, 239 + num_parents, SAM9X60_USBS_MASK); 229 240 } 230 241 231 242 struct clk_hw * __init
+3
drivers/clk/at91/pmc.h
··· 194 194 at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name, 195 195 const char *parent_name); 196 196 struct clk_hw * __init 197 + sam9x60_clk_register_usb(struct regmap *regmap, const char *name, 198 + const char **parent_names, u8 num_parents); 199 + struct clk_hw * __init 197 200 at91rm9200_clk_register_usb(struct regmap *regmap, const char *name, 198 201 const char *parent_name, const u32 *divisors); 199 202