idp.c 5.9 KB

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