Commit | Line | Data |
---|---|---|
21744f19 EB |
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 | ||
20 | #include <linux/types.h> | |
21 | #include <linux/init.h> | |
22 | ||
23 | #include <linux/platform_device.h> | |
24 | #include <linux/mtd/physmap.h> | |
25 | #include <linux/memory.h> | |
26 | #include <linux/gpio.h> | |
27 | #include <linux/interrupt.h> | |
28 | #include <linux/delay.h> | |
29 | #include <linux/i2c.h> | |
30 | #include <linux/i2c/tsc2007.h> | |
31 | #include <linux/usb/otg.h> | |
32 | #include <linux/usb/ulpi.h> | |
54dc3f46 | 33 | #include <linux/i2c-gpio.h> |
21744f19 EB |
34 | |
35 | #include <asm/mach-types.h> | |
36 | #include <asm/mach/arch.h> | |
37 | #include <asm/mach/time.h> | |
38 | #include <asm/mach/map.h> | |
39 | ||
e3372474 | 40 | #include "common.h" |
2dcf78c0 | 41 | #include "devices-imx35.h" |
3ed0bcb4 | 42 | #include "eukrea-baseboards.h" |
50f2de61 | 43 | #include "hardware.h" |
267dd34c | 44 | #include "iomux-mx35.h" |
21744f19 | 45 | |
2dcf78c0 | 46 | static const struct imxuart_platform_data uart_pdata __initconst = { |
21744f19 EB |
47 | .flags = IMXUART_HAVE_RTSCTS, |
48 | }; | |
49 | ||
2dcf78c0 | 50 | static const struct imxi2c_platform_data |
54dc3f46 EB |
51 | eukrea_cpuimx35_i2c0_data __initconst = { |
52 | .bitrate = 100000, | |
21744f19 EB |
53 | }; |
54 | ||
4d4b2562 | 55 | #define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2) |
07f9e5cf | 56 | static int tsc2007_get_pendown_state(struct device *dev) |
4d4b2562 EB |
57 | { |
58 | return !gpio_get_value(TSC2007_IRQGPIO); | |
59 | } | |
60 | ||
21744f19 EB |
61 | static struct tsc2007_platform_data tsc2007_info = { |
62 | .model = 2007, | |
63 | .x_plate_ohms = 180, | |
4d4b2562 | 64 | .get_pendown_state = tsc2007_get_pendown_state, |
21744f19 EB |
65 | }; |
66 | ||
67 | static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = { | |
68 | { | |
69 | I2C_BOARD_INFO("pcf8563", 0x51), | |
70 | }, { | |
71 | I2C_BOARD_INFO("tsc2007", 0x48), | |
21744f19 | 72 | .platform_data = &tsc2007_info, |
84715dd6 | 73 | /* irq number is run-time assigned */ |
21744f19 EB |
74 | }, |
75 | }; | |
76 | ||
8f5260c8 | 77 | static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = { |
21744f19 EB |
78 | /* UART1 */ |
79 | MX35_PAD_CTS1__UART1_CTS, | |
80 | MX35_PAD_RTS1__UART1_RTS, | |
81 | MX35_PAD_TXD1__UART1_TXD_MUX, | |
82 | MX35_PAD_RXD1__UART1_RXD_MUX, | |
83 | /* FEC */ | |
84 | MX35_PAD_FEC_TX_CLK__FEC_TX_CLK, | |
85 | MX35_PAD_FEC_RX_CLK__FEC_RX_CLK, | |
86 | MX35_PAD_FEC_RX_DV__FEC_RX_DV, | |
87 | MX35_PAD_FEC_COL__FEC_COL, | |
88 | MX35_PAD_FEC_RDATA0__FEC_RDATA_0, | |
89 | MX35_PAD_FEC_TDATA0__FEC_TDATA_0, | |
90 | MX35_PAD_FEC_TX_EN__FEC_TX_EN, | |
91 | MX35_PAD_FEC_MDC__FEC_MDC, | |
92 | MX35_PAD_FEC_MDIO__FEC_MDIO, | |
93 | MX35_PAD_FEC_TX_ERR__FEC_TX_ERR, | |
94 | MX35_PAD_FEC_RX_ERR__FEC_RX_ERR, | |
95 | MX35_PAD_FEC_CRS__FEC_CRS, | |
96 | MX35_PAD_FEC_RDATA1__FEC_RDATA_1, | |
97 | MX35_PAD_FEC_TDATA1__FEC_TDATA_1, | |
98 | MX35_PAD_FEC_RDATA2__FEC_RDATA_2, | |
99 | MX35_PAD_FEC_TDATA2__FEC_TDATA_2, | |
100 | MX35_PAD_FEC_RDATA3__FEC_RDATA_3, | |
101 | MX35_PAD_FEC_TDATA3__FEC_TDATA_3, | |
102 | /* I2C1 */ | |
103 | MX35_PAD_I2C1_CLK__I2C1_SCL, | |
104 | MX35_PAD_I2C1_DAT__I2C1_SDA, | |
105 | /* TSC2007 IRQ */ | |
106 | MX35_PAD_ATA_DA2__GPIO3_2, | |
107 | }; | |
108 | ||
2dcf78c0 | 109 | static const struct mxc_nand_platform_data |
54dc3f46 | 110 | eukrea_cpuimx35_nand_board_info __initconst = { |
21744f19 EB |
111 | .width = 1, |
112 | .hw_ecc = 1, | |
113 | .flash_bbt = 1, | |
114 | }; | |
115 | ||
4bd597b6 SH |
116 | static int eukrea_cpuimx35_otg_init(struct platform_device *pdev) |
117 | { | |
118 | return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI); | |
119 | } | |
120 | ||
2d58de28 | 121 | static const struct mxc_usbh_platform_data otg_pdata __initconst = { |
4bd597b6 | 122 | .init = eukrea_cpuimx35_otg_init, |
21744f19 | 123 | .portsc = MXC_EHCI_MODE_UTMI, |
21744f19 EB |
124 | }; |
125 | ||
4bd597b6 SH |
126 | static int eukrea_cpuimx35_usbh1_init(struct platform_device *pdev) |
127 | { | |
128 | return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_SINGLE_UNI | | |
129 | MXC_EHCI_INTERNAL_PHY | MXC_EHCI_IPPUE_DOWN); | |
130 | } | |
131 | ||
2d58de28 | 132 | static const struct mxc_usbh_platform_data usbh1_pdata __initconst = { |
4bd597b6 | 133 | .init = eukrea_cpuimx35_usbh1_init, |
21744f19 | 134 | .portsc = MXC_EHCI_MODE_SERIAL, |
21744f19 EB |
135 | }; |
136 | ||
9e1dde33 | 137 | static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { |
21744f19 EB |
138 | .operating_mode = FSL_USB2_DR_DEVICE, |
139 | .phy_mode = FSL_USB2_PHY_UTMI, | |
69cb1ec4 | 140 | .workaround = FLS_USB2_WORKAROUND_ENGCM09152, |
21744f19 EB |
141 | }; |
142 | ||
33a264dd | 143 | static bool otg_mode_host __initdata; |
21744f19 EB |
144 | |
145 | static int __init eukrea_cpuimx35_otg_mode(char *options) | |
146 | { | |
147 | if (!strcmp(options, "host")) | |
33a264dd | 148 | otg_mode_host = true; |
21744f19 | 149 | else if (!strcmp(options, "device")) |
33a264dd | 150 | otg_mode_host = false; |
21744f19 EB |
151 | else |
152 | pr_info("otg_mode neither \"host\" nor \"device\". " | |
153 | "Defaulting to device\n"); | |
33a264dd | 154 | return 1; |
21744f19 EB |
155 | } |
156 | __setup("otg_mode=", eukrea_cpuimx35_otg_mode); | |
157 | ||
158 | /* | |
159 | * Board specific initialization. | |
160 | */ | |
e134fb2b | 161 | static void __init eukrea_cpuimx35_init(void) |
21744f19 | 162 | { |
b78d8e59 SG |
163 | imx35_soc_init(); |
164 | ||
21744f19 EB |
165 | mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads, |
166 | ARRAY_SIZE(eukrea_cpuimx35_pads)); | |
167 | ||
6bd96f3c | 168 | imx35_add_fec(NULL); |
bec31a85 | 169 | imx35_add_imx2_wdt(); |
21744f19 | 170 | |
2dcf78c0 UKK |
171 | imx35_add_imx_uart0(&uart_pdata); |
172 | imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info); | |
21744f19 | 173 | |
84715dd6 | 174 | eukrea_cpuimx35_i2c_devices[1].irq = gpio_to_irq(TSC2007_IRQGPIO); |
21744f19 EB |
175 | i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices, |
176 | ARRAY_SIZE(eukrea_cpuimx35_i2c_devices)); | |
2dcf78c0 | 177 | imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data); |
21744f19 | 178 | |
52d084fc | 179 | if (otg_mode_host) |
2d58de28 | 180 | imx35_add_mxc_ehci_otg(&otg_pdata); |
52d084fc | 181 | else |
9e1dde33 | 182 | imx35_add_fsl_usb2_udc(&otg_device_pdata); |
21744f19 | 183 | |
2d58de28 | 184 | imx35_add_mxc_ehci_hs(&usbh1_pdata); |
52d084fc | 185 | |
ec53fe3d EB |
186 | #ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD |
187 | eukrea_mbimxsd35_baseboard_init(); | |
21744f19 EB |
188 | #endif |
189 | } | |
190 | ||
191 | static void __init eukrea_cpuimx35_timer_init(void) | |
192 | { | |
193 | mx35_clocks_init(); | |
194 | } | |
195 | ||
0d6cfa3a | 196 | MACHINE_START(EUKREA_CPUIMX35SD, "Eukrea CPUIMX35") |
21744f19 | 197 | /* Maintainer: Eukrea Electromatique */ |
dc8f1907 | 198 | .atag_offset = 0x100, |
97976e22 | 199 | .map_io = mx35_map_io, |
3fc6b609 | 200 | .init_early = imx35_init_early, |
97976e22 | 201 | .init_irq = mx35_init_irq, |
ffa2ea3f | 202 | .handle_irq = imx35_handle_irq, |
6bb27d73 | 203 | .init_time = eukrea_cpuimx35_timer_init, |
e134fb2b | 204 | .init_machine = eukrea_cpuimx35_init, |
65ea7884 | 205 | .restart = mxc_restart, |
21744f19 | 206 | MACHINE_END |