mach-imx27_visstrim_m10.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * mach-imx27_visstrim_m10.c
  3. *
  4. * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com>
  5. *
  6. * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. * MA 02110-1301, USA.
  22. */
  23. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  24. #include <linux/platform_device.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/i2c.h>
  27. #include <linux/i2c/pca953x.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/input.h>
  30. #include <linux/gpio.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/time.h>
  34. #include <mach/common.h>
  35. #include <mach/mmc.h>
  36. #include <mach/iomux.h>
  37. #include <mach/mxc_ehci.h>
  38. #include "devices-imx27.h"
  39. #include "devices.h"
  40. #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
  41. #define SDHC1_IRQ IRQ_GPIOB(25)
  42. static const int visstrim_m10_pins[] __initconst = {
  43. /* UART1 (console) */
  44. PE12_PF_UART1_TXD,
  45. PE13_PF_UART1_RXD,
  46. PE14_PF_UART1_CTS,
  47. PE15_PF_UART1_RTS,
  48. /* FEC */
  49. PD0_AIN_FEC_TXD0,
  50. PD1_AIN_FEC_TXD1,
  51. PD2_AIN_FEC_TXD2,
  52. PD3_AIN_FEC_TXD3,
  53. PD4_AOUT_FEC_RX_ER,
  54. PD5_AOUT_FEC_RXD1,
  55. PD6_AOUT_FEC_RXD2,
  56. PD7_AOUT_FEC_RXD3,
  57. PD8_AF_FEC_MDIO,
  58. PD9_AIN_FEC_MDC,
  59. PD10_AOUT_FEC_CRS,
  60. PD11_AOUT_FEC_TX_CLK,
  61. PD12_AOUT_FEC_RXD0,
  62. PD13_AOUT_FEC_RX_DV,
  63. PD14_AOUT_FEC_RX_CLK,
  64. PD15_AOUT_FEC_COL,
  65. PD16_AIN_FEC_TX_ER,
  66. PF23_AIN_FEC_TX_EN,
  67. /* SDHC1 */
  68. PE18_PF_SD1_D0,
  69. PE19_PF_SD1_D1,
  70. PE20_PF_SD1_D2,
  71. PE21_PF_SD1_D3,
  72. PE22_PF_SD1_CMD,
  73. PE23_PF_SD1_CLK,
  74. /* Both I2Cs */
  75. PD17_PF_I2C_DATA,
  76. PD18_PF_I2C_CLK,
  77. PC5_PF_I2C2_SDA,
  78. PC6_PF_I2C2_SCL,
  79. /* USB OTG */
  80. OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
  81. PC9_PF_USBOTG_DATA0,
  82. PC11_PF_USBOTG_DATA1,
  83. PC10_PF_USBOTG_DATA2,
  84. PC13_PF_USBOTG_DATA3,
  85. PC12_PF_USBOTG_DATA4,
  86. PC7_PF_USBOTG_DATA5,
  87. PC8_PF_USBOTG_DATA6,
  88. PE25_PF_USBOTG_DATA7,
  89. PE24_PF_USBOTG_CLK,
  90. PE2_PF_USBOTG_DIR,
  91. PE0_PF_USBOTG_NXT,
  92. PE1_PF_USBOTG_STP,
  93. PB23_PF_USB_PWR,
  94. PB24_PF_USB_OC,
  95. };
  96. /* GPIOs used as events for applications */
  97. static struct gpio_keys_button visstrim_gpio_keys[] = {
  98. {
  99. .type = EV_KEY,
  100. .code = KEY_RESTART,
  101. .gpio = (GPIO_PORTC + 15),
  102. .desc = "Default config",
  103. .active_low = 0,
  104. .wakeup = 1,
  105. },
  106. {
  107. .type = EV_KEY,
  108. .code = KEY_RECORD,
  109. .gpio = (GPIO_PORTF + 14),
  110. .desc = "Record",
  111. .active_low = 0,
  112. .wakeup = 1,
  113. },
  114. {
  115. .type = EV_KEY,
  116. .code = KEY_STOP,
  117. .gpio = (GPIO_PORTF + 13),
  118. .desc = "Stop",
  119. .active_low = 0,
  120. .wakeup = 1,
  121. }
  122. };
  123. static struct gpio_keys_platform_data visstrim_gpio_keys_platform_data = {
  124. .buttons = visstrim_gpio_keys,
  125. .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
  126. };
  127. static struct platform_device visstrim_gpio_keys_device = {
  128. .name = "gpio-keys",
  129. .id = -1,
  130. .dev = {
  131. .platform_data = &visstrim_gpio_keys_platform_data,
  132. },
  133. };
  134. /* Visstrim_SM10 has a microSD slot connected to sdhc1 */
  135. static int visstrim_m10_sdhc1_init(struct device *dev,
  136. irq_handler_t detect_irq, void *data)
  137. {
  138. int ret;
  139. ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
  140. "mmc-detect", data);
  141. return ret;
  142. }
  143. static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
  144. {
  145. free_irq(SDHC1_IRQ, data);
  146. }
  147. static struct imxmmc_platform_data visstrim_m10_sdhc_pdata = {
  148. .init = visstrim_m10_sdhc1_init,
  149. .exit = visstrim_m10_sdhc1_exit,
  150. };
  151. /* Visstrim_SM10 NOR flash */
  152. static struct physmap_flash_data visstrim_m10_flash_data = {
  153. .width = 2,
  154. };
  155. static struct resource visstrim_m10_flash_resource = {
  156. .start = 0xc0000000,
  157. .end = 0xc0000000 + SZ_64M - 1,
  158. .flags = IORESOURCE_MEM,
  159. };
  160. static struct platform_device visstrim_m10_nor_mtd_device = {
  161. .name = "physmap-flash",
  162. .id = 0,
  163. .dev = {
  164. .platform_data = &visstrim_m10_flash_data,
  165. },
  166. .num_resources = 1,
  167. .resource = &visstrim_m10_flash_resource,
  168. };
  169. static struct platform_device *platform_devices[] __initdata = {
  170. &visstrim_gpio_keys_device,
  171. &visstrim_m10_nor_mtd_device,
  172. };
  173. /* Visstrim_M10 uses UART0 as console */
  174. static const struct imxuart_platform_data uart_pdata __initconst = {
  175. .flags = IMXUART_HAVE_RTSCTS,
  176. };
  177. /* I2C */
  178. static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
  179. .bitrate = 100000,
  180. };
  181. static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
  182. .gpio_base = 240, /* After MX27 internal GPIOs */
  183. .invert = 0,
  184. };
  185. static struct i2c_board_info visstrim_m10_i2c_devices[] = {
  186. {
  187. I2C_BOARD_INFO("pca9555", 0x20),
  188. .platform_data = &visstrim_m10_pca9555_pdata,
  189. },
  190. };
  191. /* USB OTG */
  192. static int otg_phy_init(struct platform_device *pdev)
  193. {
  194. gpio_set_value(OTG_PHY_CS_GPIO, 0);
  195. return 0;
  196. }
  197. static struct mxc_usbh_platform_data visstrim_m10_usbotg_pdata = {
  198. .init = otg_phy_init,
  199. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  200. .flags = MXC_EHCI_POWER_PINS_ENABLED,
  201. };
  202. static void __init visstrim_m10_board_init(void)
  203. {
  204. int ret;
  205. ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
  206. ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
  207. if (ret)
  208. pr_err("Failed to setup pins (%d)\n", ret);
  209. imx27_add_imx_uart0(&uart_pdata);
  210. i2c_register_board_info(0, visstrim_m10_i2c_devices,
  211. ARRAY_SIZE(visstrim_m10_i2c_devices));
  212. imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
  213. imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
  214. mxc_register_device(&mxc_sdhc_device0, &visstrim_m10_sdhc_pdata);
  215. mxc_register_device(&mxc_otg_host, &visstrim_m10_usbotg_pdata);
  216. imx27_add_fec(NULL);
  217. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  218. }
  219. static void __init visstrim_m10_timer_init(void)
  220. {
  221. mx27_clocks_init((unsigned long)25000000);
  222. }
  223. static struct sys_timer visstrim_m10_timer = {
  224. .init = visstrim_m10_timer_init,
  225. };
  226. MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
  227. .boot_params = MX27_PHYS_OFFSET + 0x100,
  228. .map_io = mx27_map_io,
  229. .init_irq = mx27_init_irq,
  230. .init_machine = visstrim_m10_board_init,
  231. .timer = &visstrim_m10_timer,
  232. MACHINE_END