balloon3.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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. /* PC Card */
  80. GPIO48_nPOE,
  81. GPIO49_nPWE,
  82. GPIO50_nPIOR,
  83. GPIO51_nPIOW,
  84. GPIO85_nPCE_1,
  85. GPIO54_nPCE_2,
  86. GPIO79_PSKTSEL,
  87. GPIO55_nPREG,
  88. GPIO56_nPWAIT,
  89. GPIO57_nIOIS16,
  90. };
  91. /******************************************************************************
  92. * Compatibility: Parameter parsing
  93. ******************************************************************************/
  94. static unsigned long balloon3_irq_enabled;
  95. static unsigned long balloon3_features_present =
  96. (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  97. (1 << BALLOON3_FEATURE_AUDIO) |
  98. (1 << BALLOON3_FEATURE_TOPPOLY);
  99. int balloon3_has(enum balloon3_features feature)
  100. {
  101. return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  102. }
  103. EXPORT_SYMBOL_GPL(balloon3_has);
  104. int __init parse_balloon3_features(char *arg)
  105. {
  106. if (!arg)
  107. return 0;
  108. return strict_strtoul(arg, 0, &balloon3_features_present);
  109. }
  110. early_param("balloon3_features", parse_balloon3_features);
  111. /******************************************************************************
  112. * NOR Flash
  113. ******************************************************************************/
  114. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  115. static struct mtd_partition balloon3_nor_partitions[] = {
  116. {
  117. .name = "Flash",
  118. .offset = 0x00000000,
  119. .size = MTDPART_SIZ_FULL,
  120. }
  121. };
  122. static struct physmap_flash_data balloon3_flash_data[] = {
  123. {
  124. .width = 2, /* bankwidth in bytes */
  125. .parts = balloon3_nor_partitions,
  126. .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
  127. }
  128. };
  129. static struct resource balloon3_flash_resource = {
  130. .start = PXA_CS0_PHYS,
  131. .end = PXA_CS0_PHYS + SZ_64M - 1,
  132. .flags = IORESOURCE_MEM,
  133. };
  134. static struct platform_device balloon3_flash = {
  135. .name = "physmap-flash",
  136. .id = 0,
  137. .resource = &balloon3_flash_resource,
  138. .num_resources = 1,
  139. .dev = {
  140. .platform_data = balloon3_flash_data,
  141. },
  142. };
  143. static void __init balloon3_nor_init(void)
  144. {
  145. platform_device_register(&balloon3_flash);
  146. }
  147. #else
  148. static inline void balloon3_nor_init(void) {}
  149. #endif
  150. /******************************************************************************
  151. * Audio and Touchscreen
  152. ******************************************************************************/
  153. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  154. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  155. static struct ucb1400_pdata vpac270_ucb1400_pdata = {
  156. .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
  157. };
  158. static struct platform_device balloon3_ucb1400_device = {
  159. .name = "ucb1400_core",
  160. .id = -1,
  161. .dev = {
  162. .platform_data = &vpac270_ucb1400_pdata,
  163. },
  164. };
  165. static void __init balloon3_ts_init(void)
  166. {
  167. if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
  168. return;
  169. pxa_set_ac97_info(NULL);
  170. platform_device_register(&balloon3_ucb1400_device);
  171. }
  172. #else
  173. static inline void balloon3_ts_init(void) {}
  174. #endif
  175. /******************************************************************************
  176. * Framebuffer
  177. ******************************************************************************/
  178. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  179. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  180. {
  181. .pixclock = 38000,
  182. .xres = 480,
  183. .yres = 640,
  184. .bpp = 16,
  185. .hsync_len = 8,
  186. .left_margin = 8,
  187. .right_margin = 8,
  188. .vsync_len = 2,
  189. .upper_margin = 4,
  190. .lower_margin = 5,
  191. .sync = 0,
  192. },
  193. };
  194. static struct pxafb_mach_info balloon3_lcd_screen = {
  195. .modes = balloon3_lcd_modes,
  196. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  197. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  198. };
  199. static void balloon3_backlight_power(int on)
  200. {
  201. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  202. }
  203. static void __init balloon3_lcd_init(void)
  204. {
  205. int ret;
  206. if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
  207. return;
  208. ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
  209. if (ret) {
  210. pr_err("Requesting BKL-ON GPIO failed!\n");
  211. goto err;
  212. }
  213. ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  214. if (ret) {
  215. pr_err("Setting BKL-ON GPIO direction failed!\n");
  216. goto err2;
  217. }
  218. balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
  219. set_pxa_fb_info(&balloon3_lcd_screen);
  220. return;
  221. err2:
  222. gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
  223. err:
  224. return;
  225. }
  226. #else
  227. static inline void balloon3_lcd_init(void) {}
  228. #endif
  229. /******************************************************************************
  230. * SD/MMC card controller
  231. ******************************************************************************/
  232. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  233. static struct pxamci_platform_data balloon3_mci_platform_data = {
  234. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  235. .gpio_card_detect = -1,
  236. .gpio_card_ro = -1,
  237. .gpio_power = -1,
  238. .detect_delay_ms = 200,
  239. };
  240. static void __init balloon3_mmc_init(void)
  241. {
  242. pxa_set_mci_info(&balloon3_mci_platform_data);
  243. }
  244. #else
  245. static inline void balloon3_mmc_init(void) {}
  246. #endif
  247. /******************************************************************************
  248. * USB Gadget
  249. ******************************************************************************/
  250. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  251. static void balloon3_udc_command(int cmd)
  252. {
  253. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  254. UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
  255. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  256. UP2OCR &= ~UP2OCR_DPPUE;
  257. }
  258. static int balloon3_udc_is_connected(void)
  259. {
  260. return 1;
  261. }
  262. static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
  263. .udc_command = balloon3_udc_command,
  264. .udc_is_connected = balloon3_udc_is_connected,
  265. .gpio_pullup = -1,
  266. };
  267. static void __init balloon3_udc_init(void)
  268. {
  269. pxa_set_udc_info(&balloon3_udc_info);
  270. platform_device_register(&balloon3_gpio_vbus);
  271. }
  272. #else
  273. static inline void balloon3_udc_init(void) {}
  274. #endif
  275. /******************************************************************************
  276. * IrDA
  277. ******************************************************************************/
  278. #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
  279. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  280. .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
  281. };
  282. static void __init balloon3_irda_init(void)
  283. {
  284. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  285. }
  286. #else
  287. static inline void balloon3_irda_init(void) {}
  288. #endif
  289. /******************************************************************************
  290. * USB Host
  291. ******************************************************************************/
  292. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  293. static struct pxaohci_platform_data balloon3_ohci_info = {
  294. .port_mode = PMM_PERPORT_MODE,
  295. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  296. };
  297. static void __init balloon3_uhc_init(void)
  298. {
  299. if (!balloon3_has(BALLOON3_FEATURE_OHCI))
  300. return;
  301. pxa_set_ohci_info(&balloon3_ohci_info);
  302. }
  303. #else
  304. static inline void balloon3_uhc_init(void) {}
  305. #endif
  306. /******************************************************************************
  307. * LEDs
  308. ******************************************************************************/
  309. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  310. struct gpio_led balloon3_gpio_leds[] = {
  311. {
  312. .name = "balloon3:green:idle",
  313. .default_trigger = "heartbeat",
  314. .gpio = BALLOON3_GPIO_LED_IDLE,
  315. .active_low = 1,
  316. }, {
  317. .name = "balloon3:green:nand",
  318. .default_trigger = "nand-disk",
  319. .gpio = BALLOON3_GPIO_LED_NAND,
  320. .active_low = 1,
  321. },
  322. };
  323. static struct gpio_led_platform_data balloon3_gpio_led_info = {
  324. .leds = balloon3_gpio_leds,
  325. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  326. };
  327. static struct platform_device balloon3_leds = {
  328. .name = "leds-gpio",
  329. .id = -1,
  330. .dev = {
  331. .platform_data = &balloon3_gpio_led_info,
  332. }
  333. };
  334. static void __init balloon3_leds_init(void)
  335. {
  336. platform_device_register(&balloon3_leds);
  337. }
  338. #else
  339. static inline void balloon3_leds_init(void) {}
  340. #endif
  341. /******************************************************************************
  342. * FPGA IRQ
  343. ******************************************************************************/
  344. static void balloon3_mask_irq(unsigned int irq)
  345. {
  346. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  347. balloon3_irq_enabled &= ~(1 << balloon3_irq);
  348. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  349. }
  350. static void balloon3_unmask_irq(unsigned int irq)
  351. {
  352. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  353. balloon3_irq_enabled |= (1 << balloon3_irq);
  354. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  355. }
  356. static struct irq_chip balloon3_irq_chip = {
  357. .name = "FPGA",
  358. .ack = balloon3_mask_irq,
  359. .mask = balloon3_mask_irq,
  360. .unmask = balloon3_unmask_irq,
  361. };
  362. static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
  363. {
  364. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  365. balloon3_irq_enabled;
  366. do {
  367. /* clear useless edge notification */
  368. if (desc->chip->ack)
  369. desc->chip->ack(BALLOON3_AUX_NIRQ);
  370. while (pending) {
  371. irq = BALLOON3_IRQ(0) + __ffs(pending);
  372. generic_handle_irq(irq);
  373. pending &= pending - 1;
  374. }
  375. pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  376. balloon3_irq_enabled;
  377. } while (pending);
  378. }
  379. static void __init balloon3_init_irq(void)
  380. {
  381. int irq;
  382. pxa27x_init_irq();
  383. /* setup extra Balloon3 irqs */
  384. for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
  385. set_irq_chip(irq, &balloon3_irq_chip);
  386. set_irq_handler(irq, handle_level_irq);
  387. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  388. }
  389. set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  390. set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
  391. pr_debug("%s: chained handler installed - irq %d automatically "
  392. "enabled\n", __func__, BALLOON3_AUX_NIRQ);
  393. }
  394. /******************************************************************************
  395. * Machine init
  396. ******************************************************************************/
  397. static void __init balloon3_init(void)
  398. {
  399. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  400. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  401. pxa_set_ffuart_info(NULL);
  402. pxa_set_btuart_info(NULL);
  403. pxa_set_stuart_info(NULL);
  404. pxa_set_i2c_info(NULL);
  405. balloon3_irda_init();
  406. balloon3_lcd_init();
  407. balloon3_leds_init();
  408. balloon3_mmc_init();
  409. balloon3_nor_init();
  410. balloon3_ts_init();
  411. balloon3_udc_init();
  412. balloon3_uhc_init();
  413. }
  414. static struct map_desc balloon3_io_desc[] __initdata = {
  415. { /* CPLD/FPGA */
  416. .virtual = BALLOON3_FPGA_VIRT,
  417. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  418. .length = BALLOON3_FPGA_LENGTH,
  419. .type = MT_DEVICE,
  420. },
  421. };
  422. static void __init balloon3_map_io(void)
  423. {
  424. pxa_map_io();
  425. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  426. }
  427. MACHINE_START(BALLOON3, "Balloon3")
  428. /* Maintainer: Nick Bane. */
  429. .phys_io = 0x40000000,
  430. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  431. .map_io = balloon3_map_io,
  432. .init_irq = balloon3_init_irq,
  433. .timer = &pxa_timer,
  434. .init_machine = balloon3_init,
  435. .boot_params = PHYS_OFFSET + 0x100,
  436. MACHINE_END