lubbock.c 14 KB

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