sead3-platform.c 5.1 KB

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