lubbock.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*
  2. * linux/arch/arm/mach-pxa/lubbock.c
  3. *
  4. * Support for the Intel DBPXA250 Development Platform.
  5. *
  6. * Author: Nicolas Pitre
  7. * Created: Jun 15, 2001
  8. * Copyright: MontaVista Software Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/major.h>
  20. #include <linux/fb.h>
  21. #include <linux/interrupt.h>
  22. #include <asm/setup.h>
  23. #include <asm/memory.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/hardware.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <asm/hardware/sa1111.h>
  31. #include <asm/arch/pxa-regs.h>
  32. #include <asm/arch/lubbock.h>
  33. #include <asm/arch/udc.h>
  34. #include <asm/arch/irda.h>
  35. #include <asm/arch/pxafb.h>
  36. #include <asm/arch/mmc.h>
  37. #include "generic.h"
  38. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  39. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  40. {
  41. unsigned long flags;
  42. local_irq_save(flags);
  43. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  44. local_irq_restore(flags);
  45. }
  46. EXPORT_SYMBOL(lubbock_set_misc_wr);
  47. static unsigned long lubbock_irq_enabled;
  48. static void lubbock_mask_irq(unsigned int irq)
  49. {
  50. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  51. LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
  52. }
  53. static void lubbock_unmask_irq(unsigned int irq)
  54. {
  55. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  56. /* the irq can be acknowledged only if deasserted, so it's done here */
  57. LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
  58. LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
  59. }
  60. static struct irqchip lubbock_irq_chip = {
  61. .ack = lubbock_mask_irq,
  62. .mask = lubbock_mask_irq,
  63. .unmask = lubbock_unmask_irq,
  64. };
  65. static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
  66. struct pt_regs *regs)
  67. {
  68. unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  69. do {
  70. GEDR(0) = GPIO_bit(0); /* clear our parent irq */
  71. if (likely(pending)) {
  72. irq = LUBBOCK_IRQ(0) + __ffs(pending);
  73. desc = irq_desc + irq;
  74. desc_handle_irq(irq, desc, regs);
  75. }
  76. pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  77. } while (pending);
  78. }
  79. static void __init lubbock_init_irq(void)
  80. {
  81. int irq;
  82. pxa_init_irq();
  83. /* setup extra lubbock irqs */
  84. for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
  85. set_irq_chip(irq, &lubbock_irq_chip);
  86. set_irq_handler(irq, do_level_IRQ);
  87. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  88. }
  89. set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
  90. set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
  91. }
  92. #ifdef CONFIG_PM
  93. static int lubbock_irq_resume(struct sys_device *dev)
  94. {
  95. LUB_IRQ_MASK_EN = lubbock_irq_enabled;
  96. return 0;
  97. }
  98. static struct sysdev_class lubbock_irq_sysclass = {
  99. set_kset_name("cpld_irq"),
  100. .resume = lubbock_irq_resume,
  101. };
  102. static struct sys_device lubbock_irq_device = {
  103. .cls = &lubbock_irq_sysclass,
  104. };
  105. static int __init lubbock_irq_device_init(void)
  106. {
  107. int ret = sysdev_class_register(&lubbock_irq_sysclass);
  108. if (ret == 0)
  109. ret = sysdev_register(&lubbock_irq_device);
  110. return ret;
  111. }
  112. device_initcall(lubbock_irq_device_init);
  113. #endif
  114. static int lubbock_udc_is_connected(void)
  115. {
  116. return (LUB_MISC_RD & (1 << 9)) == 0;
  117. }
  118. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  119. .udc_is_connected = lubbock_udc_is_connected,
  120. // no D+ pullup; lubbock can't connect/disconnect in software
  121. };
  122. static struct platform_device lub_audio_device = {
  123. .name = "pxa2xx-ac97",
  124. .id = -1,
  125. };
  126. static struct resource sa1111_resources[] = {
  127. [0] = {
  128. .start = 0x10000000,
  129. .end = 0x10001fff,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. [1] = {
  133. .start = LUBBOCK_SA1111_IRQ,
  134. .end = LUBBOCK_SA1111_IRQ,
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static struct platform_device sa1111_device = {
  139. .name = "sa1111",
  140. .id = -1,
  141. .num_resources = ARRAY_SIZE(sa1111_resources),
  142. .resource = sa1111_resources,
  143. };
  144. static struct resource smc91x_resources[] = {
  145. [0] = {
  146. .name = "smc91x-regs",
  147. .start = 0x0c000000,
  148. .end = 0x0c0fffff,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. [1] = {
  152. .start = LUBBOCK_ETH_IRQ,
  153. .end = LUBBOCK_ETH_IRQ,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. [2] = {
  157. .name = "smc91x-attrib",
  158. .start = 0x0e000000,
  159. .end = 0x0e0fffff,
  160. .flags = IORESOURCE_MEM,
  161. },
  162. };
  163. static struct platform_device smc91x_device = {
  164. .name = "smc91x",
  165. .id = -1,
  166. .num_resources = ARRAY_SIZE(smc91x_resources),
  167. .resource = smc91x_resources,
  168. };
  169. static struct platform_device *devices[] __initdata = {
  170. &sa1111_device,
  171. &lub_audio_device,
  172. &smc91x_device,
  173. };
  174. static struct pxafb_mach_info sharp_lm8v31 __initdata = {
  175. .pixclock = 270000,
  176. .xres = 640,
  177. .yres = 480,
  178. .bpp = 16,
  179. .hsync_len = 1,
  180. .left_margin = 3,
  181. .right_margin = 3,
  182. .vsync_len = 1,
  183. .upper_margin = 0,
  184. .lower_margin = 0,
  185. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  186. .cmap_greyscale = 0,
  187. .cmap_inverse = 0,
  188. .cmap_static = 0,
  189. .lccr0 = LCCR0_SDS,
  190. .lccr3 = LCCR3_PCP | LCCR3_Acb(255),
  191. };
  192. static int lubbock_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data)
  193. {
  194. /* setup GPIO for PXA25x MMC controller */
  195. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  196. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  197. return 0;
  198. }
  199. static struct pxamci_platform_data lubbock_mci_platform_data = {
  200. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  201. .init = lubbock_mci_init,
  202. };
  203. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  204. {
  205. unsigned long flags;
  206. local_irq_save(flags);
  207. if (mode & IR_SIRMODE) {
  208. LUB_MISC_WR &= ~(1 << 4);
  209. } else if (mode & IR_FIRMODE) {
  210. LUB_MISC_WR |= 1 << 4;
  211. }
  212. local_irq_restore(flags);
  213. }
  214. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  215. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  216. .transceiver_mode = lubbock_irda_transceiver_mode,
  217. };
  218. static void __init lubbock_init(void)
  219. {
  220. pxa_set_udc_info(&udc_info);
  221. set_pxa_fb_info(&sharp_lm8v31);
  222. pxa_set_mci_info(&lubbock_mci_platform_data);
  223. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  224. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  225. }
  226. static struct map_desc lubbock_io_desc[] __initdata = {
  227. { /* CPLD */
  228. .virtual = LUBBOCK_FPGA_VIRT,
  229. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  230. .length = 0x00100000,
  231. .type = MT_DEVICE
  232. }
  233. };
  234. static void __init lubbock_map_io(void)
  235. {
  236. pxa_map_io();
  237. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  238. /* This enables the BTUART */
  239. pxa_gpio_mode(GPIO42_BTRXD_MD);
  240. pxa_gpio_mode(GPIO43_BTTXD_MD);
  241. pxa_gpio_mode(GPIO44_BTCTS_MD);
  242. pxa_gpio_mode(GPIO45_BTRTS_MD);
  243. /* This is for the SMC chip select */
  244. pxa_gpio_mode(GPIO79_nCS_3_MD);
  245. /* setup sleep mode values */
  246. PWER = 0x00000002;
  247. PFER = 0x00000000;
  248. PRER = 0x00000002;
  249. PGSR0 = 0x00008000;
  250. PGSR1 = 0x003F0202;
  251. PGSR2 = 0x0001C000;
  252. PCFR |= PCFR_OPDE;
  253. }
  254. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  255. /* Maintainer: MontaVista Software Inc. */
  256. .phys_ram = 0xa0000000,
  257. .phys_io = 0x40000000,
  258. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  259. .map_io = lubbock_map_io,
  260. .init_irq = lubbock_init_irq,
  261. .timer = &pxa_timer,
  262. .init_machine = lubbock_init,
  263. MACHINE_END