dev.c 8.7 KB

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