lubbock.c 12 KB

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