colibri-pxa270-income.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * linux/arch/arm/mach-pxa/income.c
  3. *
  4. * Support for Income s.r.o. SH-Dmaster PXA270 SBC
  5. *
  6. * Copyright (C) 2010
  7. * Marek Vasut <marek.vasut@gmail.com>
  8. * Pavel Revak <palo@bielyvlk.sk>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/bitops.h>
  15. #include <linux/delay.h>
  16. #include <linux/gpio.h>
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/ioport.h>
  20. #include <linux/kernel.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/pwm_backlight.h>
  23. #include <linux/sysdev.h>
  24. #include <asm/irq.h>
  25. #include <asm/mach-types.h>
  26. #include <mach/hardware.h>
  27. #include <mach/mmc.h>
  28. #include <mach/ohci.h>
  29. #include <mach/pxa27x.h>
  30. #include <mach/pxa27x-udc.h>
  31. #include <mach/pxafb.h>
  32. #include <plat/i2c.h>
  33. #include "devices.h"
  34. #include "generic.h"
  35. #define GPIO114_INCOME_ETH_IRQ (114)
  36. #define GPIO0_INCOME_SD_DETECT (0)
  37. #define GPIO0_INCOME_SD_RO (1)
  38. #define GPIO54_INCOME_LED_A (54)
  39. #define GPIO55_INCOME_LED_B (55)
  40. #define GPIO113_INCOME_TS_IRQ (113)
  41. /******************************************************************************
  42. * Pin configuration
  43. ******************************************************************************/
  44. static mfp_cfg_t income_pin_config[] __initdata = {
  45. /* MMC */
  46. GPIO32_MMC_CLK,
  47. GPIO92_MMC_DAT_0,
  48. GPIO109_MMC_DAT_1,
  49. GPIO110_MMC_DAT_2,
  50. GPIO111_MMC_DAT_3,
  51. GPIO112_MMC_CMD,
  52. GPIO0_GPIO, /* SD detect */
  53. GPIO1_GPIO, /* SD read-only */
  54. /* FFUART */
  55. GPIO39_FFUART_TXD,
  56. GPIO34_FFUART_RXD,
  57. /* BFUART */
  58. GPIO42_BTUART_RXD,
  59. GPIO43_BTUART_TXD,
  60. GPIO45_BTUART_RTS,
  61. /* STUART */
  62. GPIO46_STUART_RXD,
  63. GPIO47_STUART_TXD,
  64. /* UHC */
  65. GPIO88_USBH1_PWR,
  66. GPIO89_USBH1_PEN,
  67. /* LCD */
  68. GPIOxx_LCD_TFT_16BPP,
  69. /* PWM */
  70. GPIO16_PWM0_OUT,
  71. /* I2C */
  72. GPIO117_I2C_SCL,
  73. GPIO118_I2C_SDA,
  74. /* LED */
  75. GPIO54_GPIO, /* LED A */
  76. GPIO55_GPIO, /* LED B */
  77. };
  78. /******************************************************************************
  79. * SD/MMC card controller
  80. ******************************************************************************/
  81. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  82. static struct pxamci_platform_data income_mci_platform_data = {
  83. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  84. .gpio_power = -1,
  85. .gpio_card_detect = GPIO0_INCOME_SD_DETECT,
  86. .gpio_card_ro = GPIO0_INCOME_SD_RO,
  87. .detect_delay_ms = 200,
  88. };
  89. static void __init income_mmc_init(void)
  90. {
  91. pxa_set_mci_info(&income_mci_platform_data);
  92. }
  93. #else
  94. static inline void income_mmc_init(void) {}
  95. #endif
  96. /******************************************************************************
  97. * USB Host
  98. ******************************************************************************/
  99. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  100. static struct pxaohci_platform_data income_ohci_info = {
  101. .port_mode = PMM_PERPORT_MODE,
  102. .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  103. };
  104. static void __init income_uhc_init(void)
  105. {
  106. pxa_set_ohci_info(&income_ohci_info);
  107. }
  108. #else
  109. static inline void income_uhc_init(void) {}
  110. #endif
  111. /******************************************************************************
  112. * LED
  113. ******************************************************************************/
  114. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  115. struct gpio_led income_gpio_leds[] = {
  116. {
  117. .name = "income:green:leda",
  118. .default_trigger = "none",
  119. .gpio = GPIO54_INCOME_LED_A,
  120. .active_low = 1,
  121. },
  122. {
  123. .name = "income:green:ledb",
  124. .default_trigger = "none",
  125. .gpio = GPIO55_INCOME_LED_B,
  126. .active_low = 1,
  127. }
  128. };
  129. static struct gpio_led_platform_data income_gpio_led_info = {
  130. .leds = income_gpio_leds,
  131. .num_leds = ARRAY_SIZE(income_gpio_leds),
  132. };
  133. static struct platform_device income_leds = {
  134. .name = "leds-gpio",
  135. .id = -1,
  136. .dev = {
  137. .platform_data = &income_gpio_led_info,
  138. }
  139. };
  140. static void __init income_led_init(void)
  141. {
  142. platform_device_register(&income_leds);
  143. }
  144. #else
  145. static inline void income_led_init(void) {}
  146. #endif
  147. /******************************************************************************
  148. * I2C
  149. ******************************************************************************/
  150. #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
  151. static struct i2c_board_info __initdata income_i2c_devs[] = {
  152. {
  153. I2C_BOARD_INFO("ds1340", 0x68),
  154. }, {
  155. I2C_BOARD_INFO("lm75", 0x4f),
  156. },
  157. };
  158. static void __init income_i2c_init(void)
  159. {
  160. pxa_set_i2c_info(NULL);
  161. pxa27x_set_i2c_power_info(NULL);
  162. i2c_register_board_info(0, ARRAY_AND_SIZE(income_i2c_devs));
  163. }
  164. #else
  165. static inline void income_i2c_init(void) {}
  166. #endif
  167. /******************************************************************************
  168. * Framebuffer
  169. ******************************************************************************/
  170. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  171. static struct pxafb_mode_info income_lcd_modes[] = {
  172. {
  173. .pixclock = 144700,
  174. .xres = 320,
  175. .yres = 240,
  176. .bpp = 32,
  177. .depth = 18,
  178. .left_margin = 10,
  179. .right_margin = 10,
  180. .upper_margin = 7,
  181. .lower_margin = 8,
  182. .hsync_len = 20,
  183. .vsync_len = 2,
  184. .sync = FB_SYNC_VERT_HIGH_ACT,
  185. },
  186. };
  187. static struct pxafb_mach_info income_lcd_screen = {
  188. .modes = income_lcd_modes,
  189. .num_modes = ARRAY_SIZE(income_lcd_modes),
  190. .lcd_conn = LCD_COLOR_TFT_18BPP | LCD_PCLK_EDGE_FALL,
  191. };
  192. static void __init income_lcd_init(void)
  193. {
  194. set_pxa_fb_info(&income_lcd_screen);
  195. }
  196. #else
  197. static inline void income_lcd_init(void) {}
  198. #endif
  199. /******************************************************************************
  200. * Backlight
  201. ******************************************************************************/
  202. #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM__MODULE)
  203. static struct platform_pwm_backlight_data income_backlight_data = {
  204. .pwm_id = 0,
  205. .max_brightness = 0x3ff,
  206. .dft_brightness = 0x1ff,
  207. .pwm_period_ns = 1000000,
  208. };
  209. static struct platform_device income_backlight = {
  210. .name = "pwm-backlight",
  211. .dev = {
  212. .parent = &pxa27x_device_pwm0.dev,
  213. .platform_data = &income_backlight_data,
  214. },
  215. };
  216. static void __init income_pwm_init(void)
  217. {
  218. platform_device_register(&income_backlight);
  219. }
  220. #else
  221. static inline void income_pwm_init(void) {}
  222. #endif
  223. void __init colibri_pxa270_income_boardinit(void)
  224. {
  225. pxa2xx_mfp_config(ARRAY_AND_SIZE(income_pin_config));
  226. pxa_set_ffuart_info(NULL);
  227. pxa_set_btuart_info(NULL);
  228. pxa_set_stuart_info(NULL);
  229. income_mmc_init();
  230. income_uhc_init();
  231. income_led_init();
  232. income_i2c_init();
  233. income_lcd_init();
  234. income_pwm_init();
  235. }