arch-lpd7a40x.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /* arch/arm/mach-lh7a40x/arch-lpd7a40x.c
  2. *
  3. * Copyright (C) 2004 Logic Product Development
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * version 2 as published by the Free Software Foundation.
  8. *
  9. */
  10. #include <linux/tty.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/irq.h>
  15. #include <asm/hardware.h>
  16. #include <asm/setup.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/irq.h>
  20. #include <asm/mach/irq.h>
  21. #include <asm/mach/map.h>
  22. #include "common.h"
  23. #define CPLD_INT_NETHERNET (1<<0)
  24. #define CPLD_INTMASK_ETHERNET (1<<2)
  25. #if defined (CONFIG_MACH_LPD7A400)
  26. # define CPLD_INT_NTOUCH (1<<1)
  27. # define CPLD_INTMASK_TOUCH (1<<3)
  28. # define CPLD_INT_PEN (1<<4)
  29. # define CPLD_INTMASK_PEN (1<<4)
  30. # define CPLD_INT_PIRQ (1<<4)
  31. #endif
  32. #define CPLD_INTMASK_CPLD (1<<7)
  33. #define CPLD_INT_CPLD (1<<6)
  34. #define CPLD_CONTROL_SWINT (1<<7) /* Disable all CPLD IRQs */
  35. #define CPLD_CONTROL_OCMSK (1<<6) /* Mask USB1 connect IRQ */
  36. #define CPLD_CONTROL_PDRV (1<<5) /* PCC_nDRV high */
  37. #define CPLD_CONTROL_USB1C (1<<4) /* USB1 connect IRQ active */
  38. #define CPLD_CONTROL_USB1P (1<<3) /* USB1 power disable */
  39. #define CPLD_CONTROL_AWKP (1<<2) /* Auto-wakeup disabled */
  40. #define CPLD_CONTROL_LCD_ENABLE (1<<1) /* LCD Vee enable */
  41. #define CPLD_CONTROL_WRLAN_NENABLE (1<<0) /* SMC91x power disable */
  42. static struct resource smc91x_resources[] = {
  43. [0] = {
  44. .start = CPLD00_PHYS,
  45. .end = CPLD00_PHYS + CPLD00_SIZE - 1, /* Only needs 16B */
  46. .flags = IORESOURCE_MEM,
  47. },
  48. [1] = {
  49. .start = IRQ_LPD7A40X_ETH_INT,
  50. .end = IRQ_LPD7A40X_ETH_INT,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. static struct platform_device smc91x_device = {
  55. .name = "smc91x",
  56. .id = 0,
  57. .num_resources = ARRAY_SIZE(smc91x_resources),
  58. .resource = smc91x_resources,
  59. };
  60. static struct resource lh7a40x_usbclient_resources[] = {
  61. [0] = {
  62. .start = USB_PHYS,
  63. .end = (USB_PHYS + PAGE_SIZE),
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = IRQ_USB,
  68. .end = IRQ_USB,
  69. .flags = IORESOURCE_IRQ,
  70. },
  71. };
  72. static u64 lh7a40x_usbclient_dma_mask = 0xffffffffUL;
  73. static struct platform_device lh7a40x_usbclient_device = {
  74. // .name = "lh7a40x_udc",
  75. .name = "lh7-udc",
  76. .id = 0,
  77. .dev = {
  78. .dma_mask = &lh7a40x_usbclient_dma_mask,
  79. .coherent_dma_mask = 0xffffffffUL,
  80. },
  81. .num_resources = ARRAY_SIZE (lh7a40x_usbclient_resources),
  82. .resource = lh7a40x_usbclient_resources,
  83. };
  84. #if defined (CONFIG_ARCH_LH7A404)
  85. static struct resource lh7a404_usbhost_resources [] = {
  86. [0] = {
  87. .start = USBH_PHYS,
  88. .end = (USBH_PHYS + 0xFF),
  89. .flags = IORESOURCE_MEM,
  90. },
  91. [1] = {
  92. .start = IRQ_USHINTR,
  93. .end = IRQ_USHINTR,
  94. .flags = IORESOURCE_IRQ,
  95. },
  96. };
  97. static u64 lh7a404_usbhost_dma_mask = 0xffffffffUL;
  98. static struct platform_device lh7a404_usbhost_device = {
  99. .name = "lh7a404-ohci",
  100. .id = 0,
  101. .dev = {
  102. .dma_mask = &lh7a404_usbhost_dma_mask,
  103. .coherent_dma_mask = 0xffffffffUL,
  104. },
  105. .num_resources = ARRAY_SIZE (lh7a404_usbhost_resources),
  106. .resource = lh7a404_usbhost_resources,
  107. };
  108. #endif
  109. static struct platform_device* lpd7a40x_devs[] __initdata = {
  110. &smc91x_device,
  111. &lh7a40x_usbclient_device,
  112. #if defined (CONFIG_ARCH_LH7A404)
  113. &lh7a404_usbhost_device,
  114. #endif
  115. };
  116. extern void lpd7a400_map_io (void);
  117. static void __init lpd7a40x_init (void)
  118. {
  119. #if defined (CONFIG_MACH_LPD7A400)
  120. CPLD_CONTROL |= 0
  121. | CPLD_CONTROL_SWINT /* Disable software interrupt */
  122. | CPLD_CONTROL_OCMSK; /* Mask USB1 connection IRQ */
  123. CPLD_CONTROL &= ~(0
  124. | CPLD_CONTROL_LCD_ENABLE /* Disable LCD */
  125. | CPLD_CONTROL_WRLAN_NENABLE /* Enable SMC91x */
  126. );
  127. #endif
  128. #if defined (CONFIG_MACH_LPD7A404)
  129. CPLD_CONTROL &= ~(0
  130. | CPLD_CONTROL_WRLAN_NENABLE /* Enable SMC91x */
  131. );
  132. #endif
  133. platform_add_devices (lpd7a40x_devs, ARRAY_SIZE (lpd7a40x_devs));
  134. #if defined (CONFIG_FB_ARMCLCD)
  135. lh7a40x_clcd_init ();
  136. #endif
  137. }
  138. static void lh7a40x_ack_cpld_irq (u32 irq)
  139. {
  140. /* CPLD doesn't have ack capability, but some devices may */
  141. #if defined (CPLD_INTMASK_TOUCH)
  142. /* The touch control *must* mask the the interrupt because the
  143. * interrupt bit is read by the driver to determine if the pen
  144. * is still down. */
  145. if (irq == IRQ_TOUCH)
  146. CPLD_INTERRUPTS |= CPLD_INTMASK_TOUCH;
  147. #endif
  148. }
  149. static void lh7a40x_mask_cpld_irq (u32 irq)
  150. {
  151. switch (irq) {
  152. case IRQ_LPD7A40X_ETH_INT:
  153. CPLD_INTERRUPTS |= CPLD_INTMASK_ETHERNET;
  154. break;
  155. #if defined (IRQ_TOUCH)
  156. case IRQ_TOUCH:
  157. CPLD_INTERRUPTS |= CPLD_INTMASK_TOUCH;
  158. break;
  159. #endif
  160. }
  161. }
  162. static void lh7a40x_unmask_cpld_irq (u32 irq)
  163. {
  164. switch (irq) {
  165. case IRQ_LPD7A40X_ETH_INT:
  166. CPLD_INTERRUPTS &= ~CPLD_INTMASK_ETHERNET;
  167. break;
  168. #if defined (IRQ_TOUCH)
  169. case IRQ_TOUCH:
  170. CPLD_INTERRUPTS &= ~CPLD_INTMASK_TOUCH;
  171. break;
  172. #endif
  173. }
  174. }
  175. static struct irq_chip lpd7a40x_cpld_chip = {
  176. .name = "CPLD",
  177. .ack = lh7a40x_ack_cpld_irq,
  178. .mask = lh7a40x_mask_cpld_irq,
  179. .unmask = lh7a40x_unmask_cpld_irq,
  180. };
  181. static void lpd7a40x_cpld_handler (unsigned int irq, struct irqdesc *desc,
  182. struct pt_regs *regs)
  183. {
  184. unsigned int mask = CPLD_INTERRUPTS;
  185. desc->chip->ack (irq);
  186. if ((mask & (1<<0)) == 0) /* WLAN */
  187. IRQ_DISPATCH (IRQ_LPD7A40X_ETH_INT);
  188. #if defined (IRQ_TOUCH)
  189. if ((mask & (1<<1)) == 0) /* Touch */
  190. IRQ_DISPATCH (IRQ_TOUCH);
  191. #endif
  192. desc->chip->unmask (irq); /* Level-triggered need this */
  193. }
  194. void __init lh7a40x_init_board_irq (void)
  195. {
  196. int irq;
  197. /* Rev A (v2.8): PF0, PF1, PF2, and PF3 are available IRQs.
  198. PF7 supports the CPLD.
  199. Rev B (v3.4): PF0, PF1, and PF2 are available IRQs.
  200. PF3 supports the CPLD.
  201. (Some) LPD7A404 prerelease boards report a version
  202. number of 0x16, but we force an override since the
  203. hardware is of the newer variety.
  204. */
  205. unsigned char cpld_version = CPLD_REVISION;
  206. int pinCPLD = (cpld_version == 0x28) ? 7 : 3;
  207. #if defined CONFIG_MACH_LPD7A404
  208. cpld_version = 0x34; /* Coerce LPD7A404 to RevB */
  209. #endif
  210. /* First, configure user controlled GPIOF interrupts */
  211. GPIO_PFDD &= ~0x0f; /* PF0-3 are inputs */
  212. GPIO_INTTYPE1 &= ~0x0f; /* PF0-3 are level triggered */
  213. GPIO_INTTYPE2 &= ~0x0f; /* PF0-3 are active low */
  214. barrier ();
  215. GPIO_GPIOFINTEN |= 0x0f; /* Enable PF0, PF1, PF2, and PF3 IRQs */
  216. /* Then, configure CPLD interrupt */
  217. /* Disable all CPLD interrupts */
  218. #if defined (CONFIG_MACH_LPD7A400)
  219. CPLD_INTERRUPTS = CPLD_INTMASK_TOUCH | CPLD_INTMASK_PEN
  220. | CPLD_INTMASK_ETHERNET;
  221. /* *** FIXME: don't know why we need 7 and 4. 7 is way wrong
  222. and 4 is uncefined. */
  223. // (1<<7)|(1<<4)|(1<<3)|(1<<2);
  224. #endif
  225. #if defined (CONFIG_MACH_LPD7A404)
  226. CPLD_INTERRUPTS = CPLD_INTMASK_ETHERNET;
  227. /* *** FIXME: don't know why we need 6 and 5, neither is defined. */
  228. // (1<<6)|(1<<5)|(1<<3);
  229. #endif
  230. GPIO_PFDD &= ~(1 << pinCPLD); /* Make input */
  231. GPIO_INTTYPE1 &= ~(1 << pinCPLD); /* Level triggered */
  232. GPIO_INTTYPE2 &= ~(1 << pinCPLD); /* Active low */
  233. barrier ();
  234. GPIO_GPIOFINTEN |= (1 << pinCPLD); /* Enable */
  235. /* Cascade CPLD interrupts */
  236. for (irq = IRQ_BOARD_START;
  237. irq < IRQ_BOARD_START + NR_IRQ_BOARD; ++irq) {
  238. set_irq_chip (irq, &lpd7a40x_cpld_chip);
  239. set_irq_handler (irq, do_level_IRQ);
  240. set_irq_flags (irq, IRQF_VALID);
  241. }
  242. set_irq_chained_handler ((cpld_version == 0x28)
  243. ? IRQ_CPLD_V28
  244. : IRQ_CPLD_V34,
  245. lpd7a40x_cpld_handler);
  246. }
  247. static struct map_desc lpd7a40x_io_desc[] __initdata = {
  248. {
  249. .virtual = IO_VIRT,
  250. .pfn = __phys_to_pfn(IO_PHYS),
  251. .length = IO_SIZE,
  252. .type = MT_DEVICE
  253. },
  254. { /* Mapping added to work around chip select problems */
  255. .virtual = IOBARRIER_VIRT,
  256. .pfn = __phys_to_pfn(IOBARRIER_PHYS),
  257. .length = IOBARRIER_SIZE,
  258. .type = MT_DEVICE
  259. },
  260. {
  261. .virtual = CF_VIRT,
  262. .pfn = __phys_to_pfn(CF_PHYS),
  263. .length = CF_SIZE,
  264. .type = MT_DEVICE
  265. },
  266. {
  267. .virtual = CPLD02_VIRT,
  268. .pfn = __phys_to_pfn(CPLD02_PHYS),
  269. .length = CPLD02_SIZE,
  270. .type = MT_DEVICE
  271. },
  272. {
  273. .virtual = CPLD06_VIRT,
  274. .pfn = __phys_to_pfn(CPLD06_PHYS),
  275. .length = CPLD06_SIZE,
  276. .type = MT_DEVICE
  277. },
  278. {
  279. .virtual = CPLD08_VIRT,
  280. .pfn = __phys_to_pfn(CPLD08_PHYS),
  281. .length = CPLD08_SIZE,
  282. .type = MT_DEVICE
  283. },
  284. {
  285. .virtual = CPLD08_VIRT,
  286. .pfn = __phys_to_pfn(CPLD08_PHYS),
  287. .length = CPLD08_SIZE,
  288. .type = MT_DEVICE
  289. },
  290. {
  291. .virtual = CPLD0A_VIRT,
  292. .pfn = __phys_to_pfn(CPLD0A_PHYS),
  293. .length = CPLD0A_SIZE,
  294. .type = MT_DEVICE
  295. },
  296. {
  297. .virtual = CPLD0C_VIRT,
  298. .pfn = __phys_to_pfn(CPLD0C_PHYS),
  299. .length = CPLD0C_SIZE,
  300. .type = MT_DEVICE
  301. },
  302. {
  303. .virtual = CPLD0E_VIRT,
  304. .pfn = __phys_to_pfn(CPLD0E_PHYS),
  305. .length = CPLD0E_SIZE,
  306. .type = MT_DEVICE
  307. },
  308. {
  309. .virtual = CPLD10_VIRT,
  310. .pfn = __phys_to_pfn(CPLD10_PHYS),
  311. .length = CPLD10_SIZE,
  312. .type = MT_DEVICE
  313. },
  314. {
  315. .virtual = CPLD12_VIRT,
  316. .pfn = __phys_to_pfn(CPLD12_PHYS),
  317. .length = CPLD12_SIZE,
  318. .type = MT_DEVICE
  319. },
  320. {
  321. .virtual = CPLD14_VIRT,
  322. .pfn = __phys_to_pfn(CPLD14_PHYS),
  323. .length = CPLD14_SIZE,
  324. .type = MT_DEVICE
  325. },
  326. {
  327. .virtual = CPLD16_VIRT,
  328. .pfn = __phys_to_pfn(CPLD16_PHYS),
  329. .length = CPLD16_SIZE,
  330. .type = MT_DEVICE
  331. },
  332. {
  333. .virtual = CPLD18_VIRT,
  334. .pfn = __phys_to_pfn(CPLD18_PHYS),
  335. .length = CPLD18_SIZE,
  336. .type = MT_DEVICE
  337. },
  338. {
  339. .virtual = CPLD1A_VIRT,
  340. .pfn = __phys_to_pfn(CPLD1A_PHYS),
  341. .length = CPLD1A_SIZE,
  342. .type = MT_DEVICE
  343. },
  344. };
  345. void __init
  346. lpd7a40x_map_io(void)
  347. {
  348. iotable_init (lpd7a40x_io_desc, ARRAY_SIZE (lpd7a40x_io_desc));
  349. }
  350. #ifdef CONFIG_MACH_LPD7A400
  351. MACHINE_START (LPD7A400, "Logic Product Development LPD7A400-10")
  352. /* Maintainer: Marc Singer */
  353. .phys_io = 0x80000000,
  354. .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
  355. .boot_params = 0xc0000100,
  356. .map_io = lpd7a40x_map_io,
  357. .init_irq = lh7a400_init_irq,
  358. .timer = &lh7a40x_timer,
  359. .init_machine = lpd7a40x_init,
  360. MACHINE_END
  361. #endif
  362. #ifdef CONFIG_MACH_LPD7A404
  363. MACHINE_START (LPD7A404, "Logic Product Development LPD7A404-10")
  364. /* Maintainer: Marc Singer */
  365. .phys_io = 0x80000000,
  366. .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
  367. .boot_params = 0xc0000100,
  368. .map_io = lpd7a40x_map_io,
  369. .init_irq = lh7a404_init_irq,
  370. .timer = &lh7a40x_timer,
  371. .init_machine = lpd7a40x_init,
  372. MACHINE_END
  373. #endif