platform.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * Platform device support for Au1x00 SoCs.
  3. *
  4. * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
  5. *
  6. * (C) Copyright Embedded Alley Solutions, Inc 2005
  7. * Author: Pantelis Antoniou <pantelis@embeddedalley.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/init.h>
  16. #include <asm/mach-au1x00/au1xxx.h>
  17. #define PORT(_base, _irq) \
  18. { \
  19. .iobase = _base, \
  20. .membase = (void __iomem *)_base,\
  21. .mapbase = CPHYSADDR(_base), \
  22. .irq = _irq, \
  23. .regshift = 2, \
  24. .iotype = UPIO_AU, \
  25. .flags = UPF_SKIP_TEST \
  26. }
  27. static struct plat_serial8250_port au1x00_uart_data[] = {
  28. #if defined(CONFIG_SERIAL_8250_AU1X00)
  29. #if defined(CONFIG_SOC_AU1000)
  30. PORT(UART0_ADDR, AU1000_UART0_INT),
  31. PORT(UART1_ADDR, AU1000_UART1_INT),
  32. PORT(UART2_ADDR, AU1000_UART2_INT),
  33. PORT(UART3_ADDR, AU1000_UART3_INT),
  34. #elif defined(CONFIG_SOC_AU1500)
  35. PORT(UART0_ADDR, AU1500_UART0_INT),
  36. PORT(UART3_ADDR, AU1500_UART3_INT),
  37. #elif defined(CONFIG_SOC_AU1100)
  38. PORT(UART0_ADDR, AU1100_UART0_INT),
  39. PORT(UART1_ADDR, AU1100_UART1_INT),
  40. PORT(UART3_ADDR, AU1100_UART3_INT),
  41. #elif defined(CONFIG_SOC_AU1550)
  42. PORT(UART0_ADDR, AU1550_UART0_INT),
  43. PORT(UART1_ADDR, AU1550_UART1_INT),
  44. PORT(UART3_ADDR, AU1550_UART3_INT),
  45. #elif defined(CONFIG_SOC_AU1200)
  46. PORT(UART0_ADDR, AU1200_UART0_INT),
  47. PORT(UART1_ADDR, AU1200_UART1_INT),
  48. #endif
  49. #endif /* CONFIG_SERIAL_8250_AU1X00 */
  50. { },
  51. };
  52. static struct platform_device au1xx0_uart_device = {
  53. .name = "serial8250",
  54. .id = PLAT8250_DEV_AU1X00,
  55. .dev = {
  56. .platform_data = au1x00_uart_data,
  57. },
  58. };
  59. /* OHCI (USB full speed host controller) */
  60. static struct resource au1xxx_usb_ohci_resources[] = {
  61. [0] = {
  62. .start = USB_OHCI_BASE,
  63. .end = USB_OHCI_BASE + USB_OHCI_LEN - 1,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = AU1000_USB_HOST_INT,
  68. .end = AU1000_USB_HOST_INT,
  69. .flags = IORESOURCE_IRQ,
  70. },
  71. };
  72. /* The dmamask must be set for OHCI to work */
  73. static u64 ohci_dmamask = ~(u32)0;
  74. static struct platform_device au1xxx_usb_ohci_device = {
  75. .name = "au1xxx-ohci",
  76. .id = 0,
  77. .dev = {
  78. .dma_mask = &ohci_dmamask,
  79. .coherent_dma_mask = 0xffffffff,
  80. },
  81. .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources),
  82. .resource = au1xxx_usb_ohci_resources,
  83. };
  84. /*** AU1100 LCD controller ***/
  85. #ifdef CONFIG_FB_AU1100
  86. static struct resource au1100_lcd_resources[] = {
  87. [0] = {
  88. .start = LCD_PHYS_ADDR,
  89. .end = LCD_PHYS_ADDR + 0x800 - 1,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. [1] = {
  93. .start = AU1100_LCD_INT,
  94. .end = AU1100_LCD_INT,
  95. .flags = IORESOURCE_IRQ,
  96. }
  97. };
  98. static u64 au1100_lcd_dmamask = ~(u32)0;
  99. static struct platform_device au1100_lcd_device = {
  100. .name = "au1100-lcd",
  101. .id = 0,
  102. .dev = {
  103. .dma_mask = &au1100_lcd_dmamask,
  104. .coherent_dma_mask = 0xffffffff,
  105. },
  106. .num_resources = ARRAY_SIZE(au1100_lcd_resources),
  107. .resource = au1100_lcd_resources,
  108. };
  109. #endif
  110. #ifdef CONFIG_SOC_AU1200
  111. /* EHCI (USB high speed host controller) */
  112. static struct resource au1xxx_usb_ehci_resources[] = {
  113. [0] = {
  114. .start = USB_EHCI_BASE,
  115. .end = USB_EHCI_BASE + USB_EHCI_LEN - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = AU1000_USB_HOST_INT,
  120. .end = AU1000_USB_HOST_INT,
  121. .flags = IORESOURCE_IRQ,
  122. },
  123. };
  124. static u64 ehci_dmamask = ~(u32)0;
  125. static struct platform_device au1xxx_usb_ehci_device = {
  126. .name = "au1xxx-ehci",
  127. .id = 0,
  128. .dev = {
  129. .dma_mask = &ehci_dmamask,
  130. .coherent_dma_mask = 0xffffffff,
  131. },
  132. .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources),
  133. .resource = au1xxx_usb_ehci_resources,
  134. };
  135. /* Au1200 UDC (USB gadget controller) */
  136. static struct resource au1xxx_usb_gdt_resources[] = {
  137. [0] = {
  138. .start = USB_UDC_BASE,
  139. .end = USB_UDC_BASE + USB_UDC_LEN - 1,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. [1] = {
  143. .start = AU1200_USB_INT,
  144. .end = AU1200_USB_INT,
  145. .flags = IORESOURCE_IRQ,
  146. },
  147. };
  148. static struct resource au1xxx_mmc_resources[] = {
  149. [0] = {
  150. .start = SD0_PHYS_ADDR,
  151. .end = SD0_PHYS_ADDR + 0x7ffff,
  152. .flags = IORESOURCE_MEM,
  153. },
  154. [1] = {
  155. .start = SD1_PHYS_ADDR,
  156. .end = SD1_PHYS_ADDR + 0x7ffff,
  157. .flags = IORESOURCE_MEM,
  158. },
  159. [2] = {
  160. .start = AU1200_SD_INT,
  161. .end = AU1200_SD_INT,
  162. .flags = IORESOURCE_IRQ,
  163. }
  164. };
  165. static u64 udc_dmamask = ~(u32)0;
  166. static struct platform_device au1xxx_usb_gdt_device = {
  167. .name = "au1xxx-udc",
  168. .id = 0,
  169. .dev = {
  170. .dma_mask = &udc_dmamask,
  171. .coherent_dma_mask = 0xffffffff,
  172. },
  173. .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources),
  174. .resource = au1xxx_usb_gdt_resources,
  175. };
  176. /* Au1200 UOC (USB OTG controller) */
  177. static struct resource au1xxx_usb_otg_resources[] = {
  178. [0] = {
  179. .start = USB_UOC_BASE,
  180. .end = USB_UOC_BASE + USB_UOC_LEN - 1,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. [1] = {
  184. .start = AU1200_USB_INT,
  185. .end = AU1200_USB_INT,
  186. .flags = IORESOURCE_IRQ,
  187. },
  188. };
  189. static u64 uoc_dmamask = ~(u32)0;
  190. static struct platform_device au1xxx_usb_otg_device = {
  191. .name = "au1xxx-uoc",
  192. .id = 0,
  193. .dev = {
  194. .dma_mask = &uoc_dmamask,
  195. .coherent_dma_mask = 0xffffffff,
  196. },
  197. .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources),
  198. .resource = au1xxx_usb_otg_resources,
  199. };
  200. static struct resource au1200_lcd_resources[] = {
  201. [0] = {
  202. .start = LCD_PHYS_ADDR,
  203. .end = LCD_PHYS_ADDR + 0x800 - 1,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. [1] = {
  207. .start = AU1200_LCD_INT,
  208. .end = AU1200_LCD_INT,
  209. .flags = IORESOURCE_IRQ,
  210. }
  211. };
  212. static u64 au1200_lcd_dmamask = ~(u32)0;
  213. static struct platform_device au1200_lcd_device = {
  214. .name = "au1200-lcd",
  215. .id = 0,
  216. .dev = {
  217. .dma_mask = &au1200_lcd_dmamask,
  218. .coherent_dma_mask = 0xffffffff,
  219. },
  220. .num_resources = ARRAY_SIZE(au1200_lcd_resources),
  221. .resource = au1200_lcd_resources,
  222. };
  223. static u64 au1xxx_mmc_dmamask = ~(u32)0;
  224. static struct platform_device au1xxx_mmc_device = {
  225. .name = "au1xxx-mmc",
  226. .id = 0,
  227. .dev = {
  228. .dma_mask = &au1xxx_mmc_dmamask,
  229. .coherent_dma_mask = 0xffffffff,
  230. },
  231. .num_resources = ARRAY_SIZE(au1xxx_mmc_resources),
  232. .resource = au1xxx_mmc_resources,
  233. };
  234. #endif /* #ifdef CONFIG_SOC_AU1200 */
  235. static struct platform_device au1x00_pcmcia_device = {
  236. .name = "au1x00-pcmcia",
  237. .id = 0,
  238. };
  239. /* All Alchemy demoboards with I2C have this #define in their headers */
  240. #ifdef SMBUS_PSC_BASE
  241. static struct resource pbdb_smbus_resources[] = {
  242. {
  243. .start = CPHYSADDR(SMBUS_PSC_BASE),
  244. .end = CPHYSADDR(SMBUS_PSC_BASE + 0xfffff),
  245. .flags = IORESOURCE_MEM,
  246. },
  247. };
  248. static struct platform_device pbdb_smbus_device = {
  249. .name = "au1xpsc_smbus",
  250. .id = 0, /* bus number */
  251. .num_resources = ARRAY_SIZE(pbdb_smbus_resources),
  252. .resource = pbdb_smbus_resources,
  253. };
  254. #endif
  255. static struct platform_device *au1xxx_platform_devices[] __initdata = {
  256. &au1xx0_uart_device,
  257. &au1xxx_usb_ohci_device,
  258. &au1x00_pcmcia_device,
  259. #ifdef CONFIG_FB_AU1100
  260. &au1100_lcd_device,
  261. #endif
  262. #ifdef CONFIG_SOC_AU1200
  263. &au1xxx_usb_ehci_device,
  264. &au1xxx_usb_gdt_device,
  265. &au1xxx_usb_otg_device,
  266. &au1200_lcd_device,
  267. &au1xxx_mmc_device,
  268. #endif
  269. #ifdef SMBUS_PSC_BASE
  270. &pbdb_smbus_device,
  271. #endif
  272. };
  273. static int __init au1xxx_platform_init(void)
  274. {
  275. unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
  276. int i;
  277. /* Fill up uartclk. */
  278. for (i = 0; au1x00_uart_data[i].flags; i++)
  279. au1x00_uart_data[i].uartclk = uartclk;
  280. return platform_add_devices(au1xxx_platform_devices,
  281. ARRAY_SIZE(au1xxx_platform_devices));
  282. }
  283. arch_initcall(au1xxx_platform_init);