balloon3.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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/mtd/mtd.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/types.h>
  27. #include <asm/setup.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/irq.h>
  30. #include <asm/sizes.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <asm/mach/flash.h>
  35. #include <mach/pxa27x.h>
  36. #include <mach/balloon3.h>
  37. #include <mach/audio.h>
  38. #include <mach/pxafb.h>
  39. #include <mach/mmc.h>
  40. #include <mach/udc.h>
  41. #include <mach/pxa27x-udc.h>
  42. #include <mach/irda.h>
  43. #include <mach/ohci.h>
  44. #include <plat/i2c.h>
  45. #include "generic.h"
  46. #include "devices.h"
  47. /******************************************************************************
  48. * Pin configuration
  49. ******************************************************************************/
  50. static unsigned long balloon3_pin_config[] __initdata = {
  51. /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  52. GPIO42_BTUART_RXD,
  53. GPIO43_BTUART_TXD,
  54. GPIO44_BTUART_CTS,
  55. GPIO45_BTUART_RTS,
  56. /* Wakeup GPIO */
  57. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  58. /* NAND & IDLE LED GPIOs */
  59. GPIO9_GPIO,
  60. GPIO10_GPIO,
  61. };
  62. /******************************************************************************
  63. * Audio and Touchscreen
  64. ******************************************************************************/
  65. static unsigned long balloon3_ac97_pin_config[] = {
  66. GPIO28_AC97_BITCLK,
  67. GPIO29_AC97_SDATA_IN_0,
  68. GPIO30_AC97_SDATA_OUT,
  69. GPIO31_AC97_SYNC,
  70. GPIO113_AC97_nRESET,
  71. };
  72. /******************************************************************************
  73. * Framebuffer
  74. ******************************************************************************/
  75. static void balloon3_backlight_power(int on)
  76. {
  77. pr_debug("%s: power is %s\n", __func__, on ? "on" : "off");
  78. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  79. }
  80. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  81. {
  82. .pixclock = 38000,
  83. .xres = 480,
  84. .yres = 640,
  85. .bpp = 16,
  86. .hsync_len = 8,
  87. .left_margin = 8,
  88. .right_margin = 8,
  89. .vsync_len = 2,
  90. .upper_margin = 4,
  91. .lower_margin = 5,
  92. .sync = 0,
  93. },
  94. };
  95. static struct pxafb_mach_info balloon3_pxafb_info = {
  96. .modes = balloon3_lcd_modes,
  97. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  98. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  99. .pxafb_backlight_power = balloon3_backlight_power,
  100. };
  101. /******************************************************************************
  102. * SD/MMC card controller
  103. ******************************************************************************/
  104. static unsigned long balloon3_mmc_pin_config[] = {
  105. GPIO32_MMC_CLK,
  106. GPIO92_MMC_DAT_0,
  107. GPIO109_MMC_DAT_1,
  108. GPIO110_MMC_DAT_2,
  109. GPIO111_MMC_DAT_3,
  110. GPIO112_MMC_CMD,
  111. };
  112. static void balloon3_mci_setpower(struct device *dev, unsigned int vdd)
  113. {
  114. struct pxamci_platform_data *p_d = dev->platform_data;
  115. if ((1 << vdd) & p_d->ocr_mask) {
  116. pr_debug("%s: on\n", __func__);
  117. /* FIXME something to prod here? */
  118. } else {
  119. pr_debug("%s: off\n", __func__);
  120. /* FIXME something to prod here? */
  121. }
  122. }
  123. static struct pxamci_platform_data balloon3_mci_platform_data = {
  124. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  125. .setpower = balloon3_mci_setpower,
  126. };
  127. /******************************************************************************
  128. * USB Gadget
  129. ******************************************************************************/
  130. static int balloon3_udc_is_connected(void)
  131. {
  132. pr_debug("%s: udc connected\n", __func__);
  133. return 1;
  134. }
  135. static void balloon3_udc_command(int cmd)
  136. {
  137. switch (cmd) {
  138. case PXA2XX_UDC_CMD_CONNECT:
  139. UP2OCR |= (UP2OCR_DPPUE + UP2OCR_DPPUBE);
  140. pr_debug("%s: connect\n", __func__);
  141. break;
  142. case PXA2XX_UDC_CMD_DISCONNECT:
  143. UP2OCR &= ~UP2OCR_DPPUE;
  144. pr_debug("%s: disconnect\n", __func__);
  145. break;
  146. }
  147. }
  148. static struct pxa2xx_udc_mach_info balloon3_udc_info = {
  149. .udc_is_connected = balloon3_udc_is_connected,
  150. .udc_command = balloon3_udc_command,
  151. };
  152. /******************************************************************************
  153. * IrDA
  154. ******************************************************************************/
  155. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  156. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  157. };
  158. /******************************************************************************
  159. * USB Host
  160. ******************************************************************************/
  161. static unsigned long balloon3_ohci_pin_config[] = {
  162. GPIO88_USBH1_PWR,
  163. GPIO89_USBH1_PEN,
  164. };
  165. static struct pxaohci_platform_data balloon3_ohci_platform_data = {
  166. .port_mode = PMM_PERPORT_MODE,
  167. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  168. };
  169. /******************************************************************************
  170. * LED
  171. ******************************************************************************/
  172. static struct gpio_led balloon3_gpio_leds[] = {
  173. {
  174. .name = "balloon3:green:idle",
  175. .default_trigger = "heartbeat",
  176. .gpio = BALLOON3_GPIO_LED_IDLE,
  177. .active_low = 1,
  178. },
  179. {
  180. .name = "balloon3:green:nand",
  181. .default_trigger = "nand-disk",
  182. .gpio = BALLOON3_GPIO_LED_NAND,
  183. .active_low = 1,
  184. },
  185. };
  186. static struct gpio_led_platform_data balloon3_gpio_leds_platform_data = {
  187. .leds = balloon3_gpio_leds,
  188. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  189. };
  190. static struct platform_device balloon3led_device = {
  191. .name = "leds-gpio",
  192. .id = -1,
  193. .dev = {
  194. .platform_data = &balloon3_gpio_leds_platform_data,
  195. },
  196. };
  197. /******************************************************************************
  198. * Compatibility: Parameter parsing
  199. ******************************************************************************/
  200. static unsigned long balloon3_irq_enabled;
  201. static unsigned long balloon3_features_present =
  202. (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
  203. (1 << BALLOON3_FEATURE_AUDIO) |
  204. (1 << BALLOON3_FEATURE_TOPPOLY);
  205. int balloon3_has(enum balloon3_features feature)
  206. {
  207. return (balloon3_features_present & (1 << feature)) ? 1 : 0;
  208. }
  209. EXPORT_SYMBOL_GPL(balloon3_has);
  210. int __init parse_balloon3_features(char *arg)
  211. {
  212. if (!arg)
  213. return 0;
  214. return strict_strtoul(arg, 0, &balloon3_features_present);
  215. }
  216. early_param("balloon3_features", parse_balloon3_features);
  217. /******************************************************************************
  218. * FPGA IRQ
  219. ******************************************************************************/
  220. static void balloon3_mask_irq(unsigned int irq)
  221. {
  222. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  223. balloon3_irq_enabled &= ~(1 << balloon3_irq);
  224. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  225. }
  226. static void balloon3_unmask_irq(unsigned int irq)
  227. {
  228. int balloon3_irq = (irq - BALLOON3_IRQ(0));
  229. balloon3_irq_enabled |= (1 << balloon3_irq);
  230. __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
  231. }
  232. static struct irq_chip balloon3_irq_chip = {
  233. .name = "FPGA",
  234. .ack = balloon3_mask_irq,
  235. .mask = balloon3_mask_irq,
  236. .unmask = balloon3_unmask_irq,
  237. };
  238. static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
  239. {
  240. unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  241. balloon3_irq_enabled;
  242. do {
  243. /* clear useless edge notification */
  244. if (desc->chip->ack)
  245. desc->chip->ack(BALLOON3_AUX_NIRQ);
  246. while (pending) {
  247. irq = BALLOON3_IRQ(0) + __ffs(pending);
  248. generic_handle_irq(irq);
  249. pending &= pending - 1;
  250. }
  251. pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
  252. balloon3_irq_enabled;
  253. } while (pending);
  254. }
  255. static void __init balloon3_init_irq(void)
  256. {
  257. int irq;
  258. pxa27x_init_irq();
  259. /* setup extra Balloon3 irqs */
  260. for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
  261. set_irq_chip(irq, &balloon3_irq_chip);
  262. set_irq_handler(irq, handle_level_irq);
  263. set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
  264. }
  265. set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
  266. set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
  267. pr_debug("%s: chained handler installed - irq %d automatically "
  268. "enabled\n", __func__, BALLOON3_AUX_NIRQ);
  269. }
  270. /******************************************************************************
  271. * Machine init
  272. ******************************************************************************/
  273. static void __init balloon3_init(void)
  274. {
  275. pr_info("Initialising Balloon3\n");
  276. /* system bus arbiter setting
  277. * - Core_Park
  278. * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
  279. */
  280. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  281. pxa_set_ffuart_info(NULL);
  282. pxa_set_btuart_info(NULL);
  283. pxa_set_stuart_info(NULL);
  284. pxa_set_i2c_info(NULL);
  285. if (balloon3_has(BALLOON3_FEATURE_AUDIO)) {
  286. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
  287. pxa_set_ac97_info(NULL);
  288. }
  289. if (balloon3_has(BALLOON3_FEATURE_TOPPOLY)) {
  290. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
  291. gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT,
  292. "LCD Backlight Power");
  293. gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  294. set_pxa_fb_info(&balloon3_pxafb_info);
  295. }
  296. if (balloon3_has(BALLOON3_FEATURE_MMC)) {
  297. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
  298. pxa_set_mci_info(&balloon3_mci_platform_data);
  299. }
  300. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  301. if (balloon3_has(BALLOON3_FEATURE_OHCI)) {
  302. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ohci_pin_config));
  303. pxa_set_ohci_info(&balloon3_ohci_platform_data);
  304. }
  305. pxa_set_udc_info(&balloon3_udc_info);
  306. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  307. platform_device_register(&balloon3led_device);
  308. }
  309. static struct map_desc balloon3_io_desc[] __initdata = {
  310. { /* CPLD/FPGA */
  311. .virtual = BALLOON3_FPGA_VIRT,
  312. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  313. .length = BALLOON3_FPGA_LENGTH,
  314. .type = MT_DEVICE,
  315. },
  316. };
  317. static void __init balloon3_map_io(void)
  318. {
  319. pxa_map_io();
  320. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  321. }
  322. MACHINE_START(BALLOON3, "Balloon3")
  323. /* Maintainer: Nick Bane. */
  324. .phys_io = 0x40000000,
  325. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  326. .map_io = balloon3_map_io,
  327. .init_irq = balloon3_init_irq,
  328. .timer = &pxa_timer,
  329. .init_machine = balloon3_init,
  330. .boot_params = PHYS_OFFSET + 0x100,
  331. MACHINE_END