balloon3.c 21 KB

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