idp.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * linux/arch/arm/mach-pxa/idp.c
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Copyright (c) 2001 Cliff Brake, Accelent Systems Inc.
  9. *
  10. * 2001-09-13: Cliff Brake <cbrake@accelent.com>
  11. * Initial code
  12. *
  13. * 2005-02-15: Cliff Brake <cliff.brake@gmail.com>
  14. * <http://www.vibren.com> <http://bec-systems.com>
  15. * Updated for 2.6 kernel
  16. *
  17. */
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/irq.h>
  21. #include <linux/leds.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/fb.h>
  24. #include <asm/setup.h>
  25. #include <asm/memory.h>
  26. #include <asm/mach-types.h>
  27. #include <mach/hardware.h>
  28. #include <asm/irq.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include "pxa25x.h"
  32. #include "idp.h"
  33. #include <linux/platform_data/video-pxafb.h>
  34. #include <mach/bitfield.h>
  35. #include <linux/platform_data/mmc-pxamci.h>
  36. #include <linux/smc91x.h>
  37. #include "generic.h"
  38. #include "devices.h"
  39. /* TODO:
  40. * - add pxa2xx_audio_ops_t device structure
  41. * - Ethernet interrupt
  42. */
  43. static unsigned long idp_pin_config[] __initdata = {
  44. /* LCD */
  45. GPIOxx_LCD_DSTN_16BPP,
  46. /* BTUART */
  47. GPIO42_BTUART_RXD,
  48. GPIO43_BTUART_TXD,
  49. GPIO44_BTUART_CTS,
  50. GPIO45_BTUART_RTS,
  51. /* STUART */
  52. GPIO46_STUART_RXD,
  53. GPIO47_STUART_TXD,
  54. /* MMC */
  55. GPIO6_MMC_CLK,
  56. GPIO8_MMC_CS0,
  57. /* Ethernet */
  58. GPIO33_nCS_5, /* Ethernet CS */
  59. GPIO4_GPIO, /* Ethernet IRQ */
  60. };
  61. static struct resource smc91x_resources[] = {
  62. [0] = {
  63. .start = (IDP_ETH_PHYS + 0x300),
  64. .end = (IDP_ETH_PHYS + 0xfffff),
  65. .flags = IORESOURCE_MEM,
  66. },
  67. [1] = {
  68. .start = PXA_GPIO_TO_IRQ(4),
  69. .end = PXA_GPIO_TO_IRQ(4),
  70. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  71. }
  72. };
  73. static struct smc91x_platdata smc91x_platdata = {
  74. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
  75. SMC91X_USE_DMA | SMC91X_NOWAIT,
  76. .pxa_u16_align4 = true,
  77. };
  78. static struct platform_device smc91x_device = {
  79. .name = "smc91x",
  80. .id = 0,
  81. .num_resources = ARRAY_SIZE(smc91x_resources),
  82. .resource = smc91x_resources,
  83. .dev.platform_data = &smc91x_platdata,
  84. };
  85. static void idp_backlight_power(int on)
  86. {
  87. if (on) {
  88. IDP_CPLD_LCD |= (1<<1);
  89. } else {
  90. IDP_CPLD_LCD &= ~(1<<1);
  91. }
  92. }
  93. static void idp_vlcd(int on)
  94. {
  95. if (on) {
  96. IDP_CPLD_LCD |= (1<<2);
  97. } else {
  98. IDP_CPLD_LCD &= ~(1<<2);
  99. }
  100. }
  101. static void idp_lcd_power(int on, struct fb_var_screeninfo *var)
  102. {
  103. if (on) {
  104. IDP_CPLD_LCD |= (1<<0);
  105. } else {
  106. IDP_CPLD_LCD &= ~(1<<0);
  107. }
  108. /* call idp_vlcd for now as core driver does not support
  109. * both power and vlcd hooks. Note, this is not technically
  110. * the correct sequence, but seems to work. Disclaimer:
  111. * this may eventually damage the display.
  112. */
  113. idp_vlcd(on);
  114. }
  115. static struct pxafb_mode_info sharp_lm8v31_mode = {
  116. .pixclock = 270000,
  117. .xres = 640,
  118. .yres = 480,
  119. .bpp = 16,
  120. .hsync_len = 1,
  121. .left_margin = 3,
  122. .right_margin = 3,
  123. .vsync_len = 1,
  124. .upper_margin = 0,
  125. .lower_margin = 0,
  126. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  127. .cmap_greyscale = 0,
  128. };
  129. static struct pxafb_mach_info sharp_lm8v31 = {
  130. .modes = &sharp_lm8v31_mode,
  131. .num_modes = 1,
  132. .cmap_inverse = 0,
  133. .cmap_static = 0,
  134. .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
  135. LCD_AC_BIAS_FREQ(255),
  136. .pxafb_backlight_power = &idp_backlight_power,
  137. .pxafb_lcd_power = &idp_lcd_power
  138. };
  139. static struct pxamci_platform_data idp_mci_platform_data = {
  140. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  141. .gpio_card_detect = -1,
  142. .gpio_card_ro = -1,
  143. .gpio_power = -1,
  144. };
  145. static void __init idp_init(void)
  146. {
  147. printk("idp_init()\n");
  148. pxa2xx_mfp_config(ARRAY_AND_SIZE(idp_pin_config));
  149. pxa_set_ffuart_info(NULL);
  150. pxa_set_btuart_info(NULL);
  151. pxa_set_stuart_info(NULL);
  152. platform_device_register(&smc91x_device);
  153. //platform_device_register(&mst_audio_device);
  154. pxa_set_fb_info(NULL, &sharp_lm8v31);
  155. pxa_set_mci_info(&idp_mci_platform_data);
  156. }
  157. static struct map_desc idp_io_desc[] __initdata = {
  158. {
  159. .virtual = IDP_COREVOLT_VIRT,
  160. .pfn = __phys_to_pfn(IDP_COREVOLT_PHYS),
  161. .length = IDP_COREVOLT_SIZE,
  162. .type = MT_DEVICE
  163. }, {
  164. .virtual = IDP_CPLD_VIRT,
  165. .pfn = __phys_to_pfn(IDP_CPLD_PHYS),
  166. .length = IDP_CPLD_SIZE,
  167. .type = MT_DEVICE
  168. }
  169. };
  170. static void __init idp_map_io(void)
  171. {
  172. pxa25x_map_io();
  173. iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc));
  174. }
  175. /* LEDs */
  176. #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
  177. struct idp_led {
  178. struct led_classdev cdev;
  179. u8 mask;
  180. };
  181. /*
  182. * The triggers lines up below will only be used if the
  183. * LED triggers are compiled in.
  184. */
  185. static const struct {
  186. const char *name;
  187. const char *trigger;
  188. } idp_leds[] = {
  189. { "idp:green", "heartbeat", },
  190. { "idp:red", "cpu0", },
  191. };
  192. static void idp_led_set(struct led_classdev *cdev,
  193. enum led_brightness b)
  194. {
  195. struct idp_led *led = container_of(cdev,
  196. struct idp_led, cdev);
  197. u32 reg = IDP_CPLD_LED_CONTROL;
  198. if (b != LED_OFF)
  199. reg &= ~led->mask;
  200. else
  201. reg |= led->mask;
  202. IDP_CPLD_LED_CONTROL = reg;
  203. }
  204. static enum led_brightness idp_led_get(struct led_classdev *cdev)
  205. {
  206. struct idp_led *led = container_of(cdev,
  207. struct idp_led, cdev);
  208. return (IDP_CPLD_LED_CONTROL & led->mask) ? LED_OFF : LED_FULL;
  209. }
  210. static int __init idp_leds_init(void)
  211. {
  212. int i;
  213. if (!machine_is_pxa_idp())
  214. return -ENODEV;
  215. for (i = 0; i < ARRAY_SIZE(idp_leds); i++) {
  216. struct idp_led *led;
  217. led = kzalloc(sizeof(*led), GFP_KERNEL);
  218. if (!led)
  219. break;
  220. led->cdev.name = idp_leds[i].name;
  221. led->cdev.brightness_set = idp_led_set;
  222. led->cdev.brightness_get = idp_led_get;
  223. led->cdev.default_trigger = idp_leds[i].trigger;
  224. if (i == 0)
  225. led->mask = IDP_HB_LED;
  226. else
  227. led->mask = IDP_BUSY_LED;
  228. if (led_classdev_register(NULL, &led->cdev) < 0) {
  229. kfree(led);
  230. break;
  231. }
  232. }
  233. return 0;
  234. }
  235. /*
  236. * Since we may have triggers on any subsystem, defer registration
  237. * until after subsystem_init.
  238. */
  239. fs_initcall(idp_leds_init);
  240. #endif
  241. MACHINE_START(PXA_IDP, "Vibren PXA255 IDP")
  242. /* Maintainer: Vibren Technologies */
  243. .map_io = idp_map_io,
  244. .nr_irqs = PXA_NR_IRQS,
  245. .init_irq = pxa25x_init_irq,
  246. .handle_irq = pxa25x_handle_irq,
  247. .init_time = pxa_timer_init,
  248. .init_machine = idp_init,
  249. .restart = pxa_restart,
  250. MACHINE_END