Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. |
| 7 | */ |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 8 | #include <linux/dma-mapping.h> |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 9 | #include <linux/init.h> |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 10 | #include <linux/irq.h> |
Andrew Bresticker | 4060bbe | 2014-10-20 12:03:53 -0700 | [diff] [blame] | 11 | #include <linux/irqchip/mips-gic.h> |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 12 | #include <linux/leds.h> |
| 13 | #include <linux/mtd/physmap.h> |
| 14 | #include <linux/platform_device.h> |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 15 | #include <linux/serial_8250.h> |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 16 | #include <linux/smsc911x.h> |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 17 | |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 18 | #include <asm/mips-boards/sead3int.h> |
| 19 | |
| 20 | #define UART(base) \ |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 21 | { \ |
| 22 | .mapbase = base, \ |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 23 | .irq = -1, \ |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 24 | .uartclk = 14745600, \ |
| 25 | .iotype = UPIO_MEM32, \ |
| 26 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \ |
| 27 | .regshift = 2, \ |
| 28 | } |
| 29 | |
| 30 | static struct plat_serial8250_port uart8250_data[] = { |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 31 | UART(0x1f000900), /* ttyS0 = USB */ |
| 32 | UART(0x1f000800), /* ttyS1 = RS232 */ |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 33 | { }, |
| 34 | }; |
| 35 | |
| 36 | static struct platform_device uart8250_device = { |
| 37 | .name = "serial8250", |
| 38 | .id = PLAT8250_DEV_PLATFORM2, |
| 39 | .dev = { |
| 40 | .platform_data = uart8250_data, |
| 41 | }, |
| 42 | }; |
| 43 | |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 44 | static struct smsc911x_platform_config sead3_smsc911x_data = { |
| 45 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 46 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 47 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 48 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 49 | }; |
| 50 | |
| 51 | static struct resource sead3_net_resources[] = { |
| 52 | { |
| 53 | .start = 0x1f010000, |
| 54 | .end = 0x1f01ffff, |
| 55 | .flags = IORESOURCE_MEM |
| 56 | }, { |
| 57 | .flags = IORESOURCE_IRQ |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | static struct platform_device sead3_net_device = { |
| 62 | .name = "smsc911x", |
| 63 | .id = 0, |
| 64 | .dev = { |
| 65 | .platform_data = &sead3_smsc911x_data, |
| 66 | }, |
| 67 | .num_resources = ARRAY_SIZE(sead3_net_resources), |
| 68 | .resource = sead3_net_resources |
| 69 | }; |
| 70 | |
| 71 | static struct mtd_partition sead3_mtd_partitions[] = { |
| 72 | { |
| 73 | .name = "User FS", |
| 74 | .offset = 0x00000000, |
| 75 | .size = 0x01fc0000, |
| 76 | }, { |
| 77 | .name = "Board Config", |
| 78 | .offset = 0x01fc0000, |
| 79 | .size = 0x00040000, |
| 80 | .mask_flags = MTD_WRITEABLE |
| 81 | }, |
| 82 | }; |
| 83 | |
| 84 | static struct physmap_flash_data sead3_flash_data = { |
| 85 | .width = 4, |
| 86 | .nr_parts = ARRAY_SIZE(sead3_mtd_partitions), |
| 87 | .parts = sead3_mtd_partitions |
| 88 | }; |
| 89 | |
| 90 | static struct resource sead3_flash_resource = { |
| 91 | .start = 0x1c000000, |
| 92 | .end = 0x1dffffff, |
| 93 | .flags = IORESOURCE_MEM |
| 94 | }; |
| 95 | |
| 96 | static struct platform_device sead3_flash = { |
| 97 | .name = "physmap-flash", |
| 98 | .id = 0, |
| 99 | .dev = { |
| 100 | .platform_data = &sead3_flash_data, |
| 101 | }, |
| 102 | .num_resources = 1, |
| 103 | .resource = &sead3_flash_resource, |
| 104 | }; |
| 105 | |
| 106 | #define LEDFLAGS(bits, shift) \ |
| 107 | ((bits << 8) | (shift << 8)) |
| 108 | |
| 109 | #define LEDBITS(id, shift, bits) \ |
| 110 | .name = id #shift, \ |
| 111 | .flags = LEDFLAGS(bits, shift) |
| 112 | |
| 113 | static struct led_info led_data_info[] = { |
| 114 | { LEDBITS("bit", 0, 1) }, |
| 115 | { LEDBITS("bit", 1, 1) }, |
| 116 | { LEDBITS("bit", 2, 1) }, |
| 117 | { LEDBITS("bit", 3, 1) }, |
| 118 | { LEDBITS("bit", 4, 1) }, |
| 119 | { LEDBITS("bit", 5, 1) }, |
| 120 | { LEDBITS("bit", 6, 1) }, |
| 121 | { LEDBITS("bit", 7, 1) }, |
| 122 | { LEDBITS("all", 0, 8) }, |
| 123 | }; |
| 124 | |
| 125 | static struct led_platform_data led_data = { |
| 126 | .num_leds = ARRAY_SIZE(led_data_info), |
| 127 | .leds = led_data_info |
| 128 | }; |
| 129 | |
| 130 | static struct resource pled_resources[] = { |
| 131 | { |
| 132 | .start = 0x1f000210, |
| 133 | .end = 0x1f000217, |
| 134 | .flags = IORESOURCE_MEM |
| 135 | } |
| 136 | }; |
| 137 | |
| 138 | static struct platform_device pled_device = { |
| 139 | .name = "sead3::pled", |
| 140 | .id = 0, |
| 141 | .dev = { |
| 142 | .platform_data = &led_data, |
| 143 | }, |
| 144 | .num_resources = ARRAY_SIZE(pled_resources), |
| 145 | .resource = pled_resources |
| 146 | }; |
| 147 | |
| 148 | |
| 149 | static struct resource fled_resources[] = { |
| 150 | { |
| 151 | .start = 0x1f000218, |
| 152 | .end = 0x1f00021f, |
| 153 | .flags = IORESOURCE_MEM |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | static struct platform_device fled_device = { |
| 158 | .name = "sead3::fled", |
| 159 | .id = 0, |
| 160 | .dev = { |
| 161 | .platform_data = &led_data, |
| 162 | }, |
| 163 | .num_resources = ARRAY_SIZE(fled_resources), |
| 164 | .resource = fled_resources |
| 165 | }; |
| 166 | |
| 167 | static struct platform_device sead3_led_device = { |
| 168 | .name = "sead3-led", |
| 169 | .id = -1, |
| 170 | }; |
| 171 | |
| 172 | static struct resource ehci_resources[] = { |
| 173 | { |
| 174 | .start = 0x1b200000, |
| 175 | .end = 0x1b200fff, |
| 176 | .flags = IORESOURCE_MEM |
| 177 | }, { |
| 178 | .flags = IORESOURCE_IRQ |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | static u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32); |
| 183 | |
| 184 | static struct platform_device ehci_device = { |
| 185 | .name = "sead3-ehci", |
| 186 | .id = 0, |
| 187 | .dev = { |
| 188 | .dma_mask = &sead3_usbdev_dma_mask, |
| 189 | .coherent_dma_mask = DMA_BIT_MASK(32) |
| 190 | }, |
| 191 | .num_resources = ARRAY_SIZE(ehci_resources), |
| 192 | .resource = ehci_resources |
| 193 | }; |
| 194 | |
| 195 | static struct platform_device *sead3_platform_devices[] __initdata = { |
| 196 | &uart8250_device, |
| 197 | &sead3_flash, |
| 198 | &pled_device, |
| 199 | &fled_device, |
| 200 | &sead3_led_device, |
| 201 | &ehci_device, |
| 202 | &sead3_net_device, |
| 203 | }; |
| 204 | |
| 205 | static int __init sead3_platforms_device_init(void) |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 206 | { |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 207 | if (gic_present) { |
| 208 | uart8250_data[0].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART0; |
| 209 | uart8250_data[1].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART1; |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 210 | ehci_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_EHCI; |
| 211 | sead3_net_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_NET; |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 212 | } else { |
| 213 | uart8250_data[0].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART0; |
| 214 | uart8250_data[1].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART1; |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 215 | ehci_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_EHCI; |
| 216 | sead3_net_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_NET; |
Andrew Bresticker | 18743d2 | 2014-09-18 14:47:24 -0700 | [diff] [blame] | 217 | } |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 218 | |
| 219 | return platform_add_devices(sead3_platform_devices, |
| 220 | ARRAY_SIZE(sead3_platform_devices)); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Ralf Baechle | 612544f | 2015-04-02 17:07:26 +0200 | [diff] [blame^] | 223 | device_initcall(sead3_platforms_device_init); |