balloon3.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 unsigned long balloon3_ac97_pin_config[] = {
  115. GPIO28_AC97_BITCLK,
  116. GPIO29_AC97_SDATA_IN_0,
  117. GPIO30_AC97_SDATA_OUT,
  118. GPIO31_AC97_SYNC,
  119. GPIO113_AC97_nRESET,
  120. };
  121. static void balloon3_backlight_power(int on)
  122. {
  123. pr_debug("%s: power is %s\n", __func__, on ? "on" : "off");
  124. gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
  125. }
  126. static unsigned long balloon3_lcd_pin_config[] = {
  127. /* LCD - 16bpp Active TFT */
  128. GPIOxx_LCD_TFT_16BPP,
  129. GPIO99_GPIO, /* Backlight */
  130. };
  131. static struct pxafb_mode_info balloon3_lcd_modes[] = {
  132. {
  133. .pixclock = 38000,
  134. .xres = 480,
  135. .yres = 640,
  136. .bpp = 16,
  137. .hsync_len = 8,
  138. .left_margin = 8,
  139. .right_margin = 8,
  140. .vsync_len = 2,
  141. .upper_margin = 4,
  142. .lower_margin = 5,
  143. .sync = 0,
  144. },
  145. };
  146. static struct pxafb_mach_info balloon3_pxafb_info = {
  147. .modes = balloon3_lcd_modes,
  148. .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
  149. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  150. .pxafb_backlight_power = balloon3_backlight_power,
  151. };
  152. static unsigned long balloon3_mmc_pin_config[] = {
  153. GPIO32_MMC_CLK,
  154. GPIO92_MMC_DAT_0,
  155. GPIO109_MMC_DAT_1,
  156. GPIO110_MMC_DAT_2,
  157. GPIO111_MMC_DAT_3,
  158. GPIO112_MMC_CMD,
  159. };
  160. static void balloon3_mci_setpower(struct device *dev, unsigned int vdd)
  161. {
  162. struct pxamci_platform_data *p_d = dev->platform_data;
  163. if ((1 << vdd) & p_d->ocr_mask) {
  164. pr_debug("%s: on\n", __func__);
  165. /* FIXME something to prod here? */
  166. } else {
  167. pr_debug("%s: off\n", __func__);
  168. /* FIXME something to prod here? */
  169. }
  170. }
  171. static struct pxamci_platform_data balloon3_mci_platform_data = {
  172. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  173. .setpower = balloon3_mci_setpower,
  174. };
  175. static int balloon3_udc_is_connected(void)
  176. {
  177. pr_debug("%s: udc connected\n", __func__);
  178. return 1;
  179. }
  180. static void balloon3_udc_command(int cmd)
  181. {
  182. switch (cmd) {
  183. case PXA2XX_UDC_CMD_CONNECT:
  184. UP2OCR |= (UP2OCR_DPPUE + UP2OCR_DPPUBE);
  185. pr_debug("%s: connect\n", __func__);
  186. break;
  187. case PXA2XX_UDC_CMD_DISCONNECT:
  188. UP2OCR &= ~UP2OCR_DPPUE;
  189. pr_debug("%s: disconnect\n", __func__);
  190. break;
  191. }
  192. }
  193. static struct pxa2xx_udc_mach_info balloon3_udc_info = {
  194. .udc_is_connected = balloon3_udc_is_connected,
  195. .udc_command = balloon3_udc_command,
  196. };
  197. static struct pxaficp_platform_data balloon3_ficp_platform_data = {
  198. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  199. };
  200. static unsigned long balloon3_ohci_pin_config[] = {
  201. GPIO88_USBH1_PWR,
  202. GPIO89_USBH1_PEN,
  203. };
  204. static struct pxaohci_platform_data balloon3_ohci_platform_data = {
  205. .port_mode = PMM_PERPORT_MODE,
  206. .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  207. };
  208. static unsigned long balloon3_pin_config[] __initdata = {
  209. /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
  210. GPIO42_BTUART_RXD,
  211. GPIO43_BTUART_TXD,
  212. GPIO44_BTUART_CTS,
  213. GPIO45_BTUART_RTS,
  214. /* Wakeup GPIO */
  215. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
  216. /* NAND & IDLE LED GPIOs */
  217. GPIO9_GPIO,
  218. GPIO10_GPIO,
  219. };
  220. static struct gpio_led balloon3_gpio_leds[] = {
  221. {
  222. .name = "balloon3:green:idle",
  223. .default_trigger = "heartbeat",
  224. .gpio = BALLOON3_GPIO_LED_IDLE,
  225. .active_low = 1,
  226. },
  227. {
  228. .name = "balloon3:green:nand",
  229. .default_trigger = "nand-disk",
  230. .gpio = BALLOON3_GPIO_LED_NAND,
  231. .active_low = 1,
  232. },
  233. };
  234. static struct gpio_led_platform_data balloon3_gpio_leds_platform_data = {
  235. .leds = balloon3_gpio_leds,
  236. .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
  237. };
  238. static struct platform_device balloon3led_device = {
  239. .name = "leds-gpio",
  240. .id = -1,
  241. .dev = {
  242. .platform_data = &balloon3_gpio_leds_platform_data,
  243. },
  244. };
  245. static void __init balloon3_init(void)
  246. {
  247. pr_info("Initialising Balloon3\n");
  248. /* system bus arbiter setting
  249. * - Core_Park
  250. * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
  251. */
  252. ARB_CNTRL = ARB_CORE_PARK | 0x234;
  253. pxa_set_ffuart_info(NULL);
  254. pxa_set_btuart_info(NULL);
  255. pxa_set_stuart_info(NULL);
  256. pxa_set_i2c_info(NULL);
  257. if (balloon3_has(BALLOON3_FEATURE_AUDIO)) {
  258. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
  259. pxa_set_ac97_info(NULL);
  260. }
  261. if (balloon3_has(BALLOON3_FEATURE_TOPPOLY)) {
  262. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
  263. gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT,
  264. "LCD Backlight Power");
  265. gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
  266. set_pxa_fb_info(&balloon3_pxafb_info);
  267. }
  268. if (balloon3_has(BALLOON3_FEATURE_MMC)) {
  269. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
  270. pxa_set_mci_info(&balloon3_mci_platform_data);
  271. }
  272. pxa_set_ficp_info(&balloon3_ficp_platform_data);
  273. if (balloon3_has(BALLOON3_FEATURE_OHCI)) {
  274. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ohci_pin_config));
  275. pxa_set_ohci_info(&balloon3_ohci_platform_data);
  276. }
  277. pxa_set_udc_info(&balloon3_udc_info);
  278. pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
  279. platform_device_register(&balloon3led_device);
  280. }
  281. static struct map_desc balloon3_io_desc[] __initdata = {
  282. { /* CPLD/FPGA */
  283. .virtual = BALLOON3_FPGA_VIRT,
  284. .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
  285. .length = BALLOON3_FPGA_LENGTH,
  286. .type = MT_DEVICE,
  287. },
  288. };
  289. static void __init balloon3_map_io(void)
  290. {
  291. pxa_map_io();
  292. iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
  293. }
  294. MACHINE_START(BALLOON3, "Balloon3")
  295. /* Maintainer: Nick Bane. */
  296. .phys_io = 0x40000000,
  297. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  298. .map_io = balloon3_map_io,
  299. .init_irq = balloon3_init_irq,
  300. .timer = &pxa_timer,
  301. .init_machine = balloon3_init,
  302. .boot_params = PHYS_OFFSET + 0x100,
  303. MACHINE_END