rk30: add devices.c
author黄涛 <huangtao@rock-chips.com>
Tue, 7 Feb 2012 07:40:21 +0000 (15:40 +0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 7 Feb 2012 07:41:55 +0000 (15:41 +0800)
arch/arm/mach-rk30/Makefile
arch/arm/mach-rk30/devices.c [new file with mode: 0644]

index 80be9db8efb9601128f77c36ebdfe66507e2a39c..e58b689aebf41bda381fedefe4962a8551235b9f 100644 (file)
@@ -1,8 +1,9 @@
 obj-y += clock.o
 obj-y += common.o
+obj-y += devices.o
 obj-y += io.o
+obj-y += iomux.o
 obj-y += reset.o
 obj-y += timer.o
-obj-y += iomux.o
 obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
 obj-$(CONFIG_MACH_RK30_SDK) += board-rk30-sdk.o
diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c
new file mode 100644 (file)
index 0000000..69e7b09
--- /dev/null
@@ -0,0 +1,134 @@
+/* arch/arm/mach-rk30/devices.c
+ *
+ * Copyright (C) 2012 ROCKCHIP, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <asm/pmu.h>
+#include <mach/irqs.h>
+#include <mach/board.h>
+
+#ifdef CONFIG_UART0_RK29
+static struct resource resources_uart0[] = {
+       {
+               .start  = IRQ_UART0,
+               .end    = IRQ_UART0,
+               .flags  = IORESOURCE_IRQ,
+       },
+       {
+               .start  = RK30_UART0_PHYS,
+               .end    = RK30_UART0_PHYS + RK30_UART0_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device device_uart0 = {
+       .name   = "rk_serial",
+       .id     = 0,
+       .num_resources  = ARRAY_SIZE(resources_uart0),
+       .resource       = resources_uart0,
+};
+#endif
+
+#ifdef CONFIG_UART1_RK29
+static struct resource resources_uart1[] = {
+       {
+               .start  = IRQ_UART1,
+               .end    = IRQ_UART1,
+               .flags  = IORESOURCE_IRQ,
+       },
+       {
+               .start  = RK30_UART1_PHYS,
+               .end    = RK30_UART1_PHYS + RK30_UART1_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device device_uart1 = {
+       .name   = "rk_serial",
+       .id     = 1,
+       .num_resources  = ARRAY_SIZE(resources_uart1),
+       .resource       = resources_uart1,
+};
+#endif
+
+#ifdef CONFIG_UART2_RK29
+static struct resource resources_uart2[] = {
+       {
+               .start  = IRQ_UART2,
+               .end    = IRQ_UART2,
+               .flags  = IORESOURCE_IRQ,
+       },
+       {
+               .start  = RK30_UART2_PHYS,
+               .end    = RK30_UART2_PHYS + RK30_UART2_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device device_uart2 = {
+       .name   = "rk_serial",
+       .id     = 2,
+       .num_resources  = ARRAY_SIZE(resources_uart2),
+       .resource       = resources_uart2,
+};
+#endif
+
+#ifdef CONFIG_UART3_RK29
+static struct resource resources_uart3[] = {
+       {
+               .start  = IRQ_UART3,
+               .end    = IRQ_UART3,
+               .flags  = IORESOURCE_IRQ,
+       },
+       {
+               .start  = RK30_UART3_PHYS,
+               .end    = RK30_UART3_PHYS + RK30_UART3_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device device_uart3 = {
+       .name   = "rk_serial",
+       .id     = 3,
+       .num_resources  = ARRAY_SIZE(resources_uart3),
+       .resource       = resources_uart3,
+};
+#endif
+
+static void __init rk30_init_uart(void)
+{
+#ifdef CONFIG_UART0_RK29
+       platform_device_register(&device_uart0);
+#endif
+#ifdef CONFIG_UART1_RK29
+       platform_device_register(&device_uart1);
+#endif
+#ifdef CONFIG_UART2_RK29
+       platform_device_register(&device_uart2);
+#endif
+#ifdef CONFIG_UART3_RK29
+       platform_device_register(&device_uart3);
+#endif
+}
+
+static int __init rk30_init_devices(void)
+{
+       rk30_init_uart();
+        return 0;
+}
+arch_initcall(rk30_init_devices);