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

ARM: PRIMA2: convert to common clk and finish full clk tree

Commit 02c981c07bc95ac1e only implements a little part of primaII clk tree
due to common clk framework was not ready at that time.
This patch converts the old driver to common clk and finish the full clk
tree.

Signed-off-by: Binghua Duan <Binghua.Duan@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Binghua Duan and committed by
Mike Turquette
198678b0 fea7a08a

+954 -288
+1 -1
arch/arm/Kconfig
··· 413 413 select NO_IOPORT 414 414 select ARCH_REQUIRE_GPIOLIB 415 415 select GENERIC_CLOCKEVENTS 416 - select CLKDEV_LOOKUP 416 + select COMMON_CLK 417 417 select GENERIC_IRQ_CHIP 418 418 select MIGHT_HAVE_CACHE_L2X0 419 419 select PINCTRL
+946 -285
arch/arm/mach-prima2/clock.c
··· 8 8 9 9 #include <linux/module.h> 10 10 #include <linux/bitops.h> 11 - #include <linux/err.h> 12 - #include <linux/errno.h> 13 11 #include <linux/io.h> 14 - #include <linux/clkdev.h> 15 12 #include <linux/clk.h> 16 - #include <linux/spinlock.h> 17 - #include <linux/of.h> 13 + #include <linux/clkdev.h> 14 + #include <linux/clk-provider.h> 18 15 #include <linux/of_address.h> 19 - #include <asm/mach/map.h> 20 - #include <mach/map.h> 16 + #include <linux/syscore_ops.h> 21 17 22 18 #define SIRFSOC_CLKC_CLK_EN0 0x0000 23 19 #define SIRFSOC_CLKC_CLK_EN1 0x0004 ··· 25 29 #define SIRFSOC_CLKC_DSP_CFG 0x0028 26 30 #define SIRFSOC_CLKC_GFX_CFG 0x002c 27 31 #define SIRFSOC_CLKC_MM_CFG 0x0030 28 - #define SIRFSOC_LKC_LCD_CFG 0x0034 32 + #define SIRFSOC_CLKC_LCD_CFG 0x0034 29 33 #define SIRFSOC_CLKC_MMC_CFG 0x0038 30 34 #define SIRFSOC_CLKC_PLL1_CFG0 0x0040 31 35 #define SIRFSOC_CLKC_PLL2_CFG0 0x0044 ··· 36 40 #define SIRFSOC_CLKC_PLL1_CFG2 0x0058 37 41 #define SIRFSOC_CLKC_PLL2_CFG2 0x005c 38 42 #define SIRFSOC_CLKC_PLL3_CFG2 0x0060 43 + #define SIRFSOC_USBPHY_PLL_CTRL 0x0008 44 + #define SIRFSOC_USBPHY_PLL_POWERDOWN BIT(1) 45 + #define SIRFSOC_USBPHY_PLL_BYPASS BIT(2) 46 + #define SIRFSOC_USBPHY_PLL_LOCK BIT(3) 39 47 40 - #define SIRFSOC_CLOCK_VA_BASE SIRFSOC_VA(0x005000) 48 + static void *sirfsoc_clk_vbase, *sirfsoc_rsc_vbase; 41 49 42 50 #define KHZ 1000 43 51 #define MHZ (KHZ * KHZ) 44 52 45 - struct clk_ops { 46 - unsigned long (*get_rate)(struct clk *clk); 47 - long (*round_rate)(struct clk *clk, unsigned long rate); 48 - int (*set_rate)(struct clk *clk, unsigned long rate); 49 - int (*enable)(struct clk *clk); 50 - int (*disable)(struct clk *clk); 51 - struct clk *(*get_parent)(struct clk *clk); 52 - int (*set_parent)(struct clk *clk, struct clk *parent); 53 + /* 54 + * SiRFprimaII clock controller 55 + * - 2 oscillators: osc-26MHz, rtc-32.768KHz 56 + * - 3 standard configurable plls: pll1, pll2 & pll3 57 + * - 2 exclusive plls: usb phy pll and sata phy pll 58 + * - 8 clock domains: cpu/cpudiv, mem/memdiv, sys/io, dsp, graphic, multimedia, 59 + * display and sdphy. 60 + * Each clock domain can select its own clock source from five clock sources, 61 + * X_XIN, X_XINW, PLL1, PLL2 and PLL3. The domain clock is used as the source 62 + * clock of the group clock. 63 + * - dsp domain: gps, mf 64 + * - io domain: dmac, nand, audio, uart, i2c, spi, usp, pwm, pulse 65 + * - sys domain: security 66 + */ 67 + 68 + struct clk_pll { 69 + struct clk_hw hw; 70 + unsigned short regofs; /* register offset */ 53 71 }; 54 72 55 - struct clk { 56 - struct clk *parent; /* parent clk */ 57 - unsigned long rate; /* clock rate in Hz */ 58 - signed char usage; /* clock enable count */ 73 + #define to_pllclk(_hw) container_of(_hw, struct clk_pll, hw) 74 + 75 + struct clk_dmn { 76 + struct clk_hw hw; 59 77 signed char enable_bit; /* enable bit: 0 ~ 63 */ 60 78 unsigned short regofs; /* register offset */ 61 - struct clk_ops *ops; /* clock operation */ 62 79 }; 63 80 64 - static DEFINE_SPINLOCK(clocks_lock); 81 + #define to_dmnclk(_hw) container_of(_hw, struct clk_dmn, hw) 82 + 83 + struct clk_std { 84 + struct clk_hw hw; 85 + signed char enable_bit; /* enable bit: 0 ~ 63 */ 86 + }; 87 + 88 + #define to_stdclk(_hw) container_of(_hw, struct clk_std, hw) 89 + 90 + static int std_clk_is_enabled(struct clk_hw *hw); 91 + static int std_clk_enable(struct clk_hw *hw); 92 + static void std_clk_disable(struct clk_hw *hw); 65 93 66 94 static inline unsigned long clkc_readl(unsigned reg) 67 95 { 68 - return readl(SIRFSOC_CLOCK_VA_BASE + reg); 96 + return readl(sirfsoc_clk_vbase + reg); 69 97 } 70 98 71 99 static inline void clkc_writel(u32 val, unsigned reg) 72 100 { 73 - writel(val, SIRFSOC_CLOCK_VA_BASE + reg); 101 + writel(val, sirfsoc_clk_vbase + reg); 74 102 } 75 - 76 - /* 77 - * osc_rtc - real time oscillator - 32.768KHz 78 - * osc_sys - high speed oscillator - 26MHz 79 - */ 80 - 81 - static struct clk clk_rtc = { 82 - .rate = 32768, 83 - }; 84 - 85 - static struct clk clk_osc = { 86 - .rate = 26 * MHZ, 87 - }; 88 103 89 104 /* 90 105 * std pll 91 106 */ 92 - static unsigned long std_pll_get_rate(struct clk *clk) 107 + 108 + static unsigned long pll_clk_recalc_rate(struct clk_hw *hw, 109 + unsigned long parent_rate) 93 110 { 94 - unsigned long fin = clk_get_rate(clk->parent); 111 + unsigned long fin = parent_rate; 112 + struct clk_pll *clk = to_pllclk(hw); 95 113 u32 regcfg2 = clk->regofs + SIRFSOC_CLKC_PLL1_CFG2 - 96 114 SIRFSOC_CLKC_PLL1_CFG0; 97 115 98 116 if (clkc_readl(regcfg2) & BIT(2)) { 99 117 /* pll bypass mode */ 100 - clk->rate = fin; 118 + return fin; 101 119 } else { 102 120 /* fout = fin * nf / nr / od */ 103 121 u32 cfg0 = clkc_readl(clk->regofs); ··· 119 109 u32 nr = ((cfg0 >> 13) & (BIT(6) - 1)) + 1; 120 110 u32 od = ((cfg0 >> 19) & (BIT(4) - 1)) + 1; 121 111 WARN_ON(fin % MHZ); 122 - clk->rate = fin / MHZ * nf / nr / od * MHZ; 112 + return fin / MHZ * nf / nr / od * MHZ; 123 113 } 124 - 125 - return clk->rate; 126 114 } 127 115 128 - static int std_pll_set_rate(struct clk *clk, unsigned long rate) 116 + static long pll_clk_round_rate(struct clk_hw *hw, unsigned long rate, 117 + unsigned long *parent_rate) 129 118 { 119 + unsigned long fin, nf, nr, od; 120 + 121 + /* 122 + * fout = fin * nf / (nr * od); 123 + * set od = 1, nr = fin/MHz, so fout = nf * MHz 124 + */ 125 + rate = rate - rate % MHZ; 126 + 127 + nf = rate / MHZ; 128 + if (nf > BIT(13)) 129 + nf = BIT(13); 130 + if (nf < 1) 131 + nf = 1; 132 + 133 + fin = *parent_rate; 134 + 135 + nr = fin / MHZ; 136 + if (nr > BIT(6)) 137 + nr = BIT(6); 138 + od = 1; 139 + 140 + return fin * nf / (nr * od); 141 + } 142 + 143 + static int pll_clk_set_rate(struct clk_hw *hw, unsigned long rate, 144 + unsigned long parent_rate) 145 + { 146 + struct clk_pll *clk = to_pllclk(hw); 130 147 unsigned long fin, nf, nr, od, reg; 131 148 132 149 /* ··· 165 128 if (unlikely((rate % MHZ) || nf > BIT(13) || nf < 1)) 166 129 return -EINVAL; 167 130 168 - fin = clk_get_rate(clk->parent); 131 + fin = parent_rate; 169 132 BUG_ON(fin < MHZ); 170 133 171 134 nr = fin / MHZ; ··· 183 146 while (!(clkc_readl(reg) & BIT(6))) 184 147 cpu_relax(); 185 148 186 - clk->rate = 0; /* set to zero will force recalculation */ 187 149 return 0; 188 150 } 189 151 190 152 static struct clk_ops std_pll_ops = { 191 - .get_rate = std_pll_get_rate, 192 - .set_rate = std_pll_set_rate, 153 + .recalc_rate = pll_clk_recalc_rate, 154 + .round_rate = pll_clk_round_rate, 155 + .set_rate = pll_clk_set_rate, 193 156 }; 194 157 195 - static struct clk clk_pll1 = { 196 - .parent = &clk_osc, 158 + static const char *pll_clk_parents[] = { 159 + "osc", 160 + }; 161 + 162 + static struct clk_init_data clk_pll1_init = { 163 + .name = "pll1", 164 + .ops = &std_pll_ops, 165 + .parent_names = pll_clk_parents, 166 + .num_parents = ARRAY_SIZE(pll_clk_parents), 167 + }; 168 + 169 + static struct clk_init_data clk_pll2_init = { 170 + .name = "pll2", 171 + .ops = &std_pll_ops, 172 + .parent_names = pll_clk_parents, 173 + .num_parents = ARRAY_SIZE(pll_clk_parents), 174 + }; 175 + 176 + static struct clk_init_data clk_pll3_init = { 177 + .name = "pll3", 178 + .ops = &std_pll_ops, 179 + .parent_names = pll_clk_parents, 180 + .num_parents = ARRAY_SIZE(pll_clk_parents), 181 + }; 182 + 183 + static struct clk_pll clk_pll1 = { 197 184 .regofs = SIRFSOC_CLKC_PLL1_CFG0, 198 - .ops = &std_pll_ops, 185 + .hw = { 186 + .init = &clk_pll1_init, 187 + }, 199 188 }; 200 189 201 - static struct clk clk_pll2 = { 202 - .parent = &clk_osc, 190 + static struct clk_pll clk_pll2 = { 203 191 .regofs = SIRFSOC_CLKC_PLL2_CFG0, 204 - .ops = &std_pll_ops, 192 + .hw = { 193 + .init = &clk_pll2_init, 194 + }, 205 195 }; 206 196 207 - static struct clk clk_pll3 = { 208 - .parent = &clk_osc, 197 + static struct clk_pll clk_pll3 = { 209 198 .regofs = SIRFSOC_CLKC_PLL3_CFG0, 210 - .ops = &std_pll_ops, 199 + .hw = { 200 + .init = &clk_pll3_init, 201 + }, 211 202 }; 212 203 213 204 /* 214 - * clock domains - cpu, mem, sys/io 205 + * usb uses specified pll 215 206 */ 216 207 217 - static struct clk clk_mem; 218 - 219 - static struct clk *dmn_get_parent(struct clk *clk) 208 + static int usb_pll_clk_enable(struct clk_hw *hw) 220 209 { 221 - struct clk *clks[] = { 222 - &clk_osc, &clk_rtc, &clk_pll1, &clk_pll2, &clk_pll3 223 - }; 210 + u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL); 211 + reg &= ~(SIRFSOC_USBPHY_PLL_POWERDOWN | SIRFSOC_USBPHY_PLL_BYPASS); 212 + writel(reg, sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL); 213 + while (!(readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL) & 214 + SIRFSOC_USBPHY_PLL_LOCK)) 215 + cpu_relax(); 216 + 217 + return 0; 218 + } 219 + 220 + static void usb_pll_clk_disable(struct clk_hw *clk) 221 + { 222 + u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL); 223 + reg |= (SIRFSOC_USBPHY_PLL_POWERDOWN | SIRFSOC_USBPHY_PLL_BYPASS); 224 + writel(reg, sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL); 225 + } 226 + 227 + static unsigned long usb_pll_clk_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) 228 + { 229 + u32 reg = readl(sirfsoc_rsc_vbase + SIRFSOC_USBPHY_PLL_CTRL); 230 + return (reg & SIRFSOC_USBPHY_PLL_BYPASS) ? parent_rate : 48*MHZ; 231 + } 232 + 233 + static struct clk_ops usb_pll_ops = { 234 + .enable = usb_pll_clk_enable, 235 + .disable = usb_pll_clk_disable, 236 + .recalc_rate = usb_pll_clk_recalc_rate, 237 + }; 238 + 239 + static struct clk_init_data clk_usb_pll_init = { 240 + .name = "usb_pll", 241 + .ops = &usb_pll_ops, 242 + .parent_names = pll_clk_parents, 243 + .num_parents = ARRAY_SIZE(pll_clk_parents), 244 + }; 245 + 246 + static struct clk_hw usb_pll_clk_hw = { 247 + .init = &clk_usb_pll_init, 248 + }; 249 + 250 + /* 251 + * clock domains - cpu, mem, sys/io, dsp, gfx 252 + */ 253 + 254 + static const char *dmn_clk_parents[] = { 255 + "rtc", 256 + "osc", 257 + "pll1", 258 + "pll2", 259 + "pll3", 260 + }; 261 + 262 + static u8 dmn_clk_get_parent(struct clk_hw *hw) 263 + { 264 + struct clk_dmn *clk = to_dmnclk(hw); 224 265 u32 cfg = clkc_readl(clk->regofs); 266 + 267 + /* parent of io domain can only be pll3 */ 268 + if (strcmp(hw->init->name, "io") == 0) 269 + return 4; 270 + 225 271 WARN_ON((cfg & (BIT(3) - 1)) > 4); 226 - return clks[cfg & (BIT(3) - 1)]; 272 + 273 + return cfg & (BIT(3) - 1); 227 274 } 228 275 229 - static int dmn_set_parent(struct clk *clk, struct clk *parent) 276 + static int dmn_clk_set_parent(struct clk_hw *hw, u8 parent) 230 277 { 231 - const struct clk *clks[] = { 232 - &clk_osc, &clk_rtc, &clk_pll1, &clk_pll2, &clk_pll3 233 - }; 278 + struct clk_dmn *clk = to_dmnclk(hw); 234 279 u32 cfg = clkc_readl(clk->regofs); 235 - int i; 236 - for (i = 0; i < ARRAY_SIZE(clks); i++) { 237 - if (clks[i] == parent) { 238 - cfg &= ~(BIT(3) - 1); 239 - clkc_writel(cfg | i, clk->regofs); 240 - /* BIT(3) - switching status: 1 - busy, 0 - done */ 241 - while (clkc_readl(clk->regofs) & BIT(3)) 242 - cpu_relax(); 243 - return 0; 244 - } 245 - } 246 - return -EINVAL; 280 + 281 + /* parent of io domain can only be pll3 */ 282 + if (strcmp(hw->init->name, "io") == 0) 283 + return -EINVAL; 284 + 285 + cfg &= ~(BIT(3) - 1); 286 + clkc_writel(cfg | parent, clk->regofs); 287 + /* BIT(3) - switching status: 1 - busy, 0 - done */ 288 + while (clkc_readl(clk->regofs) & BIT(3)) 289 + cpu_relax(); 290 + 291 + return 0; 247 292 } 248 293 249 - static unsigned long dmn_get_rate(struct clk *clk) 294 + static unsigned long dmn_clk_recalc_rate(struct clk_hw *hw, 295 + unsigned long parent_rate) 296 + 250 297 { 251 - unsigned long fin = clk_get_rate(clk->parent); 298 + unsigned long fin = parent_rate; 299 + struct clk_dmn *clk = to_dmnclk(hw); 300 + 252 301 u32 cfg = clkc_readl(clk->regofs); 302 + 253 303 if (cfg & BIT(24)) { 254 304 /* fcd bypass mode */ 255 - clk->rate = fin; 305 + return fin; 256 306 } else { 257 307 /* 258 308 * wait count: bit[19:16], hold count: bit[23:20] ··· 347 223 u32 wait = (cfg >> 16) & (BIT(4) - 1); 348 224 u32 hold = (cfg >> 20) & (BIT(4) - 1); 349 225 350 - clk->rate = fin / (wait + hold + 2); 226 + return fin / (wait + hold + 2); 351 227 } 352 - 353 - return clk->rate; 354 228 } 355 229 356 - static int dmn_set_rate(struct clk *clk, unsigned long rate) 230 + static long dmn_clk_round_rate(struct clk_hw *hw, unsigned long rate, 231 + unsigned long *parent_rate) 357 232 { 358 233 unsigned long fin; 359 - unsigned ratio, wait, hold, reg; 360 - unsigned bits = (clk == &clk_mem) ? 3 : 4; 234 + unsigned ratio, wait, hold; 235 + unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4; 361 236 362 - fin = clk_get_rate(clk->parent); 237 + fin = *parent_rate; 238 + ratio = fin / rate; 239 + 240 + if (ratio < 2) 241 + ratio = 2; 242 + if (ratio > BIT(bits + 1)) 243 + ratio = BIT(bits + 1); 244 + 245 + wait = (ratio >> 1) - 1; 246 + hold = ratio - wait - 2; 247 + 248 + return fin / (wait + hold + 2); 249 + } 250 + 251 + static int dmn_clk_set_rate(struct clk_hw *hw, unsigned long rate, 252 + unsigned long parent_rate) 253 + { 254 + struct clk_dmn *clk = to_dmnclk(hw); 255 + unsigned long fin; 256 + unsigned ratio, wait, hold, reg; 257 + unsigned bits = (strcmp(hw->init->name, "mem") == 0) ? 3 : 4; 258 + 259 + fin = parent_rate; 363 260 ratio = fin / rate; 364 261 365 262 if (unlikely(ratio < 2 || ratio > BIT(bits + 1))) ··· 400 255 while (clkc_readl(clk->regofs) & BIT(25)) 401 256 cpu_relax(); 402 257 403 - clk->rate = 0; /* set to zero will force recalculation */ 404 - 405 258 return 0; 406 259 } 407 260 408 - /* 409 - * cpu clock has no FCD register in Prima2, can only change pll 410 - */ 411 - static int cpu_set_rate(struct clk *clk, unsigned long rate) 412 - { 413 - int ret1, ret2; 414 - struct clk *cur_parent, *tmp_parent; 415 - 416 - cur_parent = dmn_get_parent(clk); 417 - BUG_ON(cur_parent == NULL || cur_parent->usage > 1); 418 - 419 - /* switch to tmp pll before setting parent clock's rate */ 420 - tmp_parent = cur_parent == &clk_pll1 ? &clk_pll2 : &clk_pll1; 421 - ret1 = dmn_set_parent(clk, tmp_parent); 422 - BUG_ON(ret1); 423 - 424 - ret2 = clk_set_rate(cur_parent, rate); 425 - 426 - ret1 = dmn_set_parent(clk, cur_parent); 427 - 428 - clk->rate = 0; /* set to zero will force recalculation */ 429 - 430 - return ret2 ? ret2 : ret1; 431 - } 432 - 433 - static struct clk_ops cpu_ops = { 434 - .get_parent = dmn_get_parent, 435 - .set_parent = dmn_set_parent, 436 - .set_rate = cpu_set_rate, 437 - }; 438 - 439 - static struct clk clk_cpu = { 440 - .parent = &clk_pll1, 441 - .regofs = SIRFSOC_CLKC_CPU_CFG, 442 - .ops = &cpu_ops, 443 - }; 444 - 445 - 446 261 static struct clk_ops msi_ops = { 447 - .set_rate = dmn_set_rate, 448 - .get_rate = dmn_get_rate, 449 - .set_parent = dmn_set_parent, 450 - .get_parent = dmn_get_parent, 262 + .set_rate = dmn_clk_set_rate, 263 + .round_rate = dmn_clk_round_rate, 264 + .recalc_rate = dmn_clk_recalc_rate, 265 + .set_parent = dmn_clk_set_parent, 266 + .get_parent = dmn_clk_get_parent, 451 267 }; 452 268 453 - static struct clk clk_mem = { 454 - .parent = &clk_pll2, 269 + static struct clk_init_data clk_mem_init = { 270 + .name = "mem", 271 + .ops = &msi_ops, 272 + .parent_names = dmn_clk_parents, 273 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 274 + }; 275 + 276 + static struct clk_dmn clk_mem = { 455 277 .regofs = SIRFSOC_CLKC_MEM_CFG, 456 - .ops = &msi_ops, 457 - }; 458 - 459 - static struct clk clk_sys = { 460 - .parent = &clk_pll3, 461 - .regofs = SIRFSOC_CLKC_SYS_CFG, 462 - .ops = &msi_ops, 463 - }; 464 - 465 - static struct clk clk_io = { 466 - .parent = &clk_pll3, 467 - .regofs = SIRFSOC_CLKC_IO_CFG, 468 - .ops = &msi_ops, 469 - }; 470 - 471 - /* 472 - * on-chip clock sets 473 - */ 474 - static struct clk_lookup onchip_clks[] = { 475 - { 476 - .dev_id = "rtc", 477 - .clk = &clk_rtc, 478 - }, { 479 - .dev_id = "osc", 480 - .clk = &clk_osc, 481 - }, { 482 - .dev_id = "pll1", 483 - .clk = &clk_pll1, 484 - }, { 485 - .dev_id = "pll2", 486 - .clk = &clk_pll2, 487 - }, { 488 - .dev_id = "pll3", 489 - .clk = &clk_pll3, 490 - }, { 491 - .dev_id = "cpu", 492 - .clk = &clk_cpu, 493 - }, { 494 - .dev_id = "mem", 495 - .clk = &clk_mem, 496 - }, { 497 - .dev_id = "sys", 498 - .clk = &clk_sys, 499 - }, { 500 - .dev_id = "io", 501 - .clk = &clk_io, 278 + .hw = { 279 + .init = &clk_mem_init, 502 280 }, 503 281 }; 504 282 505 - int clk_enable(struct clk *clk) 283 + static struct clk_init_data clk_sys_init = { 284 + .name = "sys", 285 + .ops = &msi_ops, 286 + .parent_names = dmn_clk_parents, 287 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 288 + .flags = CLK_SET_RATE_GATE, 289 + }; 290 + 291 + static struct clk_dmn clk_sys = { 292 + .regofs = SIRFSOC_CLKC_SYS_CFG, 293 + .hw = { 294 + .init = &clk_sys_init, 295 + }, 296 + }; 297 + 298 + static struct clk_init_data clk_io_init = { 299 + .name = "io", 300 + .ops = &msi_ops, 301 + .parent_names = dmn_clk_parents, 302 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 303 + }; 304 + 305 + static struct clk_dmn clk_io = { 306 + .regofs = SIRFSOC_CLKC_IO_CFG, 307 + .hw = { 308 + .init = &clk_io_init, 309 + }, 310 + }; 311 + 312 + static struct clk_ops cpu_ops = { 313 + .set_parent = dmn_clk_set_parent, 314 + .get_parent = dmn_clk_get_parent, 315 + }; 316 + 317 + static struct clk_init_data clk_cpu_init = { 318 + .name = "cpu", 319 + .ops = &cpu_ops, 320 + .parent_names = dmn_clk_parents, 321 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 322 + .flags = CLK_SET_RATE_PARENT, 323 + }; 324 + 325 + static struct clk_dmn clk_cpu = { 326 + .regofs = SIRFSOC_CLKC_CPU_CFG, 327 + .hw = { 328 + .init = &clk_cpu_init, 329 + }, 330 + }; 331 + 332 + static struct clk_ops dmn_ops = { 333 + .is_enabled = std_clk_is_enabled, 334 + .enable = std_clk_enable, 335 + .disable = std_clk_disable, 336 + .set_rate = dmn_clk_set_rate, 337 + .round_rate = dmn_clk_round_rate, 338 + .recalc_rate = dmn_clk_recalc_rate, 339 + .set_parent = dmn_clk_set_parent, 340 + .get_parent = dmn_clk_get_parent, 341 + }; 342 + 343 + /* dsp, gfx, mm, lcd and vpp domain */ 344 + 345 + static struct clk_init_data clk_dsp_init = { 346 + .name = "dsp", 347 + .ops = &dmn_ops, 348 + .parent_names = dmn_clk_parents, 349 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 350 + }; 351 + 352 + static struct clk_dmn clk_dsp = { 353 + .regofs = SIRFSOC_CLKC_DSP_CFG, 354 + .enable_bit = 0, 355 + .hw = { 356 + .init = &clk_dsp_init, 357 + }, 358 + }; 359 + 360 + static struct clk_init_data clk_gfx_init = { 361 + .name = "gfx", 362 + .ops = &dmn_ops, 363 + .parent_names = dmn_clk_parents, 364 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 365 + }; 366 + 367 + static struct clk_dmn clk_gfx = { 368 + .regofs = SIRFSOC_CLKC_GFX_CFG, 369 + .enable_bit = 8, 370 + .hw = { 371 + .init = &clk_gfx_init, 372 + }, 373 + }; 374 + 375 + static struct clk_init_data clk_mm_init = { 376 + .name = "mm", 377 + .ops = &dmn_ops, 378 + .parent_names = dmn_clk_parents, 379 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 380 + }; 381 + 382 + static struct clk_dmn clk_mm = { 383 + .regofs = SIRFSOC_CLKC_MM_CFG, 384 + .enable_bit = 9, 385 + .hw = { 386 + .init = &clk_mm_init, 387 + }, 388 + }; 389 + 390 + static struct clk_init_data clk_lcd_init = { 391 + .name = "lcd", 392 + .ops = &dmn_ops, 393 + .parent_names = dmn_clk_parents, 394 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 395 + }; 396 + 397 + static struct clk_dmn clk_lcd = { 398 + .regofs = SIRFSOC_CLKC_LCD_CFG, 399 + .enable_bit = 10, 400 + .hw = { 401 + .init = &clk_lcd_init, 402 + }, 403 + }; 404 + 405 + static struct clk_init_data clk_vpp_init = { 406 + .name = "vpp", 407 + .ops = &dmn_ops, 408 + .parent_names = dmn_clk_parents, 409 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 410 + }; 411 + 412 + static struct clk_dmn clk_vpp = { 413 + .regofs = SIRFSOC_CLKC_LCD_CFG, 414 + .enable_bit = 11, 415 + .hw = { 416 + .init = &clk_vpp_init, 417 + }, 418 + }; 419 + 420 + static struct clk_init_data clk_mmc01_init = { 421 + .name = "mmc01", 422 + .ops = &dmn_ops, 423 + .parent_names = dmn_clk_parents, 424 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 425 + }; 426 + 427 + static struct clk_dmn clk_mmc01 = { 428 + .regofs = SIRFSOC_CLKC_MMC_CFG, 429 + .enable_bit = 59, 430 + .hw = { 431 + .init = &clk_mmc01_init, 432 + }, 433 + }; 434 + 435 + static struct clk_init_data clk_mmc23_init = { 436 + .name = "mmc23", 437 + .ops = &dmn_ops, 438 + .parent_names = dmn_clk_parents, 439 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 440 + }; 441 + 442 + static struct clk_dmn clk_mmc23 = { 443 + .regofs = SIRFSOC_CLKC_MMC_CFG, 444 + .enable_bit = 60, 445 + .hw = { 446 + .init = &clk_mmc23_init, 447 + }, 448 + }; 449 + 450 + static struct clk_init_data clk_mmc45_init = { 451 + .name = "mmc45", 452 + .ops = &dmn_ops, 453 + .parent_names = dmn_clk_parents, 454 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 455 + }; 456 + 457 + static struct clk_dmn clk_mmc45 = { 458 + .regofs = SIRFSOC_CLKC_MMC_CFG, 459 + .enable_bit = 61, 460 + .hw = { 461 + .init = &clk_mmc45_init, 462 + }, 463 + }; 464 + 465 + /* 466 + * peripheral controllers in io domain 467 + */ 468 + 469 + static int std_clk_is_enabled(struct clk_hw *hw) 506 470 { 507 - unsigned long flags; 471 + u32 reg; 472 + int bit; 473 + struct clk_std *clk = to_stdclk(hw); 508 474 509 - if (unlikely(IS_ERR_OR_NULL(clk))) 510 - return -EINVAL; 475 + bit = clk->enable_bit % 32; 476 + reg = clk->enable_bit / 32; 477 + reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg); 511 478 512 - if (clk->parent) 513 - clk_enable(clk->parent); 479 + return !!(clkc_readl(reg) & BIT(bit)); 480 + } 514 481 515 - spin_lock_irqsave(&clocks_lock, flags); 516 - if (!clk->usage++ && clk->ops && clk->ops->enable) 517 - clk->ops->enable(clk); 518 - spin_unlock_irqrestore(&clocks_lock, flags); 482 + static int std_clk_enable(struct clk_hw *hw) 483 + { 484 + u32 val, reg; 485 + int bit; 486 + struct clk_std *clk = to_stdclk(hw); 487 + 488 + BUG_ON(clk->enable_bit < 0 || clk->enable_bit > 63); 489 + 490 + bit = clk->enable_bit % 32; 491 + reg = clk->enable_bit / 32; 492 + reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg); 493 + 494 + val = clkc_readl(reg) | BIT(bit); 495 + clkc_writel(val, reg); 519 496 return 0; 520 497 } 521 - EXPORT_SYMBOL(clk_enable); 522 498 523 - void clk_disable(struct clk *clk) 499 + static void std_clk_disable(struct clk_hw *hw) 524 500 { 525 - unsigned long flags; 501 + u32 val, reg; 502 + int bit; 503 + struct clk_std *clk = to_stdclk(hw); 526 504 527 - if (unlikely(IS_ERR_OR_NULL(clk))) 528 - return; 505 + BUG_ON(clk->enable_bit < 0 || clk->enable_bit > 63); 529 506 530 - WARN_ON(!clk->usage); 507 + bit = clk->enable_bit % 32; 508 + reg = clk->enable_bit / 32; 509 + reg = SIRFSOC_CLKC_CLK_EN0 + reg * sizeof(reg); 531 510 532 - spin_lock_irqsave(&clocks_lock, flags); 533 - if (--clk->usage == 0 && clk->ops && clk->ops->disable) 534 - clk->ops->disable(clk); 535 - spin_unlock_irqrestore(&clocks_lock, flags); 536 - 537 - if (clk->parent) 538 - clk_disable(clk->parent); 511 + val = clkc_readl(reg) & ~BIT(bit); 512 + clkc_writel(val, reg); 539 513 } 540 - EXPORT_SYMBOL(clk_disable); 541 514 542 - unsigned long clk_get_rate(struct clk *clk) 543 - { 544 - if (unlikely(IS_ERR_OR_NULL(clk))) 545 - return 0; 515 + static const char *std_clk_io_parents[] = { 516 + "io", 517 + }; 546 518 547 - if (clk->rate) 548 - return clk->rate; 519 + static struct clk_ops ios_ops = { 520 + .is_enabled = std_clk_is_enabled, 521 + .enable = std_clk_enable, 522 + .disable = std_clk_disable, 523 + }; 549 524 550 - if (clk->ops && clk->ops->get_rate) 551 - return clk->ops->get_rate(clk); 525 + static struct clk_init_data clk_dmac0_init = { 526 + .name = "dmac0", 527 + .ops = &ios_ops, 528 + .parent_names = std_clk_io_parents, 529 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 530 + }; 552 531 553 - return clk_get_rate(clk->parent); 554 - } 555 - EXPORT_SYMBOL(clk_get_rate); 532 + static struct clk_std clk_dmac0 = { 533 + .enable_bit = 32, 534 + .hw = { 535 + .init = &clk_dmac0_init, 536 + }, 537 + }; 556 538 557 - long clk_round_rate(struct clk *clk, unsigned long rate) 558 - { 559 - if (unlikely(IS_ERR_OR_NULL(clk))) 560 - return 0; 539 + static struct clk_init_data clk_dmac1_init = { 540 + .name = "dmac1", 541 + .ops = &ios_ops, 542 + .parent_names = std_clk_io_parents, 543 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 544 + }; 561 545 562 - if (clk->ops && clk->ops->round_rate) 563 - return clk->ops->round_rate(clk, rate); 546 + static struct clk_std clk_dmac1 = { 547 + .enable_bit = 33, 548 + .hw = { 549 + .init = &clk_dmac1_init, 550 + }, 551 + }; 564 552 565 - return 0; 566 - } 567 - EXPORT_SYMBOL(clk_round_rate); 553 + static struct clk_init_data clk_nand_init = { 554 + .name = "nand", 555 + .ops = &ios_ops, 556 + .parent_names = std_clk_io_parents, 557 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 558 + }; 568 559 569 - int clk_set_rate(struct clk *clk, unsigned long rate) 570 - { 571 - if (unlikely(IS_ERR_OR_NULL(clk))) 572 - return -EINVAL; 560 + static struct clk_std clk_nand = { 561 + .enable_bit = 34, 562 + .hw = { 563 + .init = &clk_nand_init, 564 + }, 565 + }; 573 566 574 - if (!clk->ops || !clk->ops->set_rate) 575 - return -EINVAL; 567 + static struct clk_init_data clk_audio_init = { 568 + .name = "audio", 569 + .ops = &ios_ops, 570 + .parent_names = std_clk_io_parents, 571 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 572 + }; 576 573 577 - return clk->ops->set_rate(clk, rate); 578 - } 579 - EXPORT_SYMBOL(clk_set_rate); 574 + static struct clk_std clk_audio = { 575 + .enable_bit = 35, 576 + .hw = { 577 + .init = &clk_audio_init, 578 + }, 579 + }; 580 580 581 - int clk_set_parent(struct clk *clk, struct clk *parent) 582 - { 583 - int ret; 584 - unsigned long flags; 581 + static struct clk_init_data clk_uart0_init = { 582 + .name = "uart0", 583 + .ops = &ios_ops, 584 + .parent_names = std_clk_io_parents, 585 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 586 + }; 585 587 586 - if (unlikely(IS_ERR_OR_NULL(clk))) 587 - return -EINVAL; 588 + static struct clk_std clk_uart0 = { 589 + .enable_bit = 36, 590 + .hw = { 591 + .init = &clk_uart0_init, 592 + }, 593 + }; 588 594 589 - if (!clk->ops || !clk->ops->set_parent) 590 - return -EINVAL; 595 + static struct clk_init_data clk_uart1_init = { 596 + .name = "uart1", 597 + .ops = &ios_ops, 598 + .parent_names = std_clk_io_parents, 599 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 600 + }; 591 601 592 - spin_lock_irqsave(&clocks_lock, flags); 593 - ret = clk->ops->set_parent(clk, parent); 594 - if (!ret) { 595 - parent->usage += clk->usage; 596 - clk->parent->usage -= clk->usage; 597 - BUG_ON(clk->parent->usage < 0); 598 - clk->parent = parent; 599 - } 600 - spin_unlock_irqrestore(&clocks_lock, flags); 601 - return ret; 602 - } 603 - EXPORT_SYMBOL(clk_set_parent); 602 + static struct clk_std clk_uart1 = { 603 + .enable_bit = 37, 604 + .hw = { 605 + .init = &clk_uart1_init, 606 + }, 607 + }; 604 608 605 - struct clk *clk_get_parent(struct clk *clk) 606 - { 607 - unsigned long flags; 609 + static struct clk_init_data clk_uart2_init = { 610 + .name = "uart2", 611 + .ops = &ios_ops, 612 + .parent_names = std_clk_io_parents, 613 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 614 + }; 608 615 609 - if (unlikely(IS_ERR_OR_NULL(clk))) 610 - return NULL; 616 + static struct clk_std clk_uart2 = { 617 + .enable_bit = 38, 618 + .hw = { 619 + .init = &clk_uart2_init, 620 + }, 621 + }; 611 622 612 - if (!clk->ops || !clk->ops->get_parent) 613 - return clk->parent; 623 + static struct clk_init_data clk_usp0_init = { 624 + .name = "usp0", 625 + .ops = &ios_ops, 626 + .parent_names = std_clk_io_parents, 627 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 628 + }; 614 629 615 - spin_lock_irqsave(&clocks_lock, flags); 616 - clk->parent = clk->ops->get_parent(clk); 617 - spin_unlock_irqrestore(&clocks_lock, flags); 618 - return clk->parent; 619 - } 620 - EXPORT_SYMBOL(clk_get_parent); 630 + static struct clk_std clk_usp0 = { 631 + .enable_bit = 39, 632 + .hw = { 633 + .init = &clk_usp0_init, 634 + }, 635 + }; 621 636 622 - static void __init sirfsoc_clk_init(void) 623 - { 624 - clkdev_add_table(onchip_clks, ARRAY_SIZE(onchip_clks)); 625 - } 637 + static struct clk_init_data clk_usp1_init = { 638 + .name = "usp1", 639 + .ops = &ios_ops, 640 + .parent_names = std_clk_io_parents, 641 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 642 + }; 643 + 644 + static struct clk_std clk_usp1 = { 645 + .enable_bit = 40, 646 + .hw = { 647 + .init = &clk_usp1_init, 648 + }, 649 + }; 650 + 651 + static struct clk_init_data clk_usp2_init = { 652 + .name = "usp2", 653 + .ops = &ios_ops, 654 + .parent_names = std_clk_io_parents, 655 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 656 + }; 657 + 658 + static struct clk_std clk_usp2 = { 659 + .enable_bit = 41, 660 + .hw = { 661 + .init = &clk_usp2_init, 662 + }, 663 + }; 664 + 665 + static struct clk_init_data clk_vip_init = { 666 + .name = "vip", 667 + .ops = &ios_ops, 668 + .parent_names = std_clk_io_parents, 669 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 670 + }; 671 + 672 + static struct clk_std clk_vip = { 673 + .enable_bit = 42, 674 + .hw = { 675 + .init = &clk_vip_init, 676 + }, 677 + }; 678 + 679 + static struct clk_init_data clk_spi0_init = { 680 + .name = "spi0", 681 + .ops = &ios_ops, 682 + .parent_names = std_clk_io_parents, 683 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 684 + }; 685 + 686 + static struct clk_std clk_spi0 = { 687 + .enable_bit = 43, 688 + .hw = { 689 + .init = &clk_spi0_init, 690 + }, 691 + }; 692 + 693 + static struct clk_init_data clk_spi1_init = { 694 + .name = "spi1", 695 + .ops = &ios_ops, 696 + .parent_names = std_clk_io_parents, 697 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 698 + }; 699 + 700 + static struct clk_std clk_spi1 = { 701 + .enable_bit = 44, 702 + .hw = { 703 + .init = &clk_spi1_init, 704 + }, 705 + }; 706 + 707 + static struct clk_init_data clk_tsc_init = { 708 + .name = "tsc", 709 + .ops = &ios_ops, 710 + .parent_names = std_clk_io_parents, 711 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 712 + }; 713 + 714 + static struct clk_std clk_tsc = { 715 + .enable_bit = 45, 716 + .hw = { 717 + .init = &clk_tsc_init, 718 + }, 719 + }; 720 + 721 + static struct clk_init_data clk_i2c0_init = { 722 + .name = "i2c0", 723 + .ops = &ios_ops, 724 + .parent_names = std_clk_io_parents, 725 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 726 + }; 727 + 728 + static struct clk_std clk_i2c0 = { 729 + .enable_bit = 46, 730 + .hw = { 731 + .init = &clk_i2c0_init, 732 + }, 733 + }; 734 + 735 + static struct clk_init_data clk_i2c1_init = { 736 + .name = "i2c1", 737 + .ops = &ios_ops, 738 + .parent_names = std_clk_io_parents, 739 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 740 + }; 741 + 742 + static struct clk_std clk_i2c1 = { 743 + .enable_bit = 47, 744 + .hw = { 745 + .init = &clk_i2c1_init, 746 + }, 747 + }; 748 + 749 + static struct clk_init_data clk_pwmc_init = { 750 + .name = "pwmc", 751 + .ops = &ios_ops, 752 + .parent_names = std_clk_io_parents, 753 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 754 + }; 755 + 756 + static struct clk_std clk_pwmc = { 757 + .enable_bit = 48, 758 + .hw = { 759 + .init = &clk_pwmc_init, 760 + }, 761 + }; 762 + 763 + static struct clk_init_data clk_efuse_init = { 764 + .name = "efuse", 765 + .ops = &ios_ops, 766 + .parent_names = std_clk_io_parents, 767 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 768 + }; 769 + 770 + static struct clk_std clk_efuse = { 771 + .enable_bit = 49, 772 + .hw = { 773 + .init = &clk_efuse_init, 774 + }, 775 + }; 776 + 777 + static struct clk_init_data clk_pulse_init = { 778 + .name = "pulse", 779 + .ops = &ios_ops, 780 + .parent_names = std_clk_io_parents, 781 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 782 + }; 783 + 784 + static struct clk_std clk_pulse = { 785 + .enable_bit = 50, 786 + .hw = { 787 + .init = &clk_pulse_init, 788 + }, 789 + }; 790 + 791 + static const char *std_clk_dsp_parents[] = { 792 + "dsp", 793 + }; 794 + 795 + static struct clk_init_data clk_gps_init = { 796 + .name = "gps", 797 + .ops = &ios_ops, 798 + .parent_names = std_clk_dsp_parents, 799 + .num_parents = ARRAY_SIZE(std_clk_dsp_parents), 800 + }; 801 + 802 + static struct clk_std clk_gps = { 803 + .enable_bit = 1, 804 + .hw = { 805 + .init = &clk_gps_init, 806 + }, 807 + }; 808 + 809 + static struct clk_init_data clk_mf_init = { 810 + .name = "mf", 811 + .ops = &ios_ops, 812 + .parent_names = std_clk_io_parents, 813 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 814 + }; 815 + 816 + static struct clk_std clk_mf = { 817 + .enable_bit = 2, 818 + .hw = { 819 + .init = &clk_mf_init, 820 + }, 821 + }; 822 + 823 + static const char *std_clk_sys_parents[] = { 824 + "sys", 825 + }; 826 + 827 + static struct clk_init_data clk_security_init = { 828 + .name = "mf", 829 + .ops = &ios_ops, 830 + .parent_names = std_clk_sys_parents, 831 + .num_parents = ARRAY_SIZE(std_clk_sys_parents), 832 + }; 833 + 834 + static struct clk_std clk_security = { 835 + .enable_bit = 19, 836 + .hw = { 837 + .init = &clk_security_init, 838 + }, 839 + }; 840 + 841 + static const char *std_clk_usb_parents[] = { 842 + "usb_pll", 843 + }; 844 + 845 + static struct clk_init_data clk_usb0_init = { 846 + .name = "usb0", 847 + .ops = &ios_ops, 848 + .parent_names = std_clk_usb_parents, 849 + .num_parents = ARRAY_SIZE(std_clk_usb_parents), 850 + }; 851 + 852 + static struct clk_std clk_usb0 = { 853 + .enable_bit = 16, 854 + .hw = { 855 + .init = &clk_usb0_init, 856 + }, 857 + }; 858 + 859 + static struct clk_init_data clk_usb1_init = { 860 + .name = "usb1", 861 + .ops = &ios_ops, 862 + .parent_names = std_clk_usb_parents, 863 + .num_parents = ARRAY_SIZE(std_clk_usb_parents), 864 + }; 865 + 866 + static struct clk_std clk_usb1 = { 867 + .enable_bit = 17, 868 + .hw = { 869 + .init = &clk_usb1_init, 870 + }, 871 + }; 626 872 627 873 static struct of_device_id clkc_ids[] = { 628 874 { .compatible = "sirf,prima2-clkc" }, 629 875 {}, 630 876 }; 631 877 878 + static struct of_device_id rsc_ids[] = { 879 + { .compatible = "sirf,prima2-rsc" }, 880 + {}, 881 + }; 882 + 632 883 void __init sirfsoc_of_clk_init(void) 633 884 { 885 + struct clk *clk; 634 886 struct device_node *np; 635 - struct resource res; 636 - struct map_desc sirfsoc_clkc_iodesc = { 637 - .virtual = SIRFSOC_CLOCK_VA_BASE, 638 - .type = MT_DEVICE, 639 - }; 640 887 641 888 np = of_find_matching_node(NULL, clkc_ids); 642 889 if (!np) 643 890 panic("unable to find compatible clkc node in dtb\n"); 644 891 645 - if (of_address_to_resource(np, 0, &res)) 646 - panic("unable to find clkc range in dtb"); 892 + sirfsoc_clk_vbase = of_iomap(np, 0); 893 + if (!sirfsoc_clk_vbase) 894 + panic("unable to map clkc registers\n"); 895 + 647 896 of_node_put(np); 648 897 649 - sirfsoc_clkc_iodesc.pfn = __phys_to_pfn(res.start); 650 - sirfsoc_clkc_iodesc.length = 1 + res.end - res.start; 898 + np = of_find_matching_node(NULL, rsc_ids); 899 + if (!np) 900 + panic("unable to find compatible rsc node in dtb\n"); 651 901 652 - iotable_init(&sirfsoc_clkc_iodesc, 1); 902 + sirfsoc_rsc_vbase = of_iomap(np, 0); 903 + if (!sirfsoc_rsc_vbase) 904 + panic("unable to map rsc registers\n"); 653 905 654 - sirfsoc_clk_init(); 906 + of_node_put(np); 907 + 908 + 909 + /* These are always available (RTC and 26MHz OSC)*/ 910 + clk = clk_register_fixed_rate(NULL, "rtc", NULL, 911 + CLK_IS_ROOT, 32768); 912 + BUG_ON(!clk); 913 + clk = clk_register_fixed_rate(NULL, "osc", NULL, 914 + CLK_IS_ROOT, 26000000); 915 + BUG_ON(!clk); 916 + 917 + clk = clk_register(NULL, &clk_pll1.hw); 918 + BUG_ON(!clk); 919 + clk = clk_register(NULL, &clk_pll2.hw); 920 + BUG_ON(!clk); 921 + clk = clk_register(NULL, &clk_pll3.hw); 922 + BUG_ON(!clk); 923 + clk = clk_register(NULL, &clk_mem.hw); 924 + BUG_ON(!clk); 925 + clk = clk_register(NULL, &clk_sys.hw); 926 + BUG_ON(!clk); 927 + clk = clk_register(NULL, &clk_security.hw); 928 + BUG_ON(!clk); 929 + clk_register_clkdev(clk, NULL, "b8030000.security"); 930 + clk = clk_register(NULL, &clk_dsp.hw); 931 + BUG_ON(!clk); 932 + clk = clk_register(NULL, &clk_gps.hw); 933 + BUG_ON(!clk); 934 + clk_register_clkdev(clk, NULL, "a8010000.gps"); 935 + clk = clk_register(NULL, &clk_mf.hw); 936 + BUG_ON(!clk); 937 + clk = clk_register(NULL, &clk_io.hw); 938 + BUG_ON(!clk); 939 + clk_register_clkdev(clk, NULL, "io"); 940 + clk = clk_register(NULL, &clk_cpu.hw); 941 + BUG_ON(!clk); 942 + clk_register_clkdev(clk, NULL, "cpu"); 943 + clk = clk_register(NULL, &clk_uart0.hw); 944 + BUG_ON(!clk); 945 + clk_register_clkdev(clk, NULL, "b0050000.uart"); 946 + clk = clk_register(NULL, &clk_uart1.hw); 947 + BUG_ON(!clk); 948 + clk_register_clkdev(clk, NULL, "b0060000.uart"); 949 + clk = clk_register(NULL, &clk_uart2.hw); 950 + BUG_ON(!clk); 951 + clk_register_clkdev(clk, NULL, "b0070000.uart"); 952 + clk = clk_register(NULL, &clk_tsc.hw); 953 + BUG_ON(!clk); 954 + clk_register_clkdev(clk, NULL, "b0110000.tsc"); 955 + clk = clk_register(NULL, &clk_i2c0.hw); 956 + BUG_ON(!clk); 957 + clk_register_clkdev(clk, NULL, "b00e0000.i2c"); 958 + clk = clk_register(NULL, &clk_i2c1.hw); 959 + BUG_ON(!clk); 960 + clk_register_clkdev(clk, NULL, "b00f0000.i2c"); 961 + clk = clk_register(NULL, &clk_spi0.hw); 962 + BUG_ON(!clk); 963 + clk_register_clkdev(clk, NULL, "b00d0000.spi"); 964 + clk = clk_register(NULL, &clk_spi1.hw); 965 + BUG_ON(!clk); 966 + clk_register_clkdev(clk, NULL, "b0170000.spi"); 967 + clk = clk_register(NULL, &clk_pwmc.hw); 968 + BUG_ON(!clk); 969 + clk_register_clkdev(clk, NULL, "b0130000.pwm"); 970 + clk = clk_register(NULL, &clk_efuse.hw); 971 + BUG_ON(!clk); 972 + clk_register_clkdev(clk, NULL, "b0140000.efusesys"); 973 + clk = clk_register(NULL, &clk_pulse.hw); 974 + BUG_ON(!clk); 975 + clk_register_clkdev(clk, NULL, "b0150000.pulsec"); 976 + clk = clk_register(NULL, &clk_dmac0.hw); 977 + BUG_ON(!clk); 978 + clk_register_clkdev(clk, NULL, "b00b0000.dma-controller"); 979 + clk = clk_register(NULL, &clk_dmac1.hw); 980 + BUG_ON(!clk); 981 + clk_register_clkdev(clk, NULL, "b0160000.dma-controller"); 982 + clk = clk_register(NULL, &clk_nand.hw); 983 + BUG_ON(!clk); 984 + clk_register_clkdev(clk, NULL, "b0030000.nand"); 985 + clk = clk_register(NULL, &clk_audio.hw); 986 + BUG_ON(!clk); 987 + clk_register_clkdev(clk, NULL, "b0040000.audio"); 988 + clk = clk_register(NULL, &clk_usp0.hw); 989 + BUG_ON(!clk); 990 + clk_register_clkdev(clk, NULL, "b0080000.usp"); 991 + clk = clk_register(NULL, &clk_usp1.hw); 992 + BUG_ON(!clk); 993 + clk_register_clkdev(clk, NULL, "b0090000.usp"); 994 + clk = clk_register(NULL, &clk_usp2.hw); 995 + BUG_ON(!clk); 996 + clk_register_clkdev(clk, NULL, "b00a0000.usp"); 997 + clk = clk_register(NULL, &clk_vip.hw); 998 + BUG_ON(!clk); 999 + clk_register_clkdev(clk, NULL, "b00c0000.vip"); 1000 + clk = clk_register(NULL, &clk_gfx.hw); 1001 + BUG_ON(!clk); 1002 + clk_register_clkdev(clk, NULL, "98000000.graphics"); 1003 + clk = clk_register(NULL, &clk_mm.hw); 1004 + BUG_ON(!clk); 1005 + clk_register_clkdev(clk, NULL, "a0000000.multimedia"); 1006 + clk = clk_register(NULL, &clk_lcd.hw); 1007 + BUG_ON(!clk); 1008 + clk_register_clkdev(clk, NULL, "90010000.display"); 1009 + clk = clk_register(NULL, &clk_vpp.hw); 1010 + BUG_ON(!clk); 1011 + clk_register_clkdev(clk, NULL, "90020000.vpp"); 1012 + clk = clk_register(NULL, &clk_mmc01.hw); 1013 + BUG_ON(!clk); 1014 + clk = clk_register(NULL, &clk_mmc23.hw); 1015 + BUG_ON(!clk); 1016 + clk = clk_register(NULL, &clk_mmc45.hw); 1017 + BUG_ON(!clk); 1018 + clk = clk_register(NULL, &usb_pll_clk_hw); 1019 + BUG_ON(!clk); 1020 + clk = clk_register(NULL, &clk_usb0.hw); 1021 + BUG_ON(!clk); 1022 + clk_register_clkdev(clk, NULL, "b00e0000.usb"); 1023 + clk = clk_register(NULL, &clk_usb1.hw); 1024 + BUG_ON(!clk); 1025 + clk_register_clkdev(clk, NULL, "b00f0000.usb"); 655 1026 }
-1
arch/arm/mach-prima2/prima2.c
··· 38 38 MACHINE_START(PRIMA2_EVB, "prima2cb") 39 39 /* Maintainer: Barry Song <baohua.song@csr.com> */ 40 40 .atag_offset = 0x100, 41 - .init_early = sirfsoc_of_clk_init, 42 41 .map_io = sirfsoc_map_lluart, 43 42 .init_irq = sirfsoc_of_irq_init, 44 43 .timer = &sirfsoc_timer,
+7 -1
arch/arm/mach-prima2/timer.c
··· 21 21 #include <asm/sched_clock.h> 22 22 #include <asm/mach/time.h> 23 23 24 + #include "common.h" 25 + 24 26 #define SIRFSOC_TIMER_COUNTER_LO 0x0000 25 27 #define SIRFSOC_TIMER_COUNTER_HI 0x0004 26 28 #define SIRFSOC_TIMER_MATCH_0 0x0008 ··· 190 188 static void __init sirfsoc_timer_init(void) 191 189 { 192 190 unsigned long rate; 191 + struct clk *clk; 192 + 193 + /* initialize clocking early, we want to set the OS timer */ 194 + sirfsoc_of_clk_init(); 193 195 194 196 /* timer's input clock is io clock */ 195 - struct clk *clk = clk_get_sys("io", NULL); 197 + clk = clk_get_sys("io", NULL); 196 198 197 199 BUG_ON(IS_ERR(clk)); 198 200