ARM: orion: Consolidate the creation of the uart platform data.
authorAndrew Lunn <andrew@lunn.ch>
Sun, 15 May 2011 11:32:41 +0000 (13:32 +0200)
committerNicolas Pitre <nico@fluxnic.net>
Mon, 16 May 2011 18:46:17 +0000 (14:46 -0400)
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
arch/arm/mach-dove/common.c
arch/arm/mach-kirkwood/common.c
arch/arm/mach-loki/common.c
arch/arm/mach-mv78xx0/common.c
arch/arm/mach-orion5x/common.c
arch/arm/plat-orion/Makefile
arch/arm/plat-orion/common.c [new file with mode: 0644]
arch/arm/plat-orion/include/plat/common.h [new file with mode: 0644]

index 30c9518797876792ca45fa7c0925b835842d290c..fffa92e92d6cb29eb72eb5dd0718a95292357176 100644 (file)
 #include <plat/mv_xor.h>
 #include <plat/ehci-orion.h>
 #include <plat/time.h>
+#include <plat/common.h>
 #include "common.h"
 
+static int get_tclk(void);
+
 /*****************************************************************************
  * I/O Address Mapping
  ****************************************************************************/
@@ -255,173 +258,37 @@ void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
 /*****************************************************************************
  * UART0
  ****************************************************************************/
