mach-cpuimx35.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Copyright (C) 2010 Eric Benard - eric@eukrea.com
  3. * Copyright (C) 2009 Sascha Hauer, Pengutronix
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/types.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/memory.h>
  24. #include <linux/gpio.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <linux/i2c.h>
  28. #include <linux/i2c/tsc2007.h>
  29. #include <linux/usb/otg.h>
  30. #include <linux/usb/ulpi.h>
  31. #include <linux/fsl_devices.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/time.h>
  35. #include <asm/mach/map.h>
  36. #include <mach/eukrea-baseboards.h>
  37. #include <mach/hardware.h>
  38. #include <mach/common.h>
  39. #include <mach/iomux-mx35.h>
  40. #include <mach/mxc_nand.h>
  41. #include <mach/mxc_ehci.h>
  42. #include <mach/ulpi.h>
  43. #include "devices-imx35.h"
  44. #include "devices.h"
  45. static const struct imxuart_platform_data uart_pdata __initconst = {
  46. .flags = IMXUART_HAVE_RTSCTS,
  47. };
  48. static const struct imxi2c_platform_data
  49. eukrea_cpuimx35_i2c0_data __initconst = {
  50. .bitrate = 50000,
  51. };
  52. #define TSC2007_IRQGPIO (2 * 32 + 2)
  53. static int ts_get_pendown_state(void)
  54. {
  55. int val = 0;
  56. gpio_free(TSC2007_IRQGPIO);
  57. gpio_request(TSC2007_IRQGPIO, NULL);
  58. gpio_direction_input(TSC2007_IRQGPIO);
  59. val = gpio_get_value(TSC2007_IRQGPIO);
  60. gpio_free(TSC2007_IRQGPIO);
  61. gpio_request(TSC2007_IRQGPIO, NULL);
  62. return val ? 0 : 1;
  63. }
  64. static int ts_init(void)
  65. {
  66. gpio_request(TSC2007_IRQGPIO, NULL);
  67. return 0;
  68. }
  69. static struct tsc2007_platform_data tsc2007_info = {
  70. .model = 2007,
  71. .x_plate_ohms = 180,
  72. .get_pendown_state = ts_get_pendown_state,
  73. .init_platform_hw = ts_init,
  74. };
  75. static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
  76. {
  77. I2C_BOARD_INFO("pcf8563", 0x51),
  78. }, {
  79. I2C_BOARD_INFO("tsc2007", 0x48),
  80. .type = "tsc2007",
  81. .platform_data = &tsc2007_info,
  82. .irq = gpio_to_irq(TSC2007_IRQGPIO),
  83. },
  84. };
  85. static struct platform_device *devices[] __initdata = {
  86. &mxc_fec_device,
  87. &imx_wdt_device0,
  88. };
  89. static struct pad_desc eukrea_cpuimx35_pads[] = {
  90. /* UART1 */
  91. MX35_PAD_CTS1__UART1_CTS,
  92. MX35_PAD_RTS1__UART1_RTS,
  93. MX35_PAD_TXD1__UART1_TXD_MUX,
  94. MX35_PAD_RXD1__UART1_RXD_MUX,
  95. /* FEC */
  96. MX35_PAD_FEC_TX_CLK__FEC_TX_CLK,
  97. MX35_PAD_FEC_RX_CLK__FEC_RX_CLK,
  98. MX35_PAD_FEC_RX_DV__FEC_RX_DV,
  99. MX35_PAD_FEC_COL__FEC_COL,
  100. MX35_PAD_FEC_RDATA0__FEC_RDATA_0,
  101. MX35_PAD_FEC_TDATA0__FEC_TDATA_0,
  102. MX35_PAD_FEC_TX_EN__FEC_TX_EN,
  103. MX35_PAD_FEC_MDC__FEC_MDC,
  104. MX35_PAD_FEC_MDIO__FEC_MDIO,
  105. MX35_PAD_FEC_TX_ERR__FEC_TX_ERR,
  106. MX35_PAD_FEC_RX_ERR__FEC_RX_ERR,
  107. MX35_PAD_FEC_CRS__FEC_CRS,
  108. MX35_PAD_FEC_RDATA1__FEC_RDATA_1,
  109. MX35_PAD_FEC_TDATA1__FEC_TDATA_1,
  110. MX35_PAD_FEC_RDATA2__FEC_RDATA_2,
  111. MX35_PAD_FEC_TDATA2__FEC_TDATA_2,
  112. MX35_PAD_FEC_RDATA3__FEC_RDATA_3,
  113. MX35_PAD_FEC_TDATA3__FEC_TDATA_3,
  114. /* I2C1 */
  115. MX35_PAD_I2C1_CLK__I2C1_SCL,
  116. MX35_PAD_I2C1_DAT__I2C1_SDA,
  117. /* TSC2007 IRQ */
  118. MX35_PAD_ATA_DA2__GPIO3_2,
  119. };
  120. static const struct mxc_nand_platform_data
  121. eukrea_cpuimx35_nand_board_info __initconst = {
  122. .width = 1,
  123. .hw_ecc = 1,
  124. .flash_bbt = 1,
  125. };
  126. static struct mxc_usbh_platform_data otg_pdata = {
  127. .portsc = MXC_EHCI_MODE_UTMI,
  128. .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
  129. };
  130. static struct mxc_usbh_platform_data usbh1_pdata = {
  131. .portsc = MXC_EHCI_MODE_SERIAL,
  132. .flags = MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY |
  133. MXC_EHCI_IPPUE_DOWN,
  134. };
  135. static struct fsl_usb2_platform_data otg_device_pdata = {
  136. .operating_mode = FSL_USB2_DR_DEVICE,
  137. .phy_mode = FSL_USB2_PHY_UTMI,
  138. };
  139. static int otg_mode_host;
  140. static int __init eukrea_cpuimx35_otg_mode(char *options)
  141. {
  142. if (!strcmp(options, "host"))
  143. otg_mode_host = 1;
  144. else if (!strcmp(options, "device"))
  145. otg_mode_host = 0;
  146. else
  147. pr_info("otg_mode neither \"host\" nor \"device\". "
  148. "Defaulting to device\n");
  149. return 0;
  150. }
  151. __setup("otg_mode=", eukrea_cpuimx35_otg_mode);
  152. /*
  153. * Board specific initialization.
  154. */
  155. static void __init mxc_board_init(void)
  156. {
  157. mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads,
  158. ARRAY_SIZE(eukrea_cpuimx35_pads));
  159. platform_add_devices(devices, ARRAY_SIZE(devices));
  160. imx35_add_imx_uart0(&uart_pdata);
  161. imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info);
  162. i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices,
  163. ARRAY_SIZE(eukrea_cpuimx35_i2c_devices));
  164. imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data);
  165. #if defined(CONFIG_USB_ULPI)
  166. if (otg_mode_host) {
  167. otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
  168. ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
  169. mxc_register_device(&mxc_otg_host, &otg_pdata);
  170. }
  171. mxc_register_device(&mxc_usbh1, &usbh1_pdata);
  172. #endif
  173. if (!otg_mode_host)
  174. mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
  175. #ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD
  176. eukrea_mbimxsd35_baseboard_init();
  177. #endif
  178. }
  179. static void __init eukrea_cpuimx35_timer_init(void)
  180. {
  181. mx35_clocks_init();
  182. }
  183. struct sys_timer eukrea_cpuimx35_timer = {
  184. .init = eukrea_cpuimx35_timer_init,
  185. };
  186. MACHINE_START(EUKREA_CPUIMX35, "Eukrea CPUIMX35")
  187. /* Maintainer: Eukrea Electromatique */
  188. .phys_io = MX35_AIPS1_BASE_ADDR,
  189. .io_pg_offst = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  190. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  191. .map_io = mx35_map_io,
  192. .init_irq = mx35_init_irq,
  193. .init_machine = mxc_board_init,
  194. .timer = &eukrea_cpuimx35_timer,
  195. MACHINE_END