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>
17 #include <linux/serial_8250.h>
18 #include <linux/smsc911x.h>
20 #include <asm/mips-boards/sead3int.h>
26 .uartclk = 14745600, \
27 .iotype = UPIO_MEM32, \
28 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \
32 static struct plat_serial8250_port uart8250_data[] = {
33 UART(0x1f000900), /* ttyS0 = USB */
34 UART(0x1f000800), /* ttyS1 = RS232 */
38 static struct platform_device uart8250_device = {
40 .id = PLAT8250_DEV_PLATFORM2,
42 .platform_data = uart8250_data,
46 static struct smsc911x_platform_config sead3_smsc911x_data = {
47 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
48 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
49 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
50 .phy_interface = PHY_INTERFACE_MODE_MII,
53 static struct resource sead3_net_resources[] = {
57 .flags = IORESOURCE_MEM
59 .flags = IORESOURCE_IRQ
63 static struct platform_device sead3_net_device = {
67 .platform_data = &sead3_smsc911x_data,
69 .num_resources = ARRAY_SIZE(sead3_net_resources),
70 .resource = sead3_net_resources
73 static struct mtd_partition sead3_mtd_partitions[] = {
79 .name = "Board Config",
82 .mask_flags = MTD_WRITEABLE
86 static struct physmap_flash_data sead3_flash_data = {
88 .nr_parts = ARRAY_SIZE(sead3_mtd_partitions),
89 .parts = sead3_mtd_partitions
92 static struct resource sead3_flash_resource = {
95 .flags = IORESOURCE_MEM
98 static struct platform_device sead3_flash = {
99 .name = "physmap-flash",
102 .platform_data = &sead3_flash_data,
105 .resource = &sead3_flash_resource,
108 #define LEDFLAGS(bits, shift) \
109 ((bits << 8) | (shift << 8))
111 #define LEDBITS(id, shift, bits) \
113 .flags = LEDFLAGS(bits, shift)
115 static struct led_info led_data_info[] = {
116 { LEDBITS("bit", 0, 1) },
117 { LEDBITS("bit", 1, 1) },
118 { LEDBITS("bit", 2, 1) },
119 { LEDBITS("bit", 3, 1) },
120 { LEDBITS("bit", 4, 1) },
121 { LEDBITS("bit", 5, 1) },
122 { LEDBITS("bit", 6, 1) },
123 { LEDBITS("bit", 7, 1) },
124 { LEDBITS("all", 0, 8) },
127 static struct led_platform_data led_data = {
128 .num_leds = ARRAY_SIZE(led_data_info),
129 .leds = led_data_info
132 static struct resource pled_resources[] = {
136 .flags = IORESOURCE_MEM
140 static struct platform_device pled_device = {
141 .name = "sead3::pled",
144 .platform_data = &led_data,
146 .num_resources = ARRAY_SIZE(pled_resources),
147 .resource = pled_resources
151 static struct resource fled_resources[] = {
155 .flags = IORESOURCE_MEM
159 static struct platform_device fled_device = {
160 .name = "sead3::fled",
163 .platform_data = &led_data,
165 .num_resources = ARRAY_SIZE(fled_resources),
166 .resource = fled_resources
169 static struct platform_device sead3_led_device = {
174 static struct resource ehci_resources[] = {
178 .flags = IORESOURCE_MEM
180 .flags = IORESOURCE_IRQ
184 static u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32);
186 static struct platform_device ehci_device = {
187 .name = "sead3-ehci",
190 .dma_mask = &sead3_usbdev_dma_mask,
191 .coherent_dma_mask = DMA_BIT_MASK(32)
193 .num_resources = ARRAY_SIZE(ehci_resources),
194 .resource = ehci_resources
197 static struct platform_device *sead3_platform_devices[] __initdata = {
207 static int __init sead3_platforms_device_init(void)
209 const char *intc_compat;
210 struct device_node *node;
211 struct irq_domain *irqd;
214 intc_compat = "mti,gic";
216 intc_compat = "mti,cpu-interrupt-controller";
218 node = of_find_compatible_node(NULL, NULL, intc_compat);
220 pr_err("unable to find interrupt controller DT node\n");
224 irqd = irq_find_host(node);
226 pr_err("unable to find interrupt controller IRQ domain\n");
231 uart8250_data[0].irq = irq_create_mapping(irqd, GIC_INT_UART0);
232 uart8250_data[1].irq = irq_create_mapping(irqd, GIC_INT_UART1);
233 ehci_resources[1].start =
234 irq_create_mapping(irqd, GIC_INT_EHCI);
235 sead3_net_resources[1].start =
236 irq_create_mapping(irqd, GIC_INT_NET);
238 uart8250_data[0].irq = irq_create_mapping(irqd, CPU_INT_UART0);
239 uart8250_data[1].irq = irq_create_mapping(irqd, CPU_INT_UART1);
240 ehci_resources[1].start =
241 irq_create_mapping(irqd, CPU_INT_EHCI);
242 sead3_net_resources[1].start =
243 irq_create_mapping(irqd, CPU_INT_NET);
246 return platform_add_devices(sead3_platform_devices,
247 ARRAY_SIZE(sead3_platform_devices));
250 device_initcall(sead3_platforms_device_init);