mach-w90p910evb.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. /*
  2. * linux/arch/arm/mach-w90x900/mach-w90p910evb.c
  3. *
  4. * Based on mach-s3c2410/mach-smdk2410.c by Jonas Dietsche
  5. *
  6. * Copyright (C) 2008 Nuvoton technology corporation.
  7. *
  8. * Wan ZongShun <mcuos.com@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation;version 2 of the License.
  13. *
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/types.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/list.h>
  19. #include <linux/timer.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/spi/spi.h>
  26. #include <linux/spi/flash.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <asm/mach-types.h>
  31. #include <mach/regs-serial.h>
  32. #include <mach/map.h>
  33. #include "cpu.h"
  34. /*w90p910 evb norflash driver data */
  35. #define W90P910_FLASH_BASE 0xA0000000
  36. #define W90P910_FLASH_SIZE 0x400000
  37. #define SPIOFFSET 0x200
  38. #define SPIOREG_SIZE 0x100
  39. static struct mtd_partition w90p910_flash_partitions[] = {
  40. {
  41. .name = "NOR Partition 1 for kernel (960K)",
  42. .size = 0xF0000,
  43. .offset = 0x10000,
  44. },
  45. {
  46. .name = "NOR Partition 2 for image (1M)",
  47. .size = 0x100000,
  48. .offset = 0x100000,
  49. },
  50. {
  51. .name = "NOR Partition 3 for user (2M)",
  52. .size = 0x200000,
  53. .offset = 0x00200000,
  54. }
  55. };
  56. static struct physmap_flash_data w90p910_flash_data = {
  57. .width = 2,
  58. .parts = w90p910_flash_partitions,
  59. .nr_parts = ARRAY_SIZE(w90p910_flash_partitions),
  60. };
  61. static struct resource w90p910_flash_resources[] = {
  62. {
  63. .start = W90P910_FLASH_BASE,
  64. .end = W90P910_FLASH_BASE + W90P910_FLASH_SIZE - 1,
  65. .flags = IORESOURCE_MEM,
  66. }
  67. };
  68. static struct platform_device w90p910_flash_device = {
  69. .name = "physmap-flash",
  70. .id = 0,
  71. .dev = {
  72. .platform_data = &w90p910_flash_data,
  73. },
  74. .resource = w90p910_flash_resources,
  75. .num_resources = ARRAY_SIZE(w90p910_flash_resources),
  76. };
  77. /* USB EHCI Host Controller */
  78. static struct resource w90x900_usb_ehci_resource[] = {
  79. [0] = {
  80. .start = W90X900_PA_USBEHCIHOST,
  81. .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
  82. .flags = IORESOURCE_MEM,
  83. },
  84. [1] = {
  85. .start = IRQ_USBH,
  86. .end = IRQ_USBH,
  87. .flags = IORESOURCE_IRQ,
  88. }
  89. };
  90. static u64 w90x900_device_usb_ehci_dmamask = 0xffffffffUL;
  91. struct platform_device w90x900_device_usb_ehci = {
  92. .name = "w90x900-ehci",
  93. .id = -1,
  94. .num_resources = ARRAY_SIZE(w90x900_usb_ehci_resource),
  95. .resource = w90x900_usb_ehci_resource,
  96. .dev = {
  97. .dma_mask = &w90x900_device_usb_ehci_dmamask,
  98. .coherent_dma_mask = 0xffffffffUL
  99. }
  100. };
  101. EXPORT_SYMBOL(w90x900_device_usb_ehci);
  102. /* USB OHCI Host Controller */
  103. static struct resource w90x900_usb_ohci_resource[] = {
  104. [0] = {
  105. .start = W90X900_PA_USBOHCIHOST,
  106. .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
  107. .flags = IORESOURCE_MEM,
  108. },
  109. [1] = {
  110. .start = IRQ_USBH,
  111. .end = IRQ_USBH,
  112. .flags = IORESOURCE_IRQ,
  113. }
  114. };
  115. static u64 w90x900_device_usb_ohci_dmamask = 0xffffffffUL;
  116. struct platform_device w90x900_device_usb_ohci = {
  117. .name = "w90x900-ohci",
  118. .id = -1,
  119. .num_resources = ARRAY_SIZE(w90x900_usb_ohci_resource),
  120. .resource = w90x900_usb_ohci_resource,
  121. .dev = {
  122. .dma_mask = &w90x900_device_usb_ohci_dmamask,
  123. .coherent_dma_mask = 0xffffffffUL
  124. }
  125. };
  126. EXPORT_SYMBOL(w90x900_device_usb_ohci);
  127. /*TouchScreen controller*/
  128. static struct resource w90x900_ts_resource[] = {
  129. [0] = {
  130. .start = W90X900_PA_ADC,
  131. .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. [1] = {
  135. .start = IRQ_ADC,
  136. .end = IRQ_ADC,
  137. .flags = IORESOURCE_IRQ,
  138. },
  139. };
  140. struct platform_device w90x900_device_ts = {
  141. .name = "w90x900-ts",
  142. .id = -1,
  143. .resource = w90x900_ts_resource,
  144. .num_resources = ARRAY_SIZE(w90x900_ts_resource),
  145. };
  146. EXPORT_SYMBOL(w90x900_device_ts);
  147. /* RTC controller*/
  148. static struct resource w90x900_rtc_resource[] = {
  149. [0] = {
  150. .start = W90X900_PA_RTC,
  151. .end = W90X900_PA_RTC + 0xff,
  152. .flags = IORESOURCE_MEM,
  153. },
  154. [1] = {
  155. .start = IRQ_RTC,
  156. .end = IRQ_RTC,
  157. .flags = IORESOURCE_IRQ,
  158. },
  159. };
  160. struct platform_device w90x900_device_rtc = {
  161. .name = "w90x900-rtc",
  162. .id = -1,
  163. .num_resources = ARRAY_SIZE(w90x900_rtc_resource),
  164. .resource = w90x900_rtc_resource,
  165. };
  166. EXPORT_SYMBOL(w90x900_device_rtc);
  167. /* KPI controller*/
  168. static struct resource w90x900_kpi_resource[] = {
  169. [0] = {
  170. .start = W90X900_PA_KPI,
  171. .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
  172. .flags = IORESOURCE_MEM,
  173. },
  174. [1] = {
  175. .start = IRQ_KPI,
  176. .end = IRQ_KPI,
  177. .flags = IORESOURCE_IRQ,
  178. }
  179. };
  180. struct platform_device w90x900_device_kpi = {
  181. .name = "w90x900-kpi",
  182. .id = -1,
  183. .num_resources = ARRAY_SIZE(w90x900_kpi_resource),
  184. .resource = w90x900_kpi_resource,
  185. };
  186. EXPORT_SYMBOL(w90x900_device_kpi);
  187. /* USB Device (Gadget)*/
  188. static struct resource w90x900_usbgadget_resource[] = {
  189. [0] = {
  190. .start = W90X900_PA_USBDEV,
  191. .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. [1] = {
  195. .start = IRQ_USBD,
  196. .end = IRQ_USBD,
  197. .flags = IORESOURCE_IRQ,
  198. }
  199. };
  200. struct platform_device w90x900_device_usbgadget = {
  201. .name = "w90x900-usbgadget",
  202. .id = -1,
  203. .num_resources = ARRAY_SIZE(w90x900_usbgadget_resource),
  204. .resource = w90x900_usbgadget_resource,
  205. };
  206. EXPORT_SYMBOL(w90x900_device_usbgadget);
  207. /* FMI Device */
  208. static struct resource w90p910_fmi_resource[] = {
  209. [0] = {
  210. .start = W90X900_PA_FMI,
  211. .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
  212. .flags = IORESOURCE_MEM,
  213. },
  214. [1] = {
  215. .start = IRQ_FMI,
  216. .end = IRQ_FMI,
  217. .flags = IORESOURCE_IRQ,
  218. }
  219. };
  220. static struct platform_device w90p910_device_fmi = {
  221. .name = "w90p910-fmi",
  222. .id = -1,
  223. .num_resources = ARRAY_SIZE(w90p910_fmi_resource),
  224. .resource = w90p910_fmi_resource,
  225. };
  226. /* MAC device */
  227. static struct resource w90x900_emc_resource[] = {
  228. [0] = {
  229. .start = W90X900_PA_EMC,
  230. .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
  231. .flags = IORESOURCE_MEM,
  232. },
  233. [1] = {
  234. .start = IRQ_EMCTX,
  235. .end = IRQ_EMCTX,
  236. .flags = IORESOURCE_IRQ,
  237. },
  238. [2] = {
  239. .start = IRQ_EMCRX,
  240. .end = IRQ_EMCRX,
  241. .flags = IORESOURCE_IRQ,
  242. }
  243. };
  244. static u64 w90x900_device_emc_dmamask = 0xffffffffUL;
  245. static struct platform_device w90p910_device_emc = {
  246. .name = "w90p910-emc",
  247. .id = -1,
  248. .num_resources = ARRAY_SIZE(w90x900_emc_resource),
  249. .resource = w90x900_emc_resource,
  250. .dev = {
  251. .dma_mask = &w90x900_device_emc_dmamask,
  252. .coherent_dma_mask = 0xffffffffUL
  253. }
  254. };
  255. /* SPI device */
  256. static struct resource w90p910_spi_resource[] = {
  257. [0] = {
  258. .start = W90X900_PA_I2C + SPIOFFSET,
  259. .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = IRQ_SSP,
  264. .end = IRQ_SSP,
  265. .flags = IORESOURCE_IRQ,
  266. }
  267. };
  268. static struct platform_device w90p910_device_spi = {
  269. .name = "w90p910-spi",
  270. .id = -1,
  271. .num_resources = ARRAY_SIZE(w90p910_spi_resource),
  272. .resource = w90p910_spi_resource,
  273. };
  274. /* spi device, spi flash info */
  275. static struct mtd_partition w90p910_spi_flash_partitions[] = {
  276. {
  277. .name = "bootloader(spi)",
  278. .size = 0x0100000,
  279. .offset = 0,
  280. },
  281. };
  282. static struct flash_platform_data w90p910_spi_flash_data = {
  283. .name = "m25p80",
  284. .parts = w90p910_spi_flash_partitions,
  285. .nr_parts = ARRAY_SIZE(w90p910_spi_flash_partitions),
  286. .type = "w25x16",
  287. };
  288. static struct spi_board_info w90p910_spi_board_info[] __initdata = {
  289. {
  290. .modalias = "m25p80",
  291. .max_speed_hz = 20000000,
  292. .bus_num = 0,
  293. .chip_select = 1,
  294. .platform_data = &w90p910_spi_flash_data,
  295. .mode = SPI_MODE_0,
  296. },
  297. };
  298. /* WDT Device */
  299. static struct resource w90p910_wdt_resource[] = {
  300. [0] = {
  301. .start = W90X900_PA_TIMER,
  302. .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
  303. .flags = IORESOURCE_MEM,
  304. },
  305. [1] = {
  306. .start = IRQ_WDT,
  307. .end = IRQ_WDT,
  308. .flags = IORESOURCE_IRQ,
  309. }
  310. };
  311. static struct platform_device w90p910_device_wdt = {
  312. .name = "w90p910-wdt",
  313. .id = -1,
  314. .num_resources = ARRAY_SIZE(w90p910_wdt_resource),
  315. .resource = w90p910_wdt_resource,
  316. };
  317. static struct map_desc w90p910_iodesc[] __initdata = {
  318. };
  319. /*Here should be your evb resourse,such as LCD*/
  320. static struct platform_device *w90p910evb_dev[] __initdata = {
  321. &w90p910_serial_device,
  322. &w90p910_flash_device,
  323. &w90x900_device_usb_ehci,
  324. &w90x900_device_usb_ohci,
  325. &w90x900_device_ts,
  326. &w90x900_device_rtc,
  327. &w90x900_device_kpi,
  328. &w90x900_device_usbgadget,
  329. &w90p910_device_fmi,
  330. &w90p910_device_emc,
  331. &w90p910_device_spi,
  332. &w90p910_device_wdt,
  333. };
  334. static void __init w90p910evb_map_io(void)
  335. {
  336. w90p910_map_io(w90p910_iodesc, ARRAY_SIZE(w90p910_iodesc));
  337. w90p910_init_clocks();
  338. }
  339. static void __init w90p910evb_init(void)
  340. {
  341. platform_add_devices(w90p910evb_dev, ARRAY_SIZE(w90p910evb_dev));
  342. spi_register_board_info(w90p910_spi_board_info,
  343. ARRAY_SIZE(w90p910_spi_board_info));
  344. }
  345. MACHINE_START(W90P910EVB, "W90P910EVB")
  346. /* Maintainer: Wan ZongShun */
  347. .phys_io = W90X900_PA_UART,
  348. .io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
  349. .boot_params = 0,
  350. .map_io = w90p910evb_map_io,
  351. .init_irq = w90x900_init_irq,
  352. .init_machine = w90p910evb_init,
  353. .timer = &w90x900_timer,
  354. MACHINE_END