-static struct plat_serial8250_port dove_uart0_data[] = {
-       {
-               .mapbase        = DOVE_UART0_PHYS_BASE,
-               .membase        = (char *)DOVE_UART0_VIRT_BASE,
-               .irq            = IRQ_DOVE_UART_0,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource dove_uart0_resources[] = {
-       {
-               .start          = DOVE_UART0_PHYS_BASE,
-               .end            = DOVE_UART0_PHYS_BASE + SZ_256 - 1,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_DOVE_UART_0,
-               .end            = IRQ_DOVE_UART_0,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device dove_uart0 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM,
-       .dev                    = {
-               .platform_data  = dove_uart0_data,
-       },
-       .resource               = dove_uart0_resources,
-       .num_resources          = ARRAY_SIZE(dove_uart0_resources),
-};
-
 void __init dove_uart0_init(void)
 {
-       platform_device_register(&dove_uart0);
+       orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
+                        IRQ_DOVE_UART_0, get_tclk());
 }
 
 /*****************************************************************************
  * UART1
  ****************************************************************************/
-static struct plat_serial8250_port dove_uart1_data[] = {
-       {
-               .mapbase        = DOVE_UART1_PHYS_BASE,
-               .membase        = (char *)DOVE_UART1_VIRT_BASE,
-               .irq            = IRQ_DOVE_UART_1,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource dove_uart1_resources[] = {
-       {
-               .start          = DOVE_UART1_PHYS_BASE,
-               .end            = DOVE_UART1_PHYS_BASE + SZ_256 - 1,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_DOVE_UART_1,
-               .end            = IRQ_DOVE_UART_1,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device dove_uart1 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM1,
-       .dev                    = {
-               .platform_data  = dove_uart1_data,
-       },
-       .resource               = dove_uart1_resources,
-       .num_resources          = ARRAY_SIZE(dove_uart1_resources),
-};
-
 void __init dove_uart1_init(void)
 {
-       platform_device_register(&dove_uart1);
+       orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
+                        IRQ_DOVE_UART_1, get_tclk());
 }
 
 /*****************************************************************************
  * UART2
  ****************************************************************************/
-static struct plat_serial8250_port dove_uart2_data[] = {
-       {
-               .mapbase        = DOVE_UART2_PHYS_BASE,
-               .membase        = (char *)DOVE_UART2_VIRT_BASE,
-               .irq            = IRQ_DOVE_UART_2,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource dove_uart2_resources[] = {
-       {
-               .start          = DOVE_UART2_PHYS_BASE,
-               .end            = DOVE_UART2_PHYS_BASE + SZ_256 - 1,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_DOVE_UART_2,
-               .end            = IRQ_DOVE_UART_2,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device dove_uart2 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM2,
-       .dev                    = {
-               .platform_data  = dove_uart2_data,
-       },
-       .resource               = dove_uart2_resources,
-       .num_resources          = ARRAY_SIZE(dove_uart2_resources),
-};
-
 void __init dove_uart2_init(void)
 {
-       platform_device_register(&dove_uart2);
+       orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
+                        IRQ_DOVE_UART_2, get_tclk());
 }
 
 /*****************************************************************************
  * UART3
  ****************************************************************************/
-static struct plat_serial8250_port dove_uart3_data[] = {
-       {
-               .mapbase        = DOVE_UART3_PHYS_BASE,
-               .membase        = (char *)DOVE_UART3_VIRT_BASE,
-               .irq            = IRQ_DOVE_UART_3,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource dove_uart3_resources[] = {
-       {
-               .start          = DOVE_UART3_PHYS_BASE,
-               .end            = DOVE_UART3_PHYS_BASE + SZ_256 - 1,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_DOVE_UART_3,
-               .end            = IRQ_DOVE_UART_3,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device dove_uart3 = {
-       .name                   = "serial8250",
-       .id                     = 3,
-       .dev                    = {
-               .platform_data  = dove_uart3_data,
-       },
-       .resource               = dove_uart3_resources,
-       .num_resources          = ARRAY_SIZE(dove_uart3_resources),
-};
-
 void __init dove_uart3_init(void)
 {
-       platform_device_register(&dove_uart3);
+       orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
+                        IRQ_DOVE_UART_3, get_tclk());
 }
 
 /*****************************************************************************
@@ -835,10 +702,6 @@ void __init dove_init(void)
        dove_setup_cpu_mbus();
 
        dove_ge00_shared_data.t_clk = tclk;
-       dove_uart0_data[0].uartclk = tclk;
-       dove_uart1_data[0].uartclk = tclk;
-       dove_uart2_data[0].uartclk = tclk;
-       dove_uart3_data[0].uartclk = tclk;
        dove_spi0_data.tclk = tclk;
        dove_spi1_data.tclk = tclk;
 
index 4b89eed216e791ec8b6212823e8ce96946319faa..8cdf9f9f74b597a6e3e0d1c03c9cefdf8d2e1394 100644 (file)
@@ -33,6 +33,7 @@
 #include <plat/mv_xor.h>
 #include <plat/orion_nand.h>
 #include <plat/orion_wdt.h>
+#include <plat/common.h>
 #include <plat/time.h>
 #include "common.h"
 
@@ -491,91 +492,23 @@ void __init kirkwood_i2c_init(void)
 /*****************************************************************************
  * UART0
  ****************************************************************************/
-static struct plat_serial8250_port kirkwood_uart0_data[] = {
-       {
-               .mapbase        = UART0_PHYS_BASE,
-               .membase        = (char *)UART0_VIRT_BASE,
-               .irq            = IRQ_KIRKWOOD_UART_0,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource kirkwood_uart0_resources[] = {
-       {
-               .start          = UART0_PHYS_BASE,
-               .end            = UART0_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_KIRKWOOD_UART_0,
-               .end            = IRQ_KIRKWOOD_UART_0,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device kirkwood_uart0 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM,
-       .dev                    = {
-               .platform_data  = kirkwood_uart0_data,
-       },
-       .resource               = kirkwood_uart0_resources,
-       .num_resources          = ARRAY_SIZE(kirkwood_uart0_resources),
-};
 
 void __init kirkwood_uart0_init(void)
 {
-       platform_device_register(&kirkwood_uart0);
+       orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
+                        IRQ_KIRKWOOD_UART_0, kirkwood_tclk);
 }
 
 
 /*****************************************************************************
  * UART1
  ****************************************************************************/
-static struct plat_serial8250_port kirkwood_uart1_data[] = {
-       {
-               .mapbase        = UART1_PHYS_BASE,
-               .membase        = (char *)UART1_VIRT_BASE,
-               .irq            = IRQ_KIRKWOOD_UART_1,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource kirkwood_uart1_resources[] = {
-       {
-               .start          = UART1_PHYS_BASE,
-               .end            = UART1_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_KIRKWOOD_UART_1,
-               .end            = IRQ_KIRKWOOD_UART_1,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device kirkwood_uart1 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM1,
-       .dev                    = {
-               .platform_data  = kirkwood_uart1_data,
-       },
-       .resource               = kirkwood_uart1_resources,
-       .num_resources          = ARRAY_SIZE(kirkwood_uart1_resources),
-};
-
 void __init kirkwood_uart1_init(void)
 {
-       platform_device_register(&kirkwood_uart1);
+       orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
+                        IRQ_KIRKWOOD_UART_1, kirkwood_tclk);
 }
 
-
 /*****************************************************************************
  * Cryptographic Engines and Security Accelerator (CESA)
  ****************************************************************************/
@@ -987,8 +920,6 @@ void __init kirkwood_init(void)
        kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
        kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
        kirkwood_spi_plat_data.tclk = kirkwood_tclk;
-       kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
-       kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
        kirkwood_i2s_data.tclk = kirkwood_tclk;
 
        /*
index 4ff4c62c3c023fafce9c9e9779d7f0cab6082353..c07180492bf03065af9c02de59b4b7bf36bc50d7 100644 (file)
@@ -23,6 +23,7 @@
 #include <mach/loki.h>
 #include <plat/orion_nand.h>
 #include <plat/time.h>
+#include <plat/common.h>
 #include "common.h"
 
 /*****************************************************************************
@@ -204,88 +205,19 @@ void __init loki_sas_init(void)
 /*****************************************************************************
  * UART0
  ****************************************************************************/
-static struct plat_serial8250_port loki_uart0_data[] = {
-       {
-               .mapbase        = UART0_PHYS_BASE,
-               .membase        = (char *)UART0_VIRT_BASE,
-               .irq            = IRQ_LOKI_UART0,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = LOKI_TCLK,
-       }, {
-       },
-};
-
-static struct resource loki_uart0_resources[] = {
-       {
-               .start          = UART0_PHYS_BASE,
-               .end            = UART0_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_LOKI_UART0,
-               .end            = IRQ_LOKI_UART0,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device loki_uart0 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM,
-       .dev                    = {
-               .platform_data  = loki_uart0_data,
-       },
-       .resource               = loki_uart0_resources,
-       .num_resources          = ARRAY_SIZE(loki_uart0_resources),
-};
-
 void __init loki_uart0_init(void)
 {
-       platform_device_register(&loki_uart0);
+       orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
+                        IRQ_LOKI_UART0, LOKI_TCLK);
 }
 
-
 /*****************************************************************************
  * UART1
  ****************************************************************************/
-static struct plat_serial8250_port loki_uart1_data[] = {
-       {
-               .mapbase        = UART1_PHYS_BASE,
-               .membase        = (char *)UART1_VIRT_BASE,
-               .irq            = IRQ_LOKI_UART1,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = LOKI_TCLK,
-       }, {
-       },
-};
-
-static struct resource loki_uart1_resources[] = {
-       {
-               .start          = UART1_PHYS_BASE,
-               .end            = UART1_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_LOKI_UART1,
-               .end            = IRQ_LOKI_UART1,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device loki_uart1 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM1,
-       .dev                    = {
-               .platform_data  = loki_uart1_data,
-       },
-       .resource               = loki_uart1_resources,
-       .num_resources          = ARRAY_SIZE(loki_uart1_resources),
-};
-
 void __init loki_uart1_init(void)
 {
-       platform_device_register(&loki_uart1);
+       orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
+                        IRQ_LOKI_UART1, LOKI_TCLK);
 }
 
 
index c38250d1f07f6d40664a00e50dbeb43c9541efbb..5b474e4574de892cbaeb369d27fcecacc91378c3 100644 (file)
 #include <plat/ehci-orion.h>
 #include <plat/orion_nand.h>
 #include <plat/time.h>
+#include <plat/common.h>
 #include "common.h"
 
+static int get_tclk(void);
 
 /*****************************************************************************
  * Common bits
@@ -642,179 +644,41 @@ void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data)
 /*****************************************************************************
  * UART0
  ****************************************************************************/
-static struct plat_serial8250_port mv78xx0_uart0_data[] = {
-       {
-               .mapbase        = UART0_PHYS_BASE,
-               .membase        = (char *)UART0_VIRT_BASE,
-               .irq            = IRQ_MV78XX0_UART_0,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource mv78xx0_uart0_resources[] = {
-       {
-               .start          = UART0_PHYS_BASE,
-               .end            = UART0_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_MV78XX0_UART_0,
-               .end            = IRQ_MV78XX0_UART_0,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mv78xx0_uart0 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM,
-       .dev                    = {
-               .platform_data  = mv78xx0_uart0_data,
-       },
-       .resource               = mv78xx0_uart0_resources,
-       .num_resources          = ARRAY_SIZE(mv78xx0_uart0_resources),
-};
-
 void __init mv78xx0_uart0_init(void)
 {
-       platform_device_register(&mv78xx0_uart0);
+       orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
+                        IRQ_MV78XX0_UART_0, get_tclk());
 }
 
 
 /*****************************************************************************
  * UART1
  ****************************************************************************/
-static struct plat_serial8250_port mv78xx0_uart1_data[] = {
-       {
-               .mapbase        = UART1_PHYS_BASE,
-               .membase        = (char *)UART1_VIRT_BASE,
-               .irq            = IRQ_MV78XX0_UART_1,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource mv78xx0_uart1_resources[] = {
-       {
-               .start          = UART1_PHYS_BASE,
-               .end            = UART1_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_MV78XX0_UART_1,
-               .end            = IRQ_MV78XX0_UART_1,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mv78xx0_uart1 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM1,
-       .dev                    = {
-               .platform_data  = mv78xx0_uart1_data,
-       },
-       .resource               = mv78xx0_uart1_resources,
-       .num_resources          = ARRAY_SIZE(mv78xx0_uart1_resources),
-};
-
 void __init mv78xx0_uart1_init(void)
 {
-       platform_device_register(&mv78xx0_uart1);
+       orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
+                        IRQ_MV78XX0_UART_1, get_tclk());
 }
 
 
 /*****************************************************************************
  * UART2
  ****************************************************************************/
-static struct plat_serial8250_port mv78xx0_uart2_data[] = {
-       {
-               .mapbase        = UART2_PHYS_BASE,
-               .membase        = (char *)UART2_VIRT_BASE,
-               .irq            = IRQ_MV78XX0_UART_2,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource mv78xx0_uart2_resources[] = {
-       {
-               .start          = UART2_PHYS_BASE,
-               .end            = UART2_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_MV78XX0_UART_2,
-               .end            = IRQ_MV78XX0_UART_2,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mv78xx0_uart2 = {
-       .name                   = "serial8250",
-       .id                     = PLAT8250_DEV_PLATFORM2,
-       .dev                    = {
-               .platform_data  = mv78xx0_uart2_data,
-       },
-       .resource               = mv78xx0_uart2_resources,
-       .num_resources          = ARRAY_SIZE(mv78xx0_uart2_resources),
-};
-
 void __init mv78xx0_uart2_init(void)
 {
-       platform_device_register(&mv78xx0_uart2);
+       orion_uart2_init(UART2_VIRT_BASE, UART2_PHYS_BASE,
+                        IRQ_MV78XX0_UART_2, get_tclk());
 }
 
-
 /*****************************************************************************
  * UART3
  ****************************************************************************/
-static struct plat_serial8250_port mv78xx0_uart3_data[] = {
-       {
-               .mapbase        = UART3_PHYS_BASE,
-               .membase        = (char *)UART3_VIRT_BASE,
-               .irq            = IRQ_MV78XX0_UART_3,
-               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
-               .iotype         = UPIO_MEM,
-               .regshift       = 2,
-               .uartclk        = 0,
-       }, {
-       },
-};
-
-static struct resource mv78xx0_uart3_resources[] = {
-       {
-               .start          = UART3_PHYS_BASE,
-               .end            = UART3_PHYS_BASE + 0xff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_MV78XX0_UART_3,
-               .end            = IRQ_MV78XX0_UART_3,
-               .flags          = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mv78xx0_uart3 = {
-       .name                   = "serial8250",
-       .id                     = 3,
-       .dev                    = {
-               .platform_data  = mv78xx0_uart3_data,
-       },
-       .resource               = mv78xx0_uart3_resources,
-       .num_resources          = ARRAY_SIZE(mv78xx0_uart3_resources),
-};
-
 void __init mv78xx0_uart3_init(void)
 {
-       platform_device_register(&mv78xx0_uart3);
+       orion_uart3_init(UART3_VIRT_BASE, UART3_PHYS_BASE,
+                        IRQ_MV78XX0_UART_3, get_tclk());
 }
 
-
 /*****************************************************************************
  * Time handling
  ****************************************************************************/
@@ -900,8 +764,4 @@ void __init mv78xx0_init(void)
        mv78xx0_ge01_shared_data.t_clk = tclk;
        mv78xx0_ge10_shared_data.t_clk = tclk;
        mv78xx0_ge11_shared_data.t_clk = tclk;
-       mv78xx0_uart0_data[0].uartclk = tclk;
-       mv78xx0_uart1_data[0].uartclk = tclk;
-       mv78xx0_uart2_data[0].uartclk = tclk;
-       mv78xx0_uart3_data[0].uartclk = tclk;
 }
index d281b1984e4abc02c0c82e949cb361fbf3249998..310de50e1bb97feccd04b2f3d42b302339b66bd9 100644 (file)
@@ -34,6 +34,7 @@
 #include <plat/orion_nand.h>
 #include <plat/orion_wdt.h>
 #include <plat/time.h>
+#include <plat/common.h>
 #include "common.h"
 
 /*****************************************************************************
@@ -349,91 +350,21 @@ void __init orion5x_spi_init()
 /*****************************************************************************
  * 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        = 0,
-       }, {
-       },
-};
-
-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);
+       orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
+                        IRQ_ORION5X_UART0, orion5x_tclk);
 }
 
-
 /*****************************************************************************
  * 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        = 0,
-       }, {
-       },
-};
-
-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);
+       orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
+                        IRQ_ORION5X_UART1, orion5x_tclk);
 }
 
-
 /*****************************************************************************
  * XOR engine
  ****************************************************************************/
@@ -687,8 +618,6 @@ void __init orion5x_init(void)
 
        orion5x_ge00_shared_data.t_clk = orion5x_tclk;
        orion5x_spi_plat_data.tclk = orion5x_tclk;
-       orion5x_uart0_data[0].uartclk = orion5x_tclk;
-       orion5x_uart1_data[0].uartclk = orion5x_tclk;
 
        /*
         * Setup Orion address map
index 56021a72e10ce340e7ada4d4e4270dd8854bab51..0f048c58b4c9ea35c7e3d01a6709914456cc379c 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y  := irq.o pcie.o time.o
+obj-y  := irq.o pcie.o time.o common.o
 obj-m  :=
 obj-n  :=
 obj-   :=
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
new file mode 100644 (file)
index 0000000..4eac532
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * arch/arm/plat-orion/common.c
+ *
+ * Marvell Orion SoC common setup code used by multiple mach-/common.c
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
+
+/* Fill in the resources structure and link it into the platform
+   device structure. There is always a memory region, and nearly
+   always an interrupt.*/
+static void fill_resources(struct platform_device *device,
+                          struct resource *resources,
+                          resource_size_t mapbase,
+                          resource_size_t size,
+                          unsigned int irq)
+{
+       device->resource = resources;
+       device->num_resources = 1;
+       resources[0].flags = IORESOURCE_MEM;
+       resources[0].start = mapbase;
+       resources[0].end = mapbase + size;
+
+       if (irq != NO_IRQ) {
+               device->num_resources++;
+               resources[1].flags = IORESOURCE_IRQ;
+               resources[1].start = irq;
+               resources[1].end = irq;
+       }
+}
+
+/*****************************************************************************
+ * UART
+ ****************************************************************************/
+static void __init uart_complete(
+       struct platform_device *orion_uart,
+       struct plat_serial8250_port *data,
+       struct resource *resources,
+       unsigned int membase,
+       resource_size_t mapbase,
+       unsigned int irq,
+       unsigned int uartclk)
+{
+       data->mapbase = mapbase;
+       data->membase = (void __iomem *)membase;
+       data->irq = irq;
+       data->uartclk = uartclk;
+       orion_uart->dev.platform_data = data;
+
+       fill_resources(orion_uart, resources, mapbase, 0xff, irq);
+       platform_device_register(orion_uart);
+}
+
+/*****************************************************************************
+ * UART0
+ ****************************************************************************/
+static struct plat_serial8250_port orion_uart0_data[] = {
+       {
+               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+       }, {
+       },
+};
+
+static struct resource orion_uart0_resources[2];
+
+static struct platform_device orion_uart0 = {
+       .name                   = "serial8250",
+       .id                     = PLAT8250_DEV_PLATFORM,
+};
+
+void __init orion_uart0_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk)
+{
+       uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
+                     membase, mapbase, irq, uartclk);
+}
+
+/*****************************************************************************
+ * UART1
+ ****************************************************************************/
+static struct plat_serial8250_port orion_uart1_data[] = {
+       {
+               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+       }, {
+       },
+};
+
+static struct resource orion_uart1_resources[2];
+
+static struct platform_device orion_uart1 = {
+       .name                   = "serial8250",
+       .id                     = PLAT8250_DEV_PLATFORM1,
+};
+
+void __init orion_uart1_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk)
+{
+       uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
+                     membase, mapbase, irq, uartclk);
+}
+
+/*****************************************************************************
+ * UART2
+ ****************************************************************************/
+static struct plat_serial8250_port orion_uart2_data[] = {
+       {
+               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+       }, {
+       },
+};
+
+static struct resource orion_uart2_resources[2];
+
+static struct platform_device orion_uart2 = {
+       .name                   = "serial8250",
+       .id                     = PLAT8250_DEV_PLATFORM2,
+};
+
+void __init orion_uart2_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk)
+{
+       uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
+                     membase, mapbase, irq, uartclk);
+}
+
+/*****************************************************************************
+ * UART3
+ ****************************************************************************/
+static struct plat_serial8250_port orion_uart3_data[] = {
+       {
+               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+       }, {
+       },
+};
+
+static struct resource orion_uart3_resources[2];
+
+static struct platform_device orion_uart3 = {
+       .name                   = "serial8250",
+       .id                     = 3,
+};
+
+void __init orion_uart3_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk)
+{
+       uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
+                     membase, mapbase, irq, uartclk);
+}
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h
new file mode 100644 (file)
index 0000000..92ff991
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * arch/arm/plat-orion/include/plat/common.h
+ *
+ * Marvell Orion SoC common setup code used by different mach-/common.c
+ *
+ * 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_COMMON_H
+
+
+void __init orion_uart0_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk);
+
+void __init orion_uart1_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk);
+
+void __init orion_uart2_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk);
+
+void __init orion_uart3_init(unsigned int membase,
+                            resource_size_t mapbase,
+                            unsigned int irq,
+                            unsigned int uartclk);
+#endif