balloon3.c 8.7 KB

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