Skip to content

Commit

Permalink
[ARM] Orion: move EHCI/I2C/UART peripheral init into board code
Browse files Browse the repository at this point in the history
This patch moves initialisation of EHCI/I2C/UART platform devices
from the common orion5x_init() into the board support code.

The rationale behind this is that only the board support code knows
whether certain peripherals have been brought out on the board, and
not initialising peripherals that haven't been brought out is
desirable for example:
- to reduce user confusion (e.g. seeing both 'eth0' and 'eth1'
  appear while there is only one ethernet port on the board); and
- to allow for future power savings (peripherals that have not
  been brought out can be clock gated off entirely).

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Acked-by: Russell King <linux@arm.linux.org.uk>
  • Loading branch information
Lennert Buytenhek authored and Lennert Buytenhek committed Jun 22, 2008
1 parent 6eef84a commit 044f6c7
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 195 deletions.
226 changes: 136 additions & 90 deletions arch/arm/mach-orion5x/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,65 +63,20 @@ void __init orion5x_map_io(void)
iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
}


/*****************************************************************************
* UART
* EHCI
****************************************************************************/

static struct resource orion5x_uart_resources[] = {
{
.start = UART0_PHYS_BASE,
.end = UART0_PHYS_BASE + 0xff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_UART0,
.end = IRQ_ORION5X_UART0,
.flags = IORESOURCE_IRQ,
}, {
.start = UART1_PHYS_BASE,
.end = UART1_PHYS_BASE + 0xff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_UART1,
.end = IRQ_ORION5X_UART1,
.flags = IORESOURCE_IRQ,
},
};

