balloon3.c 21 KB

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