Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> |
| 7 | */ |
| 8 | |
Paul Gortmaker | 26dd3e4 | 2017-01-28 21:05:57 -0500 | [diff] [blame] | 9 | #include <linux/init.h> |
| 10 | #include <linux/export.h> |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 11 | #include <linux/mutex.h> |
| 12 | #include <linux/err.h> |
| 13 | #include <linux/clk.h> |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 14 | #include <linux/clkdev.h> |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 15 | #include <linux/delay.h> |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 16 | #include <bcm63xx_cpu.h> |
| 17 | #include <bcm63xx_io.h> |
| 18 | #include <bcm63xx_regs.h> |
Jonas Gorski | ba00e2e | 2012-10-28 12:17:55 +0000 | [diff] [blame] | 19 | #include <bcm63xx_reset.h> |
Jonas Gorski | 042df4f | 2013-04-06 10:31:02 +0000 | [diff] [blame] | 20 | |
| 21 | struct clk { |
| 22 | void (*set)(struct clk *, int); |
| 23 | unsigned int rate; |
| 24 | unsigned int usage; |
| 25 | int id; |
| 26 | }; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 27 | |
| 28 | static DEFINE_MUTEX(clocks_mutex); |
| 29 | |
| 30 | |
| 31 | static void clk_enable_unlocked(struct clk *clk) |
| 32 | { |
| 33 | if (clk->set && (clk->usage++) == 0) |
| 34 | clk->set(clk, 1); |
| 35 | } |
| 36 | |
| 37 | static void clk_disable_unlocked(struct clk *clk) |
| 38 | { |
| 39 | if (clk->set && (--clk->usage) == 0) |
| 40 | clk->set(clk, 0); |
| 41 | } |
| 42 | |
| 43 | static void bcm_hwclock_set(u32 mask, int enable) |
| 44 | { |
| 45 | u32 reg; |
| 46 | |
| 47 | reg = bcm_perf_readl(PERF_CKCTL_REG); |
| 48 | if (enable) |
| 49 | reg |= mask; |
| 50 | else |
| 51 | reg &= ~mask; |
| 52 | bcm_perf_writel(reg, PERF_CKCTL_REG); |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | * Ethernet MAC "misc" clock: dma clocks and main clock on 6348 |
| 57 | */ |
| 58 | static void enet_misc_set(struct clk *clk, int enable) |
| 59 | { |
| 60 | u32 mask; |
| 61 | |
| 62 | if (BCMCPU_IS_6338()) |
| 63 | mask = CKCTL_6338_ENET_EN; |
| 64 | else if (BCMCPU_IS_6345()) |
| 65 | mask = CKCTL_6345_ENET_EN; |
| 66 | else if (BCMCPU_IS_6348()) |
| 67 | mask = CKCTL_6348_ENET_EN; |
| 68 | else |
| 69 | /* BCMCPU_IS_6358 */ |
| 70 | mask = CKCTL_6358_EMUSB_EN; |
| 71 | bcm_hwclock_set(mask, enable); |
| 72 | } |
| 73 | |
| 74 | static struct clk clk_enet_misc = { |
| 75 | .set = enet_misc_set, |
| 76 | }; |
| 77 | |
| 78 | /* |
| 79 | * Ethernet MAC clocks: only revelant on 6358, silently enable misc |
| 80 | * clocks |
| 81 | */ |
| 82 | static void enetx_set(struct clk *clk, int enable) |
| 83 | { |
| 84 | if (enable) |
| 85 | clk_enable_unlocked(&clk_enet_misc); |
| 86 | else |
| 87 | clk_disable_unlocked(&clk_enet_misc); |
| 88 | |
Florian Fainelli | 7b93342 | 2013-06-18 16:55:40 +0000 | [diff] [blame] | 89 | if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) { |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 90 | u32 mask; |
| 91 | |
| 92 | if (clk->id == 0) |
| 93 | mask = CKCTL_6358_ENET0_EN; |
| 94 | else |
| 95 | mask = CKCTL_6358_ENET1_EN; |
| 96 | bcm_hwclock_set(mask, enable); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | static struct clk clk_enet0 = { |
| 101 | .id = 0, |
| 102 | .set = enetx_set, |
| 103 | }; |
| 104 | |
| 105 | static struct clk clk_enet1 = { |
| 106 | .id = 1, |
| 107 | .set = enetx_set, |
| 108 | }; |
| 109 | |
| 110 | /* |
| 111 | * Ethernet PHY clock |
| 112 | */ |
| 113 | static void ephy_set(struct clk *clk, int enable) |
| 114 | { |
Florian Fainelli | 7b93342 | 2013-06-18 16:55:40 +0000 | [diff] [blame] | 115 | if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) |
| 116 | bcm_hwclock_set(CKCTL_6358_EPHY_EN, enable); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | |
| 120 | static struct clk clk_ephy = { |
| 121 | .set = ephy_set, |
| 122 | }; |
| 123 | |
| 124 | /* |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 125 | * Ethernet switch clock |
| 126 | */ |
| 127 | static void enetsw_set(struct clk *clk, int enable) |
| 128 | { |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 129 | if (BCMCPU_IS_6328()) |
| 130 | bcm_hwclock_set(CKCTL_6328_ROBOSW_EN, enable); |
| 131 | else if (BCMCPU_IS_6362()) |
| 132 | bcm_hwclock_set(CKCTL_6362_ROBOSW_EN, enable); |
| 133 | else if (BCMCPU_IS_6368()) |
| 134 | bcm_hwclock_set(CKCTL_6368_ROBOSW_EN | |
| 135 | CKCTL_6368_SWPKT_USB_EN | |
| 136 | CKCTL_6368_SWPKT_SAR_EN, |
| 137 | enable); |
| 138 | else |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 139 | return; |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 140 | |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 141 | if (enable) { |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 142 | /* reset switch core afer clock change */ |
Jonas Gorski | ba00e2e | 2012-10-28 12:17:55 +0000 | [diff] [blame] | 143 | bcm63xx_core_set_reset(BCM63XX_RESET_ENETSW, 1); |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 144 | msleep(10); |
Jonas Gorski | ba00e2e | 2012-10-28 12:17:55 +0000 | [diff] [blame] | 145 | bcm63xx_core_set_reset(BCM63XX_RESET_ENETSW, 0); |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 146 | msleep(10); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | static struct clk clk_enetsw = { |
| 151 | .set = enetsw_set, |
| 152 | }; |
| 153 | |
| 154 | /* |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 155 | * PCM clock |
| 156 | */ |
| 157 | static void pcm_set(struct clk *clk, int enable) |
| 158 | { |
Florian Fainelli | 7b93342 | 2013-06-18 16:55:40 +0000 | [diff] [blame] | 159 | if (BCMCPU_IS_3368()) |
| 160 | bcm_hwclock_set(CKCTL_3368_PCM_EN, enable); |
| 161 | if (BCMCPU_IS_6358()) |
| 162 | bcm_hwclock_set(CKCTL_6358_PCM_EN, enable); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static struct clk clk_pcm = { |
| 166 | .set = pcm_set, |
| 167 | }; |
| 168 | |
| 169 | /* |
| 170 | * USB host clock |
| 171 | */ |
| 172 | static void usbh_set(struct clk *clk, int enable) |
| 173 | { |
Kevin Cernekee | dd89d60 | 2012-06-23 04:14:51 +0000 | [diff] [blame] | 174 | if (BCMCPU_IS_6328()) |
| 175 | bcm_hwclock_set(CKCTL_6328_USBH_EN, enable); |
| 176 | else if (BCMCPU_IS_6348()) |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 177 | bcm_hwclock_set(CKCTL_6348_USBH_EN, enable); |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 178 | else if (BCMCPU_IS_6362()) |
| 179 | bcm_hwclock_set(CKCTL_6362_USBH_EN, enable); |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 180 | else if (BCMCPU_IS_6368()) |
Florian Fainelli | d9831a4 | 2012-07-04 16:57:09 +0200 | [diff] [blame] | 181 | bcm_hwclock_set(CKCTL_6368_USBH_EN, enable); |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static struct clk clk_usbh = { |
| 185 | .set = usbh_set, |
| 186 | }; |
| 187 | |
| 188 | /* |
Kevin Cernekee | dd89d60 | 2012-06-23 04:14:51 +0000 | [diff] [blame] | 189 | * USB device clock |
| 190 | */ |
| 191 | static void usbd_set(struct clk *clk, int enable) |
| 192 | { |
| 193 | if (BCMCPU_IS_6328()) |
| 194 | bcm_hwclock_set(CKCTL_6328_USBD_EN, enable); |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 195 | else if (BCMCPU_IS_6362()) |
| 196 | bcm_hwclock_set(CKCTL_6362_USBD_EN, enable); |
Kevin Cernekee | dd89d60 | 2012-06-23 04:14:51 +0000 | [diff] [blame] | 197 | else if (BCMCPU_IS_6368()) |
| 198 | bcm_hwclock_set(CKCTL_6368_USBD_EN, enable); |
| 199 | } |
| 200 | |
| 201 | static struct clk clk_usbd = { |
| 202 | .set = usbd_set, |
| 203 | }; |
| 204 | |
| 205 | /* |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 206 | * SPI clock |
| 207 | */ |
| 208 | static void spi_set(struct clk *clk, int enable) |
| 209 | { |
| 210 | u32 mask; |
| 211 | |
| 212 | if (BCMCPU_IS_6338()) |
| 213 | mask = CKCTL_6338_SPI_EN; |
| 214 | else if (BCMCPU_IS_6348()) |
| 215 | mask = CKCTL_6348_SPI_EN; |
Florian Fainelli | 7b93342 | 2013-06-18 16:55:40 +0000 | [diff] [blame] | 216 | else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 217 | mask = CKCTL_6358_SPI_EN; |
Jonas Gorski | 08a41d1 | 2013-03-21 14:03:18 +0000 | [diff] [blame] | 218 | else if (BCMCPU_IS_6362()) |
| 219 | mask = CKCTL_6362_SPI_EN; |
Florian Fainelli | 19372b2 | 2012-07-04 16:58:30 +0200 | [diff] [blame] | 220 | else |
| 221 | /* BCMCPU_IS_6368 */ |
| 222 | mask = CKCTL_6368_SPI_EN; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 223 | bcm_hwclock_set(mask, enable); |
| 224 | } |
| 225 | |
| 226 | static struct clk clk_spi = { |
| 227 | .set = spi_set, |
| 228 | }; |
| 229 | |
| 230 | /* |
Jonas Gorski | 0ebe8aa | 2013-11-30 12:42:02 +0100 | [diff] [blame] | 231 | * HSSPI clock |
| 232 | */ |
| 233 | static void hsspi_set(struct clk *clk, int enable) |
| 234 | { |
| 235 | u32 mask; |
| 236 | |
| 237 | if (BCMCPU_IS_6328()) |
| 238 | mask = CKCTL_6328_HSSPI_EN; |
| 239 | else if (BCMCPU_IS_6362()) |
| 240 | mask = CKCTL_6362_HSSPI_EN; |
| 241 | else |
| 242 | return; |
| 243 | |
| 244 | bcm_hwclock_set(mask, enable); |
| 245 | } |
| 246 | |
| 247 | static struct clk clk_hsspi = { |
| 248 | .set = hsspi_set, |
| 249 | }; |
| 250 | |
Jonas Gorski | 5d69103 | 2017-09-20 13:14:06 +0200 | [diff] [blame^] | 251 | /* |
| 252 | * HSSPI PLL |
| 253 | */ |
| 254 | static struct clk clk_hsspi_pll; |
Jonas Gorski | 0ebe8aa | 2013-11-30 12:42:02 +0100 | [diff] [blame] | 255 | |
| 256 | /* |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 257 | * XTM clock |
| 258 | */ |
| 259 | static void xtm_set(struct clk *clk, int enable) |
| 260 | { |
| 261 | if (!BCMCPU_IS_6368()) |
| 262 | return; |
| 263 | |
Florian Fainelli | d9831a4 | 2012-07-04 16:57:09 +0200 | [diff] [blame] | 264 | bcm_hwclock_set(CKCTL_6368_SAR_EN | |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 265 | CKCTL_6368_SWPKT_SAR_EN, enable); |
| 266 | |
| 267 | if (enable) { |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 268 | /* reset sar core afer clock change */ |
Jonas Gorski | ba00e2e | 2012-10-28 12:17:55 +0000 | [diff] [blame] | 269 | bcm63xx_core_set_reset(BCM63XX_RESET_SAR, 1); |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 270 | mdelay(1); |
Jonas Gorski | ba00e2e | 2012-10-28 12:17:55 +0000 | [diff] [blame] | 271 | bcm63xx_core_set_reset(BCM63XX_RESET_SAR, 0); |
Maxime Bizon | 04712f3 | 2011-11-04 19:09:35 +0100 | [diff] [blame] | 272 | mdelay(1); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
| 277 | static struct clk clk_xtm = { |
| 278 | .set = xtm_set, |
| 279 | }; |
| 280 | |
| 281 | /* |
Florian Fainelli | 0b55561 | 2012-07-24 16:33:09 +0200 | [diff] [blame] | 282 | * IPsec clock |
| 283 | */ |
| 284 | static void ipsec_set(struct clk *clk, int enable) |
| 285 | { |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 286 | if (BCMCPU_IS_6362()) |
| 287 | bcm_hwclock_set(CKCTL_6362_IPSEC_EN, enable); |
| 288 | else if (BCMCPU_IS_6368()) |
| 289 | bcm_hwclock_set(CKCTL_6368_IPSEC_EN, enable); |
Florian Fainelli | 0b55561 | 2012-07-24 16:33:09 +0200 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | static struct clk clk_ipsec = { |
| 293 | .set = ipsec_set, |
| 294 | }; |
| 295 | |
| 296 | /* |
Jonas Gorski | f2d1035 | 2012-10-28 11:49:53 +0000 | [diff] [blame] | 297 | * PCIe clock |
| 298 | */ |
| 299 | |
| 300 | static void pcie_set(struct clk *clk, int enable) |
| 301 | { |
Jonas Gorski | 1cd1c04 | 2013-04-22 10:57:06 +0000 | [diff] [blame] | 302 | if (BCMCPU_IS_6328()) |
| 303 | bcm_hwclock_set(CKCTL_6328_PCIE_EN, enable); |
| 304 | else if (BCMCPU_IS_6362()) |
| 305 | bcm_hwclock_set(CKCTL_6362_PCIE_EN, enable); |
Jonas Gorski | f2d1035 | 2012-10-28 11:49:53 +0000 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | static struct clk clk_pcie = { |
| 309 | .set = pcie_set, |
| 310 | }; |
| 311 | |
| 312 | /* |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 313 | * Internal peripheral clock |
| 314 | */ |
| 315 | static struct clk clk_periph = { |
| 316 | .rate = (50 * 1000 * 1000), |
| 317 | }; |
| 318 | |
| 319 | |
| 320 | /* |
| 321 | * Linux clock API implementation |
| 322 | */ |
| 323 | int clk_enable(struct clk *clk) |
| 324 | { |
| 325 | mutex_lock(&clocks_mutex); |
| 326 | clk_enable_unlocked(clk); |
| 327 | mutex_unlock(&clocks_mutex); |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | EXPORT_SYMBOL(clk_enable); |
| 332 | |
| 333 | void clk_disable(struct clk *clk) |
| 334 | { |
Masahiro Yamada | 00ca025 | 2016-09-19 03:04:35 +0900 | [diff] [blame] | 335 | if (!clk) |
| 336 | return; |
| 337 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 338 | mutex_lock(&clocks_mutex); |
| 339 | clk_disable_unlocked(clk); |
| 340 | mutex_unlock(&clocks_mutex); |
| 341 | } |
| 342 | |
| 343 | EXPORT_SYMBOL(clk_disable); |
| 344 | |
| 345 | unsigned long clk_get_rate(struct clk *clk) |
| 346 | { |
Jonas Gorski | 1b495fa | 2017-07-18 12:17:27 +0200 | [diff] [blame] | 347 | if (!clk) |
| 348 | return 0; |
| 349 | |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 350 | return clk->rate; |
| 351 | } |
| 352 | |
| 353 | EXPORT_SYMBOL(clk_get_rate); |
| 354 | |
Markos Chandras | 7aa2d05 | 2013-07-02 09:13:44 +0000 | [diff] [blame] | 355 | int clk_set_rate(struct clk *clk, unsigned long rate) |
| 356 | { |
| 357 | return 0; |
| 358 | } |
| 359 | EXPORT_SYMBOL_GPL(clk_set_rate); |
| 360 | |
| 361 | long clk_round_rate(struct clk *clk, unsigned long rate) |
| 362 | { |
| 363 | return 0; |
| 364 | } |
| 365 | EXPORT_SYMBOL_GPL(clk_round_rate); |
| 366 | |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 367 | static struct clk_lookup bcm3368_clks[] = { |
| 368 | /* fixed rate clocks */ |
| 369 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 370 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
| 371 | CLKDEV_INIT("bcm63xx_uart.1", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 372 | /* gated clocks */ |
| 373 | CLKDEV_INIT(NULL, "enet0", &clk_enet0), |
| 374 | CLKDEV_INIT(NULL, "enet1", &clk_enet1), |
| 375 | CLKDEV_INIT(NULL, "ephy", &clk_ephy), |
| 376 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 377 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 378 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 379 | CLKDEV_INIT(NULL, "pcm", &clk_pcm), |
| 380 | }; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 381 | |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 382 | static struct clk_lookup bcm6328_clks[] = { |
| 383 | /* fixed rate clocks */ |
| 384 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 385 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
| 386 | CLKDEV_INIT("bcm63xx_uart.1", "refclk", &clk_periph), |
Jonas Gorski | 5d69103 | 2017-09-20 13:14:06 +0200 | [diff] [blame^] | 387 | CLKDEV_INIT("bcm63xx-hsspi.0", "pll", &clk_hsspi_pll), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 388 | /* gated clocks */ |
| 389 | CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), |
| 390 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 391 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 392 | CLKDEV_INIT(NULL, "hsspi", &clk_hsspi), |
| 393 | CLKDEV_INIT(NULL, "pcie", &clk_pcie), |
| 394 | }; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 395 | |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 396 | static struct clk_lookup bcm6338_clks[] = { |
| 397 | /* fixed rate clocks */ |
| 398 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 399 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 400 | /* gated clocks */ |
| 401 | CLKDEV_INIT(NULL, "enet0", &clk_enet0), |
| 402 | CLKDEV_INIT(NULL, "enet1", &clk_enet1), |
| 403 | CLKDEV_INIT(NULL, "ephy", &clk_ephy), |
| 404 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 405 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 406 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 407 | }; |
Maxime Bizon | e7300d0 | 2009-08-18 13:23:37 +0100 | [diff] [blame] | 408 | |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 409 | static struct clk_lookup bcm6345_clks[] = { |
| 410 | /* fixed rate clocks */ |
| 411 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 412 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 413 | /* gated clocks */ |
| 414 | CLKDEV_INIT(NULL, "enet0", &clk_enet0), |
| 415 | CLKDEV_INIT(NULL, "enet1", &clk_enet1), |
| 416 | CLKDEV_INIT(NULL, "ephy", &clk_ephy), |
| 417 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 418 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 419 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 420 | }; |
| 421 | |
| 422 | static struct clk_lookup bcm6348_clks[] = { |
| 423 | /* fixed rate clocks */ |
| 424 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 425 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 426 | /* gated clocks */ |
| 427 | CLKDEV_INIT(NULL, "enet0", &clk_enet0), |
| 428 | CLKDEV_INIT(NULL, "enet1", &clk_enet1), |
| 429 | CLKDEV_INIT(NULL, "ephy", &clk_ephy), |
| 430 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 431 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 432 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 433 | }; |
| 434 | |
| 435 | static struct clk_lookup bcm6358_clks[] = { |
| 436 | /* fixed rate clocks */ |
| 437 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 438 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
| 439 | CLKDEV_INIT("bcm63xx_uart.1", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 440 | /* gated clocks */ |
| 441 | CLKDEV_INIT(NULL, "enet0", &clk_enet0), |
| 442 | CLKDEV_INIT(NULL, "enet1", &clk_enet1), |
| 443 | CLKDEV_INIT(NULL, "ephy", &clk_ephy), |
| 444 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 445 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 446 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 447 | CLKDEV_INIT(NULL, "pcm", &clk_pcm), |
| 448 | }; |
| 449 | |
| 450 | static struct clk_lookup bcm6362_clks[] = { |
| 451 | /* fixed rate clocks */ |
| 452 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 453 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
| 454 | CLKDEV_INIT("bcm63xx_uart.1", "refclk", &clk_periph), |
Jonas Gorski | 5d69103 | 2017-09-20 13:14:06 +0200 | [diff] [blame^] | 455 | CLKDEV_INIT("bcm63xx-hsspi.0", "pll", &clk_hsspi_pll), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 456 | /* gated clocks */ |
| 457 | CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), |
| 458 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 459 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 460 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 461 | CLKDEV_INIT(NULL, "hsspi", &clk_hsspi), |
| 462 | CLKDEV_INIT(NULL, "pcie", &clk_pcie), |
| 463 | CLKDEV_INIT(NULL, "ipsec", &clk_ipsec), |
| 464 | }; |
| 465 | |
| 466 | static struct clk_lookup bcm6368_clks[] = { |
| 467 | /* fixed rate clocks */ |
| 468 | CLKDEV_INIT(NULL, "periph", &clk_periph), |
Jonas Gorski | 243fa27 | 2017-09-20 13:14:02 +0200 | [diff] [blame] | 469 | CLKDEV_INIT("bcm63xx_uart.0", "refclk", &clk_periph), |
| 470 | CLKDEV_INIT("bcm63xx_uart.1", "refclk", &clk_periph), |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 471 | /* gated clocks */ |
| 472 | CLKDEV_INIT(NULL, "enetsw", &clk_enetsw), |
| 473 | CLKDEV_INIT(NULL, "usbh", &clk_usbh), |
| 474 | CLKDEV_INIT(NULL, "usbd", &clk_usbd), |
| 475 | CLKDEV_INIT(NULL, "spi", &clk_spi), |
| 476 | CLKDEV_INIT(NULL, "xtm", &clk_xtm), |
| 477 | CLKDEV_INIT(NULL, "ipsec", &clk_ipsec), |
| 478 | }; |
Jonas Gorski | 26b8c07 | 2013-11-30 12:42:03 +0100 | [diff] [blame] | 479 | |
| 480 | #define HSSPI_PLL_HZ_6328 133333333 |
| 481 | #define HSSPI_PLL_HZ_6362 400000000 |
| 482 | |
| 483 | static int __init bcm63xx_clk_init(void) |
| 484 | { |
| 485 | switch (bcm63xx_get_cpu_id()) { |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 486 | case BCM3368_CPU_ID: |
| 487 | clkdev_add_table(bcm3368_clks, ARRAY_SIZE(bcm3368_clks)); |
| 488 | break; |
Jonas Gorski | 26b8c07 | 2013-11-30 12:42:03 +0100 | [diff] [blame] | 489 | case BCM6328_CPU_ID: |
Jonas Gorski | 5d69103 | 2017-09-20 13:14:06 +0200 | [diff] [blame^] | 490 | clk_hsspi_pll.rate = HSSPI_PLL_HZ_6328; |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 491 | clkdev_add_table(bcm6328_clks, ARRAY_SIZE(bcm6328_clks)); |
| 492 | break; |
| 493 | case BCM6338_CPU_ID: |
| 494 | clkdev_add_table(bcm6338_clks, ARRAY_SIZE(bcm6338_clks)); |
| 495 | break; |
| 496 | case BCM6345_CPU_ID: |
| 497 | clkdev_add_table(bcm6345_clks, ARRAY_SIZE(bcm6345_clks)); |
| 498 | break; |
| 499 | case BCM6348_CPU_ID: |
| 500 | clkdev_add_table(bcm6348_clks, ARRAY_SIZE(bcm6348_clks)); |
| 501 | break; |
| 502 | case BCM6358_CPU_ID: |
| 503 | clkdev_add_table(bcm6358_clks, ARRAY_SIZE(bcm6358_clks)); |
Jonas Gorski | 26b8c07 | 2013-11-30 12:42:03 +0100 | [diff] [blame] | 504 | break; |
| 505 | case BCM6362_CPU_ID: |
Jonas Gorski | 5d69103 | 2017-09-20 13:14:06 +0200 | [diff] [blame^] | 506 | clk_hsspi_pll.rate = HSSPI_PLL_HZ_6362; |
Jonas Gorski | c5af3c2 | 2017-09-20 13:14:01 +0200 | [diff] [blame] | 507 | clkdev_add_table(bcm6362_clks, ARRAY_SIZE(bcm6362_clks)); |
| 508 | break; |
| 509 | case BCM6368_CPU_ID: |
| 510 | clkdev_add_table(bcm6368_clks, ARRAY_SIZE(bcm6368_clks)); |
Jonas Gorski | 26b8c07 | 2013-11-30 12:42:03 +0100 | [diff] [blame] | 511 | break; |
| 512 | } |
| 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | arch_initcall(bcm63xx_clk_init); |