balloon3.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  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/leds.h>
  20. #include <linux/sched.h>
  21. #include <linux/bitops.h>
  22. #include <linux/fb.h>
  23. #include <linux/gpio.h>
  24. #include <linux/ioport.h>
  25. #include <linux/ucb1400.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/types.h>
  29. #include <linux/platform_data/pcf857x.h>
  30. #include <linux/platform_data/i2c-pxa.h>
  31. #include <linux/mtd/rawnand.h>
  32. #include <linux/mtd/physmap.h>
  33. #include <linux/regulator/max1586.h>
  34. #include <asm/setup.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/irq.h>
  37. #include <asm/sizes.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/map.h>
  40. #include <asm/mach/irq.h>
  41. #include <asm/mach/flash.h>
  42. #include "pxa27x.h"
  43. #include <mach/balloon3.h>
  44. #include <mach/audio.h>
  45. #include <linux/platform_data/video-pxafb.h>
  46. #include <linux/platform_data/mmc-pxamci.h>
  47. #include "udc.h"
  48. #include "pxa27x-udc.h"
  49. #include <linux/platform_data/irda-pxaficp.h>
  50. #include <linux/platform_data/usb-ohci-pxa27x.h>
  51. #include "generic.h"
  52. #include "devices.h"
  53. /******************************************************************************
  54. * Pin configuration
  55. ******************************************************************************/
  56. static unsigned long balloon3_pin_config[] __initdata = {
  57. /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  58. GPIO42_BTUART_RXD,
  59. GPIO43_BTUART_TXD,
  60. GPIO44_BTUART_CTS,
  61. GPIO45_BTUART_RTS,
  62. /* Reset, configured as GPIO wakeup source */
  63. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  64. };
  65. /******************************************************************************
  66. * Compatibility: Parameter parsing
  67. ******************************************************************************/
  68. static unsigned long balloon3_irq_enabled;
  69. static unsigned long balloon3_features_present =
  70. (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  71. (1 << BALLOON3_FEATURE_AUDIO) |
  72. (1 << BALLOON3_FEATURE_TOPPOLY);
  73. int balloon3_has(enum balloon3_features feature)
  74. {
  75. return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  76. }
  77. EXPORT_SYMBOL_GPL(balloon3_has);
  78. int __init parse_balloon3_features(char *arg)
  79. {
  80. if (!arg)
  81. return 0;
  82. return kstrtoul(arg, 0, &balloon3_features_present);
  83. }
  84. early_param("balloon3_features", parse_balloon3_features);
  85. /******************************************************************************
  86. * Compact Flash slot
  87. ******************************************************************************/
  88. #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
  89. static unsigned long balloon3_cf_pin_config[] __initdata = {
  90. GPIO48_nPOE,
  91. GPIO49_nPWE,
  92. GPIO50_nPIOR,
  93. GPIO51_nPIOW,
  94. GPIO85_nPCE_1,
  95. GPIO54_nPCE_2,
  96. GPIO79_PSKTSEL,
  97. GPIO55_nPREG,
  98. GPIO56_nPWAIT,
  99. GPIO57_nIOIS16,
  100. };
  101. static void __init balloon3_cf_init(void)
  102. {
  103. if (!balloon3_has(BALLOON3_FEATURE_CF))
  104. return;
  105. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_cf_pin_config));
  106. }
  107. #else
  108. static inline void balloon3_cf_init(void) {}
  109. #endif
  110. /******************************************************************************
  111. * NOR Flash
  112. ******************************************************************************/
  113. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  114. static struct mtd_partition balloon3_nor_partitions[] = {
  115. {
  116. .name = "Flash",
  117. .offset = 0x00000000,
  118. .size = MTDPART_SIZ_FULL,
  119. }
  120. };
  121. static struct physmap_flash_data balloon3_flash_data[] = {
  122. {
  123. .width = 2, /* bankwidth in bytes */
  124. .parts = balloon3_nor_partitions,
  125. .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
  126. }
  127. };
  128. static struct resource balloon3_flash_resource = {
  129. .start = PXA_CS0_PHYS,
  130. .end = PXA_CS0_PHYS + SZ_64M - 1,
  131. .flags = IORESOURCE_MEM,
  132. };
  133. static struct platform_device balloon3_flash = {
  134. .name = "physmap-flash",
  135. .id = 0,
  136. .resource = &balloon3_flash_resource,
  137. .num_resources = 1,
  138. .dev = {
  139. .platform_data = balloon3_flash_data,
  140. },
  141. };
  142. static void __init balloon3_nor_init(void)
  143. {
  144. platform_device_register(&balloon3_flash);
  145. }
  146. #else
  147. static inline void balloon3_nor_init(void) {}
  148. #endif
  149. /******************************************************************************
  150. * Audio and Touchscreen
  151. ******************************************************************************/
  152. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  153. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  154. static unsigned long balloon3_ac97_pin_config[] __initdata = {
  155. GPIO28_AC97_BITCLK,
  156. GPIO29_AC97_SDATA_IN_0,
  157. GPIO30_AC97_SDATA_OUT,
  158. GPIO31_AC97_SYNC,
  159. GPIO113_AC97_nRESET,
  160. GPIO95_GPIO,
  161. };
  162. static struct ucb1400_pdata vpac270_ucb1400_pdata = {
  163. .irq = PXA_GPIO_TO_IRQ(BALLOON3_GPIO_CODEC_IRQ),
  164. };
  165. static struct platform_device balloon3_ucb1400_device = {
  166. .name = "ucb1400_core",
  167. .id = -1,
  168. .dev = {
  169. .platform_data = &vpac270_ucb1400_pdata,
  170. },
  171. };
  172. static void __init balloon3_ts_init(void)
  173. {
  174. if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
  175. return;
  176. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
  177. pxa_set_ac97_info(NULL);
  178. platform_device_register(&balloon3_ucb1400_device);
  179. }
  180. #else
  181. static inline void balloon3_ts_init(void) {}
  182. #endif
  183. /******************************************************************************
  184. * Framebuffer
  185. ******************************************************************************/
  186. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  187. static unsigned long balloon3_lcd_pin_config[] __initdata = {
  188. GPIOxx_LCD_TFT_16BPP,
  189. GPIO99_GPIO,
  190. };
  191. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  192. {
  193. .pixclock = 38000,
  194. .xres = 480,
  195. .yres = 640,
  196. .bpp = 16,
  197. .hsync_len = 8,
  198. .left_margin = 8,
  199. .right_margin = 8,
  200. .vsync_len = 2,
  201. .upper_margin = 4,
  202. .lower_margin = 5,
  203. .sync = 0,
  204. },
  205. };
  206. static struct pxafb_mach_info balloon3_lcd_screen = {
  207. .modes = balloon3_lcd_modes,
  208. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  209. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  210. };
  211. static void balloon3_backlight_power(int on)
  212. {
  213. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  214. }
  215. static void __init balloon3_lcd_init(void)
  216. {
  217. int ret;
  218. if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
  219. return;
  220. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
  221. ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
  222. if (ret) {
  223. pr_err("Requesting BKL-ON GPIO failed!\n");
  224. goto err;
  225. }
  226. ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  227. if (ret) {
  228. pr_err("Setting BKL-ON GPIO direction failed!\n");
  229. goto err2;
  230. }
  231. balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
  232. pxa_set_fb_info(NULL, &balloon3_lcd_screen);
  233. return;
  234. err2:
  235. gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
  236. err:
  237. return;
  238. }
  239. #else
  240. static inline void balloon3_lcd_init(void) {}
  241. #endif
  242. /******************************************************************************
  243. * SD/MMC card controller
  244. ******************************************************************************/
  245. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  246. static unsigned long balloon3_mmc_pin_config[] __initdata = {
  247. GPIO32_MMC_CLK,
  248. GPIO92_MMC_DAT_0,
  249. GPIO109_MMC_DAT_1,
  250. GPIO110_MMC_DAT_2,
  251. GPIO111_MMC_DAT_3,
  252. GPIO112_MMC_CMD,
  253. };
  254. static struct pxamci_platform_data balloon3_mci_platform_data = {
  255. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  256. .gpio_card_detect = -1,
  257. .gpio_card_ro = -1,
  258. .gpio_power = -1,
  259. .detect_delay_ms = 200,
  260. };
  261. static void __init balloon3_mmc_init(void)
  262. {
  263. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
  264. pxa_set_mci_info(&balloon3_mci_platform_data);
  265. }
  266. #else
  267. static inline void balloon3_mmc_init(void) {}
  268. #endif
  269. /******************************************************************************
  270. * USB Gadget
  271. ******************************************************************************/
  272. #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
  273. static void balloon3_udc_command(int cmd)
  274. {
  275. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  276. UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  277. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  278. UP2OCR &= ~UP2OCR_DPPUE;
  279. }
  280. static int balloon3_udc_is_connected(void)
  281. {
  282. return 1;
  283. }
  284. static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
  285. .udc_command = balloon3_udc_command,
  286. .udc_is_connected = balloon3_udc_is_connected,
  287. .gpio_pullup = -1,
  288. };
  289. static void __init balloon3_udc_init(void)
  290. {
  291. pxa_set_udc_info(&balloon3_udc_info);
  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(struct irq_desc *desc)
  441. {
  442. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  443. balloon3_irq_enabled;
  444. do {
  445. struct irq_data *d = irq_desc_get_irq_data(desc);
  446. struct irq_chip *chip = irq_desc_get_chip(desc);
  447. unsigned int irq;
  448. /* clear useless edge notification */
  449. if (chip->irq_ack)
  450. chip->irq_ack(d);
  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. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  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_to_nand(mtd);
  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. struct platform_nand_data balloon3_nand_pdata = {
  594. .chip = {
  595. .nr_chips = 4,
  596. .chip_offset = 0,
  597. .nr_partitions = ARRAY_SIZE(balloon3_partition_info),
  598. .partitions = balloon3_partition_info,
  599. .chip_delay = 50,
  600. },
  601. .ctrl = {
  602. .dev_ready = balloon3_nand_dev_ready,
  603. .select_chip = balloon3_nand_select_chip,
  604. .cmd_ctrl = balloon3_nand_cmd_ctl,
  605. .probe = balloon3_nand_probe,
  606. .remove = balloon3_nand_remove,
  607. },
  608. };
  609. static struct resource balloon3_nand_resource[] = {
  610. [0] = {
  611. .start = BALLOON3_NAND_BASE,
  612. .end = BALLOON3_NAND_BASE + 0x4,
  613. .flags = IORESOURCE_MEM,
  614. },
  615. };
  616. static struct platform_device balloon3_nand = {
  617. .name = "gen_nand",
  618. .num_resources = ARRAY_SIZE(balloon3_nand_resource),
  619. .resource = balloon3_nand_resource,
  620. .id = -1,
  621. .dev = {
  622. .platform_data = &balloon3_nand_pdata,
  623. }
  624. };
  625. static void __init balloon3_nand_init(void)
  626. {
  627. platform_device_register(&balloon3_nand);
  628. }
  629. #else
  630. static inline void balloon3_nand_init(void) {}
  631. #endif
  632. /******************************************************************************
  633. * Core power regulator
  634. ******************************************************************************/
  635. #if defined(CONFIG_REGULATOR_MAX1586) || \
  636. defined(CONFIG_REGULATOR_MAX1586_MODULE)
  637. static struct regulator_consumer_supply balloon3_max1587a_consumers[] = {
  638. REGULATOR_SUPPLY("vcc_core", NULL),
  639. };
  640. static struct regulator_init_data balloon3_max1587a_v3_info = {
  641. .constraints = {
  642. .name = "vcc_core range",
  643. .min_uV = 900000,
  644. .max_uV = 1705000,
  645. .always_on = 1,
  646. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  647. },
  648. .consumer_supplies = balloon3_max1587a_consumers,
  649. .num_consumer_supplies = ARRAY_SIZE(balloon3_max1587a_consumers),
  650. };
  651. static struct max1586_subdev_data balloon3_max1587a_subdevs[] = {
  652. {
  653. .name = "vcc_core",
  654. .id = MAX1586_V3,
  655. .platform_data = &balloon3_max1587a_v3_info,
  656. }
  657. };
  658. static struct max1586_platform_data balloon3_max1587a_info = {
  659. .subdevs = balloon3_max1587a_subdevs,
  660. .num_subdevs = ARRAY_SIZE(balloon3_max1587a_subdevs),
  661. .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */
  662. };
  663. static struct i2c_board_info __initdata balloon3_pi2c_board_info[] = {
  664. {
  665. I2C_BOARD_INFO("max1586", 0x14),
  666. .platform_data = &balloon3_max1587a_info,
  667. },
  668. };
  669. static void __init balloon3_pmic_init(void)
  670. {
  671. pxa27x_set_i2c_power_info(NULL);
  672. i2c_register_board_info(1, ARRAY_AND_SIZE(balloon3_pi2c_board_info));
  673. }
  674. #else
  675. static inline void balloon3_pmic_init(void) {}
  676. #endif
  677. /******************************************************************************
  678. * Machine init
  679. ******************************************************************************/
  680. static void __init balloon3_init(void)
  681. {
  682. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  683. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  684. pxa_set_ffuart_info(NULL);
  685. pxa_set_btuart_info(NULL);
  686. pxa_set_stuart_info(NULL);
  687. balloon3_i2c_init();
  688. balloon3_irda_init();
  689. balloon3_lcd_init();
  690. balloon3_leds_init();
  691. balloon3_mmc_init();
  692. balloon3_nand_init();
  693. balloon3_nor_init();
  694. balloon3_pmic_init();
  695. balloon3_ts_init();
  696. balloon3_udc_init();
  697. balloon3_uhc_init();
  698. balloon3_cf_init();
  699. }
  700. static struct map_desc balloon3_io_desc[] __initdata = {
  701. { /* CPLD/FPGA */
  702. .virtual = (unsigned long)BALLOON3_FPGA_VIRT,
  703. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  704. .length = BALLOON3_FPGA_LENGTH,
  705. .type = MT_DEVICE,
  706. },
  707. };
  708. static void __init balloon3_map_io(void)
  709. {
  710. pxa27x_map_io();
  711. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  712. }
  713. MACHINE_START(BALLOON3, "Balloon3")
  714. /* Maintainer: Nick Bane. */
  715. .map_io = balloon3_map_io,
  716. .nr_irqs = BALLOON3_NR_IRQS,
  717. .init_irq = balloon3_init_irq,
  718. .handle_irq = pxa27x_handle_irq,
  719. .init_time = pxa_timer_init,
  720. .init_machine = balloon3_init,
  721. .atag_offset = 0x100,
  722. .restart = pxa_restart,
  723. MACHINE_END