balloon3.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. /*
  2. * linux/arch/arm/mach-pxa/balloon3.c
  3. *
  4. * Support for Balloonboard.org Balloon3 board.
  5. *
  6. * Author: Nick Bane, Wookey, Jonathan McDowell
  7. * Created: June, 2006
  8. * Copyright: Toby Churchill Ltd
  9. * Derived from mainstone.c, by Nico Pitre
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/sysdev.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/sched.h>
  20. #include <linux/bitops.h>
  21. #include <linux/fb.h>
  22. #include <linux/gpio.h>
  23. #include <linux/ioport.h>
  24. #include <linux/ucb1400.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/types.h>
  28. #include <linux/i2c/pcf857x.h>
  29. #include <linux/mtd/nand.h>
  30. #include <linux/mtd/physmap.h>
  31. #include <linux/regulator/max1586.h>
  32. #include <asm/setup.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/irq.h>
  35. #include <asm/sizes.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/irq.h>
  39. #include <asm/mach/flash.h>
  40. #include <mach/pxa27x.h>
  41. #include <mach/balloon3.h>
  42. #include <mach/audio.h>
  43. #include <mach/pxafb.h>
  44. #include <mach/mmc.h>
  45. #include <mach/udc.h>
  46. #include <mach/pxa27x-udc.h>
  47. #include <mach/irda.h>
  48. #include <mach/ohci.h>
  49. #include <plat/i2c.h>
  50. #include "generic.h"
  51. #include "devices.h"
  52. /******************************************************************************
  53. * Pin configuration
  54. ******************************************************************************/
  55. static unsigned long balloon3_pin_config[] __initdata = {
  56. /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  57. GPIO42_BTUART_RXD,
  58. GPIO43_BTUART_TXD,
  59. GPIO44_BTUART_CTS,
  60. GPIO45_BTUART_RTS,
  61. /* Reset, configured as GPIO wakeup source */
  62. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  63. /* LEDs */
  64. GPIO9_GPIO, /* NAND activity LED */
  65. GPIO10_GPIO, /* Heartbeat LED */
  66. /* AC97 */
  67. GPIO28_AC97_BITCLK,
  68. GPIO29_AC97_SDATA_IN_0,
  69. GPIO30_AC97_SDATA_OUT,
  70. GPIO31_AC97_SYNC,
  71. GPIO113_AC97_nRESET,
  72. GPIO95_GPIO,
  73. /* MMC */
  74. GPIO32_MMC_CLK,
  75. GPIO92_MMC_DAT_0,
  76. GPIO109_MMC_DAT_1,
  77. GPIO110_MMC_DAT_2,
  78. GPIO111_MMC_DAT_3,
  79. GPIO112_MMC_CMD,
  80. /* USB Host */
  81. GPIO88_USBH1_PWR,
  82. GPIO89_USBH1_PEN,
  83. /* PC Card */
  84. GPIO48_nPOE,
  85. GPIO49_nPWE,
  86. GPIO50_nPIOR,
  87. GPIO51_nPIOW,
  88. GPIO85_nPCE_1,
  89. GPIO54_nPCE_2,
  90. GPIO79_PSKTSEL,
  91. GPIO55_nPREG,
  92. GPIO56_nPWAIT,
  93. GPIO57_nIOIS16,
  94. };
  95. /******************************************************************************
  96. * Compatibility: Parameter parsing
  97. ******************************************************************************/
  98. static unsigned long balloon3_irq_enabled;
  99. static unsigned long balloon3_features_present =
  100. (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  101. (1 << BALLOON3_FEATURE_AUDIO) |
  102. (1 << BALLOON3_FEATURE_TOPPOLY);
  103. int balloon3_has(enum balloon3_features feature)
  104. {
  105. return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  106. }
  107. EXPORT_SYMBOL_GPL(balloon3_has);
  108. int __init parse_balloon3_features(char *arg)
  109. {
  110. if (!arg)
  111. return 0;
  112. return strict_strtoul(arg, 0, &balloon3_features_present);
  113. }
  114. early_param("balloon3_features", parse_balloon3_features);
  115. /******************************************************************************
  116. * NOR Flash
  117. ******************************************************************************/
  118. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  119. static struct mtd_partition balloon3_nor_partitions[] = {
  120. {
  121. .name = "Flash",
  122. .offset = 0x00000000,
  123. .size = MTDPART_SIZ_FULL,
  124. }
  125. };
  126. static struct physmap_flash_data balloon3_flash_data[] = {
  127. {
  128. .width = 2, /* bankwidth in bytes */
  129. .parts = balloon3_nor_partitions,
  130. .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
  131. }
  132. };
  133. static struct resource balloon3_flash_resource = {
  134. .start = PXA_CS0_PHYS,
  135. .end = PXA_CS0_PHYS + SZ_64M - 1,
  136. .flags = IORESOURCE_MEM,
  137. };
  138. static struct platform_device balloon3_flash = {
  139. .name = "physmap-flash",
  140. .id = 0,
  141. .resource = &balloon3_flash_resource,
  142. .num_resources = 1,
  143. .dev = {
  144. .platform_data = balloon3_flash_data,
  145. },
  146. };
  147. static void __init balloon3_nor_init(void)
  148. {
  149. platform_device_register(&balloon3_flash);
  150. }
  151. #else
  152. static inline void balloon3_nor_init(void) {}
  153. #endif
  154. /******************************************************************************
  155. * Audio and Touchscreen
  156. ******************************************************************************/
  157. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  158. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  159. static struct ucb1400_pdata vpac270_ucb1400_pdata = {
  160. .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
  161. };
  162. static struct platform_device balloon3_ucb1400_device = {
  163. .name = "ucb1400_core",
  164. .id = -1,
  165. .dev = {
  166. .platform_data = &vpac270_ucb1400_pdata,
  167. },
  168. };
  169. static void __init balloon3_ts_init(void)
  170. {
  171. if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
  172. return;
  173. pxa_set_ac97_info(NULL);
  174. platform_device_register(&balloon3_ucb1400_device);
  175. }
  176. #else
  177. static inline void balloon3_ts_init(void) {}
  178. #endif
  179. /******************************************************************************
  180. * Framebuffer
  181. ******************************************************************************/
  182. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  183. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  184. {
  185. .pixclock = 38000,
  186. .xres = 480,
  187. .yres = 640,
  188. .bpp = 16,
  189. .hsync_len = 8,
  190. .left_margin = 8,
  191. .right_margin = 8,
  192. .vsync_len = 2,
  193. .upper_margin = 4,
  194. .lower_margin = 5,
  195. .sync = 0,
  196. },
  197. };
  198. static struct pxafb_mach_info balloon3_lcd_screen = {
  199. .modes = balloon3_lcd_modes,
  200. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  201. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  202. };
  203. static void balloon3_backlight_power(int on)
  204. {
  205. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  206. }
  207. static void __init balloon3_lcd_init(void)
  208. {
  209. int ret;
  210. if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
  211. return;
  212. ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
  213. if (ret) {
  214. pr_err("Requesting BKL-ON GPIO failed!\n");
  215. goto err;
  216. }
  217. ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  218. if (ret) {
  219. pr_err("Setting BKL-ON GPIO direction failed!\n");
  220. goto err2;
  221. }
  222. balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
  223. set_pxa_fb_info(&balloon3_lcd_screen);
  224. return;
  225. err2:
  226. gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
  227. err:
  228. return;
  229. }
  230. #else
  231. static inline void balloon3_lcd_init(void) {}
  232. #endif
  233. /******************************************************************************
  234. * SD/MMC card controller
  235. ******************************************************************************/
  236. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  237. static struct pxamci_platform_data balloon3_mci_platform_data = {
  238. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  239. .gpio_card_detect = -1,
  240. .gpio_card_ro = -1,
  241. .gpio_power = -1,
  242. .detect_delay_ms = 200,
  243. };
  244. static void __init balloon3_mmc_init(void)
  245. {
  246. pxa_set_mci_info(&balloon3_mci_platform_data);
  247. }
  248. #else
  249. static inline void balloon3_mmc_init(void) {}
  250. #endif
  251. /******************************************************************************
  252. * USB Gadget
  253. ******************************************************************************/
  254. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  255. static void balloon3_udc_command(int cmd)
  256. {
  257. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  258. UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  259. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  260. UP2OCR &= ~UP2OCR_DPPUE;
  261. }
  262. static int balloon3_udc_is_connected(void)
  263. {
  264. return 1;
  265. }
  266. static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
  267. .udc_command = balloon3_udc_command,
  268. .udc_is_connected = balloon3_udc_is_connected,
  269. .gpio_pullup = -1,
  270. };
  271. static void __init balloon3_udc_init(void)
  272. {
  273. pxa_set_udc_info(&balloon3_udc_info);
  274. platform_device_register(&balloon3_gpio_vbus);
  275. }
  276. #else
  277. static inline void balloon3_udc_init(void) {}
  278. #endif
  279. /******************************************************************************
  280. * IrDA
  281. ******************************************************************************/
  282. #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
  283. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  284. .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
  285. };
  286. static void __init balloon3_irda_init(void)
  287. {
  288. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  289. }
  290. #else
  291. static inline void balloon3_irda_init(void) {}
  292. #endif
  293. /******************************************************************************
  294. * USB Host
  295. ******************************************************************************/
  296. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  297. static struct pxaohci_platform_data balloon3_ohci_info = {
  298. .port_mode = PMM_PERPORT_MODE,
  299. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  300. };
  301. static void __init balloon3_uhc_init(void)
  302. {
  303. if (!balloon3_has(BALLOON3_FEATURE_OHCI))
  304. return;
  305. pxa_set_ohci_info(&balloon3_ohci_info);
  306. }
  307. #else
  308. static inline void balloon3_uhc_init(void) {}
  309. #endif
  310. /******************************************************************************
  311. * LEDs
  312. ******************************************************************************/
  313. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  314. struct gpio_led balloon3_gpio_leds[] = {
  315. {
  316. .name = "balloon3:green:idle",
  317. .default_trigger = "heartbeat",
  318. .gpio = BALLOON3_GPIO_LED_IDLE,
  319. .active_low = 1,
  320. }, {
  321. .name = "balloon3:green:nand",
  322. .default_trigger = "nand-disk",
  323. .gpio = BALLOON3_GPIO_LED_NAND,
  324. .active_low = 1,
  325. },
  326. };
  327. static struct gpio_led_platform_data balloon3_gpio_led_info = {
  328. .leds = balloon3_gpio_leds,
  329. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  330. };
  331. static struct platform_device balloon3_leds = {
  332. .name = "leds-gpio",
  333. .id = 0,
  334. .dev = {
  335. .platform_data = &balloon3_gpio_led_info,
  336. }
  337. };
  338. struct gpio_led balloon3_pcf_gpio_leds[] = {
  339. {
  340. .name = "balloon3:green:led0",
  341. .gpio = BALLOON3_PCF_GPIO_LED0,
  342. .active_low = 1,
  343. }, {
  344. .name = "balloon3:green:led1",
  345. .gpio = BALLOON3_PCF_GPIO_LED1,
  346. .active_low = 1,
  347. }, {
  348. .name = "balloon3:orange:led2",
  349. .gpio = BALLOON3_PCF_GPIO_LED2,
  350. .active_low = 1,
  351. }, {
  352. .name = "balloon3:orange:led3",
  353. .gpio = BALLOON3_PCF_GPIO_LED3,
  354. .active_low = 1,
  355. }, {
  356. .name = "balloon3:orange:led4",
  357. .gpio = BALLOON3_PCF_GPIO_LED4,
  358. .active_low = 1,
  359. }, {
  360. .name = "balloon3:orange:led5",
  361. .gpio = BALLOON3_PCF_GPIO_LED5,
  362. .active_low = 1,
  363. }, {
  364. .name = "balloon3:red:led6",
  365. .gpio = BALLOON3_PCF_GPIO_LED6,
  366. .active_low = 1,
  367. }, {
  368. .name = "balloon3:red:led7",
  369. .gpio = BALLOON3_PCF_GPIO_LED7,
  370. .active_low = 1,
  371. },
  372. };
  373. static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = {
  374. .leds = balloon3_pcf_gpio_leds,
  375. .num_leds = ARRAY_SIZE(balloon3_pcf_gpio_leds),
  376. };
  377. static struct platform_device balloon3_pcf_leds = {
  378. .name = "leds-gpio",
  379. .id = 1,
  380. .dev = {
  381. .platform_data = &balloon3_pcf_gpio_led_info,
  382. }
  383. };
  384. static void __init balloon3_leds_init(void)
  385. {
  386. platform_device_register(&balloon3_leds);
  387. platform_device_register(&balloon3_pcf_leds);
  388. }
  389. #else
  390. static inline void balloon3_leds_init(void) {}
  391. #endif
  392. /******************************************************************************
  393. * FPGA IRQ
  394. ******************************************************************************/
  395. static void balloon3_mask_irq(unsigned int irq)
  396. {
  397. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  398. balloon3_irq_enabled &= ~(1 << balloon3_irq);
  399. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  400. }
  401. static void balloon3_unmask_irq(unsigned int irq)
  402. {
  403. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  404. balloon3_irq_enabled |= (1 << balloon3_irq);
  405. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  406. }
  407. static struct irq_chip balloon3_irq_chip = {
  408. .name = "FPGA",
  409. .ack = balloon3_mask_irq,
  410. .mask = balloon3_mask_irq,
  411. .unmask = balloon3_unmask_irq,
  412. };
  413. static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
  414. {
  415. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  416. balloon3_irq_enabled;
  417. do {
  418. /* clear useless edge notification */
  419. if (desc->chip->ack)
  420. desc->chip->ack(BALLOON3_AUX_NIRQ);
  421. while (pending) {
  422. irq = BALLOON3_IRQ(0) + __ffs(pending);
  423. generic_handle_irq(irq);
  424. pending &= pending - 1;
  425. }
  426. pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  427. balloon3_irq_enabled;
  428. } while (pending);
  429. }
  430. static void __init balloon3_init_irq(void)
  431. {
  432. int irq;
  433. pxa27x_init_irq();
  434. /* setup extra Balloon3 irqs */
  435. for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
  436. set_irq_chip(irq, &balloon3_irq_chip);
  437. set_irq_handler(irq, handle_level_irq);
  438. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  439. }
  440. set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  441. set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
  442. pr_debug("%s: chained handler installed - irq %d automatically "
  443. "enabled\n", __func__, BALLOON3_AUX_NIRQ);
  444. }
  445. /******************************************************************************
  446. * GPIO expander
  447. ******************************************************************************/
  448. #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE)
  449. static struct pcf857x_platform_data balloon3_pcf857x_pdata = {
  450. .gpio_base = BALLOON3_PCF_GPIO_BASE,
  451. .n_latch = 0,
  452. .setup = NULL,
  453. .teardown = NULL,
  454. .context = NULL,
  455. };
  456. static struct i2c_board_info __initdata balloon3_i2c_devs[] = {
  457. {
  458. I2C_BOARD_INFO("pcf8574a", 0x38),
  459. .platform_data = &balloon3_pcf857x_pdata,
  460. },
  461. };
  462. static void __init balloon3_i2c_init(void)
  463. {
  464. pxa_set_i2c_info(NULL);
  465. i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs));
  466. }
  467. #else
  468. static inline void balloon3_i2c_init(void) {}
  469. #endif
  470. /******************************************************************************
  471. * NAND
  472. ******************************************************************************/
  473. #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  474. static uint16_t balloon3_ctl =
  475. BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 |
  476. BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3 |
  477. BALLOON3_NAND_CONTROL_FLWP;
  478. static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  479. {
  480. struct nand_chip *this = mtd->priv;
  481. if (ctrl & NAND_CTRL_CHANGE) {
  482. if (ctrl & NAND_CLE)
  483. balloon3_ctl |= BALLOON3_NAND_CONTROL_FLCLE;
  484. else
  485. balloon3_ctl &= ~BALLOON3_NAND_CONTROL_FLCLE;
  486. if (ctrl & NAND_ALE)
  487. balloon3_ctl |= BALLOON3_NAND_CONTROL_FLALE;
  488. else
  489. balloon3_ctl &= ~BALLOON3_NAND_CONTROL_FLALE;
  490. __raw_writel(balloon3_ctl, BALLOON3_NAND_CONTROL_REG);
  491. }
  492. if (cmd != NAND_CMD_NONE)
  493. writeb(cmd, this->IO_ADDR_W);
  494. }
  495. static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip)
  496. {
  497. if (chip < 0 || chip > 3)
  498. return;
  499. balloon3_ctl |= BALLOON3_NAND_CONTROL_FLCE0 |
  500. BALLOON3_NAND_CONTROL_FLCE1 |
  501. BALLOON3_NAND_CONTROL_FLCE2 |
  502. BALLOON3_NAND_CONTROL_FLCE3;
  503. /* Deassert correct nCE line */
  504. balloon3_ctl &= ~(BALLOON3_NAND_CONTROL_FLCE0 << chip);
  505. __raw_writew(balloon3_ctl, BALLOON3_NAND_CONTROL_REG);
  506. }
  507. static int balloon3_nand_probe(struct platform_device *pdev)
  508. {
  509. void __iomem *temp_map;
  510. uint16_t ver;
  511. int ret;
  512. __raw_writew(BALLOON3_NAND_CONTROL2_16BIT, BALLOON3_NAND_CONTROL2_REG);
  513. ver = __raw_readw(BALLOON3_FPGA_VER);
  514. if (ver > 0x0201)
  515. pr_warn("The FPGA code, version 0x%04x, is newer than rel-0.3. "
  516. "NAND support might be broken in this version!", ver);
  517. /* Power up the NAND chips */
  518. ret = gpio_request(BALLOON3_GPIO_RUN_NAND, "NAND");
  519. if (ret)
  520. goto err1;
  521. ret = gpio_direction_output(BALLOON3_GPIO_RUN_NAND, 1);
  522. if (ret)
  523. goto err2;
  524. gpio_set_value(BALLOON3_GPIO_RUN_NAND, 1);
  525. /* Deassert all nCE lines and write protect line */
  526. __raw_writel(balloon3_ctl, BALLOON3_NAND_CONTROL_REG);
  527. return 0;
  528. err2:
  529. gpio_free(BALLOON3_GPIO_RUN_NAND);
  530. err1:
  531. return ret;
  532. }
  533. static void balloon3_nand_remove(struct platform_device *pdev)
  534. {
  535. /* Power down the NAND chips */
  536. gpio_set_value(BALLOON3_GPIO_RUN_NAND, 0);
  537. gpio_free(BALLOON3_GPIO_RUN_NAND);
  538. }
  539. static struct mtd_partition balloon3_partition_info[] = {
  540. [0] = {
  541. .name = "Boot",
  542. .offset = 0,
  543. .size = SZ_4M,
  544. },
  545. [1] = {
  546. .name = "RootFS",
  547. .offset = MTDPART_OFS_APPEND,
  548. .size = MTDPART_SIZ_FULL
  549. },
  550. };
  551. static const char *balloon3_part_probes[] = { "cmdlinepart", NULL };
  552. struct platform_nand_data balloon3_nand_pdata = {
  553. .chip = {
  554. .nr_chips = 4,
  555. .chip_offset = 0,
  556. .nr_partitions = ARRAY_SIZE(balloon3_partition_info),
  557. .partitions = balloon3_partition_info,
  558. .chip_delay = 50,
  559. .part_probe_types = balloon3_part_probes,
  560. },
  561. .ctrl = {
  562. .hwcontrol = 0,
  563. .dev_ready = 0,
  564. .select_chip = balloon3_nand_select_chip,
  565. .cmd_ctrl = balloon3_nand_cmd_ctl,
  566. .probe = balloon3_nand_probe,
  567. .remove = balloon3_nand_remove,
  568. },
  569. };
  570. static struct resource balloon3_nand_resource[] = {
  571. [0] = {
  572. .start = BALLOON3_NAND_BASE,
  573. .end = BALLOON3_NAND_BASE + 0x4,
  574. .flags = IORESOURCE_MEM,
  575. },
  576. };
  577. static struct platform_device balloon3_nand = {
  578. .name = "gen_nand",
  579. .num_resources = ARRAY_SIZE(balloon3_nand_resource),
  580. .resource = balloon3_nand_resource,
  581. .id = -1,
  582. .dev = {
  583. .platform_data = &balloon3_nand_pdata,
  584. }
  585. };
  586. static void __init balloon3_nand_init(void)
  587. {
  588. platform_device_register(&balloon3_nand);
  589. }
  590. #else
  591. static inline void balloon3_nand_init(void) {}
  592. #endif
  593. /******************************************************************************
  594. * Core power regulator
  595. ******************************************************************************/
  596. #if defined(CONFIG_REGULATOR_MAX1586) || \
  597. defined(CONFIG_REGULATOR_MAX1586_MODULE)
  598. static struct regulator_consumer_supply balloon3_max1587a_consumers[] = {
  599. {
  600. .supply = "vcc_core",
  601. }
  602. };
  603. static struct regulator_init_data balloon3_max1587a_v3_info = {
  604. .constraints = {
  605. .name = "vcc_core range",
  606. .min_uV = 900000,
  607. .max_uV = 1705000,
  608. .always_on = 1,
  609. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  610. },
  611. .consumer_supplies = balloon3_max1587a_consumers,
  612. .num_consumer_supplies = ARRAY_SIZE(balloon3_max1587a_consumers),
  613. };
  614. static struct max1586_subdev_data balloon3_max1587a_subdevs[] = {
  615. {
  616. .name = "vcc_core",
  617. .id = MAX1586_V3,
  618. .platform_data = &balloon3_max1587a_v3_info,
  619. }
  620. };
  621. static struct max1586_platform_data balloon3_max1587a_info = {
  622. .subdevs = balloon3_max1587a_subdevs,
  623. .num_subdevs = ARRAY_SIZE(balloon3_max1587a_subdevs),
  624. .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
  625. };
  626. static struct i2c_board_info __initdata balloon3_pi2c_board_info[] = {
  627. {
  628. I2C_BOARD_INFO("max1586", 0x14),
  629. .platform_data = &balloon3_max1587a_info,
  630. },
  631. };
  632. static void __init balloon3_pmic_init(void)
  633. {
  634. pxa27x_set_i2c_power_info(NULL);
  635. i2c_register_board_info(1, ARRAY_AND_SIZE(balloon3_pi2c_board_info));
  636. }
  637. #else
  638. static inline void balloon3_pmic_init(void) {}
  639. #endif
  640. /******************************************************************************
  641. * Machine init
  642. ******************************************************************************/
  643. static void __init balloon3_init(void)
  644. {
  645. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  646. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  647. pxa_set_ffuart_info(NULL);
  648. pxa_set_btuart_info(NULL);
  649. pxa_set_stuart_info(NULL);
  650. balloon3_i2c_init();
  651. balloon3_irda_init();
  652. balloon3_lcd_init();
  653. balloon3_leds_init();
  654. balloon3_mmc_init();
  655. balloon3_nand_init();
  656. balloon3_nor_init();
  657. balloon3_pmic_init();
  658. balloon3_ts_init();
  659. balloon3_udc_init();
  660. balloon3_uhc_init();
  661. }
  662. static struct map_desc balloon3_io_desc[] __initdata = {
  663. { /* CPLD/FPGA */
  664. .virtual = BALLOON3_FPGA_VIRT,
  665. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  666. .length = BALLOON3_FPGA_LENGTH,
  667. .type = MT_DEVICE,
  668. },
  669. };
  670. static void __init balloon3_map_io(void)
  671. {
  672. pxa_map_io();
  673. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  674. }
  675. MACHINE_START(BALLOON3, "Balloon3")
  676. /* Maintainer: Nick Bane. */
  677. .phys_io = 0x40000000,
  678. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  679. .map_io = balloon3_map_io,
  680. .init_irq = balloon3_init_irq,
  681. .timer = &pxa_timer,
  682. .init_machine = balloon3_init,
  683. .boot_params = PHYS_OFFSET + 0x100,
  684. MACHINE_END