balloon3.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. /*
  2. * linux/arch/arm/mach-pxa/balloon3.c
  3. *
  4. * Support for Balloonboard.org Balloon3 board.
  5. *
  6. * Author: Nick Bane, Wookey, Jonathan McDowell
  7. * Created: June, 2006
  8. * Copyright: Toby Churchill Ltd
  9. * Derived from mainstone.c, by Nico Pitre
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/sysdev.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/sched.h>
  20. #include <linux/bitops.h>
  21. #include <linux/fb.h>
  22. #include <linux/gpio.h>
  23. #include <linux/ioport.h>
  24. #include <linux/ucb1400.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/types.h>
  28. #include <asm/setup.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/irq.h>
  31. #include <asm/sizes.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/irq.h>
  35. #include <asm/mach/flash.h>
  36. #include <mach/pxa27x.h>
  37. #include <mach/balloon3.h>
  38. #include <mach/audio.h>
  39. #include <mach/pxafb.h>
  40. #include <mach/mmc.h>
  41. #include <mach/udc.h>
  42. #include <mach/pxa27x-udc.h>
  43. #include <mach/irda.h>
  44. #include <mach/ohci.h>
  45. #include <plat/i2c.h>
  46. #include "generic.h"
  47. #include "devices.h"
  48. /******************************************************************************
  49. * Pin configuration
  50. ******************************************************************************/
  51. static unsigned long balloon3_pin_config[] __initdata = {
  52. /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  53. GPIO42_BTUART_RXD,
  54. GPIO43_BTUART_TXD,
  55. GPIO44_BTUART_CTS,
  56. GPIO45_BTUART_RTS,
  57. /* Reset, configured as GPIO wakeup source */
  58. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  59. /* LEDs */
  60. GPIO9_GPIO, /* NAND activity LED */
  61. GPIO10_GPIO, /* Heartbeat LED */
  62. /* AC97 */
  63. GPIO28_AC97_BITCLK,
  64. GPIO29_AC97_SDATA_IN_0,
  65. GPIO30_AC97_SDATA_OUT,
  66. GPIO31_AC97_SYNC,
  67. GPIO113_AC97_nRESET,
  68. GPIO95_GPIO,
  69. /* MMC */
  70. GPIO32_MMC_CLK,
  71. GPIO92_MMC_DAT_0,
  72. GPIO109_MMC_DAT_1,
  73. GPIO110_MMC_DAT_2,
  74. GPIO111_MMC_DAT_3,
  75. GPIO112_MMC_CMD,
  76. /* USB Host */
  77. GPIO88_USBH1_PWR,
  78. GPIO89_USBH1_PEN,
  79. };
  80. /******************************************************************************
  81. * Compatibility: Parameter parsing
  82. ******************************************************************************/
  83. static unsigned long balloon3_irq_enabled;
  84. static unsigned long balloon3_features_present =
  85. (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  86. (1 << BALLOON3_FEATURE_AUDIO) |
  87. (1 << BALLOON3_FEATURE_TOPPOLY);
  88. int balloon3_has(enum balloon3_features feature)
  89. {
  90. return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  91. }
  92. EXPORT_SYMBOL_GPL(balloon3_has);
  93. int __init parse_balloon3_features(char *arg)
  94. {
  95. if (!arg)
  96. return 0;
  97. return strict_strtoul(arg, 0, &balloon3_features_present);
  98. }
  99. early_param("balloon3_features", parse_balloon3_features);
  100. /******************************************************************************
  101. * NOR Flash
  102. ******************************************************************************/
  103. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  104. static struct mtd_partition balloon3_nor_partitions[] = {
  105. {
  106. .name = "Flash",
  107. .offset = 0x00000000,
  108. .size = MTDPART_SIZ_FULL,
  109. }
  110. };
  111. static struct physmap_flash_data balloon3_flash_data[] = {
  112. {
  113. .width = 2, /* bankwidth in bytes */
  114. .parts = balloon3_nor_partitions,
  115. .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
  116. }
  117. };
  118. static struct resource balloon3_flash_resource = {
  119. .start = PXA_CS0_PHYS,
  120. .end = PXA_CS0_PHYS + SZ_64M - 1,
  121. .flags = IORESOURCE_MEM,
  122. };
  123. static struct platform_device balloon3_flash = {
  124. .name = "physmap-flash",
  125. .id = 0,
  126. .resource = &balloon3_flash_resource,
  127. .num_resources = 1,
  128. .dev = {
  129. .platform_data = balloon3_flash_data,
  130. },
  131. };
  132. static void __init balloon3_nor_init(void)
  133. {
  134. platform_device_register(&balloon3_flash);
  135. }
  136. #else
  137. static inline void balloon3_nor_init(void) {}
  138. #endif
  139. /******************************************************************************
  140. * Audio and Touchscreen
  141. ******************************************************************************/
  142. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  143. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  144. static struct ucb1400_pdata vpac270_ucb1400_pdata = {
  145. .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
  146. };
  147. static struct platform_device balloon3_ucb1400_device = {
  148. .name = "ucb1400_core",
  149. .id = -1,
  150. .dev = {
  151. .platform_data = &vpac270_ucb1400_pdata,
  152. },
  153. };
  154. static void __init balloon3_ts_init(void)
  155. {
  156. if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
  157. return;
  158. pxa_set_ac97_info(NULL);
  159. platform_device_register(&balloon3_ucb1400_device);
  160. }
  161. #else
  162. static inline void balloon3_ts_init(void) {}
  163. #endif
  164. /******************************************************************************
  165. * Framebuffer
  166. ******************************************************************************/
  167. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  168. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  169. {
  170. .pixclock = 38000,
  171. .xres = 480,
  172. .yres = 640,
  173. .bpp = 16,
  174. .hsync_len = 8,
  175. .left_margin = 8,
  176. .right_margin = 8,
  177. .vsync_len = 2,
  178. .upper_margin = 4,
  179. .lower_margin = 5,
  180. .sync = 0,
  181. },
  182. };
  183. static struct pxafb_mach_info balloon3_lcd_screen = {
  184. .modes = balloon3_lcd_modes,
  185. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  186. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  187. };
  188. static void balloon3_backlight_power(int on)
  189. {
  190. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  191. }
  192. static void __init balloon3_lcd_init(void)
  193. {
  194. int ret;
  195. if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
  196. return;
  197. ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
  198. if (ret) {
  199. pr_err("Requesting BKL-ON GPIO failed!\n");
  200. goto err;
  201. }
  202. ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  203. if (ret) {
  204. pr_err("Setting BKL-ON GPIO direction failed!\n");
  205. goto err2;
  206. }
  207. balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
  208. set_pxa_fb_info(&balloon3_lcd_screen);
  209. return;
  210. err2:
  211. gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
  212. err:
  213. return;
  214. }
  215. #else
  216. static inline void balloon3_lcd_init(void) {}
  217. #endif
  218. /******************************************************************************
  219. * SD/MMC card controller
  220. ******************************************************************************/
  221. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  222. static struct pxamci_platform_data balloon3_mci_platform_data = {
  223. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  224. .gpio_card_detect = -1,
  225. .gpio_card_ro = -1,
  226. .gpio_power = -1,
  227. .detect_delay_ms = 200,
  228. };
  229. static void __init balloon3_mmc_init(void)
  230. {
  231. pxa_set_mci_info(&balloon3_mci_platform_data);
  232. }
  233. #else
  234. static inline void balloon3_mmc_init(void) {}
  235. #endif
  236. /******************************************************************************
  237. * USB Gadget
  238. ******************************************************************************/
  239. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  240. static void balloon3_udc_command(int cmd)
  241. {
  242. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  243. UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  244. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  245. UP2OCR &= ~UP2OCR_DPPUE;
  246. }
  247. static int balloon3_udc_is_connected(void)
  248. {
  249. return 1;
  250. }
  251. static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
  252. .udc_command = balloon3_udc_command,
  253. .udc_is_connected = balloon3_udc_is_connected,
  254. .gpio_pullup = -1,
  255. };
  256. static void __init balloon3_udc_init(void)
  257. {
  258. pxa_set_udc_info(&balloon3_udc_info);
  259. platform_device_register(&balloon3_gpio_vbus);
  260. }
  261. #else
  262. static inline void balloon3_udc_init(void) {}
  263. #endif
  264. /******************************************************************************
  265. * IrDA
  266. ******************************************************************************/
  267. #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
  268. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  269. .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
  270. };
  271. static void __init balloon3_irda_init(void)
  272. {
  273. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  274. }
  275. #else
  276. static inline void balloon3_irda_init(void) {}
  277. #endif
  278. /******************************************************************************
  279. * USB Host
  280. ******************************************************************************/
  281. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  282. static struct pxaohci_platform_data balloon3_ohci_info = {
  283. .port_mode = PMM_PERPORT_MODE,
  284. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  285. };
  286. static void __init balloon3_uhc_init(void)
  287. {
  288. if (!balloon3_has(BALLOON3_FEATURE_OHCI))
  289. return;
  290. pxa_set_ohci_info(&balloon3_ohci_info);
  291. }
  292. #else
  293. static inline void balloon3_uhc_init(void) {}
  294. #endif
  295. /******************************************************************************
  296. * LEDs
  297. ******************************************************************************/
  298. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  299. struct gpio_led balloon3_gpio_leds[] = {
  300. {
  301. .name = "balloon3:green:idle",
  302. .default_trigger = "heartbeat",
  303. .gpio = BALLOON3_GPIO_LED_IDLE,
  304. .active_low = 1,
  305. }, {
  306. .name = "balloon3:green:nand",
  307. .default_trigger = "nand-disk",
  308. .gpio = BALLOON3_GPIO_LED_NAND,
  309. .active_low = 1,
  310. },
  311. };
  312. static struct gpio_led_platform_data balloon3_gpio_led_info = {
  313. .leds = balloon3_gpio_leds,
  314. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  315. };
  316. static struct platform_device balloon3_leds = {
  317. .name = "leds-gpio",
  318. .id = -1,
  319. .dev = {
  320. .platform_data = &balloon3_gpio_led_info,
  321. }
  322. };
  323. static void __init balloon3_leds_init(void)
  324. {
  325. platform_device_register(&balloon3_leds);
  326. }
  327. #else
  328. static inline void balloon3_leds_init(void) {}
  329. #endif
  330. /******************************************************************************
  331. * FPGA IRQ
  332. ******************************************************************************/
  333. static void balloon3_mask_irq(unsigned int irq)
  334. {
  335. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  336. balloon3_irq_enabled &= ~(1 << balloon3_irq);
  337. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  338. }
  339. static void balloon3_unmask_irq(unsigned int irq)
  340. {
  341. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  342. balloon3_irq_enabled |= (1 << balloon3_irq);
  343. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  344. }
  345. static struct irq_chip balloon3_irq_chip = {
  346. .name = "FPGA",
  347. .ack = balloon3_mask_irq,
  348. .mask = balloon3_mask_irq,
  349. .unmask = balloon3_unmask_irq,
  350. };
  351. static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
  352. {
  353. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  354. balloon3_irq_enabled;
  355. do {
  356. /* clear useless edge notification */
  357. if (desc->chip->ack)
  358. desc->chip->ack(BALLOON3_AUX_NIRQ);
  359. while (pending) {
  360. irq = BALLOON3_IRQ(0) + __ffs(pending);
  361. generic_handle_irq(irq);
  362. pending &= pending - 1;
  363. }
  364. pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  365. balloon3_irq_enabled;
  366. } while (pending);
  367. }
  368. static void __init balloon3_init_irq(void)
  369. {
  370. int irq;
  371. pxa27x_init_irq();
  372. /* setup extra Balloon3 irqs */
  373. for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
  374. set_irq_chip(irq, &balloon3_irq_chip);
  375. set_irq_handler(irq, handle_level_irq);
  376. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  377. }
  378. set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  379. set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
  380. pr_debug("%s: chained handler installed - irq %d automatically "
  381. "enabled\n", __func__, BALLOON3_AUX_NIRQ);
  382. }
  383. /******************************************************************************
  384. * Machine init
  385. ******************************************************************************/
  386. static void __init balloon3_init(void)
  387. {
  388. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  389. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  390. pxa_set_ffuart_info(NULL);
  391. pxa_set_btuart_info(NULL);
  392. pxa_set_stuart_info(NULL);
  393. pxa_set_i2c_info(NULL);
  394. balloon3_irda_init();
  395. balloon3_lcd_init();
  396. balloon3_leds_init();
  397. balloon3_mmc_init();
  398. balloon3_nor_init();
  399. balloon3_ts_init();
  400. balloon3_udc_init();
  401. balloon3_uhc_init();
  402. }
  403. static struct map_desc balloon3_io_desc[] __initdata = {
  404. { /* CPLD/FPGA */
  405. .virtual = BALLOON3_FPGA_VIRT,
  406. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  407. .length = BALLOON3_FPGA_LENGTH,
  408. .type = MT_DEVICE,
  409. },
  410. };
  411. static void __init balloon3_map_io(void)
  412. {
  413. pxa_map_io();
  414. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  415. }
  416. MACHINE_START(BALLOON3, "Balloon3")
  417. /* Maintainer: Nick Bane. */
  418. .phys_io = 0x40000000,
  419. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  420. .map_io = balloon3_map_io,
  421. .init_irq = balloon3_init_irq,
  422. .timer = &pxa_timer,
  423. .init_machine = balloon3_init,
  424. .boot_params = PHYS_OFFSET + 0x100,
  425. MACHINE_END