lubbock.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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 <linux/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <asm/arch/pxa2xx_spi.h>
  27. #include <asm/setup.h>
  28. #include <asm/memory.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/hardware.h>
  31. #include <asm/irq.h>
  32. #include <asm/sizes.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/irq.h>
  36. #include <asm/mach/flash.h>
  37. #include <asm/hardware/sa1111.h>
  38. #include <asm/arch/pxa-regs.h>
  39. #include <asm/arch/pxa2xx-regs.h>
  40. #include <asm/arch/pxa2xx-gpio.h>
  41. #include <asm/arch/lubbock.h>
  42. #include <asm/arch/udc.h>
  43. #include <asm/arch/irda.h>
  44. #include <asm/arch/pxafb.h>
  45. #include <asm/arch/mmc.h>
  46. #include "generic.h"
  47. #include "devices.h"
  48. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  49. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  50. {
  51. unsigned long flags;
  52. local_irq_save(flags);
  53. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  54. local_irq_restore(flags);
  55. }
  56. EXPORT_SYMBOL(lubbock_set_misc_wr);
  57. static unsigned long lubbock_irq_enabled;
  58. static void lubbock_mask_irq(unsigned int irq)
  59. {
  60. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  61. LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
  62. }
  63. static void lubbock_unmask_irq(unsigned int irq)
  64. {
  65. int lubbock_irq = (irq - LUBBOCK_IRQ(0));
  66. /* the irq can be acknowledged only if deasserted, so it's done here */
  67. LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
  68. LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
  69. }
  70. static struct irq_chip lubbock_irq_chip = {
  71. .name = "FPGA",
  72. .ack = lubbock_mask_irq,
  73. .mask = lubbock_mask_irq,
  74. .unmask = lubbock_unmask_irq,
  75. };
  76. static void lubbock_irq_handler(unsigned int irq, struct irq_desc *desc)
  77. {
  78. unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  79. do {
  80. GEDR(0) = GPIO_bit(0); /* clear our parent irq */
  81. if (likely(pending)) {
  82. irq = LUBBOCK_IRQ(0) + __ffs(pending);
  83. desc = irq_desc + irq;
  84. desc_handle_irq(irq, desc);
  85. }
  86. pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
  87. } while (pending);
  88. }
  89. static void __init lubbock_init_irq(void)
  90. {
  91. int irq;
  92. pxa25x_init_irq();
  93. /* setup extra lubbock irqs */
  94. for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
  95. set_irq_chip(irq, &lubbock_irq_chip);
  96. set_irq_handler(irq, handle_level_irq);
  97. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  98. }
  99. set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
  100. set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
  101. }
  102. #ifdef CONFIG_PM
  103. static int lubbock_irq_resume(struct sys_device *dev)
  104. {
  105. LUB_IRQ_MASK_EN = lubbock_irq_enabled;
  106. return 0;
  107. }
  108. static struct sysdev_class lubbock_irq_sysclass = {
  109. .name = "cpld_irq",
  110. .resume = lubbock_irq_resume,
  111. };
  112. static struct sys_device lubbock_irq_device = {
  113. .cls = &lubbock_irq_sysclass,
  114. };
  115. static int __init lubbock_irq_device_init(void)
  116. {
  117. int ret = -ENODEV;
  118. if (machine_is_lubbock()) {
  119. ret = sysdev_class_register(&lubbock_irq_sysclass);
  120. if (ret == 0)
  121. ret = sysdev_register(&lubbock_irq_device);
  122. }
  123. return ret;
  124. }
  125. device_initcall(lubbock_irq_device_init);
  126. #endif
  127. static int lubbock_udc_is_connected(void)
  128. {
  129. return (LUB_MISC_RD & (1 << 9)) == 0;
  130. }
  131. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  132. .udc_is_connected = lubbock_udc_is_connected,
  133. // no D+ pullup; lubbock can't connect/disconnect in software
  134. };
  135. static struct platform_device lub_audio_device = {
  136. .name = "pxa2xx-ac97",
  137. .id = -1,
  138. };
  139. static struct resource sa1111_resources[] = {
  140. [0] = {
  141. .start = 0x10000000,
  142. .end = 0x10001fff,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [1] = {
  146. .start = LUBBOCK_SA1111_IRQ,
  147. .end = LUBBOCK_SA1111_IRQ,
  148. .flags = IORESOURCE_IRQ,
  149. },
  150. };
  151. static struct platform_device sa1111_device = {
  152. .name = "sa1111",
  153. .id = -1,
  154. .num_resources = ARRAY_SIZE(sa1111_resources),
  155. .resource = sa1111_resources,
  156. };
  157. static struct resource smc91x_resources[] = {
  158. [0] = {
  159. .name = "smc91x-regs",
  160. .start = 0x0c000c00,
  161. .end = 0x0c0fffff,
  162. .flags = IORESOURCE_MEM,
  163. },
  164. [1] = {
  165. .start = LUBBOCK_ETH_IRQ,
  166. .end = LUBBOCK_ETH_IRQ,
  167. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  168. },
  169. [2] = {
  170. .name = "smc91x-attrib",
  171. .start = 0x0e000000,
  172. .end = 0x0e0fffff,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. };
  176. /* ADS7846 is connected through SSP ... and if your board has J5 populated,
  177. * you can select it to replace the ucb1400 by switching the touchscreen cable
  178. * (to J5) and poking board registers (as done below). Else it's only useful
  179. * for the temperature sensors.
  180. */
  181. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  182. .num_chipselect = 0,
  183. };
  184. static struct platform_device pxa_ssp = {
  185. .name = "pxa2xx-spi",
  186. .id = 1,
  187. .dev = {
  188. .platform_data = &pxa_ssp_master_info,
  189. },
  190. };
  191. static int lubbock_ads7846_pendown_state(void)
  192. {
  193. /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
  194. return 0;
  195. }
  196. static struct ads7846_platform_data ads_info = {
  197. .model = 7846,
  198. .vref_delay_usecs = 100, /* internal, no cap */
  199. .get_pendown_state = lubbock_ads7846_pendown_state,
  200. // .x_plate_ohms = 500, /* GUESS! */
  201. // .y_plate_ohms = 500, /* GUESS! */
  202. };
  203. static void ads7846_cs(u32 command)
  204. {
  205. static const unsigned TS_nCS = 1 << 11;
  206. lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
  207. }
  208. static struct pxa2xx_spi_chip ads_hw = {
  209. .tx_threshold = 1,
  210. .rx_threshold = 2,
  211. .cs_control = ads7846_cs,
  212. };
  213. static struct spi_board_info spi_board_info[] __initdata = { {
  214. .modalias = "ads7846",
  215. .platform_data = &ads_info,
  216. .controller_data = &ads_hw,
  217. .irq = LUBBOCK_BB_IRQ,
  218. .max_speed_hz = 120000 /* max sample rate at 3V */
  219. * 26 /* command + data + overhead */,
  220. .bus_num = 1,
  221. .chip_select = 0,
  222. },
  223. };
  224. static struct platform_device smc91x_device = {
  225. .name = "smc91x",
  226. .id = -1,
  227. .num_resources = ARRAY_SIZE(smc91x_resources),
  228. .resource = smc91x_resources,
  229. };
  230. static struct resource flash_resources[] = {
  231. [0] = {
  232. .start = 0x00000000,
  233. .end = SZ_64M - 1,
  234. .flags = IORESOURCE_MEM,
  235. },
  236. [1] = {
  237. .start = 0x04000000,
  238. .end = 0x04000000 + SZ_64M - 1,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. };
  242. static struct mtd_partition lubbock_partitions[] = {
  243. {
  244. .name = "Bootloader",
  245. .size = 0x00040000,
  246. .offset = 0,
  247. .mask_flags = MTD_WRITEABLE /* force read-only */
  248. },{
  249. .name = "Kernel",
  250. .size = 0x00100000,
  251. .offset = 0x00040000,
  252. },{
  253. .name = "Filesystem",
  254. .size = MTDPART_SIZ_FULL,
  255. .offset = 0x00140000
  256. }
  257. };
  258. static struct flash_platform_data lubbock_flash_data[2] = {
  259. {
  260. .map_name = "cfi_probe",
  261. .parts = lubbock_partitions,
  262. .nr_parts = ARRAY_SIZE(lubbock_partitions),
  263. }, {
  264. .map_name = "cfi_probe",
  265. .parts = NULL,
  266. .nr_parts = 0,
  267. }
  268. };
  269. static struct platform_device lubbock_flash_device[2] = {
  270. {
  271. .name = "pxa2xx-flash",
  272. .id = 0,
  273. .dev = {
  274. .platform_data = &lubbock_flash_data[0],
  275. },
  276. .resource = &flash_resources[0],
  277. .num_resources = 1,
  278. },
  279. {
  280. .name = "pxa2xx-flash",
  281. .id = 1,
  282. .dev = {
  283. .platform_data = &lubbock_flash_data[1],
  284. },
  285. .resource = &flash_resources[1],
  286. .num_resources = 1,
  287. },
  288. };
  289. static struct platform_device *devices[] __initdata = {
  290. &sa1111_device,
  291. &lub_audio_device,
  292. &smc91x_device,
  293. &lubbock_flash_device[0],
  294. &lubbock_flash_device[1],
  295. &pxa_ssp,
  296. };
  297. static struct pxafb_mode_info sharp_lm8v31_mode = {
  298. .pixclock = 270000,
  299. .xres = 640,
  300. .yres = 480,
  301. .bpp = 16,
  302. .hsync_len = 1,
  303. .left_margin = 3,
  304. .right_margin = 3,
  305. .vsync_len = 1,
  306. .upper_margin = 0,
  307. .lower_margin = 0,
  308. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  309. .cmap_greyscale = 0,
  310. };
  311. static struct pxafb_mach_info sharp_lm8v31 = {
  312. .modes = &sharp_lm8v31_mode,
  313. .num_modes = 1,
  314. .cmap_inverse = 0,
  315. .cmap_static = 0,
  316. .lccr0 = LCCR0_SDS,
  317. .lccr3 = LCCR3_PCP | LCCR3_Acb(255),
  318. };
  319. #define MMC_POLL_RATE msecs_to_jiffies(1000)
  320. static void lubbock_mmc_poll(unsigned long);
  321. static irq_handler_t mmc_detect_int;
  322. static struct timer_list mmc_timer = {
  323. .function = lubbock_mmc_poll,
  324. };
  325. static void lubbock_mmc_poll(unsigned long data)
  326. {
  327. unsigned long flags;
  328. /* clear any previous irq state, then ... */
  329. local_irq_save(flags);
  330. LUB_IRQ_SET_CLR &= ~(1 << 0);
  331. local_irq_restore(flags);
  332. /* poll until mmc/sd card is removed */
  333. if (LUB_IRQ_SET_CLR & (1 << 0))
  334. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  335. else {
  336. (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
  337. enable_irq(LUBBOCK_SD_IRQ);
  338. }
  339. }
  340. static irqreturn_t lubbock_detect_int(int irq, void *data)
  341. {
  342. /* IRQ is level triggered; disable, and poll for removal */
  343. disable_irq(irq);
  344. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  345. return mmc_detect_int(irq, data);
  346. }
  347. static int lubbock_mci_init(struct device *dev,
  348. irq_handler_t detect_int,
  349. void *data)
  350. {
  351. /* setup GPIO for PXA25x MMC controller */
  352. pxa_gpio_mode(GPIO6_MMCCLK_MD);
  353. pxa_gpio_mode(GPIO8_MMCCS0_MD);
  354. /* detect card insert/eject */
  355. mmc_detect_int = detect_int;
  356. init_timer(&mmc_timer);
  357. mmc_timer.data = (unsigned long) data;
  358. return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
  359. IRQF_SAMPLE_RANDOM, "lubbock-sd-detect", data);
  360. }
  361. static int lubbock_mci_get_ro(struct device *dev)
  362. {
  363. return (LUB_MISC_RD & (1 << 2)) != 0;
  364. }
  365. static void lubbock_mci_exit(struct device *dev, void *data)
  366. {
  367. free_irq(LUBBOCK_SD_IRQ, data);
  368. del_timer_sync(&mmc_timer);
  369. }
  370. static struct pxamci_platform_data lubbock_mci_platform_data = {
  371. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  372. .detect_delay = 1,
  373. .init = lubbock_mci_init,
  374. .get_ro = lubbock_mci_get_ro,
  375. .exit = lubbock_mci_exit,
  376. };
  377. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  378. {
  379. unsigned long flags;
  380. local_irq_save(flags);
  381. if (mode & IR_SIRMODE) {
  382. LUB_MISC_WR &= ~(1 << 4);
  383. } else if (mode & IR_FIRMODE) {
  384. LUB_MISC_WR |= 1 << 4;
  385. }
  386. local_irq_restore(flags);
  387. }
  388. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  389. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  390. .transceiver_mode = lubbock_irda_transceiver_mode,
  391. };
  392. static void __init lubbock_init(void)
  393. {
  394. int flashboot = (LUB_CONF_SWITCHES & 1);
  395. pxa_set_udc_info(&udc_info);
  396. set_pxa_fb_info(&sharp_lm8v31);
  397. pxa_set_mci_info(&lubbock_mci_platform_data);
  398. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  399. lubbock_flash_data[0].width = lubbock_flash_data[1].width =
  400. (BOOT_DEF & 1) ? 2 : 4;
  401. /* Compensate for the nROMBT switch which swaps the flash banks */
  402. printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
  403. flashboot?"Flash":"ROM", flashboot);
  404. lubbock_flash_data[flashboot^1].name = "application-flash";
  405. lubbock_flash_data[flashboot].name = "boot-rom";
  406. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  407. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  408. }
  409. static struct map_desc lubbock_io_desc[] __initdata = {
  410. { /* CPLD */
  411. .virtual = LUBBOCK_FPGA_VIRT,
  412. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  413. .length = 0x00100000,
  414. .type = MT_DEVICE
  415. }
  416. };
  417. static void __init lubbock_map_io(void)
  418. {
  419. pxa_map_io();
  420. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  421. /* SSP data pins */
  422. pxa_gpio_mode(GPIO23_SCLK_MD);
  423. pxa_gpio_mode(GPIO25_STXD_MD);
  424. pxa_gpio_mode(GPIO26_SRXD_MD);
  425. /* This enables the BTUART */
  426. pxa_gpio_mode(GPIO42_BTRXD_MD);
  427. pxa_gpio_mode(GPIO43_BTTXD_MD);
  428. pxa_gpio_mode(GPIO44_BTCTS_MD);
  429. pxa_gpio_mode(GPIO45_BTRTS_MD);
  430. GPSR(GPIO48_nPOE) =
  431. GPIO_bit(GPIO48_nPOE) |
  432. GPIO_bit(GPIO49_nPWE) |
  433. GPIO_bit(GPIO50_nPIOR) |
  434. GPIO_bit(GPIO51_nPIOW) |
  435. GPIO_bit(GPIO52_nPCE_1) |
  436. GPIO_bit(GPIO53_nPCE_2);
  437. pxa_gpio_mode(GPIO48_nPOE_MD);
  438. pxa_gpio_mode(GPIO49_nPWE_MD);
  439. pxa_gpio_mode(GPIO50_nPIOR_MD);
  440. pxa_gpio_mode(GPIO51_nPIOW_MD);
  441. pxa_gpio_mode(GPIO52_nPCE_1_MD);
  442. pxa_gpio_mode(GPIO53_nPCE_2_MD);
  443. pxa_gpio_mode(GPIO54_pSKTSEL_MD);
  444. pxa_gpio_mode(GPIO55_nPREG_MD);
  445. pxa_gpio_mode(GPIO56_nPWAIT_MD);
  446. pxa_gpio_mode(GPIO57_nIOIS16_MD);
  447. /* This is for the SMC chip select */
  448. pxa_gpio_mode(GPIO79_nCS_3_MD);
  449. /* setup sleep mode values */
  450. PWER = 0x00000002;
  451. PFER = 0x00000000;
  452. PRER = 0x00000002;
  453. PGSR0 = 0x00008000;
  454. PGSR1 = 0x003F0202;
  455. PGSR2 = 0x0001C000;
  456. PCFR |= PCFR_OPDE;
  457. }
  458. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  459. /* Maintainer: MontaVista Software Inc. */
  460. .phys_io = 0x40000000,
  461. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  462. .map_io = lubbock_map_io,
  463. .init_irq = lubbock_init_irq,
  464. .timer = &pxa_timer,
  465. .init_machine = lubbock_init,
  466. MACHINE_END