lubbock.c 6.6 KB

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