balloon3.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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 "pxa27x.h"
  42. #include <mach/balloon3.h>
  43. #include <mach/audio.h>
  44. #include <linux/platform_data/video-pxafb.h>
  45. #include <linux/platform_data/mmc-pxamci.h>
  46. #include "udc.h"
  47. #include "pxa27x-udc.h"
  48. #include <linux/platform_data/irda-pxaficp.h>
  49. #include <linux/platform_data/usb-ohci-pxa27x.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 kstrtoul(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. }
  292. #else
  293. static inline void balloon3_udc_init(void) {}
  294. #endif
  295. /******************************************************************************
  296. * IrDA
  297. ******************************************************************************/
  298. #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
  299. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  300. .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
  301. };
  302. static void __init balloon3_irda_init(void)
  303. {
  304. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  305. }
  306. #else
  307. static inline void balloon3_irda_init(void) {}
  308. #endif
  309. /******************************************************************************
  310. * USB Host
  311. ******************************************************************************/
  312. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  313. static unsigned long balloon3_uhc_pin_config[] __initdata = {
  314. GPIO88_USBH1_PWR,
  315. GPIO89_USBH1_PEN,
  316. };
  317. static struct pxaohci_platform_data balloon3_ohci_info = {
  318. .port_mode = PMM_PERPORT_MODE,
  319. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  320. };
  321. static void __init balloon3_uhc_init(void)
  322. {
  323. if (!balloon3_has(BALLOON3_FEATURE_OHCI))
  324. return;
  325. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_uhc_pin_config));
  326. pxa_set_ohci_info(&balloon3_ohci_info);
  327. }
  328. #else
  329. static inline void balloon3_uhc_init(void) {}
  330. #endif
  331. /******************************************************************************
  332. * LEDs
  333. ******************************************************************************/
  334. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  335. static unsigned long balloon3_led_pin_config[] __initdata = {
  336. GPIO9_GPIO, /* NAND activity LED */
  337. GPIO10_GPIO, /* Heartbeat LED */
  338. };
  339. struct gpio_led balloon3_gpio_leds[] = {
  340. {
  341. .name = "balloon3:green:idle",
  342. .default_trigger = "heartbeat",
  343. .gpio = BALLOON3_GPIO_LED_IDLE,
  344. .active_low = 1,
  345. }, {
  346. .name = "balloon3:green:nand",
  347. .default_trigger = "nand-disk",
  348. .gpio = BALLOON3_GPIO_LED_NAND,
  349. .active_low = 1,
  350. },
  351. };
  352. static struct gpio_led_platform_data balloon3_gpio_led_info = {
  353. .leds = balloon3_gpio_leds,
  354. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  355. };
  356. static struct platform_device balloon3_leds = {
  357. .name = "leds-gpio",
  358. .id = 0,
  359. .dev = {
  360. .platform_data = &balloon3_gpio_led_info,
  361. }
  362. };
  363. struct gpio_led balloon3_pcf_gpio_leds[] = {
  364. {
  365. .name = "balloon3:green:led0",
  366. .gpio = BALLOON3_PCF_GPIO_LED0,
  367. .active_low = 1,
  368. }, {
  369. .name = "balloon3:green:led1",
  370. .gpio = BALLOON3_PCF_GPIO_LED1,
  371. .active_low = 1,
  372. }, {
  373. .name = "balloon3:orange:led2",
  374. .gpio = BALLOON3_PCF_GPIO_LED2,
  375. .active_low = 1,
  376. }, {
  377. .name = "balloon3:orange:led3",
  378. .gpio = BALLOON3_PCF_GPIO_LED3,
  379. .active_low = 1,
  380. }, {
  381. .name = "balloon3:orange:led4",
  382. .gpio = BALLOON3_PCF_GPIO_LED4,
  383. .active_low = 1,
  384. }, {
  385. .name = "balloon3:orange:led5",
  386. .gpio = BALLOON3_PCF_GPIO_LED5,
  387. .active_low = 1,
  388. }, {
  389. .name = "balloon3:red:led6",
  390. .gpio = BALLOON3_PCF_GPIO_LED6,
  391. .active_low = 1,
  392. }, {
  393. .name = "balloon3:red:led7",
  394. .gpio = BALLOON3_PCF_GPIO_LED7,
  395. .active_low = 1,
  396. },
  397. };
  398. static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = {
  399. .leds = balloon3_pcf_gpio_leds,
  400. .num_leds = ARRAY_SIZE(balloon3_pcf_gpio_leds),
  401. };
  402. static struct platform_device balloon3_pcf_leds = {
  403. .name = "leds-gpio",
  404. .id = 1,
  405. .dev = {
  406. .platform_data = &balloon3_pcf_gpio_led_info,
  407. }
  408. };
  409. static void __init balloon3_leds_init(void)
  410. {
  411. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_led_pin_config));
  412. platform_device_register(&balloon3_leds);
  413. platform_device_register(&balloon3_pcf_leds);
  414. }
  415. #else
  416. static inline void balloon3_leds_init(void) {}
  417. #endif
  418. /******************************************************************************
  419. * FPGA IRQ
  420. ******************************************************************************/
  421. static void balloon3_mask_irq(struct irq_data *d)
  422. {
  423. int balloon3_irq = (d->irq - BALLOON3_IRQ(0));
  424. balloon3_irq_enabled &= ~(1 << balloon3_irq);
  425. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  426. }
  427. static void balloon3_unmask_irq(struct irq_data *d)
  428. {
  429. int balloon3_irq = (d->irq - BALLOON3_IRQ(0));
  430. balloon3_irq_enabled |= (1 << balloon3_irq);
  431. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  432. }
  433. static struct irq_chip balloon3_irq_chip = {
  434. .name = "FPGA",
  435. .irq_ack = balloon3_mask_irq,
  436. .irq_mask = balloon3_mask_irq,
  437. .irq_unmask = balloon3_unmask_irq,
  438. };
  439. static void balloon3_irq_handler(struct irq_desc *desc)
  440. {
  441. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  442. balloon3_irq_enabled;
  443. do {
  444. struct irq_data *d = irq_desc_get_irq_data(desc);
  445. struct irq_chip *chip = irq_desc_get_chip(desc);
  446. unsigned int irq;
  447. /* clear useless edge notification */
  448. if (chip->irq_ack)
  449. chip->irq_ack(d);
  450. while (pending) {
  451. irq = BALLOON3_IRQ(0) + __ffs(pending);
  452. generic_handle_irq(irq);
  453. pending &= pending - 1;
  454. }
  455. pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  456. balloon3_irq_enabled;
  457. } while (pending);
  458. }
  459. static void __init balloon3_init_irq(void)
  460. {
  461. int irq;
  462. pxa27x_init_irq();
  463. /* setup extra Balloon3 irqs */
  464. for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
  465. irq_set_chip_and_handler(irq, &balloon3_irq_chip,
  466. handle_level_irq);
  467. irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
  468. }
  469. irq_set_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  470. irq_set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
  471. pr_debug("%s: chained handler installed - irq %d automatically "
  472. "enabled\n", __func__, BALLOON3_AUX_NIRQ);
  473. }
  474. /******************************************************************************
  475. * GPIO expander
  476. ******************************************************************************/
  477. #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE)
  478. static struct pcf857x_platform_data balloon3_pcf857x_pdata = {
  479. .gpio_base = BALLOON3_PCF_GPIO_BASE,
  480. .n_latch = 0,
  481. .setup = NULL,
  482. .teardown = NULL,
  483. .context = NULL,
  484. };
  485. static struct i2c_board_info __initdata balloon3_i2c_devs[] = {
  486. {
  487. I2C_BOARD_INFO("pcf8574a", 0x38),
  488. .platform_data = &balloon3_pcf857x_pdata,
  489. },
  490. };
  491. static void __init balloon3_i2c_init(void)
  492. {
  493. pxa_set_i2c_info(NULL);
  494. i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs));
  495. }
  496. #else
  497. static inline void balloon3_i2c_init(void) {}
  498. #endif
  499. /******************************************************************************
  500. * NAND
  501. ******************************************************************************/
  502. #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  503. static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  504. {
  505. struct nand_chip *this = mtd_to_nand(mtd);
  506. uint8_t balloon3_ctl_set = 0, balloon3_ctl_clr = 0;
  507. if (ctrl & NAND_CTRL_CHANGE) {
  508. if (ctrl & NAND_CLE)
  509. balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLCLE;
  510. else
  511. balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLCLE;
  512. if (ctrl & NAND_ALE)
  513. balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLALE;
  514. else
  515. balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLALE;
  516. if (balloon3_ctl_clr)
  517. __raw_writel(balloon3_ctl_clr,
  518. BALLOON3_NAND_CONTROL_REG);
  519. if (balloon3_ctl_set)
  520. __raw_writel(balloon3_ctl_set,
  521. BALLOON3_NAND_CONTROL_REG +
  522. BALLOON3_FPGA_SETnCLR);
  523. }
  524. if (cmd != NAND_CMD_NONE)
  525. writeb(cmd, this->IO_ADDR_W);
  526. }
  527. static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip)
  528. {
  529. if (chip < 0 || chip > 3)
  530. return;
  531. /* Assert all nCE lines */
  532. __raw_writew(
  533. BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 |
  534. BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3,
  535. BALLOON3_NAND_CONTROL_REG + BALLOON3_FPGA_SETnCLR);
  536. /* Deassert correct nCE line */
  537. __raw_writew(BALLOON3_NAND_CONTROL_FLCE0 << chip,
  538. BALLOON3_NAND_CONTROL_REG);
  539. }
  540. static int balloon3_nand_dev_ready(struct mtd_info *mtd)
  541. {
  542. return __raw_readl(BALLOON3_NAND_STAT_REG) & BALLOON3_NAND_STAT_RNB;
  543. }
  544. static int balloon3_nand_probe(struct platform_device *pdev)
  545. {
  546. uint16_t ver;
  547. int ret;
  548. __raw_writew(BALLOON3_NAND_CONTROL2_16BIT,
  549. BALLOON3_NAND_CONTROL2_REG + BALLOON3_FPGA_SETnCLR);
  550. ver = __raw_readw(BALLOON3_FPGA_VER);
  551. if (ver < 0x4f08)
  552. pr_warn("The FPGA code, version 0x%04x, is too old. "
  553. "NAND support might be broken in this version!", ver);
  554. /* Power up the NAND chips */
  555. ret = gpio_request(BALLOON3_GPIO_RUN_NAND, "NAND");
  556. if (ret)
  557. goto err1;
  558. ret = gpio_direction_output(BALLOON3_GPIO_RUN_NAND, 1);
  559. if (ret)
  560. goto err2;
  561. gpio_set_value(BALLOON3_GPIO_RUN_NAND, 1);
  562. /* Deassert all nCE lines and write protect line */
  563. __raw_writel(
  564. BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 |
  565. BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3 |
  566. BALLOON3_NAND_CONTROL_FLWP,
  567. BALLOON3_NAND_CONTROL_REG + BALLOON3_FPGA_SETnCLR);
  568. return 0;
  569. err2:
  570. gpio_free(BALLOON3_GPIO_RUN_NAND);
  571. err1:
  572. return ret;
  573. }
  574. static void balloon3_nand_remove(struct platform_device *pdev)
  575. {
  576. /* Power down the NAND chips */
  577. gpio_set_value(BALLOON3_GPIO_RUN_NAND, 0);
  578. gpio_free(BALLOON3_GPIO_RUN_NAND);
  579. }
  580. static struct mtd_partition balloon3_partition_info[] = {
  581. [0] = {
  582. .name = "Boot",
  583. .offset = 0,
  584. .size = SZ_4M,
  585. },
  586. [1] = {
  587. .name = "RootFS",
  588. .offset = MTDPART_OFS_APPEND,
  589. .size = MTDPART_SIZ_FULL
  590. },
  591. };
  592. struct platform_nand_data balloon3_nand_pdata = {
  593. .chip = {
  594. .nr_chips = 4,
  595. .chip_offset = 0,
  596. .nr_partitions = ARRAY_SIZE(balloon3_partition_info),
  597. .partitions = balloon3_partition_info,
  598. .chip_delay = 50,
  599. },
  600. .ctrl = {
  601. .hwcontrol = 0,
  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