Commit 3c0dec5f authored by Arnd Bergmann's avatar Arnd Bergmann

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: default avatarArnd Bergmann <arnd@arndb.de>
parents fcd8d84a 7e0fa1b5
...@@ -1142,6 +1142,7 @@ config PLAT_ORION ...@@ -1142,6 +1142,7 @@ config PLAT_ORION
bool bool
select CLKSRC_MMIO select CLKSRC_MMIO
select GENERIC_IRQ_CHIP select GENERIC_IRQ_CHIP
select COMMON_CLK
config PLAT_PXA config PLAT_PXA
bool bool
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/clk.h> #include <linux/clk-provider.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -67,6 +67,19 @@ void __init dove_map_io(void) ...@@ -67,6 +67,19 @@ void __init dove_map_io(void)
iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc)); iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
} }
/*****************************************************************************
* CLK tree
****************************************************************************/
static struct clk *tclk;
static void __init clk_init(void)
{
tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
get_tclk());
orion_clkdev_init(tclk);
}
/***************************************************************************** /*****************************************************************************
* EHCI0 * EHCI0
****************************************************************************/ ****************************************************************************/
...@@ -89,8 +102,7 @@ void __init dove_ehci1_init(void) ...@@ -89,8 +102,7 @@ void __init dove_ehci1_init(void)
void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
{ {
orion_ge00_init(eth_data, orion_ge00_init(eth_data,
DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM, 0);
0, get_tclk());
} }
/***************************************************************************** /*****************************************************************************
...@@ -116,7 +128,7 @@ void __init dove_sata_init(struct mv_sata_platform_data *sata_data) ...@@ -116,7 +128,7 @@ void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
void __init dove_uart0_init(void) void __init dove_uart0_init(void)
{ {
orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE, orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
IRQ_DOVE_UART_0, get_tclk()); IRQ_DOVE_UART_0, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -125,7 +137,7 @@ void __init dove_uart0_init(void) ...@@ -125,7 +137,7 @@ void __init dove_uart0_init(void)
void __init dove_uart1_init(void) void __init dove_uart1_init(void)
{ {
orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE, orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
IRQ_DOVE_UART_1, get_tclk()); IRQ_DOVE_UART_1, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -134,7 +146,7 @@ void __init dove_uart1_init(void) ...@@ -134,7 +146,7 @@ void __init dove_uart1_init(void)
void __init dove_uart2_init(void) void __init dove_uart2_init(void)
{ {
orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE, orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
IRQ_DOVE_UART_2, get_tclk()); IRQ_DOVE_UART_2, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -143,7 +155,7 @@ void __init dove_uart2_init(void) ...@@ -143,7 +155,7 @@ void __init dove_uart2_init(void)
void __init dove_uart3_init(void) void __init dove_uart3_init(void)
{ {
orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE, orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
IRQ_DOVE_UART_3, get_tclk()); IRQ_DOVE_UART_3, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -151,12 +163,12 @@ void __init dove_uart3_init(void) ...@@ -151,12 +163,12 @@ void __init dove_uart3_init(void)
****************************************************************************/ ****************************************************************************/
void __init dove_spi0_init(void) void __init dove_spi0_init(void)
{ {
orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk()); orion_spi_init(DOVE_SPI0_PHYS_BASE);
} }
void __init dove_spi1_init(void) void __init dove_spi1_init(void)
{ {
orion_spi_1_init(DOVE_SPI1_PHYS_BASE, get_tclk()); orion_spi_1_init(DOVE_SPI1_PHYS_BASE);
} }
/***************************************************************************** /*****************************************************************************
...@@ -272,18 +284,17 @@ void __init dove_sdio1_init(void) ...@@ -272,18 +284,17 @@ void __init dove_sdio1_init(void)
void __init dove_init(void) void __init dove_init(void)
{ {
int tclk;
tclk = get_tclk();
printk(KERN_INFO "Dove 88AP510 SoC, "); printk(KERN_INFO "Dove 88AP510 SoC, ");
printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000); printk(KERN_INFO "TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
#ifdef CONFIG_CACHE_TAUROS2 #ifdef CONFIG_CACHE_TAUROS2
tauros2_init(); tauros2_init();
#endif #endif
dove_setup_cpu_mbus(); dove_setup_cpu_mbus();
/* Setup root of clk tree */
clk_init();
/* internal devices that every board has */ /* internal devices that every board has */
dove_rtc_init(); dove_rtc_init();
dove_xor0_init(); dove_xor0_init();
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
#include <asm/mach/map.h> #include <asm/mach/map.h>
......
...@@ -42,6 +42,9 @@ static void __init kirkwood_dt_init(void) ...@@ -42,6 +42,9 @@ static void __init kirkwood_dt_init(void)
kirkwood_l2_init(); kirkwood_l2_init();
#endif #endif
/* Setup root of clk tree */
kirkwood_clk_init();
/* internal devices that every board has */ /* internal devices that every board has */
kirkwood_wdt_init(); kirkwood_wdt_init();
kirkwood_xor0_init(); kirkwood_xor0_init();
......
This diff is collapsed.
...@@ -50,6 +50,7 @@ void kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, int delay); ...@@ -50,6 +50,7 @@ void kirkwood_nand_init(struct mtd_partition *parts, int nr_parts, int delay);
void kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, int (*dev_ready)(struct mtd_info *)); void kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, int (*dev_ready)(struct mtd_info *));
void kirkwood_audio_init(void); void kirkwood_audio_init(void);
void kirkwood_restart(char, const char *); void kirkwood_restart(char, const char *);
void kirkwood_clk_init(void);
/* board init functions for boards not fully converted to fdt */ /* board init functions for boards not fully converted to fdt */
#ifdef CONFIG_MACH_DREAMPLUG_DT #ifdef CONFIG_MACH_DREAMPLUG_DT
......
...@@ -43,6 +43,22 @@ ...@@ -43,6 +43,22 @@
#define L2_WRITETHROUGH 0x00000010 #define L2_WRITETHROUGH 0x00000010
#define CLOCK_GATING_CTRL (BRIDGE_VIRT_BASE | 0x11c) #define CLOCK_GATING_CTRL (BRIDGE_VIRT_BASE | 0x11c)
#define CGC_BIT_GE0 (0)
#define CGC_BIT_PEX0 (2)
#define CGC_BIT_USB0 (3)
#define CGC_BIT_SDIO (4)
#define CGC_BIT_TSU (5)
#define CGC_BIT_DUNIT (6)
#define CGC_BIT_RUNIT (7)
#define CGC_BIT_XOR0 (8)
#define CGC_BIT_AUDIO (9)
#define CGC_BIT_SATA0 (14)
#define CGC_BIT_SATA1 (15)
#define CGC_BIT_XOR1 (16)
#define CGC_BIT_CRYPTO (17)
#define CGC_BIT_PEX1 (18)
#define CGC_BIT_GE1 (19)
#define CGC_BIT_TDM (20)
#define CGC_GE0 (1 << 0) #define CGC_GE0 (1 << 0)
#define CGC_PEX0 (1 << 2) #define CGC_PEX0 (1 << 2)
#define CGC_USB0 (1 << 3) #define CGC_USB0 (1 << 3)
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <net/dsa.h> #include <net/dsa.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/clk.h>
#include <video/vga.h> #include <video/vga.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/mach/pci.h> #include <asm/mach/pci.h>
...@@ -19,6 +20,23 @@ ...@@ -19,6 +20,23 @@
#include <plat/addr-map.h> #include <plat/addr-map.h>
#include "common.h" #include "common.h"
static void kirkwood_enable_pcie_clk(const char *port)
{
struct clk *clk;
clk = clk_get_sys("pcie", port);
if (IS_ERR(clk)) {
printk(KERN_ERR "PCIE clock %s missing\n", port);
return;
}
clk_prepare_enable(clk);
clk_put(clk);
}
/* This function is called very early in the boot when probing the
hardware to determine what we actually are, and what rate tclk is
ticking at. Hence calling kirkwood_enable_pcie_clk() is not
possible since the clk tree has not been created yet. */
void kirkwood_enable_pcie(void) void kirkwood_enable_pcie(void)
{ {
u32 curr = readl(CLOCK_GATING_CTRL); u32 curr = readl(CLOCK_GATING_CTRL);
...@@ -26,7 +44,7 @@ void kirkwood_enable_pcie(void) ...@@ -26,7 +44,7 @@ void kirkwood_enable_pcie(void)
writel(curr | CGC_PEX0, CLOCK_GATING_CTRL); writel(curr | CGC_PEX0, CLOCK_GATING_CTRL);
} }
void __init kirkwood_pcie_id(u32 *dev, u32 *rev) void kirkwood_pcie_id(u32 *dev, u32 *rev)
{ {
kirkwood_enable_pcie(); kirkwood_enable_pcie();
*dev = orion_pcie_dev_id((void __iomem *)PCIE_VIRT_BASE); *dev = orion_pcie_dev_id((void __iomem *)PCIE_VIRT_BASE);
...@@ -163,7 +181,6 @@ static void __init pcie1_ioresources_init(struct pcie_port *pp) ...@@ -163,7 +181,6 @@ static void __init pcie1_ioresources_init(struct pcie_port *pp)
static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
{ {
extern unsigned int kirkwood_clk_ctrl;
struct pcie_port *pp; struct pcie_port *pp;
int index; int index;
...@@ -182,11 +199,11 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) ...@@ -182,11 +199,11 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
switch (index) { switch (index) {
case 0: case 0:
kirkwood_clk_ctrl |= CGC_PEX0; kirkwood_enable_pcie_clk("0");
pcie0_ioresources_init(pp); pcie0_ioresources_init(pp);
break; break;
case 1: case 1:
kirkwood_clk_ctrl |= CGC_PEX1; kirkwood_enable_pcie_clk("1");
pcie1_ioresources_init(pp); pcie1_ioresources_init(pp);
break; break;
default: default:
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
#include <mach/kirkwood.h> #include <mach/kirkwood.h>
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/mv643xx_eth.h> #include <linux/mv643xx_eth.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <linux/serial_reg.h> #include <linux/serial_reg.h>
#include <mach/kirkwood.h> #include <mach/kirkwood.h>
#include "common.h" #include "common.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/clk-provider.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <asm/mach/map.h> #include <asm/mach/map.h>
#include <asm/mach/time.h> #include <asm/mach/time.h>
...@@ -103,24 +104,24 @@ static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk) ...@@ -103,24 +104,24 @@ static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk)
static int get_tclk(void) static int get_tclk(void)
{ {
int tclk; int tclk_freq;
/* /*
* TCLK tick rate is configured by DEV_A[2:0] strap pins. * TCLK tick rate is configured by DEV_A[2:0] strap pins.
*/ */
switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) { switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) {
case 1: case 1:
tclk = 166666667; tclk_freq = 166666667;
break; break;
case 3: case 3:
tclk = 200000000; tclk_freq = 200000000;
break; break;
default: default:
panic("unknown TCLK PLL setting: %.8x\n", panic("unknown TCLK PLL setting: %.8x\n",
readl(SAMPLE_AT_RESET_HIGH)); readl(SAMPLE_AT_RESET_HIGH));
} }
return tclk; return tclk_freq;
} }
...@@ -165,6 +166,19 @@ void __init mv78xx0_map_io(void) ...@@ -165,6 +166,19 @@ void __init mv78xx0_map_io(void)
} }
/*****************************************************************************
* CLK tree
****************************************************************************/
static struct clk *tclk;
static void __init clk_init(void)
{
tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
get_tclk());
orion_clkdev_init(tclk);
}
/***************************************************************************** /*****************************************************************************
* EHCI * EHCI
****************************************************************************/ ****************************************************************************/
...@@ -199,7 +213,7 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data) ...@@ -199,7 +213,7 @@ void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data)
{ {
orion_ge00_init(eth_data, orion_ge00_init(eth_data,
GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM,
IRQ_MV78XX0_GE_ERR, get_tclk()); IRQ_MV78XX0_GE_ERR);
} }
...@@ -210,7 +224,7 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data) ...@@ -210,7 +224,7 @@ void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data)
{ {
orion_ge01_init(eth_data, orion_ge01_init(eth_data,
GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM,
NO_IRQ, get_tclk()); NO_IRQ);
} }
...@@ -234,7 +248,7 @@ void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data) ...@@ -234,7 +248,7 @@ void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data)
orion_ge10_init(eth_data, orion_ge10_init(eth_data,
GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM, GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM,
NO_IRQ, get_tclk()); NO_IRQ);
} }
...@@ -258,7 +272,7 @@ void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data) ...@@ -258,7 +272,7 @@ void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data)
orion_ge11_init(eth_data, orion_ge11_init(eth_data,
GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM, GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM,
NO_IRQ, get_tclk()); NO_IRQ);
} }
/***************************************************************************** /*****************************************************************************
...@@ -285,7 +299,7 @@ void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data) ...@@ -285,7 +299,7 @@ void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
void __init mv78xx0_uart0_init(void) void __init mv78xx0_uart0_init(void)
{ {
orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
IRQ_MV78XX0_UART_0, get_tclk()); IRQ_MV78XX0_UART_0, tclk);
} }
...@@ -295,7 +309,7 @@ void __init mv78xx0_uart0_init(void) ...@@ -295,7 +309,7 @@ void __init mv78xx0_uart0_init(void)
void __init mv78xx0_uart1_init(void) void __init mv78xx0_uart1_init(void)
{ {
orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
IRQ_MV78XX0_UART_1, get_tclk()); IRQ_MV78XX0_UART_1, tclk);
} }
...@@ -305,7 +319,7 @@ void __init mv78xx0_uart1_init(void) ...@@ -305,7 +319,7 @@ void __init mv78xx0_uart1_init(void)
void __init mv78xx0_uart2_init(void) void __init mv78xx0_uart2_init(void)
{ {
orion_uart2_init(UART2_VIRT_BASE, UART2_PHYS_BASE, orion_uart2_init(UART2_VIRT_BASE, UART2_PHYS_BASE,
IRQ_MV78XX0_UART_2, get_tclk()); IRQ_MV78XX0_UART_2, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -314,7 +328,7 @@ void __init mv78xx0_uart2_init(void) ...@@ -314,7 +328,7 @@ void __init mv78xx0_uart2_init(void)
void __init mv78xx0_uart3_init(void) void __init mv78xx0_uart3_init(void)
{ {
orion_uart3_init(UART3_VIRT_BASE, UART3_PHYS_BASE, orion_uart3_init(UART3_VIRT_BASE, UART3_PHYS_BASE,
IRQ_MV78XX0_UART_3, get_tclk()); IRQ_MV78XX0_UART_3, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -378,25 +392,26 @@ void __init mv78xx0_init(void) ...@@ -378,25 +392,26 @@ void __init mv78xx0_init(void)
int hclk; int hclk;
int pclk; int pclk;
int l2clk; int l2clk;
int tclk;
core_index = mv78xx0_core_index(); core_index = mv78xx0_core_index();
hclk = get_hclk(); hclk = get_hclk();
get_pclk_l2clk(hclk, core_index, &pclk, &l2clk); get_pclk_l2clk(hclk, core_index, &pclk, &l2clk);
tclk = get_tclk();
printk(KERN_INFO "%s ", mv78xx0_id()); printk(KERN_INFO "%s ", mv78xx0_id());
printk("core #%d, ", core_index); printk("core #%d, ", core_index);
printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000); printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000);
printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000); printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000);
printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000); printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000);
printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000); printk("TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
mv78xx0_setup_cpu_mbus(); mv78xx0_setup_cpu_mbus();
#ifdef CONFIG_CACHE_FEROCEON_L2 #ifdef CONFIG_CACHE_FEROCEON_L2
feroceon_l2_init(is_l2_writethrough()); feroceon_l2_init(is_l2_writethrough());
#endif #endif
/* Setup root of clk tree */
clk_init();
} }
void mv78xx0_restart(char mode, const char *cmd) void mv78xx0_restart(char mode, const char *cmd)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/mv643xx_i2c.h> #include <linux/mv643xx_i2c.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clk-provider.h>
#include <net/dsa.h> #include <net/dsa.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/setup.h> #include <asm/setup.h>
...@@ -69,6 +70,19 @@ void __init orion5x_map_io(void) ...@@ -69,6 +70,19 @@ void __init orion5x_map_io(void)
} }
/*****************************************************************************
* CLK tree
****************************************************************************/
static struct clk *tclk;
static void __init clk_init(void)
{
tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT,
orion5x_tclk);
orion_clkdev_init(tclk);
}
/***************************************************************************** /*****************************************************************************
* EHCI0 * EHCI0
****************************************************************************/ ****************************************************************************/
...@@ -95,7 +109,7 @@ void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data) ...@@ -95,7 +109,7 @@ void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
{ {
orion_ge00_init(eth_data, orion_ge00_init(eth_data,
ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM,
IRQ_ORION5X_ETH_ERR, orion5x_tclk); IRQ_ORION5X_ETH_ERR);
} }
...@@ -132,7 +146,7 @@ void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data) ...@@ -132,7 +146,7 @@ void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
****************************************************************************/ ****************************************************************************/
void __init orion5x_spi_init() void __init orion5x_spi_init()
{ {
orion_spi_init(SPI_PHYS_BASE, orion5x_tclk); orion_spi_init(SPI_PHYS_BASE);
} }
...@@ -142,7 +156,7 @@ void __init orion5x_spi_init() ...@@ -142,7 +156,7 @@ void __init orion5x_spi_init()
void __init orion5x_uart0_init(void) void __init orion5x_uart0_init(void)
{ {
orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
IRQ_ORION5X_UART0, orion5x_tclk); IRQ_ORION5X_UART0, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -151,7 +165,7 @@ void __init orion5x_uart0_init(void) ...@@ -151,7 +165,7 @@ void __init orion5x_uart0_init(void)
void __init orion5x_uart1_init(void) void __init orion5x_uart1_init(void)
{ {
orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
IRQ_ORION5X_UART1, orion5x_tclk); IRQ_ORION5X_UART1, tclk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -179,7 +193,7 @@ static void __init orion5x_crypto_init(void) ...@@ -179,7 +193,7 @@ static void __init orion5x_crypto_init(void)
****************************************************************************/ ****************************************************************************/
void __init orion5x_wdt_init(void) void __init orion5x_wdt_init(void)
{ {
orion_wdt_init(orion5x_tclk); orion_wdt_init();
} }
...@@ -276,6 +290,9 @@ void __init orion5x_init(void) ...@@ -276,6 +290,9 @@ void __init orion5x_init(void)
*/ */
orion5x_setup_cpu_mbus_bridge(); orion5x_setup_cpu_mbus_bridge();
/* Setup root of clk tree */
clk_init();
/* /*
* Don't issue "Wait for Interrupt" instruction if we are * Don't issue "Wait for Interrupt" instruction if we are
* running on D0 5281 silicon. * running on D0 5281 silicon.
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/mv643xx_eth.h> #include <linux/mv643xx_eth.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <net/dsa.h> #include <net/dsa.h>
......
...@@ -14,15 +14,41 @@ ...@@ -14,15 +14,41 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/ata_platform.h> #include <linux/ata_platform.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/mv643xx_eth.h> #include <linux/mv643xx_eth.h>
#include <linux/mv643xx_i2c.h> #include <linux/mv643xx_i2c.h>
#include <net/dsa.h> #include <net/dsa.h>
#include <linux/spi/orion_spi.h>
#include <plat/orion_wdt.h>
#include <plat/mv_xor.h> #include <plat/mv_xor.h>
#include <plat/ehci-orion.h> #include <plat/ehci-orion.h>
#include <mach/bridge-regs.h> #include <mach/bridge-regs.h>
/* Create a clkdev entry for a given device/clk */
void __init orion_clkdev_add(const char *con_id, const char *dev_id,
struct clk *clk)
{
struct clk_lookup *cl;
cl = clkdev_alloc(clk, con_id, dev_id);
if (cl)
clkdev_add(cl);
}
/* Create clkdev entries for all orion platforms except kirkwood.
Kirkwood has gated clocks for some of its peripherals, so creates
its own clkdev entries. For all the other orion devices, create
clkdev entries to the tclk. */
void __init orion_clkdev_init(struct clk *tclk)
{
orion_clkdev_add(NULL, "orion_spi.0", tclk);
orion_clkdev_add(NULL, "orion_spi.1", tclk);
orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk);
orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk);
orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
orion_clkdev_add(NULL, "orion_wdt", tclk);
}
/* Fill in the resources structure and link it into the platform /* Fill in the resources structure and link it into the platform
device structure. There is always a memory region, and nearly device structure. There is always a memory region, and nearly
always an interrupt.*/ always an interrupt.*/
...@@ -49,6 +75,12 @@ static void fill_resources(struct platform_device *device, ...@@ -49,6 +75,12 @@ static void fill_resources(struct platform_device *device,
/***************************************************************************** /*****************************************************************************
* UART * UART
****************************************************************************/ ****************************************************************************/
static unsigned long __init uart_get_clk_rate(struct clk *clk)
{
clk_prepare_enable(clk);
return clk_get_rate(clk);
}
static void __init uart_complete( static void __init uart_complete(
struct platform_device *orion_uart, struct platform_device *orion_uart,
struct plat_serial8250_port *data, struct plat_serial8250_port *data,
...@@ -56,12 +88,12 @@ static void __init uart_complete( ...@@ -56,12 +88,12 @@ static void __init uart_complete(
unsigned int membase, unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk) struct clk *clk)
{ {
data->mapbase = mapbase; data->mapbase = mapbase;
data->membase = (void __iomem *)membase; data->membase = (void __iomem *)membase;
data->irq = irq; data->irq = irq;
data->uartclk = uartclk; data->uartclk = uart_get_clk_rate(clk);
orion_uart->dev.platform_data = data; orion_uart->dev.platform_data = data;
fill_resources(orion_uart, resources, mapbase, 0xff, irq); fill_resources(orion_uart, resources, mapbase, 0xff, irq);
...@@ -90,10 +122,10 @@ static struct platform_device orion_uart0 = { ...@@ -90,10 +122,10 @@ static struct platform_device orion_uart0 = {
void __init orion_uart0_init(unsigned int membase, void __init orion_uart0_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk) struct clk *clk)
{ {
uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources, uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
membase, mapbase, irq, uartclk); membase, mapbase, irq, clk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -118,10 +150,10 @@ static struct platform_device orion_uart1 = { ...@@ -118,10 +150,10 @@ static struct platform_device orion_uart1 = {
void __init orion_uart1_init(unsigned int membase, void __init orion_uart1_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk) struct clk *clk)
{ {
uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources, uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
membase, mapbase, irq, uartclk); membase, mapbase, irq, clk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -146,10 +178,10 @@ static struct platform_device orion_uart2 = { ...@@ -146,10 +178,10 @@ static struct platform_device orion_uart2 = {
void __init orion_uart2_init(unsigned int membase, void __init orion_uart2_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk) struct clk *clk)
{ {
uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources, uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
membase, mapbase, irq, uartclk); membase, mapbase, irq, clk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -174,10 +206,10 @@ static struct platform_device orion_uart3 = { ...@@ -174,10 +206,10 @@ static struct platform_device orion_uart3 = {
void __init orion_uart3_init(unsigned int membase, void __init orion_uart3_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk) struct clk *clk)
{ {
uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources, uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
membase, mapbase, irq, uartclk); membase, mapbase, irq, clk);
} }
/***************************************************************************** /*****************************************************************************
...@@ -203,13 +235,11 @@ void __init orion_rtc_init(unsigned long mapbase, ...@@ -203,13 +235,11 @@ void __init orion_rtc_init(unsigned long mapbase,
****************************************************************************/ ****************************************************************************/
static __init void ge_complete( static __init void ge_complete(
struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
int tclk,
struct resource *orion_ge_resource, unsigned long irq, struct resource *orion_ge_resource, unsigned long irq,
struct platform_device *orion_ge_shared, struct platform_device *orion_ge_shared,
struct mv643xx_eth_platform_data *eth_data, struct mv643xx_eth_platform_data *eth_data,
struct platform_device *orion_ge) struct platform_device *orion_ge)
{ {
orion_ge_shared_data->t_clk = tclk;
orion_ge_resource->start = irq; orion_ge_resource->start = irq;
orion_ge_resource->end = irq; orion_ge_resource->end = irq;
eth_data->shared = orion_ge_shared; eth_data->shared = orion_ge_shared;
...@@ -260,12 +290,11 @@ static struct platform_device orion_ge00 = { ...@@ -260,12 +290,11 @@ static struct platform_device orion_ge00 = {
void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err)
int tclk)
{ {
fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
mapbase + 0x2000, SZ_16K - 1, irq_err); mapbase + 0x2000, SZ_16K - 1, irq_err);
ge_complete(&orion_ge00_shared_data, tclk, ge_complete(&orion_ge00_shared_data,
orion_ge00_resources, irq, &orion_ge00_shared, orion_ge00_resources, irq, &orion_ge00_shared,
eth_data, &orion_ge00); eth_data, &orion_ge00);
} }
...@@ -313,12 +342,11 @@ static struct platform_device orion_ge01 = { ...@@ -313,12 +342,11 @@ static struct platform_device orion_ge01 = {
void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err)
int tclk)
{ {
fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
mapbase + 0x2000, SZ_16K - 1, irq_err); mapbase + 0x2000, SZ_16K - 1, irq_err);
ge_complete(&orion_ge01_shared_data, tclk, ge_complete(&orion_ge01_shared_data,
orion_ge01_resources, irq, &orion_ge01_shared, orion_ge01_resources, irq, &orion_ge01_shared,
eth_data, &orion_ge01); eth_data, &orion_ge01);
} }
...@@ -366,12 +394,11 @@ static struct platform_device orion_ge10 = { ...@@ -366,12 +394,11 @@ static struct platform_device orion_ge10 = {
void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err)
int tclk)
{ {
fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
mapbase + 0x2000, SZ_16K - 1, irq_err); mapbase + 0x2000, SZ_16K - 1, irq_err);
ge_complete(&orion_ge10_shared_data, tclk, ge_complete(&orion_ge10_shared_data,
orion_ge10_resources, irq, &orion_ge10_shared, orion_ge10_resources, irq, &orion_ge10_shared,
eth_data, &orion_ge10); eth_data, &orion_ge10);
} }
...@@ -419,12 +446,11 @@ static struct platform_device orion_ge11 = { ...@@ -419,12 +446,11 @@ static struct platform_device orion_ge11 = {
void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err)
int tclk)
{ {
fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
mapbase + 0x2000, SZ_16K - 1, irq_err); mapbase + 0x2000, SZ_16K - 1, irq_err);
ge_complete(&orion_ge11_shared_data, tclk, ge_complete(&orion_ge11_shared_data,
orion_ge11_resources, irq, &orion_ge11_shared, orion_ge11_resources, irq, &orion_ge11_shared,
eth_data, &orion_ge11); eth_data, &orion_ge11);
} }
...@@ -521,44 +547,32 @@ void __init orion_i2c_1_init(unsigned long mapbase, ...@@ -521,44 +547,32 @@ void __init orion_i2c_1_init(unsigned long mapbase,
/***************************************************************************** /*****************************************************************************
* SPI * SPI
****************************************************************************/ ****************************************************************************/
static struct orion_spi_info orion_spi_plat_data;
static struct resource orion_spi_resources; static struct resource orion_spi_resources;
static struct platform_device orion_spi = { static struct platform_device orion_spi = {
.name = "orion_spi", .name = "orion_spi",
.id = 0, .id = 0,
.dev = {
.platform_data = &orion_spi_plat_data,
},
}; };
static struct orion_spi_info orion_spi_1_plat_data;
static struct resource orion_spi_1_resources; static struct resource orion_spi_1_resources;
static struct platform_device orion_spi_1 = { static struct platform_device orion_spi_1 = {
.name = "orion_spi", .name = "orion_spi",
.id = 1, .id = 1,
.dev = {
.platform_data = &orion_spi_1_plat_data,
},
}; };
/* Note: The SPI silicon core does have interrupts. However the /* Note: The SPI silicon core does have interrupts. However the
* current Linux software driver does not use interrupts. */ * current Linux software driver does not use interrupts. */
void __init orion_spi_init(unsigned long mapbase, void __init orion_spi_init(unsigned long mapbase)
unsigned long tclk)
{ {
orion_spi_plat_data.tclk = tclk;
fill_resources(&orion_spi, &orion_spi_resources, fill_resources(&orion_spi, &orion_spi_resources,
mapbase, SZ_512 - 1, NO_IRQ); mapbase, SZ_512 - 1, NO_IRQ);
platform_device_register(&orion_spi); platform_device_register(&orion_spi);
} }
void __init orion_spi_1_init(unsigned long mapbase, void __init orion_spi_1_init(unsigned long mapbase)
unsigned long tclk)
{ {
orion_spi_1_plat_data.tclk = tclk;
fill_resources(&orion_spi_1, &orion_spi_1_resources, fill_resources(&orion_spi_1, &orion_spi_1_resources,
mapbase, SZ_512 - 1, NO_IRQ); mapbase, SZ_512 - 1, NO_IRQ);
platform_device_register(&orion_spi_1); platform_device_register(&orion_spi_1);
...@@ -567,24 +581,18 @@ void __init orion_spi_1_init(unsigned long mapbase, ...@@ -567,24 +581,18 @@ void __init orion_spi_1_init(unsigned long mapbase,
/***************************************************************************** /*****************************************************************************
* Watchdog * Watchdog
****************************************************************************/ ****************************************************************************/
static struct orion_wdt_platform_data orion_wdt_data;
static struct resource orion_wdt_resource = static struct resource orion_wdt_resource =
DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28); DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28);
static struct platform_device orion_wdt_device = { static struct platform_device orion_wdt_device = {
.name = "orion_wdt", .name = "orion_wdt",
.id = -1, .id = -1,
.dev = {
.platform_data = &orion_wdt_data,
},
.resource = &orion_wdt_resource,
.num_resources = 1, .num_resources = 1,
.resource = &orion_wdt_resource,
}; };
void __init orion_wdt_init(unsigned long tclk) void __init orion_wdt_init(void)
{ {
orion_wdt_data.tclk = tclk;
platform_device_register(&orion_wdt_device); platform_device_register(&orion_wdt_device);
} }
......
...@@ -16,22 +16,22 @@ struct dsa_platform_data; ...@@ -16,22 +16,22 @@ struct dsa_platform_data;
void __init orion_uart0_init(unsigned int membase, void __init orion_uart0_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk); struct clk *clk);
void __init orion_uart1_init(unsigned int membase, void __init orion_uart1_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk); struct clk *clk);
void __init orion_uart2_init(unsigned int membase, void __init orion_uart2_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk); struct clk *clk);
void __init orion_uart3_init(unsigned int membase, void __init orion_uart3_init(unsigned int membase,
resource_size_t mapbase, resource_size_t mapbase,
unsigned int irq, unsigned int irq,
unsigned int uartclk); struct clk *clk);
void __init orion_rtc_init(unsigned long mapbase, void __init orion_rtc_init(unsigned long mapbase,
unsigned long irq); unsigned long irq);
...@@ -39,29 +39,26 @@ void __init orion_rtc_init(unsigned long mapbase, ...@@ -39,29 +39,26 @@ void __init orion_rtc_init(unsigned long mapbase,
void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err);
int tclk);
void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err);
int tclk);
void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err);
int tclk);
void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
unsigned long mapbase, unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long irq_err, unsigned long irq_err);
int tclk);
void __init orion_ge00_switch_init(struct dsa_platform_data *d, void __init orion_ge00_switch_init(struct dsa_platform_data *d,
int irq); int irq);
void __init orion_i2c_init(unsigned long mapbase, void __init orion_i2c_init(unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long freq_m); unsigned long freq_m);
...@@ -70,13 +67,11 @@ void __init orion_i2c_1_init(unsigned long mapbase, ...@@ -70,13 +67,11 @@ void __init orion_i2c_1_init(unsigned long mapbase,
unsigned long irq, unsigned long irq,
unsigned long freq_m); unsigned long freq_m);
void __init orion_spi_init(unsigned long mapbase, void __init orion_spi_init(unsigned long mapbase);
unsigned long tclk);
void __init orion_spi_1_init(unsigned long mapbase, void __init orion_spi_1_init(unsigned long mapbase);
unsigned long tclk);
void __init orion_wdt_init(unsigned long tclk); void __init orion_wdt_init(void);
void __init orion_xor0_init(unsigned long mapbase_low, void __init orion_xor0_init(unsigned long mapbase_low,
unsigned long mapbase_high, unsigned long mapbase_high,
...@@ -106,4 +101,9 @@ void __init orion_crypto_init(unsigned long mapbase, ...@@ -106,4 +101,9 @@ void __init orion_crypto_init(unsigned long mapbase,
unsigned long srambase, unsigned long srambase,
unsigned long sram_size, unsigned long sram_size,
unsigned long irq); unsigned long irq);
void __init orion_clkdev_add(const char *con_id, const char *dev_id,
struct clk *clk);
void __init orion_clkdev_init(struct clk *tclk);
#endif #endif
/*
* arch/arm/plat-orion/include/plat/orion_wdt.h
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#ifndef __PLAT_ORION_WDT_H
#define __PLAT_ORION_WDT_H
struct orion_wdt_platform_data {
u32 tclk; /* no <linux/clk.h> support yet */
};
#endif
...@@ -52,12 +52,12 @@ ...@@ -52,12 +52,12 @@
#define PCIE_DEBUG_SOFT_RESET (1<<20) #define PCIE_DEBUG_SOFT_RESET (1<<20)
u32 __init orion_pcie_dev_id(void __iomem *base) u32 orion_pcie_dev_id(void __iomem *base)
{ {
return readl(base + PCIE_DEV_ID_OFF) >> 16; return readl(base + PCIE_DEV_ID_OFF) >> 16;
} }
u32 __init orion_pcie_rev(void __iomem *base) u32 orion_pcie_rev(void __iomem *base)
{ {
return readl(base + PCIE_DEV_REV_OFF) & 0xff; return readl(base + PCIE_DEV_REV_OFF) & 0xff;
} }
......
...@@ -553,6 +553,7 @@ struct mv_host_priv { ...@@ -553,6 +553,7 @@ struct mv_host_priv {
#if defined(CONFIG_HAVE_CLK) #if defined(CONFIG_HAVE_CLK)
struct clk *clk; struct clk *clk;
struct clk **port_clks;
#endif #endif
/* /*
* These consistent DMA memory pools give us guaranteed * These consistent DMA memory pools give us guaranteed
...@@ -4027,6 +4028,9 @@ static int mv_platform_probe(struct platform_device *pdev) ...@@ -4027,6 +4028,9 @@ static int mv_platform_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
int n_ports = 0; int n_ports = 0;
int rc; int rc;
#if defined(CONFIG_HAVE_CLK)
int port;
#endif
ata_print_version_once(&pdev->dev, DRV_VERSION); ata_print_version_once(&pdev->dev, DRV_VERSION);
...@@ -4054,6 +4058,13 @@ static int mv_platform_probe(struct platform_device *pdev) ...@@ -4054,6 +4058,13 @@ static int mv_platform_probe(struct platform_device *pdev)
if (!host || !hpriv) if (!host || !hpriv)
return -ENOMEM; return -ENOMEM;
#if defined(CONFIG_HAVE_CLK)
hpriv->port_clks = devm_kzalloc(&pdev->dev,
sizeof(struct clk *) * n_ports,
GFP_KERNEL);
if (!hpriv->port_clks)
return -ENOMEM;
#endif
host->private_data = hpriv; host->private_data = hpriv;
hpriv->n_ports = n_ports; hpriv->n_ports = n_ports;
hpriv->board_idx = chip_soc; hpriv->board_idx = chip_soc;
...@@ -4066,9 +4077,17 @@ static int mv_platform_probe(struct platform_device *pdev) ...@@ -4066,9 +4077,17 @@ static int mv_platform_probe(struct platform_device *pdev)
#if defined(CONFIG_HAVE_CLK) #if defined(CONFIG_HAVE_CLK)
hpriv->clk = clk_get(&pdev->dev, NULL); hpriv->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(hpriv->clk)) if (IS_ERR(hpriv->clk))
dev_notice(&pdev->dev, "cannot get clkdev\n"); dev_notice(&pdev->dev, "cannot get optional clkdev\n");
else else
clk_enable(hpriv->clk); clk_prepare_enable(hpriv->clk);
for (port = 0; port < n_ports; port++) {
char port_number[16];
sprintf(port_number, "%d", port);
hpriv->port_clks[port] = clk_get(&pdev->dev, port_number);
if (!IS_ERR(hpriv->port_clks[port]))
clk_prepare_enable(hpriv->port_clks[port]);
}
#endif #endif
/* /*
...@@ -4098,9 +4117,15 @@ static int mv_platform_probe(struct platform_device *pdev) ...@@ -4098,9 +4117,15 @@ static int mv_platform_probe(struct platform_device *pdev)
err: err:
#if defined(CONFIG_HAVE_CLK) #if defined(CONFIG_HAVE_CLK)
if (!IS_ERR(hpriv->clk)) { if (!IS_ERR(hpriv->clk)) {
clk_disable(hpriv->clk); clk_disable_unprepare(hpriv->clk);
clk_put(hpriv->clk); clk_put(hpriv->clk);
} }
for (port = 0; port < n_ports; port++) {
if (!IS_ERR(hpriv->port_clks[port])) {
clk_disable_unprepare(hpriv->port_clks[port]);
clk_put(hpriv->port_clks[port]);
}
}
#endif #endif
return rc; return rc;
...@@ -4119,14 +4144,21 @@ static int __devexit mv_platform_remove(struct platform_device *pdev) ...@@ -4119,14 +4144,21 @@ static int __devexit mv_platform_remove(struct platform_device *pdev)
struct ata_host *host = platform_get_drvdata(pdev); struct ata_host *host = platform_get_drvdata(pdev);
#if defined(CONFIG_HAVE_CLK) #if defined(CONFIG_HAVE_CLK)
struct mv_host_priv *hpriv = host->private_data; struct mv_host_priv *hpriv = host->private_data;
int port;
#endif #endif
ata_host_detach(host); ata_host_detach(host);
#if defined(CONFIG_HAVE_CLK) #if defined(CONFIG_HAVE_CLK)
if (!IS_ERR(hpriv->clk)) { if (!IS_ERR(hpriv->clk)) {
clk_disable(hpriv->clk); clk_disable_unprepare(hpriv->clk);
clk_put(hpriv->clk); clk_put(hpriv->clk);
} }
for (port = 0; port < host->n_ports; port++) {
if (!IS_ERR(hpriv->port_clks[port])) {
clk_disable_unprepare(hpriv->port_clks[port]);
clk_put(hpriv->port_clks[port]);
}
}
#endif #endif
return 0; return 0;
} }
......
...@@ -903,7 +903,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate) ...@@ -903,7 +903,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
if (rate == clk->rate) if (rate == clk->rate)
goto out; goto out;
if ((clk->flags & CLK_SET_RATE_GATE) && __clk_is_enabled(clk)) { if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
ret = -EBUSY; ret = -EBUSY;
goto out; goto out;
} }
...@@ -1420,6 +1420,15 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) ...@@ -1420,6 +1420,15 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
} }
EXPORT_SYMBOL_GPL(clk_register); EXPORT_SYMBOL_GPL(clk_register);
/**
* clk_unregister - unregister a currently registered clock
* @clk: clock to unregister
*
* Currently unimplemented.
*/
void clk_unregister(struct clk *clk) {}
EXPORT_SYMBOL_GPL(clk_unregister);
/*** clk rate change notifiers ***/ /*** clk rate change notifiers ***/
/** /**
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/clk.h>
#include <crypto/internal/hash.h> #include <crypto/internal/hash.h>
#include <crypto/sha.h> #include <crypto/sha.h>
...@@ -79,6 +80,7 @@ struct crypto_priv { ...@@ -79,6 +80,7 @@ struct crypto_priv {
void __iomem *reg; void __iomem *reg;
void __iomem *sram; void __iomem *sram;
int irq; int irq;
struct clk *clk;
struct task_struct *queue_th; struct task_struct *queue_th;
/* the lock protects queue and eng_st */ /* the lock protects queue and eng_st */
...@@ -1053,6 +1055,12 @@ static int mv_probe(struct platform_device *pdev) ...@@ -1053,6 +1055,12 @@ static int mv_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_thread; goto err_thread;
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
cp->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(cp->clk))
clk_prepare_enable(cp->clk);
writel(SEC_INT_ACCEL0_DONE, cpg->reg + SEC_ACCEL_INT_MASK); writel(SEC_INT_ACCEL0_DONE, cpg->reg + SEC_ACCEL_INT_MASK);
writel(SEC_CFG_STOP_DIG_ERR, cpg->reg + SEC_ACCEL_CFG); writel(SEC_CFG_STOP_DIG_ERR, cpg->reg + SEC_ACCEL_CFG);
writel(SRAM_CONFIG, cpg->reg + SEC_ACCEL_DESC_P0); writel(SRAM_CONFIG, cpg->reg + SEC_ACCEL_DESC_P0);
...@@ -1118,6 +1126,12 @@ static int mv_remove(struct platform_device *pdev) ...@@ -1118,6 +1126,12 @@ static int mv_remove(struct platform_device *pdev)
memset(cp->sram, 0, cp->sram_size); memset(cp->sram, 0, cp->sram_size);
iounmap(cp->sram); iounmap(cp->sram);
iounmap(cp->reg); iounmap(cp->reg);
if (!IS_ERR(cp->clk)) {
clk_disable_unprepare(cp->clk);
clk_put(cp->clk);
}
kfree(cp); kfree(cp);
cpg = NULL; cpg = NULL;
return 0; return 0;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/memory.h> #include <linux/memory.h>
#include <linux/clk.h>
#include <plat/mv_xor.h> #include <plat/mv_xor.h>
#include "dmaengine.h" #include "dmaengine.h"
...@@ -1307,11 +1308,25 @@ static int mv_xor_shared_probe(struct platform_device *pdev) ...@@ -1307,11 +1308,25 @@ static int mv_xor_shared_probe(struct platform_device *pdev)
if (dram) if (dram)
mv_xor_conf_mbus_windows(msp, dram); mv_xor_conf_mbus_windows(msp, dram);
/* Not all platforms can gate the clock, so it is not
* an error if the clock does not exists.
*/
msp->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(msp->clk))
clk_prepare_enable(msp->clk);
return 0; return 0;
} }
static int mv_xor_shared_remove(struct platform_device *pdev) static int mv_xor_shared_remove(struct platform_device *pdev)
{ {
struct mv_xor_shared_private *msp = platform_get_drvdata(pdev);
if (!IS_ERR(msp->clk)) {
clk_disable_unprepare(msp->clk);
clk_put(msp->clk);
}
return 0; return 0;
} }
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
struct mv_xor_shared_private { struct mv_xor_shared_private {
void __iomem *xor_base; void __iomem *xor_base;
void __iomem *xor_high_base; void __iomem *xor_high_base;
struct clk *clk;
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/clk.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
...@@ -51,6 +52,7 @@ struct mvsd_host { ...@@ -51,6 +52,7 @@ struct mvsd_host {
struct device *dev; struct device *dev;
struct resource *res; struct resource *res;
int irq; int irq;
struct clk *clk;
int gpio_card_detect; int gpio_card_detect;
int gpio_write_protect; int gpio_write_protect;
}; };
...@@ -770,6 +772,13 @@ static int __init mvsd_probe(struct platform_device *pdev) ...@@ -770,6 +772,13 @@ static int __init mvsd_probe(struct platform_device *pdev)
} else } else
host->irq = irq; host->irq = irq;
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
host->clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(host->clk)) {
clk_prepare_enable(host->clk);
}
if (mvsd_data->gpio_card_detect) { if (mvsd_data->gpio_card_detect) {
ret = gpio_request(mvsd_data->gpio_card_detect, ret = gpio_request(mvsd_data->gpio_card_detect,
DRIVER_NAME " cd"); DRIVER_NAME " cd");
...@@ -854,6 +863,11 @@ static int __exit mvsd_remove(struct platform_device *pdev) ...@@ -854,6 +863,11 @@ static int __exit mvsd_remove(struct platform_device *pdev)
mvsd_power_down(host); mvsd_power_down(host);
iounmap(host->base); iounmap(host->base);
release_resource(host->res); release_resource(host->res);
if (!IS_ERR(host->clk)) {
clk_disable_unprepare(host->clk);
clk_put(host->clk);
}
mmc_free_host(mmc); mmc_free_host(mmc);
} }
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/sizes.h> #include <asm/sizes.h>
#include <mach/hardware.h> #include <mach/hardware.h>
...@@ -77,6 +79,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -77,6 +79,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
struct nand_chip *nc; struct nand_chip *nc;
struct orion_nand_data *board; struct orion_nand_data *board;
struct resource *res; struct resource *res;
struct clk *clk;
void __iomem *io_base; void __iomem *io_base;
int ret = 0; int ret = 0;
...@@ -123,6 +126,14 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -123,6 +126,14 @@ static int __init orion_nand_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mtd); platform_set_drvdata(pdev, mtd);
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_prepare_enable(clk);
clk_put(clk);
}
if (nand_scan(mtd, 1)) { if (nand_scan(mtd, 1)) {
ret = -ENXIO; ret = -ENXIO;
goto no_dev; goto no_dev;
...@@ -151,6 +162,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) ...@@ -151,6 +162,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
{ {
struct mtd_info *mtd = platform_get_drvdata(pdev); struct mtd_info *mtd = platform_get_drvdata(pdev);
struct nand_chip *nc = mtd->priv; struct nand_chip *nc = mtd->priv;
struct clk *clk;
nand_release(mtd); nand_release(mtd);
...@@ -158,6 +170,12 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) ...@@ -158,6 +170,12 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
kfree(nc); kfree(nc);
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
return 0; return 0;
} }
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/inet_lro.h> #include <linux/inet_lro.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/clk.h>
static char mv643xx_eth_driver_name[] = "mv643xx_eth"; static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4"; static char mv643xx_eth_driver_version[] = "1.4";
...@@ -289,10 +290,10 @@ struct mv643xx_eth_shared_private { ...@@ -289,10 +290,10 @@ struct mv643xx_eth_shared_private {
/* /*
* Hardware-specific parameters. * Hardware-specific parameters.
*/ */
unsigned int t_clk;
int extended_rx_coal_limit; int extended_rx_coal_limit;
int tx_bw_control; int tx_bw_control;
int tx_csum_limit; int tx_csum_limit;
}; };
#define TX_BW_CONTROL_ABSENT 0 #define TX_BW_CONTROL_ABSENT 0
...@@ -431,6 +432,12 @@ struct mv643xx_eth_private { ...@@ -431,6 +432,12 @@ struct mv643xx_eth_private {
int tx_desc_sram_size; int tx_desc_sram_size;
int txq_count; int txq_count;
struct tx_queue txq[8]; struct tx_queue txq[8];
/*
* Hardware-specific parameters.
*/
struct clk *clk;
unsigned int t_clk;
}; };
...@@ -1010,7 +1017,7 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst) ...@@ -1010,7 +1017,7 @@ static void tx_set_rate(struct mv643xx_eth_private *mp, int rate, int burst)
int mtu; int mtu;
int bucket_size; int bucket_size;
token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000);
if (token_rate > 1023) if (token_rate > 1023)
token_rate = 1023; token_rate = 1023;
...@@ -1042,7 +1049,7 @@ static void txq_set_rate(struct tx_queue *txq, int rate, int burst) ...@@ -1042,7 +1049,7 @@ static void txq_set_rate(struct tx_queue *txq, int rate, int burst)
int token_rate; int token_rate;
int bucket_size; int bucket_size;
token_rate = ((rate / 1000) * 64) / (mp->shared->t_clk / 1000); token_rate = ((rate / 1000) * 64) / (mp->t_clk / 1000);
if (token_rate > 1023) if (token_rate > 1023)
token_rate = 1023; token_rate = 1023;
...@@ -1309,7 +1316,7 @@ static unsigned int get_rx_coal(struct mv643xx_eth_private *mp) ...@@ -1309,7 +1316,7 @@ static unsigned int get_rx_coal(struct mv643xx_eth_private *mp)
temp = (val & 0x003fff00) >> 8; temp = (val & 0x003fff00) >> 8;
temp *= 64000000; temp *= 64000000;
do_div(temp, mp->shared->t_clk); do_div(temp, mp->t_clk);
return (unsigned int)temp; return (unsigned int)temp;
} }
...@@ -1319,7 +1326,7 @@ static void set_rx_coal(struct mv643xx_eth_private *mp, unsigned int usec) ...@@ -1319,7 +1326,7 @@ static void set_rx_coal(struct mv643xx_eth_private *mp, unsigned int usec)
u64 temp; u64 temp;
u32 val; u32 val;
temp = (u64)usec * mp->shared->t_clk; temp = (u64)usec * mp->t_clk;
temp += 31999999; temp += 31999999;
do_div(temp, 64000000); do_div(temp, 64000000);
...@@ -1345,7 +1352,7 @@ static unsigned int get_tx_coal(struct mv643xx_eth_private *mp) ...@@ -1345,7 +1352,7 @@ static unsigned int get_tx_coal(struct mv643xx_eth_private *mp)
temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4; temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4;
temp *= 64000000; temp *= 64000000;
do_div(temp, mp->shared->t_clk); do_div(temp, mp->t_clk);
return (unsigned int)temp; return (unsigned int)temp;
} }
...@@ -1354,7 +1361,7 @@ static void set_tx_coal(struct mv643xx_eth_private *mp, unsigned int usec) ...@@ -1354,7 +1361,7 @@ static void set_tx_coal(struct mv643xx_eth_private *mp, unsigned int usec)
{ {
u64 temp; u64 temp;
temp = (u64)usec * mp->shared->t_clk; temp = (u64)usec * mp->t_clk;
temp += 31999999; temp += 31999999;
do_div(temp, 64000000); do_div(temp, 64000000);
...@@ -2662,10 +2669,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) ...@@ -2662,10 +2669,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
if (dram) if (dram)
mv643xx_eth_conf_mbus_windows(msp, dram); mv643xx_eth_conf_mbus_windows(msp, dram);
/*
* Detect hardware parameters.
*/
msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ? msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
pd->tx_csum_limit : 9 * 1024; pd->tx_csum_limit : 9 * 1024;
infer_hw_params(msp); infer_hw_params(msp);
...@@ -2890,6 +2893,18 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -2890,6 +2893,18 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
mp->dev = dev; mp->dev = dev;
/*
* Get the clk rate, if there is one, otherwise use the default.
*/
mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0"));
if (!IS_ERR(mp->clk)) {
clk_prepare_enable(mp->clk);
mp->t_clk = clk_get_rate(mp->clk);
} else {
mp->t_clk = 133000000;
printk(KERN_WARNING "Unable to get clock");
}
set_params(mp, pd); set_params(mp, pd);
netif_set_real_num_tx_queues(dev, mp->txq_count); netif_set_real_num_tx_queues(dev, mp->txq_count);
netif_set_real_num_rx_queues(dev, mp->rxq_count); netif_set_real_num_rx_queues(dev, mp->rxq_count);
...@@ -2978,6 +2993,11 @@ static int mv643xx_eth_remove(struct platform_device *pdev) ...@@ -2978,6 +2993,11 @@ static int mv643xx_eth_remove(struct platform_device *pdev)
if (mp->phy != NULL) if (mp->phy != NULL)
phy_detach(mp->phy); phy_detach(mp->phy);
cancel_work_sync(&mp->tx_timeout_task); cancel_work_sync(&mp->tx_timeout_task);
if (!IS_ERR(mp->clk)) {
clk_disable_unprepare(mp->clk);
clk_put(mp->clk);
}
free_netdev(mp->dev); free_netdev(mp->dev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/orion_spi.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/clk.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#define DRIVER_NAME "orion_spi" #define DRIVER_NAME "orion_spi"
...@@ -46,6 +46,7 @@ struct orion_spi { ...@@ -46,6 +46,7 @@ struct orion_spi {
unsigned int max_speed; unsigned int max_speed;
unsigned int min_speed; unsigned int min_speed;
struct orion_spi_info *spi_info; struct orion_spi_info *spi_info;
struct clk *clk;
}; };
static struct workqueue_struct *orion_spi_wq; static struct workqueue_struct *orion_spi_wq;
...@@ -104,7 +105,7 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed) ...@@ -104,7 +105,7 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed)
orion_spi = spi_master_get_devdata(spi->master); orion_spi = spi_master_get_devdata(spi->master);
tclk_hz = orion_spi->spi_info->tclk; tclk_hz = clk_get_rate(orion_spi->clk);
/* /*
* the supported rates are: 4,6,8...30 * the supported rates are: 4,6,8...30
...@@ -450,6 +451,7 @@ static int __init orion_spi_probe(struct platform_device *pdev) ...@@ -450,6 +451,7 @@ static int __init orion_spi_probe(struct platform_device *pdev)
struct orion_spi *spi; struct orion_spi *spi;
struct resource *r; struct resource *r;
struct orion_spi_info *spi_info; struct orion_spi_info *spi_info;
unsigned long tclk_hz;
int status = 0; int status = 0;
spi_info = pdev->dev.platform_data; spi_info = pdev->dev.platform_data;
...@@ -476,19 +478,28 @@ static int __init orion_spi_probe(struct platform_device *pdev) ...@@ -476,19 +478,28 @@ static int __init orion_spi_probe(struct platform_device *pdev)
spi->master = master; spi->master = master;
spi->spi_info = spi_info; spi->spi_info = spi_info;
spi->max_speed = DIV_ROUND_UP(spi_info->tclk, 4); spi->clk = clk_get(&pdev->dev, NULL);
spi->min_speed = DIV_ROUND_UP(spi_info->tclk, 30); if (IS_ERR(spi->clk)) {
status = PTR_ERR(spi->clk);
goto out;
}
clk_prepare(spi->clk);
clk_enable(spi->clk);
tclk_hz = clk_get_rate(spi->clk);
spi->max_speed = DIV_ROUND_UP(tclk_hz, 4);
spi->min_speed = DIV_ROUND_UP(tclk_hz, 30);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) { if (r == NULL) {
status = -ENODEV; status = -ENODEV;
goto out; goto out_rel_clk;
} }
if (!request_mem_region(r->start, resource_size(r), if (!request_mem_region(r->start, resource_size(r),
dev_name(&pdev->dev))) { dev_name(&pdev->dev))) {
status = -EBUSY; status = -EBUSY;
goto out; goto out_rel_clk;
} }
spi->base = ioremap(r->start, SZ_1K); spi->base = ioremap(r->start, SZ_1K);
...@@ -508,7 +519,9 @@ static int __init orion_spi_probe(struct platform_device *pdev) ...@@ -508,7 +519,9 @@ static int __init orion_spi_probe(struct platform_device *pdev)
out_rel_mem: out_rel_mem:
release_mem_region(r->start, resource_size(r)); release_mem_region(r->start, resource_size(r));
out_rel_clk:
clk_disable_unprepare(spi->clk);
clk_put(spi->clk);
out: out:
spi_master_put(master); spi_master_put(master);
return status; return status;
...@@ -526,6 +539,9 @@ static int __exit orion_spi_remove(struct platform_device *pdev) ...@@ -526,6 +539,9 @@ static int __exit orion_spi_remove(struct platform_device *pdev)
cancel_work_sync(&spi->work); cancel_work_sync(&spi->work);
clk_disable_unprepare(spi->clk);
clk_put(spi->clk);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(r->start, resource_size(r)); release_mem_region(r->start, resource_size(r));
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mbus.h> #include <linux/mbus.h>
#include <linux/clk.h>
#include <plat/ehci-orion.h> #include <plat/ehci-orion.h>
#define rdl(off) __raw_readl(hcd->regs + (off)) #define rdl(off) __raw_readl(hcd->regs + (off))
...@@ -198,6 +199,7 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) ...@@ -198,6 +199,7 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
struct usb_hcd *hcd; struct usb_hcd *hcd;
struct ehci_hcd *ehci; struct ehci_hcd *ehci;
struct clk *clk;
void __iomem *regs; void __iomem *regs;
int irq, err; int irq, err;
...@@ -238,6 +240,14 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) ...@@ -238,6 +240,14 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
goto err2; goto err2;
} }
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_prepare_enable(clk);
clk_put(clk);
}
hcd = usb_create_hcd(&ehci_orion_hc_driver, hcd = usb_create_hcd(&ehci_orion_hc_driver,
&pdev->dev, dev_name(&pdev->dev)); &pdev->dev, dev_name(&pdev->dev));
if (!hcd) { if (!hcd) {
...@@ -301,12 +311,18 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) ...@@ -301,12 +311,18 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev)
static int __exit ehci_orion_drv_remove(struct platform_device *pdev) static int __exit ehci_orion_drv_remove(struct platform_device *pdev)
{ {
struct usb_hcd *hcd = platform_get_drvdata(pdev); struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct clk *clk;
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap(hcd->regs); iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
return 0; return 0;
} }
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/clk.h>
#include <mach/bridge-regs.h> #include <mach/bridge-regs.h>
#include <plat/orion_wdt.h>
/* /*
* Watchdog timer block registers. * Watchdog timer block registers.
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
static bool nowayout = WATCHDOG_NOWAYOUT; static bool nowayout = WATCHDOG_NOWAYOUT;
static int heartbeat = -1; /* module parameter (seconds) */ static int heartbeat = -1; /* module parameter (seconds) */
static unsigned int wdt_max_duration; /* (seconds) */ static unsigned int wdt_max_duration; /* (seconds) */
static struct clk *clk;
static unsigned int wdt_tclk; static unsigned int wdt_tclk;
static void __iomem *wdt_reg; static void __iomem *wdt_reg;
static unsigned long wdt_status; static unsigned long wdt_status;
...@@ -237,16 +238,16 @@ static struct miscdevice orion_wdt_miscdev = { ...@@ -237,16 +238,16 @@ static struct miscdevice orion_wdt_miscdev = {
static int __devinit orion_wdt_probe(struct platform_device *pdev) static int __devinit orion_wdt_probe(struct platform_device *pdev)
{ {
struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
struct resource *res; struct resource *res;
int ret; int ret;
if (pdata) { clk = clk_get(&pdev->dev, NULL);
wdt_tclk = pdata->tclk; if (IS_ERR(clk)) {
} else { printk(KERN_ERR "Orion Watchdog missing clock\n");
pr_err("misses platform data\n");
return -ENODEV; return -ENODEV;
} }
clk_prepare_enable(clk);
wdt_tclk = clk_get_rate(clk);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -282,6 +283,9 @@ static int __devexit orion_wdt_remove(struct platform_device *pdev) ...@@ -282,6 +283,9 @@ static int __devexit orion_wdt_remove(struct platform_device *pdev)
if (!ret) if (!ret)
orion_wdt_miscdev.parent = NULL; orion_wdt_miscdev.parent = NULL;
clk_disable_unprepare(clk);
clk_put(clk);
return ret; return ret;
} }
......
...@@ -312,6 +312,8 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name, ...@@ -312,6 +312,8 @@ struct clk *clk_register_fixed_factor(struct device *dev, const char *name,
*/ */
struct clk *clk_register(struct device *dev, struct clk_hw *hw); struct clk *clk_register(struct device *dev, struct clk_hw *hw);
void clk_unregister(struct clk *clk);
/* helper functions */ /* helper functions */
const char *__clk_get_name(struct clk *clk); const char *__clk_get_name(struct clk *clk);
struct clk_hw *__clk_get_hw(struct clk *clk); struct clk_hw *__clk_get_hw(struct clk *clk);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
struct mv643xx_eth_shared_platform_data { struct mv643xx_eth_shared_platform_data {
struct mbus_dram_target_info *dram; struct mbus_dram_target_info *dram;
struct platform_device *shared_smi; struct platform_device *shared_smi;
unsigned int t_clk;
/* /*
* Max packet size for Tx IP/Layer 4 checksum, when set to 0, default * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default
* limit of 9KiB will be used. * limit of 9KiB will be used.
......
/*
* orion_spi.h
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#ifndef __LINUX_SPI_ORION_SPI_H
#define __LINUX_SPI_ORION_SPI_H
struct orion_spi_info {
u32 tclk; /* no <linux/clk.h> support yet */
};
#endif
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mbus.h> #include <linux/mbus.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clk.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -449,6 +450,14 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) ...@@ -449,6 +450,14 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
priv->burst = data->burst; priv->burst = data->burst;
priv->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "no clock\n");
err = PTR_ERR(priv->clk);
goto err_ioremap;
}
clk_prepare_enable(priv->clk);
return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai); return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
err_ioremap: err_ioremap:
...@@ -466,6 +475,10 @@ static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev) ...@@ -466,6 +475,10 @@ static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_dai(&pdev->dev); snd_soc_unregister_dai(&pdev->dev);
clk_disable_unprepare(priv->clk);
clk_put(priv->clk);
iounmap(priv->io); iounmap(priv->io);
release_mem_region(priv->mem->start, SZ_16K); release_mem_region(priv->mem->start, SZ_16K);
kfree(priv); kfree(priv);
......
...@@ -123,6 +123,7 @@ struct kirkwood_dma_data { ...@@ -123,6 +123,7 @@ struct kirkwood_dma_data {
void __iomem *io; void __iomem *io;
int irq; int irq;
int burst; int burst;
struct clk *clk;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment