mach-imx27_visstrim_m10.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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/input.h>
  29. #include <linux/gpio.h>
  30. #include <linux/delay.h>
  31. #include <sound/tlv320aic32x4.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/time.h>
  35. #include <mach/common.h>
  36. #include <mach/iomux-mx27.h>
  37. #include "devices-imx27.h"
  38. #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
  39. #define SDHC1_IRQ IRQ_GPIOB(25)
  40. static const int visstrim_m10_pins[] __initconst = {
  41. /* UART1 (console) */
  42. PE12_PF_UART1_TXD,
  43. PE13_PF_UART1_RXD,
  44. PE14_PF_UART1_CTS,
  45. PE15_PF_UART1_RTS,
  46. /* FEC */
  47. PD0_AIN_FEC_TXD0,
  48. PD1_AIN_FEC_TXD1,
  49. PD2_AIN_FEC_TXD2,
  50. PD3_AIN_FEC_TXD3,
  51. PD4_AOUT_FEC_RX_ER,
  52. PD5_AOUT_FEC_RXD1,
  53. PD6_AOUT_FEC_RXD2,
  54. PD7_AOUT_FEC_RXD3,
  55. PD8_AF_FEC_MDIO,
  56. PD9_AIN_FEC_MDC,
  57. PD10_AOUT_FEC_CRS,
  58. PD11_AOUT_FEC_TX_CLK,
  59. PD12_AOUT_FEC_RXD0,
  60. PD13_AOUT_FEC_RX_DV,
  61. PD14_AOUT_FEC_RX_CLK,
  62. PD15_AOUT_FEC_COL,
  63. PD16_AIN_FEC_TX_ER,
  64. PF23_AIN_FEC_TX_EN,
  65. /* SSI1 */
  66. PC20_PF_SSI1_FS,
  67. PC21_PF_SSI1_RXD,
  68. PC22_PF_SSI1_TXD,
  69. PC23_PF_SSI1_CLK,
  70. /* SDHC1 */
  71. PE18_PF_SD1_D0,
  72. PE19_PF_SD1_D1,
  73. PE20_PF_SD1_D2,
  74. PE21_PF_SD1_D3,
  75. PE22_PF_SD1_CMD,
  76. PE23_PF_SD1_CLK,
  77. /* Both I2Cs */
  78. PD17_PF_I2C_DATA,
  79. PD18_PF_I2C_CLK,
  80. PC5_PF_I2C2_SDA,
  81. PC6_PF_I2C2_SCL,
  82. /* USB OTG */
  83. OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
  84. PC9_PF_USBOTG_DATA0,
  85. PC11_PF_USBOTG_DATA1,
  86. PC10_PF_USBOTG_DATA2,
  87. PC13_PF_USBOTG_DATA3,
  88. PC12_PF_USBOTG_DATA4,
  89. PC7_PF_USBOTG_DATA5,
  90. PC8_PF_USBOTG_DATA6,
  91. PE25_PF_USBOTG_DATA7,
  92. PE24_PF_USBOTG_CLK,
  93. PE2_PF_USBOTG_DIR,
  94. PE0_PF_USBOTG_NXT,
  95. PE1_PF_USBOTG_STP,
  96. PB23_PF_USB_PWR,
  97. PB24_PF_USB_OC,
  98. };
  99. /* GPIOs used as events for applications */
  100. static struct gpio_keys_button visstrim_gpio_keys[] = {
  101. {
  102. .type = EV_KEY,
  103. .code = KEY_RESTART,
  104. .gpio = (GPIO_PORTC + 15),
  105. .desc = "Default config",
  106. .active_low = 0,
  107. .wakeup = 1,
  108. },
  109. {
  110. .type = EV_KEY,
  111. .code = KEY_RECORD,
  112. .gpio = (GPIO_PORTF + 14),
  113. .desc = "Record",
  114. .active_low = 0,
  115. .wakeup = 1,
  116. },
  117. {
  118. .type = EV_KEY,
  119. .code = KEY_STOP,
  120. .gpio = (GPIO_PORTF + 13),
  121. .desc = "Stop",
  122. .active_low = 0,
  123. .wakeup = 1,
  124. }
  125. };
  126. static const struct gpio_keys_platform_data
  127. visstrim_gpio_keys_platform_data __initconst = {
  128. .buttons = visstrim_gpio_keys,
  129. .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
  130. };
  131. /* Visstrim_SM10 has a microSD slot connected to sdhc1 */
  132. static int visstrim_m10_sdhc1_init(struct device *dev,
  133. irq_handler_t detect_irq, void *data)
  134. {
  135. int ret;
  136. ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
  137. "mmc-detect", data);
  138. return ret;
  139. }
  140. static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
  141. {
  142. free_irq(SDHC1_IRQ, data);
  143. }
  144. static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
  145. .init = visstrim_m10_sdhc1_init,
  146. .exit = visstrim_m10_sdhc1_exit,
  147. };
  148. /* Visstrim_SM10 NOR flash */
  149. static struct physmap_flash_data visstrim_m10_flash_data = {
  150. .width = 2,
  151. };
  152. static struct resource visstrim_m10_flash_resource = {
  153. .start = 0xc0000000,
  154. .end = 0xc0000000 + SZ_64M - 1,
  155. .flags = IORESOURCE_MEM,
  156. };
  157. static struct platform_device visstrim_m10_nor_mtd_device = {
  158. .name = "physmap-flash",
  159. .id = 0,
  160. .dev = {
  161. .platform_data = &visstrim_m10_flash_data,
  162. },
  163. .num_resources = 1,
  164. .resource = &visstrim_m10_flash_resource,
  165. };
  166. static struct platform_device *platform_devices[] __initdata = {
  167. &visstrim_m10_nor_mtd_device,
  168. };
  169. /* Visstrim_M10 uses UART0 as console */
  170. static const struct imxuart_platform_data uart_pdata __initconst = {
  171. .flags = IMXUART_HAVE_RTSCTS,
  172. };
  173. /* I2C */
  174. static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
  175. .bitrate = 100000,
  176. };
  177. static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
  178. .gpio_base = 240, /* After MX27 internal GPIOs */
  179. .invert = 0,
  180. };
  181. static struct aic32x4_pdata visstrim_m10_aic32x4_pdata = {
  182. .power_cfg = AIC32X4_PWR_MICBIAS_2075_LDOIN |
  183. AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE |
  184. AIC32X4_PWR_AIC32X4_LDO_ENABLE |
  185. AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 |
  186. AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED,
  187. .micpga_routing = AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K |
  188. AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K,
  189. .swapdacs = false,
  190. };
  191. static struct i2c_board_info visstrim_m10_i2c_devices[] = {
  192. {
  193. I2C_BOARD_INFO("pca9555", 0x20),
  194. .platform_data = &visstrim_m10_pca9555_pdata,
  195. },
  196. {
  197. I2C_BOARD_INFO("tlv320aic32x4", 0x18),
  198. .platform_data = &visstrim_m10_aic32x4_pdata,
  199. },
  200. {
  201. I2C_BOARD_INFO("m41t00", 0x68),
  202. }
  203. };
  204. /* USB OTG */
  205. static int otg_phy_init(struct platform_device *pdev)
  206. {
  207. gpio_set_value(OTG_PHY_CS_GPIO, 0);
  208. mdelay(10);
  209. return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
  210. }
  211. static const struct mxc_usbh_platform_data
  212. visstrim_m10_usbotg_pdata __initconst = {
  213. .init = otg_phy_init,
  214. .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
  215. };
  216. /* SSI */
  217. static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
  218. .flags = IMX_SSI_DMA | IMX_SSI_SYN,
  219. };
  220. static void __init visstrim_m10_board_init(void)
  221. {
  222. int ret;
  223. imx27_soc_init();
  224. ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
  225. ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
  226. if (ret)
  227. pr_err("Failed to setup pins (%d)\n", ret);
  228. imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata);
  229. imx27_add_imx_uart0(&uart_pdata);
  230. i2c_register_board_info(0, visstrim_m10_i2c_devices,
  231. ARRAY_SIZE(visstrim_m10_i2c_devices));
  232. imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
  233. imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
  234. imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
  235. imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
  236. imx27_add_fec(NULL);
  237. imx_add_gpio_keys(&visstrim_gpio_keys_platform_data);
  238. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  239. }
  240. static void __init visstrim_m10_timer_init(void)
  241. {
  242. mx27_clocks_init((unsigned long)25000000);
  243. }
  244. static struct sys_timer visstrim_m10_timer = {
  245. .init = visstrim_m10_timer_init,
  246. };
  247. MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
  248. .atag_offset = 0x100,
  249. .map_io = mx27_map_io,
  250. .init_early = imx27_init_early,
  251. .init_irq = mx27_init_irq,
  252. .handle_irq = imx27_handle_irq,
  253. .timer = &visstrim_m10_timer,
  254. .init_machine = visstrim_m10_board_init,
  255. .restart = mxc_restart,
  256. MACHINE_END