lubbock.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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/gpio.h>
  15. #include <linux/gpio/machine.h>
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/io.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/syscore_ops.h>
  22. #include <linux/major.h>
  23. #include <linux/fb.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/smc91x.h>
  28. #include <linux/slab.h>
  29. #include <linux/leds.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/spi/ads7846.h>
  32. #include <linux/spi/pxa2xx_spi.h>
  33. #include <asm/setup.h>
  34. #include <asm/memory.h>
  35. #include <asm/mach-types.h>
  36. #include <mach/hardware.h>
  37. #include <asm/irq.h>
  38. #include <asm/sizes.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/map.h>
  41. #include <asm/mach/irq.h>
  42. #include <asm/mach/flash.h>
  43. #include <asm/hardware/sa1111.h>
  44. #include <mach/pxa25x.h>
  45. #include <mach/audio.h>
  46. #include <mach/lubbock.h>
  47. #include <mach/udc.h>
  48. #include <linux/platform_data/irda-pxaficp.h>
  49. #include <linux/platform_data/video-pxafb.h>
  50. #include <linux/platform_data/mmc-pxamci.h>
  51. #include <mach/pm.h>
  52. #include <mach/smemc.h>
  53. #include "generic.h"
  54. #include "clock.h"
  55. #include "devices.h"
  56. static unsigned long lubbock_pin_config[] __initdata = {
  57. GPIO15_nCS_1, /* CS1 - Flash */
  58. GPIO78_nCS_2, /* CS2 - Baseboard FGPA */
  59. GPIO79_nCS_3, /* CS3 - SMC ethernet */
  60. GPIO80_nCS_4, /* CS4 - SA1111 */
  61. /* SSP data pins */
  62. GPIO23_SSP1_SCLK,
  63. GPIO25_SSP1_TXD,
  64. GPIO26_SSP1_RXD,
  65. /* AC97 */
  66. GPIO28_AC97_BITCLK,
  67. GPIO29_AC97_SDATA_IN_0,
  68. GPIO30_AC97_SDATA_OUT,
  69. GPIO31_AC97_SYNC,
  70. /* LCD - 16bpp DSTN */
  71. GPIOxx_LCD_DSTN_16BPP,
  72. /* BTUART */
  73. GPIO42_BTUART_RXD,
  74. GPIO43_BTUART_TXD,
  75. GPIO44_BTUART_CTS,
  76. GPIO45_BTUART_RTS,
  77. /* PC Card */
  78. GPIO48_nPOE,
  79. GPIO49_nPWE,
  80. GPIO50_nPIOR,
  81. GPIO51_nPIOW,
  82. GPIO52_nPCE_1,
  83. GPIO53_nPCE_2,
  84. GPIO54_nPSKTSEL,
  85. GPIO55_nPREG,
  86. GPIO56_nPWAIT,
  87. GPIO57_nIOIS16,
  88. /* MMC */
  89. GPIO6_MMC_CLK,
  90. GPIO8_MMC_CS0,
  91. /* wakeup */
  92. GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
  93. };
  94. #define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
  95. #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
  96. void lubbock_set_hexled(uint32_t value)
  97. {
  98. LUB_HEXLED = value;
  99. }
  100. void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
  101. {
  102. unsigned long flags;
  103. local_irq_save(flags);
  104. LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
  105. local_irq_restore(flags);
  106. }
  107. EXPORT_SYMBOL(lubbock_set_misc_wr);
  108. static int lubbock_udc_is_connected(void)
  109. {
  110. return (LUB_MISC_RD & (1 << 9)) == 0;
  111. }
  112. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  113. .udc_is_connected = lubbock_udc_is_connected,
  114. // no D+ pullup; lubbock can't connect/disconnect in software
  115. };
  116. static struct resource sa1111_resources[] = {
  117. [0] = {
  118. .start = 0x10000000,
  119. .end = 0x10001fff,
  120. .flags = IORESOURCE_MEM,
  121. },
  122. [1] = {
  123. .start = LUBBOCK_SA1111_IRQ,
  124. .end = LUBBOCK_SA1111_IRQ,
  125. .flags = IORESOURCE_IRQ,
  126. },
  127. };
  128. static struct sa1111_platform_data sa1111_info = {
  129. .irq_base = LUBBOCK_SA1111_IRQ_BASE,
  130. .disable_devs = SA1111_DEVID_SAC,
  131. };
  132. static struct platform_device sa1111_device = {
  133. .name = "sa1111",
  134. .id = -1,
  135. .num_resources = ARRAY_SIZE(sa1111_resources),
  136. .resource = sa1111_resources,
  137. .dev = {
  138. .platform_data = &sa1111_info,
  139. },
  140. };
  141. /* ADS7846 is connected through SSP ... and if your board has J5 populated,
  142. * you can select it to replace the ucb1400 by switching the touchscreen cable
  143. * (to J5) and poking board registers (as done below). Else it's only useful
  144. * for the temperature sensors.
  145. */
  146. static struct pxa2xx_spi_master pxa_ssp_master_info = {
  147. .num_chipselect = 1,
  148. };
  149. static int lubbock_ads7846_pendown_state(void)
  150. {
  151. /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
  152. return 0;
  153. }
  154. static struct ads7846_platform_data ads_info = {
  155. .model = 7846,
  156. .vref_delay_usecs = 100, /* internal, no cap */
  157. .get_pendown_state = lubbock_ads7846_pendown_state,
  158. // .x_plate_ohms = 500, /* GUESS! */
  159. // .y_plate_ohms = 500, /* GUESS! */
  160. };
  161. static void ads7846_cs(u32 command)
  162. {
  163. static const unsigned TS_nCS = 1 << 11;
  164. lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
  165. }
  166. static struct pxa2xx_spi_chip ads_hw = {
  167. .tx_threshold = 1,
  168. .rx_threshold = 2,
  169. .cs_control = ads7846_cs,
  170. };
  171. static struct spi_board_info spi_board_info[] __initdata = { {
  172. .modalias = "ads7846",
  173. .platform_data = &ads_info,
  174. .controller_data = &ads_hw,
  175. .irq = LUBBOCK_BB_IRQ,
  176. .max_speed_hz = 120000 /* max sample rate at 3V */
  177. * 26 /* command + data + overhead */,
  178. .bus_num = 1,
  179. .chip_select = 0,
  180. },
  181. };
  182. static struct resource smc91x_resources[] = {
  183. [0] = {
  184. .name = "smc91x-regs",
  185. .start = 0x0c000c00,
  186. .end = 0x0c0fffff,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. [1] = {
  190. .start = LUBBOCK_ETH_IRQ,
  191. .end = LUBBOCK_ETH_IRQ,
  192. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  193. },
  194. [2] = {
  195. .name = "smc91x-attrib",
  196. .start = 0x0e000000,
  197. .end = 0x0e0fffff,
  198. .flags = IORESOURCE_MEM,
  199. },
  200. };
  201. static struct smc91x_platdata lubbock_smc91x_info = {
  202. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
  203. };
  204. static struct platform_device smc91x_device = {
  205. .name = "smc91x",
  206. .id = -1,
  207. .num_resources = ARRAY_SIZE(smc91x_resources),
  208. .resource = smc91x_resources,
  209. .dev = {
  210. .platform_data = &lubbock_smc91x_info,
  211. },
  212. };
  213. static struct resource flash_resources[] = {
  214. [0] = {
  215. .start = 0x00000000,
  216. .end = SZ_64M - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. [1] = {
  220. .start = 0x04000000,
  221. .end = 0x04000000 + SZ_64M - 1,
  222. .flags = IORESOURCE_MEM,
  223. },
  224. };
  225. static struct mtd_partition lubbock_partitions[] = {
  226. {
  227. .name = "Bootloader",
  228. .size = 0x00040000,
  229. .offset = 0,
  230. .mask_flags = MTD_WRITEABLE /* force read-only */
  231. },{
  232. .name = "Kernel",
  233. .size = 0x00100000,
  234. .offset = 0x00040000,
  235. },{
  236. .name = "Filesystem",
  237. .size = MTDPART_SIZ_FULL,
  238. .offset = 0x00140000
  239. }
  240. };
  241. static struct flash_platform_data lubbock_flash_data[2] = {
  242. {
  243. .map_name = "cfi_probe",
  244. .parts = lubbock_partitions,
  245. .nr_parts = ARRAY_SIZE(lubbock_partitions),
  246. }, {
  247. .map_name = "cfi_probe",
  248. .parts = NULL,
  249. .nr_parts = 0,
  250. }
  251. };
  252. static struct platform_device lubbock_flash_device[2] = {
  253. {
  254. .name = "pxa2xx-flash",
  255. .id = 0,
  256. .dev = {
  257. .platform_data = &lubbock_flash_data[0],
  258. },
  259. .resource = &flash_resources[0],
  260. .num_resources = 1,
  261. },
  262. {
  263. .name = "pxa2xx-flash",
  264. .id = 1,
  265. .dev = {
  266. .platform_data = &lubbock_flash_data[1],
  267. },
  268. .resource = &flash_resources[1],
  269. .num_resources = 1,
  270. },
  271. };
  272. static struct resource lubbock_cplds_resources[] = {
  273. [0] = {
  274. .start = LUBBOCK_FPGA_PHYS + 0xc0,
  275. .end = LUBBOCK_FPGA_PHYS + 0xe0 - 1,
  276. .flags = IORESOURCE_MEM,
  277. },
  278. [1] = {
  279. .start = PXA_GPIO_TO_IRQ(0),
  280. .end = PXA_GPIO_TO_IRQ(0),
  281. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  282. },
  283. [2] = {
  284. .start = LUBBOCK_IRQ(0),
  285. .end = LUBBOCK_IRQ(6),
  286. .flags = IORESOURCE_IRQ,
  287. },
  288. };
  289. static struct platform_device lubbock_cplds_device = {
  290. .name = "pxa_cplds_irqs",
  291. .id = -1,
  292. .resource = &lubbock_cplds_resources[0],
  293. .num_resources = 3,
  294. };
  295. static struct platform_device *devices[] __initdata = {
  296. &sa1111_device,
  297. &smc91x_device,
  298. &lubbock_flash_device[0],
  299. &lubbock_flash_device[1],
  300. &lubbock_cplds_device,
  301. };
  302. static struct pxafb_mode_info sharp_lm8v31_mode = {
  303. .pixclock = 270000,
  304. .xres = 640,
  305. .yres = 480,
  306. .bpp = 16,
  307. .hsync_len = 1,
  308. .left_margin = 3,
  309. .right_margin = 3,
  310. .vsync_len = 1,
  311. .upper_margin = 0,
  312. .lower_margin = 0,
  313. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  314. .cmap_greyscale = 0,
  315. };
  316. static struct pxafb_mach_info sharp_lm8v31 = {
  317. .modes = &sharp_lm8v31_mode,
  318. .num_modes = 1,
  319. .cmap_inverse = 0,
  320. .cmap_static = 0,
  321. .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
  322. LCD_AC_BIAS_FREQ(255),
  323. };
  324. #define MMC_POLL_RATE msecs_to_jiffies(1000)
  325. static void lubbock_mmc_poll(unsigned long);
  326. static irq_handler_t mmc_detect_int;
  327. static struct timer_list mmc_timer = {
  328. .function = lubbock_mmc_poll,
  329. };
  330. static void lubbock_mmc_poll(unsigned long data)
  331. {
  332. unsigned long flags;
  333. /* clear any previous irq state, then ... */
  334. local_irq_save(flags);
  335. LUB_IRQ_SET_CLR &= ~(1 << 0);
  336. local_irq_restore(flags);
  337. /* poll until mmc/sd card is removed */
  338. if (LUB_IRQ_SET_CLR & (1 << 0))
  339. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  340. else {
  341. (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
  342. enable_irq(LUBBOCK_SD_IRQ);
  343. }
  344. }
  345. static irqreturn_t lubbock_detect_int(int irq, void *data)
  346. {
  347. /* IRQ is level triggered; disable, and poll for removal */
  348. disable_irq(irq);
  349. mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
  350. return mmc_detect_int(irq, data);
  351. }
  352. static int lubbock_mci_init(struct device *dev,
  353. irq_handler_t detect_int,
  354. void *data)
  355. {
  356. /* detect card insert/eject */
  357. mmc_detect_int = detect_int;
  358. init_timer(&mmc_timer);
  359. mmc_timer.data = (unsigned long) data;
  360. return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
  361. 0, "lubbock-sd-detect", data);
  362. }
  363. static int lubbock_mci_get_ro(struct device *dev)
  364. {
  365. return (LUB_MISC_RD & (1 << 2)) != 0;
  366. }
  367. static void lubbock_mci_exit(struct device *dev, void *data)
  368. {
  369. free_irq(LUBBOCK_SD_IRQ, data);
  370. del_timer_sync(&mmc_timer);
  371. }
  372. static struct pxamci_platform_data lubbock_mci_platform_data = {
  373. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  374. .detect_delay_ms = 10,
  375. .init = lubbock_mci_init,
  376. .get_ro = lubbock_mci_get_ro,
  377. .exit = lubbock_mci_exit,
  378. .gpio_card_detect = -1,
  379. .gpio_card_ro = -1,
  380. .gpio_power = -1,
  381. };
  382. static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
  383. {
  384. unsigned long flags;
  385. local_irq_save(flags);
  386. if (mode & IR_SIRMODE) {
  387. LUB_MISC_WR &= ~(1 << 4);
  388. } else if (mode & IR_FIRMODE) {
  389. LUB_MISC_WR |= 1 << 4;
  390. }
  391. pxa2xx_transceiver_mode(dev, mode);
  392. local_irq_restore(flags);
  393. }
  394. static struct pxaficp_platform_data lubbock_ficp_platform_data = {
  395. .gpio_pwdown = -1,
  396. .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
  397. .transceiver_mode = lubbock_irda_transceiver_mode,
  398. };
  399. static void __init lubbock_init(void)
  400. {
  401. int flashboot = (LUB_CONF_SWITCHES & 1);
  402. pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
  403. pxa_set_ffuart_info(NULL);
  404. pxa_set_btuart_info(NULL);
  405. pxa_set_stuart_info(NULL);
  406. clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
  407. pxa_set_udc_info(&udc_info);
  408. pxa_set_fb_info(NULL, &sharp_lm8v31);
  409. pxa_set_mci_info(&lubbock_mci_platform_data);
  410. pxa_set_ficp_info(&lubbock_ficp_platform_data);
  411. pxa_set_ac97_info(NULL);
  412. lubbock_flash_data[0].width = lubbock_flash_data[1].width =
  413. (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
  414. /* Compensate for the nROMBT switch which swaps the flash banks */
  415. printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
  416. flashboot?"Flash":"ROM", flashboot);
  417. lubbock_flash_data[flashboot^1].name = "application-flash";
  418. lubbock_flash_data[flashboot].name = "boot-rom";
  419. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  420. pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
  421. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  422. }
  423. static struct map_desc lubbock_io_desc[] __initdata = {
  424. { /* CPLD */
  425. .virtual = LUBBOCK_FPGA_VIRT,
  426. .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
  427. .length = 0x00100000,
  428. .type = MT_DEVICE
  429. }
  430. };
  431. static void __init lubbock_map_io(void)
  432. {
  433. pxa25x_map_io();
  434. iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
  435. PCFR |= PCFR_OPDE;
  436. }
  437. /*
  438. * Driver for the 8 discrete LEDs available for general use:
  439. * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
  440. * so be sure to not monkey with them here.
  441. */
  442. #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
  443. struct lubbock_led {
  444. struct led_classdev cdev;
  445. u8 mask;
  446. };
  447. /*
  448. * The triggers lines up below will only be used if the
  449. * LED triggers are compiled in.
  450. */
  451. static const struct {
  452. const char *name;
  453. const char *trigger;
  454. } lubbock_leds[] = {
  455. { "lubbock:D28", "default-on", },
  456. { "lubbock:D27", "cpu0", },
  457. { "lubbock:D26", "heartbeat" },
  458. { "lubbock:D25", },
  459. { "lubbock:D24", },
  460. { "lubbock:D23", },
  461. { "lubbock:D22", },
  462. { "lubbock:D21", },
  463. };
  464. static void lubbock_led_set(struct led_classdev *cdev,
  465. enum led_brightness b)
  466. {
  467. struct lubbock_led *led = container_of(cdev,
  468. struct lubbock_led, cdev);
  469. u32 reg = LUB_DISC_BLNK_LED;
  470. if (b != LED_OFF)
  471. reg |= led->mask;
  472. else
  473. reg &= ~led->mask;
  474. LUB_DISC_BLNK_LED = reg;
  475. }
  476. static enum led_brightness lubbock_led_get(struct led_classdev *cdev)
  477. {
  478. struct lubbock_led *led = container_of(cdev,
  479. struct lubbock_led, cdev);
  480. u32 reg = LUB_DISC_BLNK_LED;
  481. return (reg & led->mask) ? LED_FULL : LED_OFF;
  482. }
  483. static int __init lubbock_leds_init(void)
  484. {
  485. int i;
  486. if (!machine_is_lubbock())
  487. return -ENODEV;
  488. /* All ON */
  489. LUB_DISC_BLNK_LED |= 0xff;
  490. for (i = 0; i < ARRAY_SIZE(lubbock_leds); i++) {
  491. struct lubbock_led *led;
  492. led = kzalloc(sizeof(*led), GFP_KERNEL);
  493. if (!led)
  494. break;
  495. led->cdev.name = lubbock_leds[i].name;
  496. led->cdev.brightness_set = lubbock_led_set;
  497. led->cdev.brightness_get = lubbock_led_get;
  498. led->cdev.default_trigger = lubbock_leds[i].trigger;
  499. led->mask = BIT(i);
  500. if (led_classdev_register(NULL, &led->cdev) < 0) {
  501. kfree(led);
  502. break;
  503. }
  504. }
  505. return 0;
  506. }
  507. /*
  508. * Since we may have triggers on any subsystem, defer registration
  509. * until after subsystem_init.
  510. */
  511. fs_initcall(lubbock_leds_init);
  512. #endif
  513. MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
  514. /* Maintainer: MontaVista Software Inc. */
  515. .map_io = lubbock_map_io,
  516. .nr_irqs = LUBBOCK_NR_IRQS,
  517. .init_irq = pxa25x_init_irq,
  518. .handle_irq = pxa25x_handle_irq,
  519. .init_time = pxa_timer_init,
  520. .init_machine = lubbock_init,
  521. .restart = pxa_restart,
  522. MACHINE_END