lubbock.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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 <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <asm/setup.h>
  25. #include <asm/memory.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/hardware.h>
  28. #include <asm/irq.h>
  29. #include <asm/sizes.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/irq.h>
  33. #include <asm/mach/flash.h>
  34. #include <asm/hardware/sa1111.h>
  35. #include <asm/arch/pxa-regs.h>
  36. #include <asm/arch/lubbock.h>
  37. #include <asm/arch/udc.h>
  38. #include <asm/arch/irda.h>
  39. #include <asm/arch/pxafb.h>
  40. #include <asm/arch/mmc.h>
  41. #include "generic.h"
  42. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  43. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  44. {
  45. unsigned long flags;
  46. local_irq_save(flags);
  47. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  48. local_irq_restore(flags);
  49. }
  50. EXPORT_SYMBOL(lubbock_set_misc_wr);
  51. static unsigned long lubbock_irq_enabled;
  52. static void lubbock_mask_irq(unsigned int irq)
  53. {
  54. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  55. LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
  56. }
  57. static void lubbock_unmask_irq(unsigned int irq)
  58. {
  59. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  60. /* the irq can be acknowledged only if deasserted, so it's done here */
  61. LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
  62. LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
  63. }
  64. static struct irqchip lubbock_irq_chip = {
  65. .ack = lubbock_mask_irq,
  66. .mask = lubbock_mask_irq,
  67. .unmask = lubbock_unmask_irq,
  68. };
  69. static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
  70. struct pt_regs *regs)
  71. {
  72. unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  73. do {
  74. GEDR(0) = GPIO_bit(0); /* clear our parent irq */
  75. if (likely(pending)) {
  76. irq = LUBBOCK_IRQ(0) + __ffs(pending);
  77. desc = irq_desc + irq;
  78. desc_handle_irq(irq, desc, regs);
  79. }
  80. pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  81. } while (pending);
  82. }
  83. static void __init lubbock_init_irq(void)
  84. {
  85. int irq;
  86. pxa_init_irq();
  87. /* setup extra lubbock irqs */
  88. for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
  89. set_irq_chip(irq, &lubbock_irq_chip);
  90. set_irq_handler(irq, do_level_IRQ);
  91. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  92. }
  93. set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
  94. set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
  95. }
  96. #ifdef CONFIG_PM
  97. static int lubbock_irq_resume(struct sys_device *dev)
  98. {
  99. LUB_IRQ_MASK_EN = lubbock_irq_enabled;
  100. return 0;
  101. }
  102. static struct sysdev_class lubbock_irq_sysclass = {
  103. set_kset_name("cpld_irq"),
  104. .resume = lubbock_irq_resume,
  105. };
  106. static struct sys_device lubbock_irq_device = {
  107. .cls = &lubbock_irq_sysclass,
  108. };
  109. static int __init lubbock_irq_device_init(void)
  110. {
  111. int ret = sysdev_class_register(&lubbock_irq_sysclass);
  112. if (ret == 0)
  113. ret = sysdev_register(&lubbock_irq_device);
  114. return ret;
  115. }
  116. device_initcall(lubbock_irq_device_init);
  117. #endif
  118. static int lubbock_udc_is_connected(void)
  119. {
  120. return (LUB_MISC_RD & (1 << 9)) == 0;
  121. }
  122. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  123. .udc_is_connected = lubbock_udc_is_connected,
  124. // no D+ pullup; lubbock can't connect/disconnect in software
  125. };
  126. static struct platform_device lub_audio_device = {
  127. .name = "pxa2xx-ac97",
  128. .id = -1,
  129. };
  130. static struct resource sa1111_resources[] = {
  131. [0] = {
  132. .start = 0x10000000,
  133. .end = 0x10001fff,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = LUBBOCK_SA1111_IRQ,
  138. .end = LUBBOCK_SA1111_IRQ,
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. };
  142. static struct platform_device sa1111_device = {
  143. .name = "sa1111",
  144. .id = -1,
  145. .num_resources = ARRAY_SIZE(sa1111_resources),
  146. .resource = sa1111_resources,
  147. };
  148. static struct resource smc91x_resources[] = {
  149. [0] = {
  150. .name = "smc91x-regs",
  151. .start = 0x0c000c00,
  152. .end = 0x0c0fffff,
  153. .flags = IORESOURCE_MEM,
  154. },
  155. [1] = {
  156. .start = LUBBOCK_ETH_IRQ,
  157. .end = LUBBOCK_ETH_IRQ,
  158. .flags = IORESOURCE_IRQ,
  159. },
  160. [2] = {
  161. .name = "smc91x-attrib",
  162. .start = 0x0e000000,
  163. .end = 0x0e0fffff,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. };
  167. static struct platform_device smc91x_device = {
  168. .name = "smc91x",
  169. .id = -1,
  170. .num_resources = ARRAY_SIZE(smc91x_resources),
  171. .resource = smc91x_resources,
  172. };
  173. static struct resource flash_resources[] = {
  174. [0] = {
  175. .start = 0x00000000,
  176. .end = SZ_64M - 1,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = 0x04000000,
  181. .end = 0x04000000 + SZ_64M - 1,
  182. .flags = IORESOURCE_MEM,
  183. },
  184. };
  185. static struct mtd_partition lubbock_partitions[] = {
  186. {
  187. .name = "Bootloader",
  188. .size = 0x00040000,
  189. .offset = 0,
  190. .mask_flags = MTD_WRITEABLE /* force read-only */
  191. },{
  192. .name = "Kernel",
  193. .size = 0x00100000,
  194. .offset = 0x00040000,
  195. },{
  196. .name = "Filesystem",
  197. .size = MTDPART_SIZ_FULL,
  198. .offset = 0x00140000
  199. }
  200. };
  201. static struct flash_platform_data lubbock_flash_data[2] = {
  202. {
  203. .map_name = "cfi_probe",
  204. .parts = lubbock_partitions,
  205. .nr_parts = ARRAY_SIZE(lubbock_partitions),
  206. }, {
  207. .map_name = "cfi_probe",
  208. .parts = NULL,
  209. .nr_parts = 0,
  210. }
  211. };
  212. static struct platform_device lubbock_flash_device[2] = {
  213. {
  214. .name = "pxa2xx-flash",
  215. .id = 0,
  216. .dev = {
  217. .platform_data = &lubbock_flash_data[0],
  218. },
  219. .resource = &flash_resources[0],
  220. .num_resources = 1,
  221. },
  222. {
  223. .name = "pxa2xx-flash",
  224. .id = 1,
  225. .dev = {
  226. .platform_data = &lubbock_flash_data[1],
  227. },
  228. .resource = &flash_resources[1],
  229. .num_resources = 1,
  230. },
  231. };
  232. static struct platform_device *devices[] __initdata = {
  233. &sa1111_device,
  234. &lub_audio_device,
  235. &smc91x_device,
  236. &lubbock_flash_device[0],
  237. &lubbock_flash_device[1],
  238. };
  239. static struct pxafb_mach_info sharp_lm8v31 __initdata = {
  240. .pixclock = 270000,
  241. .xres = 640,
  242. .yres = 480,
  243. .bpp = 16,
  244. .hsync_len = 1,
  245. .left_margin = 3,
  246. .right_margin = 3,
  247. .vsync_len = 1,
  248. .upper_margin = 0,
  249. .lower_margin = 0,
  250. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  251. .cmap_greyscale = 0,
  252. .cmap_inverse = 0,
  253. .cmap_static = 0,
  254. .lccr0 = LCCR0_SDS,
  255. .lccr3 = LCCR3_PCP | LCCR3_Acb(255),
  256. };
  257. #define MMC_POLL_RATE msecs_to_jiffies(1000)
  258. static void lubbock_mmc_poll(unsigned long);
  259. static irqreturn_t (*mmc_detect_int)(int, void *, struct pt_regs *);
  260. static struct timer_list mmc_timer = {
  261. .function = lubbock_mmc_poll,
  262. };
  263. static void lubbock_mmc_poll(unsigned long data)
  264. {
  265. unsigned long flags;
  266. /* clear any previous irq state, then ... */
  267. local_irq_save(flags);
  268. LUB_IRQ_SET_CLR &= ~(1 << 0);
  269. local_irq_restore(flags);
  270. /* poll until mmc/sd card is removed */
  271. if (LUB_IRQ_SET_CLR & (1 << 0))
  272. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  273. else {
  274. (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data, NULL);
  275. enable_irq(LUBBOCK_SD_IRQ);
  276. }
  277. }
  278. static irqreturn_t lubbock_detect_int(int irq, void *data, struct pt_regs *regs)
  279. {
  280. /* IRQ is level triggered; disable, and poll for removal */
  281. disable_irq(irq);
  282. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  283. return mmc_detect_int(irq, data, regs);
  284. }
  285. static int lubbock_mci_init(struct device *dev,
  286. irqreturn_t (*detect_int)(int, void *, struct pt_regs *),
  287. void *data)
  288. {
  289. /* setup GPIO for PXA25x MMC controller */
  290. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  291. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  292. /* detect card insert/eject */
  293. mmc_detect_int = detect_int;
  294. init_timer(&mmc_timer);
  295. mmc_timer.data = (unsigned long) data;
  296. return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
  297. SA_SAMPLE_RANDOM, "lubbock-sd-detect", data);
  298. }
  299. static int lubbock_mci_get_ro(struct device *dev)
  300. {
  301. return (LUB_MISC_RD & (1 << 2)) != 0;
  302. }
  303. static void lubbock_mci_exit(struct device *dev, void *data)
  304. {
  305. free_irq(LUBBOCK_SD_IRQ, data);
  306. del_timer_sync(&mmc_timer);
  307. }
  308. static struct pxamci_platform_data lubbock_mci_platform_data = {
  309. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  310. .detect_delay = 1,
  311. .init = lubbock_mci_init,
  312. .get_ro = lubbock_mci_get_ro,
  313. .exit = lubbock_mci_exit,
  314. };
  315. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  316. {
  317. unsigned long flags;
  318. local_irq_save(flags);
  319. if (mode & IR_SIRMODE) {
  320. LUB_MISC_WR &= ~(1 << 4);
  321. } else if (mode & IR_FIRMODE) {
  322. LUB_MISC_WR |= 1 << 4;
  323. }
  324. local_irq_restore(flags);
  325. }
  326. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  327. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  328. .transceiver_mode = lubbock_irda_transceiver_mode,
  329. };
  330. static void __init lubbock_init(void)
  331. {
  332. int flashboot = (LUB_CONF_SWITCHES & 1);
  333. pxa_set_udc_info(&udc_info);
  334. set_pxa_fb_info(&sharp_lm8v31);
  335. pxa_set_mci_info(&lubbock_mci_platform_data);
  336. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  337. lubbock_flash_data[0].width = lubbock_flash_data[1].width =
  338. (BOOT_DEF & 1) ? 2 : 4;
  339. /* Compensate for the nROMBT switch which swaps the flash banks */
  340. printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
  341. flashboot?"Flash":"ROM", flashboot);
  342. lubbock_flash_data[flashboot^1].name = "application-flash";
  343. lubbock_flash_data[flashboot].name = "boot-rom";
  344. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  345. }
  346. static struct map_desc lubbock_io_desc[] __initdata = {
  347. { /* CPLD */
  348. .virtual = LUBBOCK_FPGA_VIRT,
  349. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  350. .length = 0x00100000,
  351. .type = MT_DEVICE
  352. }
  353. };
  354. static void __init lubbock_map_io(void)
  355. {
  356. pxa_map_io();
  357. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  358. /* This enables the BTUART */
  359. pxa_gpio_mode(GPIO42_BTRXD_MD);
  360. pxa_gpio_mode(GPIO43_BTTXD_MD);
  361. pxa_gpio_mode(GPIO44_BTCTS_MD);
  362. pxa_gpio_mode(GPIO45_BTRTS_MD);
  363. /* This is for the SMC chip select */
  364. pxa_gpio_mode(GPIO79_nCS_3_MD);
  365. /* setup sleep mode values */
  366. PWER = 0x00000002;
  367. PFER = 0x00000000;
  368. PRER = 0x00000002;
  369. PGSR0 = 0x00008000;
  370. PGSR1 = 0x003F0202;
  371. PGSR2 = 0x0001C000;
  372. PCFR |= PCFR_OPDE;
  373. }
  374. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  375. /* Maintainer: MontaVista Software Inc. */
  376. .phys_io = 0x40000000,
  377. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  378. .map_io = lubbock_map_io,
  379. .init_irq = lubbock_init_irq,
  380. .timer = &pxa_timer,
  381. .init_machine = lubbock_init,
  382. MACHINE_END