2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
8 #include <linux/dma-mapping.h>
9 #include <linux/init.h>
10 #include <linux/irq.h>
11 #include <linux/irqchip/mips-gic.h>
12 #include <linux/irqdomain.h>
13 #include <linux/leds.h>
14 #include <linux/mtd/physmap.h>
16 #include <linux/platform_device.h>
18 #include <asm/mips-boards/sead3int.h>
20 static struct mtd_partition sead3_mtd_partitions[] = {
26 .name = "Board Config",
29 .mask_flags = MTD_WRITEABLE
33 static struct physmap_flash_data sead3_flash_data = {
35 .nr_parts = ARRAY_SIZE(sead3_mtd_partitions),
36 .parts = sead3_mtd_partitions
39 static struct resource sead3_flash_resource = {
42 .flags = IORESOURCE_MEM
45 static struct platform_device sead3_flash = {
46 .name = "physmap-flash",
49 .platform_data = &sead3_flash_data,
52 .resource = &sead3_flash_resource,
55 #define LEDFLAGS(bits, shift) \
56 ((bits << 8) | (shift << 8))
58 #define LEDBITS(id, shift, bits) \
60 .flags = LEDFLAGS(bits, shift)
62 static struct led_info led_data_info[] = {
63 { LEDBITS("bit", 0, 1) },
64 { LEDBITS("bit", 1, 1) },
65 { LEDBITS("bit", 2, 1) },
66 { LEDBITS("bit", 3, 1) },
67 { LEDBITS("bit", 4, 1) },
68 { LEDBITS("bit", 5, 1) },
69 { LEDBITS("bit", 6, 1) },
70 { LEDBITS("bit", 7, 1) },
71 { LEDBITS("all", 0, 8) },
74 static struct led_platform_data led_data = {
75 .num_leds = ARRAY_SIZE(led_data_info),
79 static struct resource pled_resources[] = {
83 .flags = IORESOURCE_MEM
87 static struct platform_device pled_device = {
88 .name = "sead3::pled",
91 .platform_data = &led_data,
93 .num_resources = ARRAY_SIZE(pled_resources),
94 .resource = pled_resources
98 static struct resource fled_resources[] = {
102 .flags = IORESOURCE_MEM
106 static struct platform_device fled_device = {
107 .name = "sead3::fled",
110 .platform_data = &led_data,
112 .num_resources = ARRAY_SIZE(fled_resources),
113 .resource = fled_resources
116 static struct platform_device sead3_led_device = {
121 static struct resource ehci_resources[] = {
125 .flags = IORESOURCE_MEM
127 .flags = IORESOURCE_IRQ
131 static u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32);
133 static struct platform_device ehci_device = {
134 .name = "sead3-ehci",
137 .dma_mask = &sead3_usbdev_dma_mask,
138 .coherent_dma_mask = DMA_BIT_MASK(32)
140 .num_resources = ARRAY_SIZE(ehci_resources),
141 .resource = ehci_resources
144 static struct platform_device *sead3_platform_devices[] __initdata = {
152 static int __init sead3_platforms_device_init(void)
154 const char *intc_compat;
155 struct device_node *node;
156 struct irq_domain *irqd;
159 intc_compat = "mti,gic";
161 intc_compat = "mti,cpu-interrupt-controller";
163 node = of_find_compatible_node(NULL, NULL, intc_compat);
165 pr_err("unable to find interrupt controller DT node\n");
169 irqd = irq_find_host(node);
171 pr_err("unable to find interrupt controller IRQ domain\n");
176 ehci_resources[1].start =
177 irq_create_mapping(irqd, GIC_INT_EHCI);
179 ehci_resources[1].start =
180 irq_create_mapping(irqd, CPU_INT_EHCI);
183 return platform_add_devices(sead3_platform_devices,
184 ARRAY_SIZE(sead3_platform_devices));
187 device_initcall(sead3_platforms_device_init);