balloon3.c 8.4 KB

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