lubbock.c 13 KB

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