[adm8668] get rid of the specific UART driver and use AMBA PL010
[15.05/openwrt.git] / target / linux / adm8668 / files / arch / mips / adm8668 / platform.c
index 4c158dd..5030565 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
+ * Copyright (C) 2012 Florian Fainelli <florian@openwrt.org>
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
@@ -13,6 +14,9 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/serial.h>
+
 #include <asm/reboot.h>
 #include <asm/time.h>
 #include <asm/addrspace.h>
 #include <asm/io.h>
 #include <adm8668.h>
 
-static struct resource uart_resources[] = {
-       {
+static void adm8668_uart_set_mctrl(struct amba_device *dev,
+                                       void __iomem *base,
+                                       unsigned int mcrtl)
+{
+}
+
+static struct amba_pl010_data adm8668_uart0_data = {
+       .set_mctrl = adm8668_uart_set_mctrl,
+};
+
+static struct amba_device adm8668_uart0_device = {
+       .dev = {
+               .init_name      = "apb:uart0",
+               .platform_data  = &adm8668_uart0_data,
+       },
+       .res = {
                .start          = ADM8668_UART0_BASE,
                .end            = ADM8668_UART0_BASE + 0xF,
                .flags          = IORESOURCE_MEM,
        },
-       {
-               .start          = INT_LVL_UART0,
-               .flags          = IORESOURCE_IRQ,
+       .irq = {
+               INT_LVL_UART0,
+               -1
        },
-};
-
-static struct platform_device adm8668_uart_device = {
-       .name           = "adm8668_uart",
-       .id             = 0,
-       .resource       = uart_resources,
-       .num_resources  = ARRAY_SIZE(uart_resources),
+       .periphid = 0x0041010,
 };
 
 static struct resource eth0_resources[] = {
@@ -78,13 +90,18 @@ static struct platform_device adm8668_eth1_device = {
 };
 
 static struct platform_device *adm8668_devs[] = {
-       &adm8668_uart_device,
        &adm8668_eth0_device,
        &adm8668_eth1_device,
 };
 
 int __devinit adm8668_devs_register(void)
 {
+       int ret;
+
+       ret = amba_device_register(&adm8668_uart0_device, &iomem_resource);
+       if (ret)
+               panic("failed to register AMBA UART");
+
        return platform_add_devices(adm8668_devs, ARRAY_SIZE(adm8668_devs));
 }
 arch_initcall(adm8668_devs_register);