eukrea_mbimxsd51-baseboard.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (C) 2010 Eric Benard - eric@eukrea.com
  3. *
  4. * Based on pcm970-baseboard.c which is :
  5. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. * MA 02110-1301, USA.
  20. */
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. #include <linux/gpio.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/leds.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/input.h>
  28. #include <linux/i2c.h>
  29. #include <video/platform_lcd.h>
  30. #include <linux/backlight.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/time.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/hardware.h>
  36. #include <mach/common.h>
  37. #include <mach/iomux-mx51.h>
  38. #include "devices-imx51.h"
  39. static iomux_v3_cfg_t eukrea_mbimxsd51_pads[] = {
  40. /* LED */
  41. MX51_PAD_NANDF_D10__GPIO3_30,
  42. /* SWITCH */
  43. NEW_PAD_CTRL(MX51_PAD_NANDF_D9__GPIO3_31, PAD_CTL_PUS_22K_UP |
  44. PAD_CTL_PKE | PAD_CTL_SRE_FAST |
  45. PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),
  46. /* UART2 */
  47. MX51_PAD_UART2_RXD__UART2_RXD,
  48. MX51_PAD_UART2_TXD__UART2_TXD,
  49. /* UART 3 */
  50. MX51_PAD_UART3_RXD__UART3_RXD,
  51. MX51_PAD_UART3_TXD__UART3_TXD,
  52. MX51_PAD_KEY_COL4__UART3_RTS,
  53. MX51_PAD_KEY_COL5__UART3_CTS,
  54. /* SD */
  55. MX51_PAD_SD1_CMD__SD1_CMD,
  56. MX51_PAD_SD1_CLK__SD1_CLK,
  57. MX51_PAD_SD1_DATA0__SD1_DATA0,
  58. MX51_PAD_SD1_DATA1__SD1_DATA1,
  59. MX51_PAD_SD1_DATA2__SD1_DATA2,
  60. MX51_PAD_SD1_DATA3__SD1_DATA3,
  61. /* SD1 CD */
  62. NEW_PAD_CTRL(MX51_PAD_GPIO1_0__SD1_CD, PAD_CTL_PUS_22K_UP |
  63. PAD_CTL_PKE | PAD_CTL_SRE_FAST |
  64. PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),
  65. /* SSI */
  66. MX51_PAD_AUD3_BB_TXD__AUD3_TXD,
  67. MX51_PAD_AUD3_BB_RXD__AUD3_RXD,
  68. MX51_PAD_AUD3_BB_CK__AUD3_TXC,
  69. MX51_PAD_AUD3_BB_FS__AUD3_TXFS,
  70. /* LCD Backlight */
  71. MX51_PAD_DI1_D1_CS__GPIO3_4,
  72. /* LCD RST */
  73. MX51_PAD_CSI1_D9__GPIO3_13,
  74. };
  75. #define GPIO_LED1 IMX_GPIO_NR(3, 30)
  76. #define GPIO_SWITCH1 IMX_GPIO_NR(3, 31)
  77. #define GPIO_LCDRST IMX_GPIO_NR(3, 13)
  78. #define GPIO_LCDBL IMX_GPIO_NR(3, 4)
  79. static void eukrea_mbimxsd51_lcd_power_set(struct plat_lcd_data *pd,
  80. unsigned int power)
  81. {
  82. if (power)
  83. gpio_direction_output(GPIO_LCDRST, 1);
  84. else
  85. gpio_direction_output(GPIO_LCDRST, 0);
  86. }
  87. static struct plat_lcd_data eukrea_mbimxsd51_lcd_power_data = {
  88. .set_power = eukrea_mbimxsd51_lcd_power_set,
  89. };
  90. static struct platform_device eukrea_mbimxsd51_lcd_powerdev = {
  91. .name = "platform-lcd",
  92. .dev.platform_data = &eukrea_mbimxsd51_lcd_power_data,
  93. };
  94. static void eukrea_mbimxsd51_bl_set_intensity(int intensity)
  95. {
  96. if (intensity)
  97. gpio_direction_output(GPIO_LCDBL, 1);
  98. else
  99. gpio_direction_output(GPIO_LCDBL, 0);
  100. }
  101. static struct generic_bl_info eukrea_mbimxsd51_bl_info = {
  102. .name = "eukrea_mbimxsd51-bl",
  103. .max_intensity = 0xff,
  104. .default_intensity = 0xff,
  105. .set_bl_intensity = eukrea_mbimxsd51_bl_set_intensity,
  106. };
  107. static struct platform_device eukrea_mbimxsd51_bl_dev = {
  108. .name = "generic-bl",
  109. .id = 1,
  110. .dev = {
  111. .platform_data = &eukrea_mbimxsd51_bl_info,
  112. },
  113. };
  114. static const struct gpio_led eukrea_mbimxsd51_leds[] __initconst = {
  115. {
  116. .name = "led1",
  117. .default_trigger = "heartbeat",
  118. .active_low = 1,
  119. .gpio = GPIO_LED1,
  120. },
  121. };
  122. static const struct gpio_led_platform_data
  123. eukrea_mbimxsd51_led_info __initconst = {
  124. .leds = eukrea_mbimxsd51_leds,
  125. .num_leds = ARRAY_SIZE(eukrea_mbimxsd51_leds),
  126. };
  127. static struct gpio_keys_button eukrea_mbimxsd51_gpio_buttons[] = {
  128. {
  129. .gpio = GPIO_SWITCH1,
  130. .code = BTN_0,
  131. .desc = "BP1",
  132. .active_low = 1,
  133. .wakeup = 1,
  134. },
  135. };
  136. static const struct gpio_keys_platform_data
  137. eukrea_mbimxsd51_button_data __initconst = {
  138. .buttons = eukrea_mbimxsd51_gpio_buttons,
  139. .nbuttons = ARRAY_SIZE(eukrea_mbimxsd51_gpio_buttons),
  140. };
  141. static const struct imxuart_platform_data uart_pdata __initconst = {
  142. .flags = IMXUART_HAVE_RTSCTS,
  143. };
  144. static struct i2c_board_info eukrea_mbimxsd51_i2c_devices[] = {
  145. {
  146. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  147. },
  148. };
  149. static const
  150. struct imx_ssi_platform_data eukrea_mbimxsd51_ssi_pdata __initconst = {
  151. .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
  152. };
  153. static int screen_type;
  154. static int __init eukrea_mbimxsd51_screen_type(char *options)
  155. {
  156. if (!strcmp(options, "dvi"))
  157. screen_type = 1;
  158. else if (!strcmp(options, "tft"))
  159. screen_type = 0;
  160. return 0;
  161. }
  162. __setup("screen_type=", eukrea_mbimxsd51_screen_type);
  163. /*
  164. * system init for baseboard usage. Will be called by cpuimx51sd init.
  165. *
  166. * Add platform devices present on this baseboard and init
  167. * them from CPU side as far as required to use them later on
  168. */
  169. void __init eukrea_mbimxsd51_baseboard_init(void)
  170. {
  171. if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd51_pads,
  172. ARRAY_SIZE(eukrea_mbimxsd51_pads)))
  173. printk(KERN_ERR "error setting mbimxsd pads !\n");
  174. imx51_add_imx_uart(1, NULL);
  175. imx51_add_imx_uart(2, &uart_pdata);
  176. imx51_add_sdhci_esdhc_imx(0, NULL);
  177. imx51_add_imx_ssi(0, &eukrea_mbimxsd51_ssi_pdata);
  178. gpio_request(GPIO_LED1, "LED1");
  179. gpio_direction_output(GPIO_LED1, 1);
  180. gpio_free(GPIO_LED1);
  181. gpio_request(GPIO_SWITCH1, "SWITCH1");
  182. gpio_direction_input(GPIO_SWITCH1);
  183. gpio_free(GPIO_SWITCH1);
  184. gpio_request(GPIO_LCDRST, "LCDRST");
  185. gpio_direction_output(GPIO_LCDRST, 0);
  186. gpio_request(GPIO_LCDBL, "LCDBL");
  187. gpio_direction_output(GPIO_LCDBL, 0);
  188. if (!screen_type) {
  189. platform_device_register(&eukrea_mbimxsd51_bl_dev);
  190. platform_device_register(&eukrea_mbimxsd51_lcd_powerdev);
  191. } else {
  192. gpio_free(GPIO_LCDRST);
  193. gpio_free(GPIO_LCDBL);
  194. }
  195. i2c_register_board_info(0, eukrea_mbimxsd51_i2c_devices,
  196. ARRAY_SIZE(eukrea_mbimxsd51_i2c_devices));
  197. gpio_led_register_device(-1, &eukrea_mbimxsd51_led_info);
  198. imx_add_gpio_keys(&eukrea_mbimxsd51_button_data);
  199. }