static struct plat_serial8250_port orion5x_uart_data[] = {
{
.mapbase = UART0_PHYS_BASE,
.membase = (char *)UART0_VIRT_BASE,
.irq = IRQ_ORION5X_UART0,
.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
.iotype = UPIO_MEM,
.regshift = 2,
.uartclk = ORION5X_TCLK,
}, {
.mapbase = UART1_PHYS_BASE,
.membase = (char *)UART1_VIRT_BASE,
.irq = IRQ_ORION5X_UART1,
.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
.iotype = UPIO_MEM,
.regshift = 2,
.uartclk = ORION5X_TCLK,
}, {
},
static struct orion_ehci_data orion5x_ehci_data = {
.dram = &orion5x_mbus_dram_info,
};

static struct platform_device orion5x_uart = {
.name = "serial8250",
.id = PLAT8250_DEV_PLATFORM,
.dev = {
.platform_data = orion5x_uart_data,
},
.resource = orion5x_uart_resources,
.num_resources = ARRAY_SIZE(orion5x_uart_resources),
};
static u64 ehci_dmamask = 0xffffffffUL;

/*******************************************************************************
* USB Controller - 2 interfaces
******************************************************************************/

/*****************************************************************************
* EHCI0
****************************************************************************/
static struct resource orion5x_ehci0_resources[] = {
{
.start = ORION5X_USB0_PHYS_BASE,
Expand All @@ -134,24 +89,6 @@ static struct resource orion5x_ehci0_resources[] = {
},
};

static struct resource orion5x_ehci1_resources[] = {
{
.start = ORION5X_USB1_PHYS_BASE,
.end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_USB1_CTRL,
.end = IRQ_ORION5X_USB1_CTRL,
.flags = IORESOURCE_IRQ,
},
};

static struct orion_ehci_data orion5x_ehci_data = {
.dram = &orion5x_mbus_dram_info,
};

static u64 ehci_dmamask = 0xffffffffUL;

static struct platform_device orion5x_ehci0 = {
.name = "orion-ehci",
.id = 0,
Expand All @@ -164,6 +101,27 @@ static struct platform_device orion5x_ehci0 = {
.num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
};

void __init orion5x_ehci0_init(void)
{
platform_device_register(&orion5x_ehci0);
}


/*****************************************************************************
* EHCI1
****************************************************************************/
static struct resource orion5x_ehci1_resources[] = {
{
.start = ORION5X_USB1_PHYS_BASE,
.end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_USB1_CTRL,
.end = IRQ_ORION5X_USB1_CTRL,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device orion5x_ehci1 = {
.name = "orion-ehci",
.id = 1,
Expand All @@ -176,11 +134,15 @@ static struct platform_device orion5x_ehci1 = {
.num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
};

void __init orion5x_ehci1_init(void)
{
platform_device_register(&orion5x_ehci1);
}


/*****************************************************************************
* Gigabit Ethernet port
* (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
* GigE
****************************************************************************/

struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
.dram = &orion5x_mbus_dram_info,
.t_clk = ORION5X_TCLK,
Expand Down Expand Up @@ -229,11 +191,10 @@ void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
platform_device_register(&orion5x_eth);
}


/*****************************************************************************
* I2C controller
* (The Orion and Discovery (MV643xx) families share the same I2C controller)
* I2C
****************************************************************************/

static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
.freq_m = 8, /* assumes 166 MHz TCLK */
.freq_n = 3,
Expand All @@ -244,7 +205,7 @@ static struct resource orion5x_i2c_resources[] = {
{
.name = "i2c base",
.start = I2C_PHYS_BASE,
.end = I2C_PHYS_BASE + 0x20 -1,
.end = I2C_PHYS_BASE + 0x1f,
.flags = IORESOURCE_MEM,
}, {
.name = "i2c irq",
Expand All @@ -264,8 +225,14 @@ static struct platform_device orion5x_i2c = {
},
};

void __init orion5x_i2c_init(void)
{
platform_device_register(&orion5x_i2c);
}


/*****************************************************************************
* Sata port
* SATA
****************************************************************************/
static struct resource orion5x_sata_resources[] = {
{
Expand Down Expand Up @@ -298,10 +265,98 @@ void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
platform_device_register(&orion5x_sata);
}


/*****************************************************************************
* Time handling
* UART0
****************************************************************************/
static struct plat_serial8250_port orion5x_uart0_data[] = {
{
.mapbase = UART0_PHYS_BASE,
.membase = (char *)UART0_VIRT_BASE,
.irq = IRQ_ORION5X_UART0,
.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
.iotype = UPIO_MEM,
.regshift = 2,
.uartclk = ORION5X_TCLK,
}, {
},
};

static struct resource orion5x_uart0_resources[] = {
{
.start = UART0_PHYS_BASE,
.end = UART0_PHYS_BASE + 0xff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_UART0,
.end = IRQ_ORION5X_UART0,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device orion5x_uart0 = {
.name = "serial8250",
.id = PLAT8250_DEV_PLATFORM,
.dev = {
.platform_data = orion5x_uart0_data,
},
.resource = orion5x_uart0_resources,
.num_resources = ARRAY_SIZE(orion5x_uart0_resources),
};

void __init orion5x_uart0_init(void)
{
platform_device_register(&orion5x_uart0);
}


/*****************************************************************************
* UART1
****************************************************************************/
static struct plat_serial8250_port orion5x_uart1_data[] = {
{
.mapbase = UART1_PHYS_BASE,
.membase = (char *)UART1_VIRT_BASE,
.irq = IRQ_ORION5X_UART1,
.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
.iotype = UPIO_MEM,
.regshift = 2,
.uartclk = ORION5X_TCLK,
}, {
},
};

static struct resource orion5x_uart1_resources[] = {
{
.start = UART1_PHYS_BASE,
.end = UART1_PHYS_BASE + 0xff,
.flags = IORESOURCE_MEM,
}, {
.start = IRQ_ORION5X_UART1,
.end = IRQ_ORION5X_UART1,
.flags = IORESOURCE_IRQ,
},
};

static struct platform_device orion5x_uart1 = {
.name = "serial8250",
.id = PLAT8250_DEV_PLATFORM1,
.dev = {
.platform_data = orion5x_uart1_data,
},
.resource = orion5x_uart1_resources,
.num_resources = ARRAY_SIZE(orion5x_uart1_resources),
};

void __init orion5x_uart1_init(void)
{
platform_device_register(&orion5x_uart1);
}


/*****************************************************************************
* Time handling
****************************************************************************/
static void orion5x_timer_init(void)
{
orion_time_init(IRQ_ORION5X_BRIDGE, ORION5X_TCLK);
Expand All @@ -311,10 +366,10 @@ struct sys_timer orion5x_timer = {
.init = orion5x_timer_init,
};


/*****************************************************************************
* General
****************************************************************************/

/*
* Identify device ID and rev from PCIe configuration header space '0'.
*/
Expand Down Expand Up @@ -359,15 +414,6 @@ void __init orion5x_init(void)
* Setup Orion address map
*/
orion5x_setup_cpu_mbus_bridge();

/*
* Register devices.
*/
platform_device_register(&orion5x_uart);
platform_device_register(&orion5x_ehci0);
if (dev == MV88F5182_DEV_ID)
platform_device_register(&orion5x_ehci1);
platform_device_register(&orion5x_i2c);
}

/*
Expand Down
35 changes: 13 additions & 22 deletions arch/arm/mach-orion5x/common.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef __ARCH_ORION5X_COMMON_H
#define __ARCH_ORION5X_COMMON_H

struct mv643xx_eth_platform_data;
struct mv_sata_platform_data;

/*
* Basic Orion init functions used early by machine-setup.
*/

void orion5x_map_io(void);
void orion5x_init_irq(void);
void orion5x_init(void);
Expand All @@ -23,13 +25,19 @@ void orion5x_setup_dev1_win(u32 base, u32 size);
void orion5x_setup_dev2_win(u32 base, u32 size);
void orion5x_setup_pcie_wa_win(u32 base, u32 size);

void orion5x_ehci0_init(void);
void orion5x_ehci1_init(void);
void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
void orion5x_i2c_init(void);
void orion5x_sata_init(struct mv_sata_platform_data *sata_data);
void orion5x_uart0_init(void);
void orion5x_uart1_init(void);

/*
* Shared code used internally by other Orion core functions.
* (/mach-orion/pci.c)
* PCIe/PCI functions.
*/

struct pci_sys_data;
struct pci_bus;
struct pci_sys_data;

void orion5x_pcie_id(u32 *dev, u32 *rev);
int orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys);
Expand All @@ -40,26 +48,9 @@ int orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
* Valid GPIO pins according to MPP setup, used by machine-setup.
* (/mach-orion/gpio.c).
*/

void orion5x_gpio_set_valid_pins(u32 pins);
void gpio_display(void); /* debug */

/*
* Pull in Orion Ethernet platform_data, used by machine-setup
*/

struct mv643xx_eth_platform_data;

void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);

/*
* Orion Sata platform_data, used by machine-setup
*/

struct mv_sata_platform_data;

void orion5x_sata_init(struct mv_sata_platform_data *sata_data);

struct machine_desc;
struct meminfo;
struct tag;
Expand Down
Loading

0 comments on commit 044f6c7

Please sign in to comment.