Commit | Line | Data |
---|---|---|
ec9be0de FE |
1 | /* |
2 | * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. | |
3 | * | |
4 | * Author: Fabio Estevam <fabio.estevam@freescale.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
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. | |
ec9be0de FE |
15 | */ |
16 | ||
8fdca37a UKK |
17 | /* |
18 | * This machine is known as: | |
19 | * - i.MX27 3-Stack Development System | |
20 | * - i.MX27 Platform Development Kit (i.MX27 PDK) | |
21 | */ | |
22 | ||
ec9be0de FE |
23 | #include <linux/platform_device.h> |
24 | #include <linux/gpio.h> | |
b5ec73eb | 25 | #include <linux/irq.h> |
96cf4239 FE |
26 | #include <linux/usb/otg.h> |
27 | #include <linux/usb/ulpi.h> | |
28 | #include <linux/delay.h> | |
c67a3e09 FE |
29 | #include <linux/mfd/mc13783.h> |
30 | #include <linux/spi/spi.h> | |
31 | #include <linux/regulator/machine.h> | |
96cf4239 | 32 | |
ec9be0de FE |
33 | #include <asm/mach-types.h> |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/time.h> | |
36 | #include <mach/hardware.h> | |
37 | #include <mach/common.h> | |
e835d88e | 38 | #include <mach/iomux-mx27.h> |
96cf4239 | 39 | #include <mach/ulpi.h> |
92cb33f1 FE |
40 | #include <mach/irqs.h> |
41 | #include <mach/3ds_debugboard.h> | |
ec9be0de | 42 | |
d5dac4a6 | 43 | #include "devices-imx27.h" |
ec9be0de | 44 | |
b5ec73eb | 45 | #define SD1_EN_GPIO (GPIO_PORTB + 25) |
96cf4239 | 46 | #define OTG_PHY_RESET_GPIO (GPIO_PORTB + 23) |
c67a3e09 | 47 | #define SPI2_SS0 (GPIO_PORTD + 21) |
92cb33f1 | 48 | #define EXPIO_PARENT_INT (MXC_INTERNAL_IRQS + GPIO_PORTC + 28) |
b5ec73eb | 49 | |
6c80ee51 | 50 | static const int mx27pdk_pins[] __initconst = { |
ec9be0de FE |
51 | /* UART1 */ |
52 | PE12_PF_UART1_TXD, | |
53 | PE13_PF_UART1_RXD, | |
54 | PE14_PF_UART1_CTS, | |
55 | PE15_PF_UART1_RTS, | |
56 | /* FEC */ | |
57 | PD0_AIN_FEC_TXD0, | |
58 | PD1_AIN_FEC_TXD1, | |
59 | PD2_AIN_FEC_TXD2, | |
60 | PD3_AIN_FEC_TXD3, | |
61 | PD4_AOUT_FEC_RX_ER, | |
62 | PD5_AOUT_FEC_RXD1, | |
63 | PD6_AOUT_FEC_RXD2, | |
64 | PD7_AOUT_FEC_RXD3, | |
65 | PD8_AF_FEC_MDIO, | |
66 | PD9_AIN_FEC_MDC, | |
67 | PD10_AOUT_FEC_CRS, | |
68 | PD11_AOUT_FEC_TX_CLK, | |
69 | PD12_AOUT_FEC_RXD0, | |
70 | PD13_AOUT_FEC_RX_DV, | |
71 | PD14_AOUT_FEC_RX_CLK, | |
72 | PD15_AOUT_FEC_COL, | |
73 | PD16_AIN_FEC_TX_ER, | |
74 | PF23_AIN_FEC_TX_EN, | |
b5ec73eb RP |
75 | /* SDHC1 */ |
76 | PE18_PF_SD1_D0, | |
77 | PE19_PF_SD1_D1, | |
78 | PE20_PF_SD1_D2, | |
79 | PE21_PF_SD1_D3, | |
80 | PE22_PF_SD1_CMD, | |
81 | PE23_PF_SD1_CLK, | |
82 | SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT, | |
96cf4239 FE |
83 | /* OTG */ |
84 | OTG_PHY_RESET_GPIO | GPIO_GPIO | GPIO_OUT, | |
85 | PC7_PF_USBOTG_DATA5, | |
86 | PC8_PF_USBOTG_DATA6, | |
87 | PC9_PF_USBOTG_DATA0, | |
88 | PC10_PF_USBOTG_DATA2, | |
89 | PC11_PF_USBOTG_DATA1, | |
90 | PC12_PF_USBOTG_DATA4, | |
91 | PC13_PF_USBOTG_DATA3, | |
92 | PE0_PF_USBOTG_NXT, | |
93 | PE1_PF_USBOTG_STP, | |
94 | PE2_PF_USBOTG_DIR, | |
95 | PE24_PF_USBOTG_CLK, | |
96 | PE25_PF_USBOTG_DATA7, | |
c67a3e09 FE |
97 | /* CSPI2 */ |
98 | PD22_PF_CSPI2_SCLK, | |
99 | PD23_PF_CSPI2_MISO, | |
100 | PD24_PF_CSPI2_MOSI, | |
ec9be0de FE |
101 | }; |
102 | ||
d5dac4a6 | 103 | static const struct imxuart_platform_data uart_pdata __initconst = { |
ec9be0de FE |
104 | .flags = IMXUART_HAVE_RTSCTS, |
105 | }; | |
106 | ||
3fac6cf3 RP |
107 | /* |
108 | * Matrix keyboard | |
109 | */ | |
110 | ||
111 | static const uint32_t mx27_3ds_keymap[] = { | |
112 | KEY(0, 0, KEY_UP), | |
113 | KEY(0, 1, KEY_DOWN), | |
114 | KEY(1, 0, KEY_RIGHT), | |
115 | KEY(1, 1, KEY_LEFT), | |
116 | KEY(1, 2, KEY_ENTER), | |
117 | KEY(2, 0, KEY_F6), | |
118 | KEY(2, 1, KEY_F8), | |
119 | KEY(2, 2, KEY_F9), | |
120 | KEY(2, 3, KEY_F10), | |
121 | }; | |
122 | ||
3f880141 | 123 | static const struct matrix_keymap_data mx27_3ds_keymap_data __initconst = { |
3fac6cf3 RP |
124 | .keymap = mx27_3ds_keymap, |
125 | .keymap_size = ARRAY_SIZE(mx27_3ds_keymap), | |
126 | }; | |
127 | ||
b5ec73eb RP |
128 | static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq, |
129 | void *data) | |
130 | { | |
131 | return request_irq(IRQ_GPIOB(26), detect_irq, IRQF_TRIGGER_FALLING | | |
132 | IRQF_TRIGGER_RISING, "sdhc1-card-detect", data); | |
133 | } | |
134 | ||
135 | static void mx27_3ds_sdhc1_exit(struct device *dev, void *data) | |
136 | { | |
137 | free_irq(IRQ_GPIOB(26), data); | |
138 | } | |
139 | ||
9d3d945a | 140 | static const struct imxmmc_platform_data sdhc1_pdata __initconst = { |
b5ec73eb RP |
141 | .init = mx27_3ds_sdhc1_init, |
142 | .exit = mx27_3ds_sdhc1_exit, | |
143 | }; | |
144 | ||
145 | static void mx27_3ds_sdhc1_enable_level_translator(void) | |
146 | { | |
147 | /* Turn on TXB0108 OE pin */ | |
148 | gpio_request(SD1_EN_GPIO, "sd1_enable"); | |
149 | gpio_direction_output(SD1_EN_GPIO, 1); | |
150 | } | |
151 | ||
96cf4239 FE |
152 | |
153 | static int otg_phy_init(void) | |
154 | { | |
155 | gpio_request(OTG_PHY_RESET_GPIO, "usb-otg-reset"); | |
156 | gpio_direction_output(OTG_PHY_RESET_GPIO, 0); | |
157 | mdelay(1); | |
158 | gpio_set_value(OTG_PHY_RESET_GPIO, 1); | |
159 | return 0; | |
160 | } | |
161 | ||
162 | #if defined(CONFIG_USB_ULPI) | |
163 | ||
164 | static struct mxc_usbh_platform_data otg_pdata __initdata = { | |
165 | .portsc = MXC_EHCI_MODE_ULPI, | |
166 | .flags = MXC_EHCI_INTERFACE_DIFF_UNI, | |
167 | }; | |
168 | #endif | |
169 | ||
170 | static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { | |
171 | .operating_mode = FSL_USB2_DR_DEVICE, | |
172 | .phy_mode = FSL_USB2_PHY_ULPI, | |
173 | }; | |
174 | ||
175 | static int otg_mode_host; | |
176 | ||
177 | static int __init mx27_3ds_otg_mode(char *options) | |
178 | { | |
179 | if (!strcmp(options, "host")) | |
180 | otg_mode_host = 1; | |
181 | else if (!strcmp(options, "device")) | |
182 | otg_mode_host = 0; | |
183 | else | |
184 | pr_info("otg_mode neither \"host\" nor \"device\". " | |
185 | "Defaulting to device\n"); | |
186 | return 0; | |
187 | } | |
188 | __setup("otg_mode=", mx27_3ds_otg_mode); | |
189 | ||
c67a3e09 FE |
190 | /* Regulators */ |
191 | static struct regulator_consumer_supply vmmc1_consumers[] = { | |
192 | REGULATOR_SUPPLY("lcd_2v8", NULL), | |
193 | }; | |
194 | ||
195 | static struct regulator_init_data vmmc1_init = { | |
196 | .constraints = { | |
197 | .min_uV = 2800000, | |
198 | .max_uV = 2800000, | |
199 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, | |
200 | }, | |
201 | .num_consumer_supplies = ARRAY_SIZE(vmmc1_consumers), | |
202 | .consumer_supplies = vmmc1_consumers, | |
203 | }; | |
204 | ||
205 | static struct regulator_consumer_supply vgen_consumers[] = { | |
206 | REGULATOR_SUPPLY("vdd_lcdio", NULL), | |
207 | }; | |
208 | ||
209 | static struct regulator_init_data vgen_init = { | |
210 | .constraints = { | |
211 | .min_uV = 1800000, | |
212 | .max_uV = 1800000, | |
213 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, | |
214 | }, | |
215 | .num_consumer_supplies = ARRAY_SIZE(vgen_consumers), | |
216 | .consumer_supplies = vgen_consumers, | |
217 | }; | |
218 | ||
219 | static struct mc13783_regulator_init_data mx27_3ds_regulators[] = { | |
220 | { | |
074cee92 | 221 | .id = MC13783_REG_VMMC1, |
c67a3e09 FE |
222 | .init_data = &vmmc1_init, |
223 | }, { | |
074cee92 | 224 | .id = MC13783_REG_VGEN, |
c67a3e09 FE |
225 | .init_data = &vgen_init, |
226 | }, | |
227 | }; | |
228 | ||
229 | /* MC13783 */ | |
230 | static struct mc13783_platform_data mc13783_pdata __initdata = { | |
231 | .regulators = mx27_3ds_regulators, | |
232 | .num_regulators = ARRAY_SIZE(mx27_3ds_regulators), | |
233 | .flags = MC13783_USE_REGULATOR, | |
234 | }; | |
235 | ||
236 | /* SPI */ | |
237 | static int spi2_internal_chipselect[] = {SPI2_SS0}; | |
238 | ||
239 | static const struct spi_imx_master spi2_pdata __initconst = { | |
240 | .chipselect = spi2_internal_chipselect, | |
241 | .num_chipselect = ARRAY_SIZE(spi2_internal_chipselect), | |
242 | }; | |
243 | ||
244 | static struct spi_board_info mx27_3ds_spi_devs[] __initdata = { | |
245 | { | |
246 | .modalias = "mc13783", | |
247 | .max_speed_hz = 1000000, | |
248 | .bus_num = 1, | |
249 | .chip_select = 0, /* SS0 */ | |
250 | .platform_data = &mc13783_pdata, | |
251 | .irq = IRQ_GPIOC(14), | |
252 | .mode = SPI_CS_HIGH, | |
253 | }, | |
254 | }; | |
255 | ||
96cf4239 | 256 | |
ec9be0de FE |
257 | static void __init mx27pdk_init(void) |
258 | { | |
259 | mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), | |
260 | "mx27pdk"); | |
b5ec73eb | 261 | mx27_3ds_sdhc1_enable_level_translator(); |
d5dac4a6 | 262 | imx27_add_imx_uart0(&uart_pdata); |
6bd96f3c | 263 | imx27_add_fec(NULL); |
3f880141 | 264 | imx27_add_imx_keypad(&mx27_3ds_keymap_data); |
9d3d945a | 265 | imx27_add_mxc_mmc(0, &sdhc1_pdata); |
8be9252f | 266 | imx27_add_imx2_wdt(NULL); |
96cf4239 FE |
267 | otg_phy_init(); |
268 | #if defined(CONFIG_USB_ULPI) | |
269 | if (otg_mode_host) { | |
270 | otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops, | |
271 | ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); | |
272 | ||
273 | imx27_add_mxc_ehci_otg(&otg_pdata); | |
274 | } | |
275 | #endif | |
276 | if (!otg_mode_host) | |
277 | imx27_add_fsl_usb2_udc(&otg_device_pdata); | |
278 | ||
c67a3e09 FE |
279 | imx27_add_spi_imx1(&spi2_pdata); |
280 | spi_register_board_info(mx27_3ds_spi_devs, | |
281 | ARRAY_SIZE(mx27_3ds_spi_devs)); | |
92cb33f1 FE |
282 | |
283 | if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT)) | |
284 | pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n"); | |
ec9be0de FE |
285 | } |
286 | ||
287 | static void __init mx27pdk_timer_init(void) | |
288 | { | |
289 | mx27_clocks_init(26000000); | |
290 | } | |
291 | ||
292 | static struct sys_timer mx27pdk_timer = { | |
293 | .init = mx27pdk_timer_init, | |
294 | }; | |
295 | ||
296 | MACHINE_START(MX27_3DS, "Freescale MX27PDK") | |
297 | /* maintainer: Freescale Semiconductor, Inc. */ | |
34101237 | 298 | .boot_params = MX27_PHYS_OFFSET + 0x100, |
add85a41 | 299 | .map_io = mx27_map_io, |
c5aa0ad0 | 300 | .init_irq = mx27_init_irq, |
ec9be0de FE |
301 | .init_machine = mx27pdk_init, |
302 | .timer = &mx27pdk_timer, | |
303 | MACHINE_END |