dev.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /*
  2. * linux/arch/arm/mach-w90x900/dev.c
  3. *
  4. * Copyright (C) 2009 Nuvoton corporation.
  5. *
  6. * Wan ZongShun <mcuos.com@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation;version 2 of the License.
  11. *
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/timer.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/flash.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <asm/mach-types.h>
  29. #include <mach/regs-serial.h>
  30. #include <mach/map.h>
  31. #include "cpu.h"
  32. /*NUC900 evb norflash driver data */
  33. #define NUC900_FLASH_BASE 0xA0000000
  34. #define NUC900_FLASH_SIZE 0x400000
  35. #define SPIOFFSET 0x200
  36. #define SPIOREG_SIZE 0x100
  37. static struct mtd_partition nuc900_flash_partitions[] = {
  38. {
  39. .name = "NOR Partition 1 for kernel (960K)",
  40. .size = 0xF0000,
  41. .offset = 0x10000,
  42. },
  43. {
  44. .name = "NOR Partition 2 for image (1M)",
  45. .size = 0x100000,
  46. .offset = 0x100000,
  47. },
  48. {
  49. .name = "NOR Partition 3 for user (2M)",
  50. .size = 0x200000,
  51. .offset = 0x00200000,
  52. }
  53. };
  54. static struct physmap_flash_data nuc900_flash_data = {
  55. .width = 2,
  56. .parts = nuc900_flash_partitions,
  57. .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
  58. };
  59. static struct resource nuc900_flash_resources[] = {
  60. {
  61. .start = NUC900_FLASH_BASE,
  62. .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
  63. .flags = IORESOURCE_MEM,
  64. }
  65. };
  66. static struct platform_device nuc900_flash_device = {
  67. .name = "physmap-flash",
  68. .id = 0,
  69. .dev = {
  70. .platform_data = &nuc900_flash_data,
  71. },
  72. .resource = nuc900_flash_resources,
  73. .num_resources = ARRAY_SIZE(nuc900_flash_resources),
  74. };
  75. /* USB EHCI Host Controller */
  76. static struct resource nuc900_usb_ehci_resource[] = {
  77. [0] = {
  78. .start = W90X900_PA_USBEHCIHOST,
  79. .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [1] = {
  83. .start = IRQ_USBH,
  84. .end = IRQ_USBH,
  85. .flags = IORESOURCE_IRQ,
  86. }
  87. };
  88. static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
  89. static struct platform_device nuc900_device_usb_ehci = {
  90. .name = "nuc900-ehci",
  91. .id = -1,
  92. .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
  93. .resource = nuc900_usb_ehci_resource,
  94. .dev = {
  95. .dma_mask = &nuc900_device_usb_ehci_dmamask,
  96. .coherent_dma_mask = 0xffffffffUL
  97. }
  98. };
  99. /* USB OHCI Host Controller */
  100. static struct resource nuc900_usb_ohci_resource[] = {
  101. [0] = {
  102. .start = W90X900_PA_USBOHCIHOST,
  103. .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. [1] = {
  107. .start = IRQ_USBH,
  108. .end = IRQ_USBH,
  109. .flags = IORESOURCE_IRQ,
  110. }
  111. };
  112. static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
  113. static struct platform_device nuc900_device_usb_ohci = {
  114. .name = "nuc900-ohci",
  115. .id = -1,
  116. .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
  117. .resource = nuc900_usb_ohci_resource,
  118. .dev = {
  119. .dma_mask = &nuc900_device_usb_ohci_dmamask,
  120. .coherent_dma_mask = 0xffffffffUL
  121. }
  122. };
  123. /* USB Device (Gadget)*/
  124. static struct resource nuc900_usbgadget_resource[] = {
  125. [0] = {
  126. .start = W90X900_PA_USBDEV,
  127. .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
  128. .flags = IORESOURCE_MEM,
  129. },
  130. [1] = {
  131. .start = IRQ_USBD,
  132. .end = IRQ_USBD,
  133. .flags = IORESOURCE_IRQ,
  134. }
  135. };
  136. static struct platform_device nuc900_device_usbgadget = {
  137. .name = "nuc900-usbgadget",
  138. .id = -1,
  139. .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
  140. .resource = nuc900_usbgadget_resource,
  141. };
  142. /* MAC device */
  143. static struct resource nuc900_emc_resource[] = {
  144. [0] = {
  145. .start = W90X900_PA_EMC,
  146. .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. [1] = {
  150. .start = IRQ_EMCTX,
  151. .end = IRQ_EMCTX,
  152. .flags = IORESOURCE_IRQ,
  153. },
  154. [2] = {
  155. .start = IRQ_EMCRX,
  156. .end = IRQ_EMCRX,
  157. .flags = IORESOURCE_IRQ,
  158. }
  159. };
  160. static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
  161. static struct platform_device nuc900_device_emc = {
  162. .name = "nuc900-emc",
  163. .id = -1,
  164. .num_resources = ARRAY_SIZE(nuc900_emc_resource),
  165. .resource = nuc900_emc_resource,
  166. .dev = {
  167. .dma_mask = &nuc900_device_emc_dmamask,
  168. .coherent_dma_mask = 0xffffffffUL
  169. }
  170. };
  171. /* SPI device */
  172. static struct resource nuc900_spi_resource[] = {
  173. [0] = {
  174. .start = W90X900_PA_I2C + SPIOFFSET,
  175. .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. [1] = {
  179. .start = IRQ_SSP,
  180. .end = IRQ_SSP,
  181. .flags = IORESOURCE_IRQ,
  182. }
  183. };
  184. static struct platform_device nuc900_device_spi = {
  185. .name = "nuc900-spi",
  186. .id = -1,
  187. .num_resources = ARRAY_SIZE(nuc900_spi_resource),
  188. .resource = nuc900_spi_resource,
  189. };
  190. /* spi device, spi flash info */
  191. static struct mtd_partition nuc900_spi_flash_partitions[] = {
  192. {
  193. .name = "bootloader(spi)",
  194. .size = 0x0100000,
  195. .offset = 0,
  196. },
  197. };
  198. static struct flash_platform_data nuc900_spi_flash_data = {
  199. .name = "m25p80",
  200. .parts = nuc900_spi_flash_partitions,
  201. .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
  202. .type = "w25x16",
  203. };
  204. static struct spi_board_info nuc900_spi_board_info[] __initdata = {
  205. {
  206. .modalias = "m25p80",
  207. .max_speed_hz = 20000000,
  208. .bus_num = 0,
  209. .chip_select = 1,
  210. .platform_data = &nuc900_spi_flash_data,
  211. .mode = SPI_MODE_0,
  212. },
  213. };
  214. /* WDT Device */
  215. static struct resource nuc900_wdt_resource[] = {
  216. [0] = {
  217. .start = W90X900_PA_TIMER,
  218. .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
  219. .flags = IORESOURCE_MEM,
  220. },
  221. [1] = {
  222. .start = IRQ_WDT,
  223. .end = IRQ_WDT,
  224. .flags = IORESOURCE_IRQ,
  225. }
  226. };
  227. static struct platform_device nuc900_device_wdt = {
  228. .name = "nuc900-wdt",
  229. .id = -1,
  230. .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
  231. .resource = nuc900_wdt_resource,
  232. };
  233. /*
  234. * public device definition between 910 and 920, or 910
  235. * and 950 or 950 and 960...,their dev platform register
  236. * should be in specific file such as nuc950, nuc960 c
  237. * files rather than the public dev.c file here. so the
  238. * corresponding platform_device definition should not be
  239. * static.
  240. */
  241. /* RTC controller*/
  242. static struct resource nuc900_rtc_resource[] = {
  243. [0] = {
  244. .start = W90X900_PA_RTC,
  245. .end = W90X900_PA_RTC + 0xff,
  246. .flags = IORESOURCE_MEM,
  247. },
  248. [1] = {
  249. .start = IRQ_RTC,
  250. .end = IRQ_RTC,
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. };
  254. struct platform_device nuc900_device_rtc = {
  255. .name = "nuc900-rtc",
  256. .id = -1,
  257. .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
  258. .resource = nuc900_rtc_resource,
  259. };
  260. /*TouchScreen controller*/
  261. static struct resource nuc900_ts_resource[] = {
  262. [0] = {
  263. .start = W90X900_PA_ADC,
  264. .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. [1] = {
  268. .start = IRQ_ADC,
  269. .end = IRQ_ADC,
  270. .flags = IORESOURCE_IRQ,
  271. },
  272. };
  273. struct platform_device nuc900_device_ts = {
  274. .name = "nuc900-ts",
  275. .id = -1,
  276. .resource = nuc900_ts_resource,
  277. .num_resources = ARRAY_SIZE(nuc900_ts_resource),
  278. };
  279. /* FMI Device */
  280. static struct resource nuc900_fmi_resource[] = {
  281. [0] = {
  282. .start = W90X900_PA_FMI,
  283. .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
  284. .flags = IORESOURCE_MEM,
  285. },
  286. [1] = {
  287. .start = IRQ_FMI,
  288. .end = IRQ_FMI,
  289. .flags = IORESOURCE_IRQ,
  290. }
  291. };
  292. struct platform_device nuc900_device_fmi = {
  293. .name = "nuc900-fmi",
  294. .id = -1,
  295. .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
  296. .resource = nuc900_fmi_resource,
  297. };
  298. /* KPI controller*/
  299. static struct resource nuc900_kpi_resource[] = {
  300. [0] = {
  301. .start = W90X900_PA_KPI,
  302. .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .start = IRQ_KPI,
  307. .end = IRQ_KPI,
  308. .flags = IORESOURCE_IRQ,
  309. }
  310. };
  311. struct platform_device nuc900_device_kpi = {
  312. .name = "nuc900-kpi",
  313. .id = -1,
  314. .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
  315. .resource = nuc900_kpi_resource,
  316. };
  317. /*Here should be your evb resourse,such as LCD*/
  318. static struct platform_device *nuc900_public_dev[] __initdata = {
  319. &nuc900_serial_device,
  320. &nuc900_flash_device,
  321. &nuc900_device_usb_ehci,
  322. &nuc900_device_usb_ohci,
  323. &nuc900_device_usbgadget,
  324. &nuc900_device_emc,
  325. &nuc900_device_spi,
  326. &nuc900_device_wdt,
  327. };
  328. /* Provide adding specific CPU platform devices API */
  329. void __init nuc900_board_init(struct platform_device **device, int size)
  330. {
  331. platform_add_devices(device, size);
  332. platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
  333. spi_register_board_info(nuc900_spi_board_info,
  334. ARRAY_SIZE(nuc900_spi_board_info));
  335. }