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

Merge branch 'clk-next' of git://git.linaro.org/people/mturquette/linux into next/clock

* 'clk-next' of git://git.linaro.org/people/mturquette/linux:
clk: Fix CLK_SET_RATE_GATE flag validation in clk_set_rate().
clk: Provide dummy clk_unregister()
ARM: Kirkwood: Replace clock gating
ARM: Orion: Audio: Add clk/clkdev support
ARM: Orion: PCIE: Add support for clk
ARM: Orion: XOR: Add support for clk
ARM: Orion: CESA: Add support for clk
ARM: Orion: SDIO: Add support for clk.
ARM: Orion: NAND: Add support for clk, if there is one.
ARM: Orion: EHCI: Add support for enabling clocks
ARM: Orion: SATA: Add per channel clk/clkdev support.
ARM: Orion: UART: Get the clock rate via clk_get_rate().
ARM: Orion: WDT: Add clk/clkdev support
ARM: Orion: Eth: Add clk/clkdev support.
ARM: Orion: SPI: Add clk/clkdev support.
ARM: Orion: Add clocks using the generic clk infrastructure.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+585 -264
+1
arch/arm/Kconfig
··· 1142 1142 bool 1143 1143 select CLKSRC_MMIO 1144 1144 select GENERIC_IRQ_CHIP 1145 + select COMMON_CLK 1145 1146 1146 1147 config PLAT_PXA 1147 1148 bool
+25 -14
arch/arm/mach-dove/common.c
··· 13 13 #include <linux/init.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/pci.h> 16 - #include <linux/clk.h> 16 + #include <linux/clk-provider.h> 17 17 #include <linux/ata_platform.h> 18 18 #include <linux/gpio.h> 19 19 #include <asm/page.h> ··· 68 68 } 69 69 70 70 /***************************************************************************** 71 + * CLK tree 72 + ****************************************************************************/ 73 + static struct clk *tclk; 74 + 75 + static void __init clk_init(void) 76 + { 77 + tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT, 78 + get_tclk()); 79 + 80 + orion_clkdev_init(tclk); 81 + } 82 + 83 + /***************************************************************************** 71 84 * EHCI0 72 85 ****************************************************************************/ 73 86 void __init dove_ehci0_init(void) ··· 102 89 void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) 103 90 { 104 91 orion_ge00_init(eth_data, 105 - DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, 106 - 0, get_tclk()); 92 + DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, 0); 107 93 } 108 94 109 95 /***************************************************************************** ··· 128 116 void __init dove_uart0_init(void) 129 117 { 130 118 orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE, 131 - IRQ_DOVE_UART_0, get_tclk()); 119 + IRQ_DOVE_UART_0, tclk); 132 120 } 133 121 134 122 /***************************************************************************** ··· 137 125 void __init dove_uart1_init(void) 138 126 { 139 127 orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE, 140 - IRQ_DOVE_UART_1, get_tclk()); 128 + IRQ_DOVE_UART_1, tclk); 141 129 } 142 130 143 131 /***************************************************************************** ··· 146 134 void __init dove_uart2_init(void) 147 135 { 148 136 orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE, 149 - IRQ_DOVE_UART_2, get_tclk()); 137 + IRQ_DOVE_UART_2, tclk); 150 138 } 151 139 152 140 /***************************************************************************** ··· 155 143 void __init dove_uart3_init(void) 156 144 { 157 145 orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE, 158 - IRQ_DOVE_UART_3, get_tclk()); 146 + IRQ_DOVE_UART_3, tclk); 159 147 } 160 148 161 149 /***************************************************************************** ··· 163 151 ****************************************************************************/ 164 152 void __init dove_spi0_init(void) 165 153 { 166 - orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk()); 154 + orion_spi_init(DOVE_SPI0_PHYS_BASE); 167 155 } 168 156 169 157 void __init dove_spi1_init(void) 170 158 { 171 - orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk()); 159 + orion_spi_1_init(DOVE_SPI1_PHYS_BASE); 172 160 } 173 161 174 162 /***************************************************************************** ··· 284 272 285 273 void __init dove_init(void) 286 274 { 287 - int tclk; 288 - 289 - tclk = get_tclk(); 290 - 291 275 printk(KERN_INFO "Dove 88AP510 SoC, "); 292 - printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000); 276 + printk(KERN_INFO "TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000); 293 277 294 278 #ifdef CONFIG_CACHE_TAUROS2 295 279 tauros2_init(); 296 280 #endif 297 281 dove_setup_cpu_mbus(); 282 + 283 + /* Setup root of clk tree */ 284 + clk_init(); 298 285 299 286 /* internal devices that every board has */ 300 287 dove_rtc_init();
-1
arch/arm/mach-dove/dove-db-setup.c
··· 20 20 #include <linux/i2c.h> 21 21 #include <linux/pci.h> 22 22 #include <linux/spi/spi.h> 23 - #include <linux/spi/orion_spi.h> 24 23 #include <linux/spi/flash.h> 25 24 #include <linux/gpio.h> 26 25 #include <asm/mach-types.h>
-1
arch/arm/mach-kirkwood/board-dreamplug.c
··· 27 27 #include <linux/mtd/physmap.h> 28 28 #include <linux/spi/flash.h> 29 29 #include <linux/spi/spi.h> 30 - #include <linux/spi/orion_spi.h> 31 30 #include <asm/mach-types.h> 32 31 #include <asm/mach/arch.h> 33 32 #include <asm/mach/map.h>
+3
arch/arm/mach-kirkwood/board-dt.c
··· 42 42 kirkwood_l2_init(); 43 43 #endif 44 44 45 + /* Setup root of clk tree */ 46 + kirkwood_clk_init(); 47 + 45 48 /* internal devices that every board has */ 46 49 kirkwood_wdt_init(); 47 50 kirkwood_xor0_init();
+187 -87
arch/arm/mach-kirkwood/common.c
··· 15 15 #include <linux/ata_platform.h> 16 16 #include <linux/mtd/nand.h> 17 17 #include <linux/dma-mapping.h> 18 + #include <linux/clk-provider.h> 19 + #include <linux/spinlock.h> 18 20 #include <net/dsa.h> 19 21 #include <asm/page.h> 20 22 #include <asm/timex.h> ··· 33 31 #include <plat/common.h> 34 32 #include <plat/time.h> 35 33 #include <plat/addr-map.h> 34 + #include <plat/mv_xor.h> 36 35 #include "common.h" 37 36 38 37 /***************************************************************************** ··· 63 60 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc)); 64 61 } 65 62 66 - /* 67 - * Default clock control bits. Any bit _not_ set in this variable 68 - * will be cleared from the hardware after platform devices have been 69 - * registered. Some reserved bits must be set to 1. 70 - */ 71 - unsigned int kirkwood_clk_ctrl = CGC_DUNIT | CGC_RESERVED; 63 + /***************************************************************************** 64 + * CLK tree 65 + ****************************************************************************/ 72 66 67 + static void disable_sata0(void) 68 + { 69 + /* Disable PLL and IVREF */ 70 + writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2); 71 + /* Disable PHY */ 72 + writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL); 73 + } 74 + 75 + static void disable_sata1(void) 76 + { 77 + /* Disable PLL and IVREF */ 78 + writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2); 79 + /* Disable PHY */ 80 + writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL); 81 + } 82 + 83 + static void disable_pcie0(void) 84 + { 85 + writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL); 86 + while (1) 87 + if (readl(PCIE_STATUS) & 0x1) 88 + break; 89 + writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL); 90 + } 91 + 92 + static void disable_pcie1(void) 93 + { 94 + u32 dev, rev; 95 + 96 + kirkwood_pcie_id(&dev, &rev); 97 + 98 + if (dev == MV88F6282_DEV_ID) { 99 + writel(readl(PCIE1_LINK_CTRL) | 0x10, PCIE1_LINK_CTRL); 100 + while (1) 101 + if (readl(PCIE1_STATUS) & 0x1) 102 + break; 103 + writel(readl(PCIE1_LINK_CTRL) & ~0x10, PCIE1_LINK_CTRL); 104 + } 105 + } 106 + 107 + /* An extended version of the gated clk. This calls fn() before 108 + * disabling the clock. We use this to turn off PHYs etc. */ 109 + struct clk_gate_fn { 110 + struct clk_gate gate; 111 + void (*fn)(void); 112 + }; 113 + 114 + #define to_clk_gate_fn(_gate) container_of(_gate, struct clk_gate_fn, gate) 115 + #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) 116 + 117 + static void clk_gate_fn_disable(struct clk_hw *hw) 118 + { 119 + struct clk_gate *gate = to_clk_gate(hw); 120 + struct clk_gate_fn *gate_fn = to_clk_gate_fn(gate); 121 + 122 + if (gate_fn->fn) 123 + gate_fn->fn(); 124 + 125 + clk_gate_ops.disable(hw); 126 + } 127 + 128 + static struct clk_ops clk_gate_fn_ops; 129 + 130 + static struct clk __init *clk_register_gate_fn(struct device *dev, 131 + const char *name, 132 + const char *parent_name, unsigned long flags, 133 + void __iomem *reg, u8 bit_idx, 134 + u8 clk_gate_flags, spinlock_t *lock, 135 + void (*fn)(void)) 136 + { 137 + struct clk_gate_fn *gate_fn; 138 + struct clk *clk; 139 + struct clk_init_data init; 140 + 141 + gate_fn = kzalloc(sizeof(struct clk_gate_fn), GFP_KERNEL); 142 + if (!gate_fn) { 143 + pr_err("%s: could not allocate gated clk\n", __func__); 144 + return ERR_PTR(-ENOMEM); 145 + } 146 + 147 + init.name = name; 148 + init.ops = &clk_gate_fn_ops; 149 + init.flags = flags; 150 + init.parent_names = (parent_name ? &parent_name : NULL); 151 + init.num_parents = (parent_name ? 1 : 0); 152 + 153 + /* struct clk_gate assignments */ 154 + gate_fn->gate.reg = reg; 155 + gate_fn->gate.bit_idx = bit_idx; 156 + gate_fn->gate.flags = clk_gate_flags; 157 + gate_fn->gate.lock = lock; 158 + gate_fn->gate.hw.init = &init; 159 + 160 + /* ops is the gate ops, but with our disable function */ 161 + if (clk_gate_fn_ops.disable != clk_gate_fn_disable) { 162 + clk_gate_fn_ops = clk_gate_ops; 163 + clk_gate_fn_ops.disable = clk_gate_fn_disable; 164 + } 165 + 166 + clk = clk_register(dev, &gate_fn->gate.hw); 167 + 168 + if (IS_ERR(clk)) 169 + kfree(gate_fn); 170 + 171 + return clk; 172 + } 173 + 174 + static DEFINE_SPINLOCK(gating_lock); 175 + static struct clk *tclk; 176 + 177 + static struct clk __init *kirkwood_register_gate(const char *name, u8 bit_idx) 178 + { 179 + return clk_register_gate(NULL, name, "tclk", 0, 180 + (void __iomem *)CLOCK_GATING_CTRL, 181 + bit_idx, 0, &gating_lock); 182 + } 183 + 184 + static struct clk __init *kirkwood_register_gate_fn(const char *name, 185 + u8 bit_idx, 186 + void (*fn)(void)) 187 + { 188 + return clk_register_gate_fn(NULL, name, "tclk", 0, 189 + (void __iomem *)CLOCK_GATING_CTRL, 190 + bit_idx, 0, &gating_lock, fn); 191 + } 192 + 193 + void __init kirkwood_clk_init(void) 194 + { 195 + struct clk *runit, *ge0, *ge1, *sata0, *sata1, *usb0, *sdio; 196 + struct clk *crypto, *xor0, *xor1, *pex0, *pex1, *audio; 197 + 198 + tclk = clk_register_fixed_rate(NULL, "tclk", NULL, 199 + CLK_IS_ROOT, kirkwood_tclk); 200 + 201 + runit = kirkwood_register_gate("runit", CGC_BIT_RUNIT); 202 + ge0 = kirkwood_register_gate("ge0", CGC_BIT_GE0); 203 + ge1 = kirkwood_register_gate("ge1", CGC_BIT_GE1); 204 + sata0 = kirkwood_register_gate_fn("sata0", CGC_BIT_SATA0, 205 + disable_sata0); 206 + sata1 = kirkwood_register_gate_fn("sata1", CGC_BIT_SATA1, 207 + disable_sata1); 208 + usb0 = kirkwood_register_gate("usb0", CGC_BIT_USB0); 209 + sdio = kirkwood_register_gate("sdio", CGC_BIT_SDIO); 210 + crypto = kirkwood_register_gate("crypto", CGC_BIT_CRYPTO); 211 + xor0 = kirkwood_register_gate("xor0", CGC_BIT_XOR0); 212 + xor1 = kirkwood_register_gate("xor1", CGC_BIT_XOR1); 213 + pex0 = kirkwood_register_gate_fn("pex0", CGC_BIT_PEX0, 214 + disable_pcie0); 215 + pex1 = kirkwood_register_gate_fn("pex1", CGC_BIT_PEX1, 216 + disable_pcie1); 217 + audio = kirkwood_register_gate("audio", CGC_BIT_AUDIO); 218 + kirkwood_register_gate("tdm", CGC_BIT_TDM); 219 + kirkwood_register_gate("tsu", CGC_BIT_TSU); 220 + 221 + /* clkdev entries, mapping clks to devices */ 222 + orion_clkdev_add(NULL, "orion_spi.0", runit); 223 + orion_clkdev_add(NULL, "orion_spi.1", runit); 224 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", ge0); 225 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", ge1); 226 + orion_clkdev_add(NULL, "orion_wdt", tclk); 227 + orion_clkdev_add("0", "sata_mv.0", sata0); 228 + orion_clkdev_add("1", "sata_mv.0", sata1); 229 + orion_clkdev_add(NULL, "orion-ehci.0", usb0); 230 + orion_clkdev_add(NULL, "orion_nand", runit); 231 + orion_clkdev_add(NULL, "mvsdio", sdio); 232 + orion_clkdev_add(NULL, "mv_crypto", crypto); 233 + orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".0", xor0); 234 + orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".1", xor1); 235 + orion_clkdev_add("0", "pcie", pex0); 236 + orion_clkdev_add("1", "pcie", pex1); 237 + orion_clkdev_add(NULL, "kirkwood-i2s", audio); 238 + } 73 239 74 240 /***************************************************************************** 75 241 * EHCI0 76 242 ****************************************************************************/ 77 243 void __init kirkwood_ehci_init(void) 78 244 { 79 - kirkwood_clk_ctrl |= CGC_USB0; 80 245 orion_ehci_init(USB_PHYS_BASE, IRQ_KIRKWOOD_USB, EHCI_PHY_NA); 81 246 } 82 247 ··· 254 83 ****************************************************************************/ 255 84 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data) 256 85 { 257 - kirkwood_clk_ctrl |= CGC_GE0; 258 - 259 86 orion_ge00_init(eth_data, 260 87 GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, 261 - IRQ_KIRKWOOD_GE00_ERR, kirkwood_tclk); 88 + IRQ_KIRKWOOD_GE00_ERR); 262 89 } 263 90 264 91 ··· 265 96 ****************************************************************************/ 266 97 void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data) 267 98 { 268 - 269 - kirkwood_clk_ctrl |= CGC_GE1; 270 - 271 99 orion_ge01_init(eth_data, 272 100 GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM, 273 - IRQ_KIRKWOOD_GE01_ERR, kirkwood_tclk); 101 + IRQ_KIRKWOOD_GE01_ERR); 274 102 } 275 103 276 104 ··· 309 143 void __init kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, 310 144 int chip_delay) 311 145 { 312 - kirkwood_clk_ctrl |= CGC_RUNIT; 313 146 kirkwood_nand_data.parts = parts; 314 147 kirkwood_nand_data.nr_parts = nr_parts; 315 148 kirkwood_nand_data.chip_delay = chip_delay; ··· 318 153 void __init kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, 319 154 int (*dev_ready)(struct mtd_info *)) 320 155 { 321 - kirkwood_clk_ctrl |= CGC_RUNIT; 322 156 kirkwood_nand_data.parts = parts; 323 157 kirkwood_nand_data.nr_parts = nr_parts; 324 158 kirkwood_nand_data.dev_ready = dev_ready; ··· 338 174 ****************************************************************************/ 339 175 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data) 340 176 { 341 - kirkwood_clk_ctrl |= CGC_SATA0; 342 - if (sata_data->n_ports > 1) 343 - kirkwood_clk_ctrl |= CGC_SATA1; 344 - 345 177 orion_sata_init(sata_data, SATA_PHYS_BASE, IRQ_KIRKWOOD_SATA); 346 178 } 347 179 ··· 380 220 mvsdio_data->clock = 100000000; 381 221 else 382 222 mvsdio_data->clock = 200000000; 383 - kirkwood_clk_ctrl |= CGC_SDIO; 384 223 kirkwood_sdio.dev.platform_data = mvsdio_data; 385 224 platform_device_register(&kirkwood_sdio); 386 225 } ··· 390 231 ****************************************************************************/ 391 232 void __init kirkwood_spi_init() 392 233 { 393 - kirkwood_clk_ctrl |= CGC_RUNIT; 394 - orion_spi_init(SPI_PHYS_BASE, kirkwood_tclk); 234 + orion_spi_init(SPI_PHYS_BASE); 395 235 } 396 236 397 237 ··· 410 252 void __init kirkwood_uart0_init(void) 411 253 { 412 254 orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, 413 - IRQ_KIRKWOOD_UART_0, kirkwood_tclk); 255 + IRQ_KIRKWOOD_UART_0, tclk); 414 256 } 415 257 416 258 ··· 420 262 void __init kirkwood_uart1_init(void) 421 263 { 422 264 orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, 423 - IRQ_KIRKWOOD_UART_1, kirkwood_tclk); 265 + IRQ_KIRKWOOD_UART_1, tclk); 424 266 } 425 267 426 268 /***************************************************************************** ··· 428 270 ****************************************************************************/ 429 271 void __init kirkwood_crypto_init(void) 430 272 { 431 - kirkwood_clk_ctrl |= CGC_CRYPTO; 432 273 orion_crypto_init(CRYPTO_PHYS_BASE, KIRKWOOD_SRAM_PHYS_BASE, 433 274 KIRKWOOD_SRAM_SIZE, IRQ_KIRKWOOD_CRYPTO); 434 275 } ··· 438 281 ****************************************************************************/ 439 282 void __init kirkwood_xor0_init(void) 440 283 { 441 - kirkwood_clk_ctrl |= CGC_XOR0; 442 - 443 284 orion_xor0_init(XOR0_PHYS_BASE, XOR0_HIGH_PHYS_BASE, 444 285 IRQ_KIRKWOOD_XOR_00, IRQ_KIRKWOOD_XOR_01); 445 286 } ··· 448 293 ****************************************************************************/ 449 294 void __init kirkwood_xor1_init(void) 450 295 { 451 - kirkwood_clk_ctrl |= CGC_XOR1; 452 - 453 296 orion_xor1_init(XOR1_PHYS_BASE, XOR1_HIGH_PHYS_BASE, 454 297 IRQ_KIRKWOOD_XOR_10, IRQ_KIRKWOOD_XOR_11); 455 298 } ··· 458 305 ****************************************************************************/ 459 306 void __init kirkwood_wdt_init(void) 460 307 { 461 - orion_wdt_init(kirkwood_tclk); 308 + orion_wdt_init(); 462 309 } 463 310 464 311 ··· 534 381 535 382 void __init kirkwood_audio_init(void) 536 383 { 537 - kirkwood_clk_ctrl |= CGC_AUDIO; 538 384 platform_device_register(&kirkwood_i2s_device); 539 385 platform_device_register(&kirkwood_pcm_device); 540 386 } ··· 617 465 kirkwood_l2_init(); 618 466 #endif 619 467 468 + /* Setup root of clk tree */ 469 + kirkwood_clk_init(); 470 + 620 471 /* internal devices that every board has */ 621 472 kirkwood_rtc_init(); 622 473 kirkwood_wdt_init(); ··· 631 476 kexec_reinit = kirkwood_enable_pcie; 632 477 #endif 633 478 } 634 - 635 - static int __init kirkwood_clock_gate(void) 636 - { 637 - unsigned int curr = readl(CLOCK_GATING_CTRL); 638 - u32 dev, rev; 639 - 640 - kirkwood_pcie_id(&dev, &rev); 641 - printk(KERN_DEBUG "Gating clock of unused units\n"); 642 - printk(KERN_DEBUG "before: 0x%08x\n", curr); 643 - 644 - /* Make sure those units are accessible */ 645 - writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL); 646 - 647 - /* For SATA: first shutdown the phy */ 648 - if (!(kirkwood_clk_ctrl & CGC_SATA0)) { 649 - /* Disable PLL and IVREF */ 650 - writel(readl(SATA0_PHY_MODE_2) & ~0xf, SATA0_PHY_MODE_2); 651 - /* Disable PHY */ 652 - writel(readl(SATA0_IF_CTRL) | 0x200, SATA0_IF_CTRL); 653 - } 654 - if (!(kirkwood_clk_ctrl & CGC_SATA1)) { 655 - /* Disable PLL and IVREF */ 656 - writel(readl(SATA1_PHY_MODE_2) & ~0xf, SATA1_PHY_MODE_2); 657 - /* Disable PHY */ 658 - writel(readl(SATA1_IF_CTRL) | 0x200, SATA1_IF_CTRL); 659 - } 660 - 661 - /* For PCIe: first shutdown the phy */ 662 - if (!(kirkwood_clk_ctrl & CGC_PEX0)) { 663 - writel(readl(PCIE_LINK_CTRL) | 0x10, PCIE_LINK_CTRL); 664 - while (1) 665 - if (readl(PCIE_STATUS) & 0x1) 666 - break; 667 - writel(readl(PCIE_LINK_CTRL) & ~0x10, PCIE_LINK_CTRL); 668 - } 669 - 670 - /* For PCIe 1: first shutdown the phy */ 671 - if (dev == MV88F6282_DEV_ID) { 672 - if (!(kirkwood_clk_ctrl & CGC_PEX1)) { 673 - writel(readl(PCIE1_LINK_CTRL) | 0x10, PCIE1_LINK_CTRL); 674 - while (1) 675 - if (readl(PCIE1_STATUS) & 0x1) 676 - break; 677 - writel(readl(PCIE1_LINK_CTRL) & ~0x10, PCIE1_LINK_CTRL); 678 - } 679 - } else /* keep this bit set for devices that don't have PCIe1 */ 680 - kirkwood_clk_ctrl |= CGC_PEX1; 681 - 682 - /* Now gate clock the required units */ 683 - writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL); 684 - printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL)); 685 - 686 - return 0; 687 - } 688 - late_initcall(kirkwood_clock_gate); 689 479 690 480 void kirkwood_restart(char mode, const char *cmd) 691 481 {
+1
arch/arm/mach-kirkwood/common.h
··· 50 50 void kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, int (*dev_ready)(struct mtd_info *)); 51 51 void kirkwood_audio_init(void); 52 52 void kirkwood_restart(char, const char *); 53 + void kirkwood_clk_init(void); 53 54 54 55 /* board init functions for boards not fully converted to fdt */ 55 56 #ifdef CONFIG_MACH_DREAMPLUG_DT
+16
arch/arm/mach-kirkwood/include/mach/bridge-regs.h
··· 43 43 #define L2_WRITETHROUGH 0x00000010 44 44 45 45 #define CLOCK_GATING_CTRL (BRIDGE_VIRT_BASE | 0x11c) 46 + #define CGC_BIT_GE0 (0) 47 + #define CGC_BIT_PEX0 (2) 48 + #define CGC_BIT_USB0 (3) 49 + #define CGC_BIT_SDIO (4) 50 + #define CGC_BIT_TSU (5) 51 + #define CGC_BIT_DUNIT (6) 52 + #define CGC_BIT_RUNIT (7) 53 + #define CGC_BIT_XOR0 (8) 54 + #define CGC_BIT_AUDIO (9) 55 + #define CGC_BIT_SATA0 (14) 56 + #define CGC_BIT_SATA1 (15) 57 + #define CGC_BIT_XOR1 (16) 58 + #define CGC_BIT_CRYPTO (17) 59 + #define CGC_BIT_PEX1 (18) 60 + #define CGC_BIT_GE1 (19) 61 + #define CGC_BIT_TDM (20) 46 62 #define CGC_GE0 (1 << 0) 47 63 #define CGC_PEX0 (1 << 2) 48 64 #define CGC_USB0 (1 << 3)
-1
arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c
··· 23 23 #include <linux/gpio_keys.h> 24 24 #include <linux/spi/flash.h> 25 25 #include <linux/spi/spi.h> 26 - #include <linux/spi/orion_spi.h> 27 26 #include <net/dsa.h> 28 27 #include <asm/mach-types.h> 29 28 #include <asm/mach/arch.h>
+21 -4
arch/arm/mach-kirkwood/pcie.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/pci.h> 13 13 #include <linux/slab.h> 14 + #include <linux/clk.h> 14 15 #include <video/vga.h> 15 16 #include <asm/irq.h> 16 17 #include <asm/mach/pci.h> ··· 20 19 #include <plat/addr-map.h> 21 20 #include "common.h" 22 21 22 + static void kirkwood_enable_pcie_clk(const char *port) 23 + { 24 + struct clk *clk; 25 + 26 + clk = clk_get_sys("pcie", port); 27 + if (IS_ERR(clk)) { 28 + printk(KERN_ERR "PCIE clock %s missing\n", port); 29 + return; 30 + } 31 + clk_prepare_enable(clk); 32 + clk_put(clk); 33 + } 34 + 35 + /* This function is called very early in the boot when probing the 36 + hardware to determine what we actually are, and what rate tclk is 37 + ticking at. Hence calling kirkwood_enable_pcie_clk() is not 38 + possible since the clk tree has not been created yet. */ 23 39 void kirkwood_enable_pcie(void) 24 40 { 25 41 u32 curr = readl(CLOCK_GATING_CTRL); ··· 44 26 writel(curr | CGC_PEX0, CLOCK_GATING_CTRL); 45 27 } 46 28 47 - void __init kirkwood_pcie_id(u32 *dev, u32 *rev) 29 + void kirkwood_pcie_id(u32 *dev, u32 *rev) 48 30 { 49 31 kirkwood_enable_pcie(); 50 32 *dev = orion_pcie_dev_id((void __iomem *)PCIE_VIRT_BASE); ··· 181 163 182 164 static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) 183 165 { 184 - extern unsigned int kirkwood_clk_ctrl; 185 166 struct pcie_port *pp; 186 167 int index; 187 168 ··· 199 182 200 183 switch (index) { 201 184 case 0: 202 - kirkwood_clk_ctrl |= CGC_PEX0; 185 + kirkwood_enable_pcie_clk("0"); 203 186 pcie0_ioresources_init(pp); 204 187 break; 205 188 case 1: 206 - kirkwood_clk_ctrl |= CGC_PEX1; 189 + kirkwood_enable_pcie_clk("1"); 207 190 pcie1_ioresources_init(pp); 208 191 break; 209 192 default:
-1
arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
··· 16 16 #include <linux/gpio.h> 17 17 #include <linux/spi/flash.h> 18 18 #include <linux/spi/spi.h> 19 - #include <linux/spi/orion_spi.h> 20 19 #include <asm/mach-types.h> 21 20 #include <asm/mach/arch.h> 22 21 #include <mach/kirkwood.h>
-1
arch/arm/mach-kirkwood/t5325-setup.c
··· 16 16 #include <linux/mtd/physmap.h> 17 17 #include <linux/spi/flash.h> 18 18 #include <linux/spi/spi.h> 19 - #include <linux/spi/orion_spi.h> 20 19 #include <linux/i2c.h> 21 20 #include <linux/mv643xx_eth.h> 22 21 #include <linux/ata_platform.h>
-1
arch/arm/mach-kirkwood/tsx1x-common.c
··· 4 4 #include <linux/mtd/physmap.h> 5 5 #include <linux/spi/flash.h> 6 6 #include <linux/spi/spi.h> 7 - #include <linux/spi/orion_spi.h> 8 7 #include <linux/serial_reg.h> 9 8 #include <mach/kirkwood.h> 10 9 #include "common.h"
+30 -15
arch/arm/mach-mv78xx0/common.c
··· 13 13 #include <linux/platform_device.h> 14 14 #include <linux/serial_8250.h> 15 15 #include <linux/ata_platform.h> 16 + #include <linux/clk-provider.h> 16 17 #include <linux/ethtool.h> 17 18 #include <asm/mach/map.h> 18 19 #include <asm/mach/time.h> ··· 104 103 105 104 static int get_tclk(void) 106 105 { 107 - int tclk; 106 + int tclk_freq; 108 107 109 108 /* 110 109 * TCLK tick rate is configured by DEV_A[2:0] strap pins. 111 110 */ 112 111 switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) { 113 112 case 1: 114 - tclk = 166666667; 113 + tclk_freq = 166666667; 115 114 break; 116 115 case 3: 117 - tclk = 200000000; 116 + tclk_freq = 200000000; 118 117 break; 119 118 default: 120 119 panic("unknown TCLK PLL setting: %.8x\n", 121 120 readl(SAMPLE_AT_RESET_HIGH)); 122 121 } 123 122 124 - return tclk; 123 + return tclk_freq; 125 124 } 126 125 127 126 ··· 167 166 168 167 169 168 /***************************************************************************** 169 + * CLK tree 170 + ****************************************************************************/ 171 + static struct clk *tclk; 172 + 173 + static void __init clk_init(void) 174 + { 175 + tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT, 176 + get_tclk()); 177 + 178 + orion_clkdev_init(tclk); 179 + } 180 + 181 + /***************************************************************************** 170 182 * EHCI 171 183 ****************************************************************************/ 172 184 void __init mv78xx0_ehci0_init(void) ··· 213 199 { 214 200 orion_ge00_init(eth_data, 215 201 GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, 216 - IRQ_MV78XX0_GE_ERR, get_tclk()); 202 + IRQ_MV78XX0_GE_ERR); 217 203 } 218 204 219 205 ··· 224 210 { 225 211 orion_ge01_init(eth_data, 226 212 GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, 227 - NO_IRQ, get_tclk()); 213 + NO_IRQ); 228 214 } 229 215 230 216 ··· 248 234 249 235 orion_ge10_init(eth_data, 250 236 GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM, 251 - NO_IRQ, get_tclk()); 237 + NO_IRQ); 252 238 } 253 239 254 240 ··· 272 258 273 259 orion_ge11_init(eth_data, 274 260 GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM, 275 - NO_IRQ, get_tclk()); 261 + NO_IRQ); 276 262 } 277 263 278 264 /***************************************************************************** ··· 299 285 void __init mv78xx0_uart0_init(void) 300 286 { 301 287 orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, 302 - IRQ_MV78XX0_UART_0, get_tclk()); 288 + IRQ_MV78XX0_UART_0, tclk); 303 289 } 304 290 305 291 ··· 309 295 void __init mv78xx0_uart1_init(void) 310 296 { 311 297 orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, 312 - IRQ_MV78XX0_UART_1, get_tclk()); 298 + IRQ_MV78XX0_UART_1, tclk); 313 299 } 314 300 315 301 ··· 319 305 void __init mv78xx0_uart2_init(void) 320 306 { 321 307 orion_uart2_init(UART2_VIRT_BASE, UART2_PHYS_BASE, 322 - IRQ_MV78XX0_UART_2, get_tclk()); 308 + IRQ_MV78XX0_UART_2, tclk); 323 309 } 324 310 325 311 /***************************************************************************** ··· 328 314 void __init mv78xx0_uart3_init(void) 329 315 { 330 316 orion_uart3_init(UART3_VIRT_BASE, UART3_PHYS_BASE, 331 - IRQ_MV78XX0_UART_3, get_tclk()); 317 + IRQ_MV78XX0_UART_3, tclk); 332 318 } 333 319 334 320 /***************************************************************************** ··· 392 378 int hclk; 393 379 int pclk; 394 380 int l2clk; 395 - int tclk; 396 381 397 382 core_index = mv78xx0_core_index(); 398 383 hclk = get_hclk(); 399 384 get_pclk_l2clk(hclk, core_index, &pclk, &l2clk); 400 - tclk = get_tclk(); 401 385 402 386 printk(KERN_INFO "%s ", mv78xx0_id()); 403 387 printk("core #%d, ", core_index); 404 388 printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000); 405 389 printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000); 406 390 printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000); 407 - printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000); 391 + printk("TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000); 408 392 409 393 mv78xx0_setup_cpu_mbus(); 410 394 411 395 #ifdef CONFIG_CACHE_FEROCEON_L2 412 396 feroceon_l2_init(is_l2_writethrough()); 413 397 #endif 398 + 399 + /* Setup root of clk tree */ 400 + clk_init(); 414 401 } 415 402 416 403 void mv78xx0_restart(char mode, const char *cmd)
+22 -5
arch/arm/mach-orion5x/common.c
··· 18 18 #include <linux/mv643xx_i2c.h> 19 19 #include <linux/ata_platform.h> 20 20 #include <linux/delay.h> 21 + #include <linux/clk-provider.h> 21 22 #include <net/dsa.h> 22 23 #include <asm/page.h> 23 24 #include <asm/setup.h> ··· 71 70 72 71 73 72 /***************************************************************************** 73 + * CLK tree 74 + ****************************************************************************/ 75 + static struct clk *tclk; 76 + 77 + static void __init clk_init(void) 78 + { 79 + tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT, 80 + orion5x_tclk); 81 + 82 + orion_clkdev_init(tclk); 83 + } 84 + 85 + /***************************************************************************** 74 86 * EHCI0 75 87 ****************************************************************************/ 76 88 void __init orion5x_ehci0_init(void) ··· 109 95 { 110 96 orion_ge00_init(eth_data, 111 97 ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, 112 - IRQ_ORION5X_ETH_ERR, orion5x_tclk); 98 + IRQ_ORION5X_ETH_ERR); 113 99 } 114 100 115 101 ··· 146 132 ****************************************************************************/ 147 133 void __init orion5x_spi_init() 148 134 { 149 - orion_spi_init(SPI_PHYS_BASE, orion5x_tclk); 135 + orion_spi_init(SPI_PHYS_BASE); 150 136 } 151 137 152 138 ··· 156 142 void __init orion5x_uart0_init(void) 157 143 { 158 144 orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, 159 - IRQ_ORION5X_UART0, orion5x_tclk); 145 + IRQ_ORION5X_UART0, tclk); 160 146 } 161 147 162 148 /***************************************************************************** ··· 165 151 void __init orion5x_uart1_init(void) 166 152 { 167 153 orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, 168 - IRQ_ORION5X_UART1, orion5x_tclk); 154 + IRQ_ORION5X_UART1, tclk); 169 155 } 170 156 171 157 /***************************************************************************** ··· 193 179 ****************************************************************************/ 194 180 void __init orion5x_wdt_init(void) 195 181 { 196 - orion_wdt_init(orion5x_tclk); 182 + orion_wdt_init(); 197 183 } 198 184 199 185 ··· 289 275 * Setup Orion address map 290 276 */ 291 277 orion5x_setup_cpu_mbus_bridge(); 278 + 279 + /* Setup root of clk tree */ 280 + clk_init(); 292 281 293 282 /* 294 283 * Don't issue "Wait for Interrupt" instruction if we are
-1
arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
··· 16 16 #include <linux/mtd/physmap.h> 17 17 #include <linux/mv643xx_eth.h> 18 18 #include <linux/spi/spi.h> 19 - #include <linux/spi/orion_spi.h> 20 19 #include <linux/spi/flash.h> 21 20 #include <linux/ethtool.h> 22 21 #include <net/dsa.h>
+56 -48
arch/arm/plat-orion/common.c
··· 14 14 #include <linux/dma-mapping.h> 15 15 #include <linux/serial_8250.h> 16 16 #include <linux/ata_platform.h> 17 + #include <linux/clk.h> 18 + #include <linux/clkdev.h> 17 19 #include <linux/mv643xx_eth.h> 18 20 #include <linux/mv643xx_i2c.h> 19 21 #include <net/dsa.h> 20 - #include <linux/spi/orion_spi.h> 21 - #include <plat/orion_wdt.h> 22 22 #include <plat/mv_xor.h> 23 23 #include <plat/ehci-orion.h> 24 24 #include <mach/bridge-regs.h> 25 + 26 + /* Create a clkdev entry for a given device/clk */ 27 + void __init orion_clkdev_add(const char *con_id, const char *dev_id, 28 + struct clk *clk) 29 + { 30 + struct clk_lookup *cl; 31 + 32 + cl = clkdev_alloc(clk, con_id, dev_id); 33 + if (cl) 34 + clkdev_add(cl); 35 + } 36 + 37 + /* Create clkdev entries for all orion platforms except kirkwood. 38 + Kirkwood has gated clocks for some of its peripherals, so creates 39 + its own clkdev entries. For all the other orion devices, create 40 + clkdev entries to the tclk. */ 41 + void __init orion_clkdev_init(struct clk *tclk) 42 + { 43 + orion_clkdev_add(NULL, "orion_spi.0", tclk); 44 + orion_clkdev_add(NULL, "orion_spi.1", tclk); 45 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk); 46 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk); 47 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk); 48 + orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk); 49 + orion_clkdev_add(NULL, "orion_wdt", tclk); 50 + } 25 51 26 52 /* Fill in the resources structure and link it into the platform 27 53 device structure. There is always a memory region, and nearly ··· 75 49 /***************************************************************************** 76 50 * UART 77 51 ****************************************************************************/ 52 + static unsigned long __init uart_get_clk_rate(struct clk *clk) 53 + { 54 + clk_prepare_enable(clk); 55 + return clk_get_rate(clk); 56 + } 57 + 78 58 static void __init uart_complete( 79 59 struct platform_device *orion_uart, 80 60 struct plat_serial8250_port *data, ··· 88 56 unsigned int membase, 89 57 resource_size_t mapbase, 90 58 unsigned int irq, 91 - unsigned int uartclk) 59 + struct clk *clk) 92 60 { 93 61 data->mapbase = mapbase; 94 62 data->membase = (void __iomem *)membase; 95 63 data->irq = irq; 96 - data->uartclk = uartclk; 64 + data->uartclk = uart_get_clk_rate(clk); 97 65 orion_uart->dev.platform_data = data; 98 66 99 67 fill_resources(orion_uart, resources, mapbase, 0xff, irq); ··· 122 90 void __init orion_uart0_init(unsigned int membase, 123 91 resource_size_t mapbase, 124 92 unsigned int irq, 125 - unsigned int uartclk) 93 + struct clk *clk) 126 94 { 127 95 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources, 128 - membase, mapbase, irq, uartclk); 96 + membase, mapbase, irq, clk); 129 97 } 130 98 131 99 /***************************************************************************** ··· 150 118 void __init orion_uart1_init(unsigned int membase, 151 119 resource_size_t mapbase, 152 120 unsigned int irq, 153 - unsigned int uartclk) 121 + struct clk *clk) 154 122 { 155 123 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources, 156 - membase, mapbase, irq, uartclk); 124 + membase, mapbase, irq, clk); 157 125 } 158 126 159 127 /***************************************************************************** ··· 178 146 void __init orion_uart2_init(unsigned int membase, 179 147 resource_size_t mapbase, 180 148 unsigned int irq, 181 - unsigned int uartclk) 149 + struct clk *clk) 182 150 { 183 151 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources, 184 - membase, mapbase, irq, uartclk); 152 + membase, mapbase, irq, clk); 185 153 } 186 154 187 155 /***************************************************************************** ··· 206 174 void __init orion_uart3_init(unsigned int membase, 207 175 resource_size_t mapbase, 208 176 unsigned int irq, 209 - unsigned int uartclk) 177 + struct clk *clk) 210 178 { 211 179 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources, 212 - membase, mapbase, irq, uartclk); 180 + membase, mapbase, irq, clk); 213 181 } 214 182 215 183 /***************************************************************************** ··· 235 203 ****************************************************************************/ 236 204 static __init void ge_complete( 237 205 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, 238 - int tclk, 239 206 struct resource *orion_ge_resource, unsigned long irq, 240 207 struct platform_device *orion_ge_shared, 241 208 struct mv643xx_eth_platform_data *eth_data, 242 209 struct platform_device *orion_ge) 243 210 { 244 - orion_ge_shared_data->t_clk = tclk; 245 211 orion_ge_resource->start = irq; 246 212 orion_ge_resource->end = irq; 247 213 eth_data->shared = orion_ge_shared; ··· 290 260 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, 291 261 unsigned long mapbase, 292 262 unsigned long irq, 293 - unsigned long irq_err, 294 - int tclk) 263 + unsigned long irq_err) 295 264 { 296 265 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, 297 266 mapbase + 0x2000, SZ_16K - 1, irq_err); 298 - ge_complete(&orion_ge00_shared_data, tclk, 267 + ge_complete(&orion_ge00_shared_data, 299 268 orion_ge00_resources, irq, &orion_ge00_shared, 300 269 eth_data, &orion_ge00); 301 270 } ··· 342 313 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, 343 314 unsigned long mapbase, 344 315 unsigned long irq, 345 - unsigned long irq_err, 346 - int tclk) 316 + unsigned long irq_err) 347 317 { 348 318 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, 349 319 mapbase + 0x2000, SZ_16K - 1, irq_err); 350 - ge_complete(&orion_ge01_shared_data, tclk, 320 + ge_complete(&orion_ge01_shared_data, 351 321 orion_ge01_resources, irq, &orion_ge01_shared, 352 322 eth_data, &orion_ge01); 353 323 } ··· 394 366 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, 395 367 unsigned long mapbase, 396 368 unsigned long irq, 397 - unsigned long irq_err, 398 - int tclk) 369 + unsigned long irq_err) 399 370 { 400 371 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, 401 372 mapbase + 0x2000, SZ_16K - 1, irq_err); 402 - ge_complete(&orion_ge10_shared_data, tclk, 373 + ge_complete(&orion_ge10_shared_data, 403 374 orion_ge10_resources, irq, &orion_ge10_shared, 404 375 eth_data, &orion_ge10); 405 376 } ··· 446 419 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, 447 420 unsigned long mapbase, 448 421 unsigned long irq, 449 - unsigned long irq_err, 450 - int tclk) 422 + unsigned long irq_err) 451 423 { 452 424 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, 453 425 mapbase + 0x2000, SZ_16K - 1, irq_err); 454 - ge_complete(&orion_ge11_shared_data, tclk, 426 + ge_complete(&orion_ge11_shared_data, 455 427 orion_ge11_resources, irq, &orion_ge11_shared, 456 428 eth_data, &orion_ge11); 457 429 } ··· 547 521 /***************************************************************************** 548 522 * SPI 549 523 ****************************************************************************/ 550 - static struct orion_spi_info orion_spi_plat_data; 551 524 static struct resource orion_spi_resources; 552 525 553 526 static struct platform_device orion_spi = { 554 527 .name = "orion_spi", 555 528 .id = 0, 556 - .dev = { 557 - .platform_data = &orion_spi_plat_data, 558 - }, 559 529 }; 560 530 561 - static struct orion_spi_info orion_spi_1_plat_data; 562 531 static struct resource orion_spi_1_resources; 563 532 564 533 static struct platform_device orion_spi_1 = { 565 534 .name = "orion_spi", 566 535 .id = 1, 567 - .dev = { 568 - .platform_data = &orion_spi_1_plat_data, 569 - }, 570 536 }; 571 537 572 538 /* Note: The SPI silicon core does have interrupts. However the 573 539 * current Linux software driver does not use interrupts. */ 574 540 575 - void __init orion_spi_init(unsigned long mapbase, 576 - unsigned long tclk) 541 + void __init orion_spi_init(unsigned long mapbase) 577 542 { 578 - orion_spi_plat_data.tclk = tclk; 579 543 fill_resources(&orion_spi, &orion_spi_resources, 580 544 mapbase, SZ_512 - 1, NO_IRQ); 581 545 platform_device_register(&orion_spi); 582 546 } 583 547 584 - void __init orion_spi_1_init(unsigned long mapbase, 585 - unsigned long tclk) 548 + void __init orion_spi_1_init(unsigned long mapbase) 586 549 { 587 - orion_spi_1_plat_data.tclk = tclk; 588 550 fill_resources(&orion_spi_1, &orion_spi_1_resources, 589 551 mapbase, SZ_512 - 1, NO_IRQ); 590 552 platform_device_register(&orion_spi_1); ··· 581 567 /***************************************************************************** 582 568 * Watchdog 583 569 ****************************************************************************/ 584 - static struct orion_wdt_platform_data orion_wdt_data; 585 - 586 570 static struct resource orion_wdt_resource = 587 571 DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28); 588 572 589 573 static struct platform_device orion_wdt_device = { 590 574 .name = "orion_wdt", 591 575 .id = -1, 592 - .dev = { 593 - .platform_data = &orion_wdt_data, 594 - }, 595 - .resource = &orion_wdt_resource, 596 576 .num_resources = 1, 577 + .resource = &orion_wdt_resource, 597 578 }; 598 579 599 - void __init orion_wdt_init(unsigned long tclk) 580 + void __init orion_wdt_init(void) 600 581 { 601 - orion_wdt_data.tclk = tclk; 602 582 platform_device_register(&orion_wdt_device); 603 583 } 604 584
+17 -17
arch/arm/plat-orion/include/plat/common.h
··· 16 16 void __init orion_uart0_init(unsigned int membase, 17 17 resource_size_t mapbase, 18 18 unsigned int irq, 19 - unsigned int uartclk); 19 + struct clk *clk); 20 20 21 21 void __init orion_uart1_init(unsigned int membase, 22 22 resource_size_t mapbase, 23 23 unsigned int irq, 24 - unsigned int uartclk); 24 + struct clk *clk); 25 25 26 26 void __init orion_uart2_init(unsigned int membase, 27 27 resource_size_t mapbase, 28 28 unsigned int irq, 29 - unsigned int uartclk); 29 + struct clk *clk); 30 30 31 31 void __init orion_uart3_init(unsigned int membase, 32 32 resource_size_t mapbase, 33 33 unsigned int irq, 34 - unsigned int uartclk); 34 + struct clk *clk); 35 35 36 36 void __init orion_rtc_init(unsigned long mapbase, 37 37 unsigned long irq); ··· 39 39 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, 40 40 unsigned long mapbase, 41 41 unsigned long irq, 42 - unsigned long irq_err, 43 - int tclk); 42 + unsigned long irq_err); 44 43 45 44 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, 46 45 unsigned long mapbase, 47 46 unsigned long irq, 48 - unsigned long irq_err, 49 - int tclk); 47 + unsigned long irq_err); 50 48 51 49 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, 52 50 unsigned long mapbase, 53 51 unsigned long irq, 54 - unsigned long irq_err, 55 - int tclk); 52 + unsigned long irq_err); 56 53 57 54 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, 58 55 unsigned long mapbase, 59 56 unsigned long irq, 60 - unsigned long irq_err, 61 - int tclk); 57 + unsigned long irq_err); 62 58 63 59 void __init orion_ge00_switch_init(struct dsa_platform_data *d, 64 60 int irq); 61 + 65 62 void __init orion_i2c_init(unsigned long mapbase, 66 63 unsigned long irq, 67 64 unsigned long freq_m); ··· 67 70 unsigned long irq, 68 71 unsigned long freq_m); 69 72 70 - void __init orion_spi_init(unsigned long mapbase, 71 - unsigned long tclk); 73 + void __init orion_spi_init(unsigned long mapbase); 72 74 73 - void __init orion_spi_1_init(unsigned long mapbase, 74 - unsigned long tclk); 75 + void __init orion_spi_1_init(unsigned long mapbase); 75 76 76 - void __init orion_wdt_init(unsigned long tclk); 77 + void __init orion_wdt_init(void); 77 78 78 79 void __init orion_xor0_init(unsigned long mapbase_low, 79 80 unsigned long mapbase_high, ··· 101 106 unsigned long srambase, 102 107 unsigned long sram_size, 103 108 unsigned long irq); 109 + 110 + void __init orion_clkdev_add(const char *con_id, const char *dev_id, 111 + struct clk *clk); 112 + 113 + void __init orion_clkdev_init(struct clk *tclk); 104 114 #endif
-18
arch/arm/plat-orion/include/plat/orion_wdt.h
··· 1 - /* 2 - * arch/arm/plat-orion/include/plat/orion_wdt.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __PLAT_ORION_WDT_H 10 - #define __PLAT_ORION_WDT_H 11 - 12 - struct orion_wdt_platform_data { 13 - u32 tclk; /* no <linux/clk.h> support yet */ 14 - }; 15 - 16 - 17 - #endif 18 -
+2 -2
arch/arm/plat-orion/pcie.c
··· 52 52 #define PCIE_DEBUG_SOFT_RESET (1<<20) 53 53 54 54 55 - u32 __init orion_pcie_dev_id(void __iomem *base) 55 + u32 orion_pcie_dev_id(void __iomem *base) 56 56 { 57 57 return readl(base + PCIE_DEV_ID_OFF) >> 16; 58 58 } 59 59 60 - u32 __init orion_pcie_rev(void __iomem *base) 60 + u32 orion_pcie_rev(void __iomem *base) 61 61 { 62 62 return readl(base + PCIE_DEV_REV_OFF) & 0xff; 63 63 }
+36 -4
drivers/ata/sata_mv.c
··· 553 553 554 554 #if defined(CONFIG_HAVE_CLK) 555 555 struct clk *clk; 556 + struct clk **port_clks; 556 557 #endif 557 558 /* 558 559 * These consistent DMA memory pools give us guaranteed ··· 4028 4027 struct resource *res; 4029 4028 int n_ports = 0; 4030 4029 int rc; 4030 + #if defined(CONFIG_HAVE_CLK) 4031 + int port; 4032 + #endif 4031 4033 4032 4034 ata_print_version_once(&pdev->dev, DRV_VERSION); 4033 4035 ··· 4058 4054 4059 4055 if (!host || !hpriv) 4060 4056 return -ENOMEM; 4057 + #if defined(CONFIG_HAVE_CLK) 4058 + hpriv->port_clks = devm_kzalloc(&pdev->dev, 4059 + sizeof(struct clk *) * n_ports, 4060 + GFP_KERNEL); 4061 + if (!hpriv->port_clks) 4062 + return -ENOMEM; 4063 + #endif 4061 4064 host->private_data = hpriv; 4062 4065 hpriv->n_ports = n_ports; 4063 4066 hpriv->board_idx = chip_soc; ··· 4077 4066 #if defined(CONFIG_HAVE_CLK) 4078 4067 hpriv->clk = clk_get(&pdev->dev, NULL); 4079 4068 if (IS_ERR(hpriv->clk)) 4080 - dev_notice(&pdev->dev, "cannot get clkdev\n"); 4069 + dev_notice(&pdev->dev, "cannot get optional clkdev\n"); 4081 4070 else 4082 - clk_enable(hpriv->clk); 4071 + clk_prepare_enable(hpriv->clk); 4072 + 4073 + for (port = 0; port < n_ports; port++) { 4074 + char port_number[16]; 4075 + sprintf(port_number, "%d", port); 4076 + hpriv->port_clks[port] = clk_get(&pdev->dev, port_number); 4077 + if (!IS_ERR(hpriv->port_clks[port])) 4078 + clk_prepare_enable(hpriv->port_clks[port]); 4079 + } 4083 4080 #endif 4084 4081 4085 4082 /* ··· 4117 4098 err: 4118 4099 #if defined(CONFIG_HAVE_CLK) 4119 4100 if (!IS_ERR(hpriv->clk)) { 4120 - clk_disable(hpriv->clk); 4101 + clk_disable_unprepare(hpriv->clk); 4121 4102 clk_put(hpriv->clk); 4103 + } 4104 + for (port = 0; port < n_ports; port++) { 4105 + if (!IS_ERR(hpriv->port_clks[port])) { 4106 + clk_disable_unprepare(hpriv->port_clks[port]); 4107 + clk_put(hpriv->port_clks[port]); 4108 + } 4122 4109 } 4123 4110 #endif 4124 4111 ··· 4144 4119 struct ata_host *host = platform_get_drvdata(pdev); 4145 4120 #if defined(CONFIG_HAVE_CLK) 4146 4121 struct mv_host_priv *hpriv = host->private_data; 4122 + int port; 4147 4123 #endif 4148 4124 ata_host_detach(host); 4149 4125 4150 4126 #if defined(CONFIG_HAVE_CLK) 4151 4127 if (!IS_ERR(hpriv->clk)) { 4152 - clk_disable(hpriv->clk); 4128 + clk_disable_unprepare(hpriv->clk); 4153 4129 clk_put(hpriv->clk); 4130 + } 4131 + for (port = 0; port < host->n_ports; port++) { 4132 + if (!IS_ERR(hpriv->port_clks[port])) { 4133 + clk_disable_unprepare(hpriv->port_clks[port]); 4134 + clk_put(hpriv->port_clks[port]); 4135 + } 4154 4136 } 4155 4137 #endif 4156 4138 return 0;
+10 -1
drivers/clk/clk.c
··· 903 903 if (rate == clk->rate) 904 904 goto out; 905 905 906 - if ((clk->flags & CLK_SET_RATE_GATE) && __clk_is_enabled(clk)) { 906 + if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) { 907 907 ret = -EBUSY; 908 908 goto out; 909 909 } ··· 1419 1419 return ERR_PTR(ret); 1420 1420 } 1421 1421 EXPORT_SYMBOL_GPL(clk_register); 1422 + 1423 + /** 1424 + * clk_unregister - unregister a currently registered clock 1425 + * @clk: clock to unregister 1426 + * 1427 + * Currently unimplemented. 1428 + */ 1429 + void clk_unregister(struct clk *clk) {} 1430 + EXPORT_SYMBOL_GPL(clk_unregister); 1422 1431 1423 1432 /*** clk rate change notifiers ***/ 1424 1433
+14
drivers/crypto/mv_cesa.c
··· 16 16 #include <linux/scatterlist.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/module.h> 19 + #include <linux/clk.h> 19 20 #include <crypto/internal/hash.h> 20 21 #include <crypto/sha.h> 21 22 ··· 80 79 void __iomem *reg; 81 80 void __iomem *sram; 82 81 int irq; 82 + struct clk *clk; 83 83 struct task_struct *queue_th; 84 84 85 85 /* the lock protects queue and eng_st */ ··· 1055 1053 if (ret) 1056 1054 goto err_thread; 1057 1055 1056 + /* Not all platforms can gate the clock, so it is not 1057 + an error if the clock does not exists. */ 1058 + cp->clk = clk_get(&pdev->dev, NULL); 1059 + if (!IS_ERR(cp->clk)) 1060 + clk_prepare_enable(cp->clk); 1061 + 1058 1062 writel(SEC_INT_ACCEL0_DONE, cpg->reg + SEC_ACCEL_INT_MASK); 1059 1063 writel(SEC_CFG_STOP_DIG_ERR, cpg->reg + SEC_ACCEL_CFG); 1060 1064 writel(SRAM_CONFIG, cpg->reg + SEC_ACCEL_DESC_P0); ··· 1126 1118 memset(cp->sram, 0, cp->sram_size); 1127 1119 iounmap(cp->sram); 1128 1120 iounmap(cp->reg); 1121 + 1122 + if (!IS_ERR(cp->clk)) { 1123 + clk_disable_unprepare(cp->clk); 1124 + clk_put(cp->clk); 1125 + } 1126 + 1129 1127 kfree(cp); 1130 1128 cpg = NULL; 1131 1129 return 0;
+15
drivers/dma/mv_xor.c
··· 25 25 #include <linux/interrupt.h> 26 26 #include <linux/platform_device.h> 27 27 #include <linux/memory.h> 28 + #include <linux/clk.h> 28 29 #include <plat/mv_xor.h> 29 30 30 31 #include "dmaengine.h" ··· 1308 1307 if (dram) 1309 1308 mv_xor_conf_mbus_windows(msp, dram); 1310 1309 1310 + /* Not all platforms can gate the clock, so it is not 1311 + * an error if the clock does not exists. 1312 + */ 1313 + msp->clk = clk_get(&pdev->dev, NULL); 1314 + if (!IS_ERR(msp->clk)) 1315 + clk_prepare_enable(msp->clk); 1316 + 1311 1317 return 0; 1312 1318 } 1313 1319 1314 1320 static int mv_xor_shared_remove(struct platform_device *pdev) 1315 1321 { 1322 + struct mv_xor_shared_private *msp = platform_get_drvdata(pdev); 1323 + 1324 + if (!IS_ERR(msp->clk)) { 1325 + clk_disable_unprepare(msp->clk); 1326 + clk_put(msp->clk); 1327 + } 1328 + 1316 1329 return 0; 1317 1330 } 1318 1331
+1
drivers/dma/mv_xor.h
··· 55 55 struct mv_xor_shared_private { 56 56 void __iomem *xor_base; 57 57 void __iomem *xor_high_base; 58 + struct clk *clk; 58 59 }; 59 60 60 61
+14
drivers/mmc/host/mvsdio.c
··· 19 19 #include <linux/dma-mapping.h> 20 20 #include <linux/scatterlist.h> 21 21 #include <linux/irq.h> 22 + #include <linux/clk.h> 22 23 #include <linux/gpio.h> 23 24 #include <linux/mmc/host.h> 24 25 ··· 52 51 struct device *dev; 53 52 struct resource *res; 54 53 int irq; 54 + struct clk *clk; 55 55 int gpio_card_detect; 56 56 int gpio_write_protect; 57 57 }; ··· 772 770 } else 773 771 host->irq = irq; 774 772 773 + /* Not all platforms can gate the clock, so it is not 774 + an error if the clock does not exists. */ 775 + host->clk = clk_get(&pdev->dev, NULL); 776 + if (!IS_ERR(host->clk)) { 777 + clk_prepare_enable(host->clk); 778 + } 779 + 775 780 if (mvsd_data->gpio_card_detect) { 776 781 ret = gpio_request(mvsd_data->gpio_card_detect, 777 782 DRIVER_NAME " cd"); ··· 863 854 mvsd_power_down(host); 864 855 iounmap(host->base); 865 856 release_resource(host->res); 857 + 858 + if (!IS_ERR(host->clk)) { 859 + clk_disable_unprepare(host->clk); 860 + clk_put(host->clk); 861 + } 866 862 mmc_free_host(mmc); 867 863 } 868 864 platform_set_drvdata(pdev, NULL);
+18
drivers/mtd/nand/orion_nand.c
··· 16 16 #include <linux/mtd/mtd.h> 17 17 #include <linux/mtd/nand.h> 18 18 #include <linux/mtd/partitions.h> 19 + #include <linux/clk.h> 20 + #include <linux/err.h> 19 21 #include <asm/io.h> 20 22 #include <asm/sizes.h> 21 23 #include <mach/hardware.h> ··· 79 77 struct nand_chip *nc; 80 78 struct orion_nand_data *board; 81 79 struct resource *res; 80 + struct clk *clk; 82 81 void __iomem *io_base; 83 82 int ret = 0; 84 83 ··· 126 123 127 124 platform_set_drvdata(pdev, mtd); 128 125 126 + /* Not all platforms can gate the clock, so it is not 127 + an error if the clock does not exists. */ 128 + clk = clk_get(&pdev->dev, NULL); 129 + if (!IS_ERR(clk)) { 130 + clk_prepare_enable(clk); 131 + clk_put(clk); 132 + } 133 + 129 134 if (nand_scan(mtd, 1)) { 130 135 ret = -ENXIO; 131 136 goto no_dev; ··· 162 151 { 163 152 struct mtd_info *mtd = platform_get_drvdata(pdev); 164 153 struct nand_chip *nc = mtd->priv; 154 + struct clk *clk; 165 155 166 156 nand_release(mtd); 167 157 168 158 iounmap(nc->IO_ADDR_W); 169 159 170 160 kfree(nc); 161 + 162 + clk = clk_get(&pdev->dev, NULL); 163 + if (!IS_ERR(clk)) { 164 + clk_disable_unprepare(clk); 165 + clk_put(clk); 166 + } 171 167 172 168 return 0; 173 169 }
+31 -11
drivers/net/ethernet/marvell/mv643xx_eth.c
··· 57 57 #include <linux/types.h> 58 58 #include <linux/inet_lro.h> 59 59 #include <linux/slab.h> 60 + #include <linux/clk.h> 60 61 61 62 static char mv643xx_eth_driver_name[] = "mv643xx_eth"; 62 63 static char mv643xx_eth_driver_version[] = "1.4"; ··· 290 289 /* 291 290 * Hardware-specific parameters. 292 291 */ 293 - unsigned int t_clk; 294 292 int extended_rx_coal_limit; 295 293 int tx_bw_control; 296 294 int tx_csum_limit; 295 + 297 296 }; 298 297 299 298 #define TX_BW_CONTROL_ABSENT 0 ··· 432 431 int tx_desc_sram_size; 433 432 int txq_count; 434 433 struct tx_queue txq[8]; 434 + 435 + /* 436 + * Hardware-specific parameters. 437 + */ 438 + struct clk *clk; 439 + unsigned int t_clk; 435 440 }; 436 441 437 442 ··· 1017 1010 int mtu; 1018 1011 int bucket_size; 1019 1012 1020 - token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); 1013 + token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); 1021 1014 if (token_rate > 1023) 1022 1015 token_rate = 1023; 1023 1016 ··· 1049 1042 int token_rate; 1050 1043 int bucket_size; 1051 1044 1052 - token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); 1045 + token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000); 1053 1046 if (token_rate > 1023) 1054 1047 token_rate = 1023; 1055 1048 ··· 1316 1309 temp = (val & 0x003fff00) >> 8; 1317 1310 1318 1311 temp *= 64000000; 1319 - do_div(temp, mp->shared->t_clk); 1312 + do_div(temp, mp->t_clk); 1320 1313 1321 1314 return (unsigned int)temp; 1322 1315 } ··· 1326 1319 u64 temp; 1327 1320 u32 val; 1328 1321 1329 - temp = (u64)usec * mp->shared->t_clk; 1322 + temp = (u64)usec * mp->t_clk; 1330 1323 temp += 31999999; 1331 1324 do_div(temp, 64000000); 1332 1325 ··· 1352 1345 1353 1346 temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4; 1354 1347 temp *= 64000000; 1355 - do_div(temp, mp->shared->t_clk); 1348 + do_div(temp, mp->t_clk); 1356 1349 1357 1350 return (unsigned int)temp; 1358 1351 } ··· 1361 1354 { 1362 1355 u64 temp; 1363 1356 1364 - temp = (u64)usec * mp->shared->t_clk; 1357 + temp = (u64)usec * mp->t_clk; 1365 1358 temp += 31999999; 1366 1359 do_div(temp, 64000000); 1367 1360 ··· 2669 2662 if (dram) 2670 2663 mv643xx_eth_conf_mbus_windows(msp, dram); 2671 2664 2672 - /* 2673 - * Detect hardware parameters. 2674 - */ 2675 - msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000; 2676 2665 msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? 2677 2666 pd->tx_csum_limit : 9 * 1024; 2678 2667 infer_hw_params(msp); ··· 2893 2890 2894 2891 mp->dev = dev; 2895 2892 2893 + /* 2894 + * Get the clk rate, if there is one, otherwise use the default. 2895 + */ 2896 + mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); 2897 + if (!IS_ERR(mp->clk)) { 2898 + clk_prepare_enable(mp->clk); 2899 + mp->t_clk = clk_get_rate(mp->clk); 2900 + } else { 2901 + mp->t_clk = 133000000; 2902 + printk(KERN_WARNING "Unable to get clock"); 2903 + } 2904 + 2896 2905 set_params(mp, pd); 2897 2906 netif_set_real_num_tx_queues(dev, mp->txq_count); 2898 2907 netif_set_real_num_rx_queues(dev, mp->rxq_count); ··· 2993 2978 if (mp->phy != NULL) 2994 2979 phy_detach(mp->phy); 2995 2980 cancel_work_sync(&mp->tx_timeout_task); 2981 + 2982 + if (!IS_ERR(mp->clk)) { 2983 + clk_disable_unprepare(mp->clk); 2984 + clk_put(mp->clk); 2985 + } 2996 2986 free_netdev(mp->dev); 2997 2987 2998 2988 platform_set_drvdata(pdev, NULL);
+23 -7
drivers/spi/spi-orion.c
··· 16 16 #include <linux/err.h> 17 17 #include <linux/io.h> 18 18 #include <linux/spi/spi.h> 19 - #include <linux/spi/orion_spi.h> 20 19 #include <linux/module.h> 20 + #include <linux/clk.h> 21 21 #include <asm/unaligned.h> 22 22 23 23 #define DRIVER_NAME "orion_spi" ··· 46 46 unsigned int max_speed; 47 47 unsigned int min_speed; 48 48 struct orion_spi_info *spi_info; 49 + struct clk *clk; 49 50 }; 50 51 51 52 static struct workqueue_struct *orion_spi_wq; ··· 105 104 106 105 orion_spi = spi_master_get_devdata(spi->master); 107 106 108 - tclk_hz = orion_spi->spi_info->tclk; 107 + tclk_hz = clk_get_rate(orion_spi->clk); 109 108 110 109 /* 111 110 * the supported rates are: 4,6,8...30 ··· 451 450 struct orion_spi *spi; 452 451 struct resource *r; 453 452 struct orion_spi_info *spi_info; 453 + unsigned long tclk_hz; 454 454 int status = 0; 455 455 456 456 spi_info = pdev->dev.platform_data; ··· 478 476 spi->master = master; 479 477 spi->spi_info = spi_info; 480 478 481 - spi->max_speed = DIV_ROUND_UP(spi_info->tclk, 4); 482 - spi->min_speed = DIV_ROUND_UP(spi_info->tclk, 30); 479 + spi->clk = clk_get(&pdev->dev, NULL); 480 + if (IS_ERR(spi->clk)) { 481 + status = PTR_ERR(spi->clk); 482 + goto out; 483 + } 484 + 485 + clk_prepare(spi->clk); 486 + clk_enable(spi->clk); 487 + tclk_hz = clk_get_rate(spi->clk); 488 + spi->max_speed = DIV_ROUND_UP(tclk_hz, 4); 489 + spi->min_speed = DIV_ROUND_UP(tclk_hz, 30); 483 490 484 491 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 485 492 if (r == NULL) { 486 493 status = -ENODEV; 487 - goto out; 494 + goto out_rel_clk; 488 495 } 489 496 490 497 if (!request_mem_region(r->start, resource_size(r), 491 498 dev_name(&pdev->dev))) { 492 499 status = -EBUSY; 493 - goto out; 500 + goto out_rel_clk; 494 501 } 495 502 spi->base = ioremap(r->start, SZ_1K); 496 503 ··· 519 508 520 509 out_rel_mem: 521 510 release_mem_region(r->start, resource_size(r)); 522 - 511 + out_rel_clk: 512 + clk_disable_unprepare(spi->clk); 513 + clk_put(spi->clk); 523 514 out: 524 515 spi_master_put(master); 525 516 return status; ··· 538 525 spi = spi_master_get_devdata(master); 539 526 540 527 cancel_work_sync(&spi->work); 528 + 529 + clk_disable_unprepare(spi->clk); 530 + clk_put(spi->clk); 541 531 542 532 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 543 533 release_mem_region(r->start, resource_size(r));
+16
drivers/usb/host/ehci-orion.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/mbus.h> 15 + #include <linux/clk.h> 15 16 #include <plat/ehci-orion.h> 16 17 17 18 #define rdl(off) __raw_readl(hcd->regs + (off)) ··· 199 198 struct resource *res; 200 199 struct usb_hcd *hcd; 201 200 struct ehci_hcd *ehci; 201 + struct clk *clk; 202 202 void __iomem *regs; 203 203 int irq, err; 204 204 ··· 238 236 dev_dbg(&pdev->dev, "error mapping memory\n"); 239 237 err = -EFAULT; 240 238 goto err2; 239 + } 240 + 241 + /* Not all platforms can gate the clock, so it is not 242 + an error if the clock does not exists. */ 243 + clk = clk_get(&pdev->dev, NULL); 244 + if (!IS_ERR(clk)) { 245 + clk_prepare_enable(clk); 246 + clk_put(clk); 241 247 } 242 248 243 249 hcd = usb_create_hcd(&ehci_orion_hc_driver, ··· 311 301 static int __exit ehci_orion_drv_remove(struct platform_device *pdev) 312 302 { 313 303 struct usb_hcd *hcd = platform_get_drvdata(pdev); 304 + struct clk *clk; 314 305 315 306 usb_remove_hcd(hcd); 316 307 iounmap(hcd->regs); 317 308 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 318 309 usb_put_hcd(hcd); 319 310 311 + clk = clk_get(&pdev->dev, NULL); 312 + if (!IS_ERR(clk)) { 313 + clk_disable_unprepare(clk); 314 + clk_put(clk); 315 + } 320 316 return 0; 321 317 } 322 318
+10 -6
drivers/watchdog/orion_wdt.c
··· 24 24 #include <linux/uaccess.h> 25 25 #include <linux/io.h> 26 26 #include <linux/spinlock.h> 27 + #include <linux/clk.h> 27 28 #include <mach/bridge-regs.h> 28 - #include <plat/orion_wdt.h> 29 29 30 30 /* 31 31 * Watchdog timer block registers. ··· 41 41 static bool nowayout = WATCHDOG_NOWAYOUT; 42 42 static int heartbeat = -1; /* module parameter (seconds) */ 43 43 static unsigned int wdt_max_duration; /* (seconds) */ 44 + static struct clk *clk; 44 45 static unsigned int wdt_tclk; 45 46 static void __iomem *wdt_reg; 46 47 static unsigned long wdt_status; ··· 238 237 239 238 static int __devinit orion_wdt_probe(struct platform_device *pdev) 240 239 { 241 - struct orion_wdt_platform_data *pdata = pdev->dev.platform_data; 242 240 struct resource *res; 243 241 int ret; 244 242 245 - if (pdata) { 246 - wdt_tclk = pdata->tclk; 247 - } else { 248 - pr_err("misses platform data\n"); 243 + clk = clk_get(&pdev->dev, NULL); 244 + if (IS_ERR(clk)) { 245 + printk(KERN_ERR "Orion Watchdog missing clock\n"); 249 246 return -ENODEV; 250 247 } 248 + clk_prepare_enable(clk); 249 + wdt_tclk = clk_get_rate(clk); 251 250 252 251 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 253 252 ··· 282 281 ret = misc_deregister(&orion_wdt_miscdev); 283 282 if (!ret) 284 283 orion_wdt_miscdev.parent = NULL; 284 + 285 + clk_disable_unprepare(clk); 286 + clk_put(clk); 285 287 286 288 return ret; 287 289 }
+2
include/linux/clk-provider.h
··· 312 312 */ 313 313 struct clk *clk_register(struct device *dev, struct clk_hw *hw); 314 314 315 + void clk_unregister(struct clk *clk); 316 + 315 317 /* helper functions */ 316 318 const char *__clk_get_name(struct clk *clk); 317 319 struct clk_hw *__clk_get_hw(struct clk *clk);
-1
include/linux/mv643xx_eth.h
··· 18 18 struct mv643xx_eth_shared_platform_data { 19 19 struct mbus_dram_target_info *dram; 20 20 struct platform_device *shared_smi; 21 - unsigned int t_clk; 22 21 /* 23 22 * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default 24 23 * limit of 9KiB will be used.
-17
include/linux/spi/orion_spi.h
··· 1 - /* 2 - * orion_spi.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __LINUX_SPI_ORION_SPI_H 10 - #define __LINUX_SPI_ORION_SPI_H 11 - 12 - struct orion_spi_info { 13 - u32 tclk; /* no <linux/clk.h> support yet */ 14 - }; 15 - 16 - 17 - #endif
+13
sound/soc/kirkwood/kirkwood-i2s.c
··· 17 17 #include <linux/slab.h> 18 18 #include <linux/mbus.h> 19 19 #include <linux/delay.h> 20 + #include <linux/clk.h> 20 21 #include <sound/pcm.h> 21 22 #include <sound/pcm_params.h> 22 23 #include <sound/soc.h> ··· 450 449 451 450 priv->burst = data->burst; 452 451 452 + priv->clk = clk_get(&pdev->dev, NULL); 453 + if (IS_ERR(priv->clk)) { 454 + dev_err(&pdev->dev, "no clock\n"); 455 + err = PTR_ERR(priv->clk); 456 + goto err_ioremap; 457 + } 458 + clk_prepare_enable(priv->clk); 459 + 453 460 return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai); 454 461 455 462 err_ioremap: ··· 475 466 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); 476 467 477 468 snd_soc_unregister_dai(&pdev->dev); 469 + 470 + clk_disable_unprepare(priv->clk); 471 + clk_put(priv->clk); 472 + 478 473 iounmap(priv->io); 479 474 release_mem_region(priv->mem->start, SZ_16K); 480 475 kfree(priv);
+1
sound/soc/kirkwood/kirkwood.h
··· 123 123 void __iomem *io; 124 124 int irq; 125 125 int burst; 126 + struct clk *clk; 126 127 }; 127 128 128 129 #endif