blob: 21305c67afcf420739da80d997bc3e43399a98e7 [file] [log] [blame]
Sascha Hauer54df5262009-02-06 15:42:26 +01001/*
2 * Copyright (C) 2009 Sascha Hauer, Pengutronix
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Sascha Hauer54df5262009-02-06 15:42:26 +010013 */
14
15#include <linux/types.h>
16#include <linux/init.h>
17
18#include <linux/platform_device.h>
19#include <linux/mtd/physmap.h>
20#include <linux/mtd/plat-ram.h>
21#include <linux/memory.h>
22#include <linux/gpio.h>
23#include <linux/smc911x.h>
24#include <linux/interrupt.h>
Sascha Hauerd2831d12010-02-09 11:04:36 +010025#include <linux/delay.h>
Sascha Hauer54df5262009-02-06 15:42:26 +010026#include <linux/i2c.h>
27#include <linux/i2c/at24.h>
Sascha Hauercb2dc112010-02-04 14:32:53 +010028#include <linux/usb/otg.h>
29#include <linux/usb/ulpi.h>
30#include <linux/fsl_devices.h>
Sascha Hauer54df5262009-02-06 15:42:26 +010031
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
37#include <mach/hardware.h>
38#include <mach/common.h>
39#include <mach/imx-uart.h>
Sascha Hauer54df5262009-02-06 15:42:26 +010040#include <mach/iomux-mx35.h>
41#include <mach/ipu.h>
42#include <mach/mx3fb.h>
Sascha Hauercb2dc112010-02-04 14:32:53 +010043#include <mach/mxc_ehci.h>
44#include <mach/ulpi.h>
Sascha Hauerd2831d12010-02-09 11:04:36 +010045#include <mach/audmux.h>
46#include <mach/ssi.h>
Sascha Hauer54df5262009-02-06 15:42:26 +010047
Uwe Kleine-Könige2611ba2010-06-16 12:26:53 +020048#include "devices-imx35.h"
Sascha Hauer54df5262009-02-06 15:42:26 +010049#include "devices.h"
50
51static const struct fb_videomode fb_modedb[] = {
52 {
53 /* 240x320 @ 60 Hz */
54 .name = "Sharp-LQ035Q7",
55 .refresh = 60,
56 .xres = 240,
57 .yres = 320,
58 .pixclock = 185925,
59 .left_margin = 9,
60 .right_margin = 16,
61 .upper_margin = 7,
62 .lower_margin = 9,
63 .hsync_len = 1,
64 .vsync_len = 1,
65 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_SHARP_MODE | FB_SYNC_CLK_INVERT | FB_SYNC_CLK_IDLE_EN,
66 .vmode = FB_VMODE_NONINTERLACED,
67 .flag = 0,
68 }, {
69 /* 240x320 @ 60 Hz */
70 .name = "TX090",
71 .refresh = 60,
72 .xres = 240,
73 .yres = 320,
74 .pixclock = 38255,
75 .left_margin = 144,
76 .right_margin = 0,
77 .upper_margin = 7,
78 .lower_margin = 40,
79 .hsync_len = 96,
80 .vsync_len = 1,
81 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
82 .vmode = FB_VMODE_NONINTERLACED,
83 .flag = 0,
84 },
85};
86
87static struct ipu_platform_data mx3_ipu_data = {
88 .irq_base = MXC_IPU_IRQ_START,
89};
90
91static struct mx3fb_platform_data mx3fb_pdata = {
92 .dma_dev = &mx3_ipu.dev,
93 .name = "Sharp-LQ035Q7",
94 .mode = fb_modedb,
95 .num_modes = ARRAY_SIZE(fb_modedb),
96};
97
98static struct physmap_flash_data pcm043_flash_data = {
99 .width = 2,
100};
101
102static struct resource pcm043_flash_resource = {
103 .start = 0xa0000000,
104 .end = 0xa1ffffff,
105 .flags = IORESOURCE_MEM,
106};
107
108static struct platform_device pcm043_flash = {
109 .name = "physmap-flash",
110 .id = 0,
111 .dev = {
112 .platform_data = &pcm043_flash_data,
113 },
114 .resource = &pcm043_flash_resource,
115 .num_resources = 1,
116};
117
118static struct imxuart_platform_data uart_pdata = {
119 .flags = IMXUART_HAVE_RTSCTS,
120};
121
122#if defined CONFIG_I2C_IMX || defined CONFIG_I2C_IMX_MODULE
Uwe Kleine-König7cdc8fa2010-06-16 19:25:34 +0200123static const struct imxi2c_platform_data pcm043_i2c0_data __initconst = {
Sascha Hauer54df5262009-02-06 15:42:26 +0100124 .bitrate = 50000,
125};
126
127static struct at24_platform_data board_eeprom = {
128 .byte_len = 4096,
129 .page_size = 32,
130 .flags = AT24_FLAG_ADDR16,
131};
132
133static struct i2c_board_info pcm043_i2c_devices[] = {
134 {
135 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
136 .platform_data = &board_eeprom,
137 }, {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200138 I2C_BOARD_INFO("pcf8563", 0x51),
Sascha Hauer54df5262009-02-06 15:42:26 +0100139 }
140};
141#endif
142
143static struct platform_device *devices[] __initdata = {
144 &pcm043_flash,
145 &mxc_fec_device,
Wolfram Sang3170ba52010-04-29 10:03:19 +0200146 &imx_wdt_device0,
Sascha Hauer54df5262009-02-06 15:42:26 +0100147};
148
149static struct pad_desc pcm043_pads[] = {
150 /* UART1 */
151 MX35_PAD_CTS1__UART1_CTS,
152 MX35_PAD_RTS1__UART1_RTS,
153 MX35_PAD_TXD1__UART1_TXD_MUX,
154 MX35_PAD_RXD1__UART1_RXD_MUX,
155 /* UART2 */
156 MX35_PAD_CTS2__UART2_CTS,
157 MX35_PAD_RTS2__UART2_RTS,
158 MX35_PAD_TXD2__UART2_TXD_MUX,
159 MX35_PAD_RXD2__UART2_RXD_MUX,
160 /* FEC */
161 MX35_PAD_FEC_TX_CLK__FEC_TX_CLK,
162 MX35_PAD_FEC_RX_CLK__FEC_RX_CLK,
163 MX35_PAD_FEC_RX_DV__FEC_RX_DV,
164 MX35_PAD_FEC_COL__FEC_COL,
165 MX35_PAD_FEC_RDATA0__FEC_RDATA_0,
166 MX35_PAD_FEC_TDATA0__FEC_TDATA_0,
167 MX35_PAD_FEC_TX_EN__FEC_TX_EN,
168 MX35_PAD_FEC_MDC__FEC_MDC,
169 MX35_PAD_FEC_MDIO__FEC_MDIO,
170 MX35_PAD_FEC_TX_ERR__FEC_TX_ERR,
171 MX35_PAD_FEC_RX_ERR__FEC_RX_ERR,
172 MX35_PAD_FEC_CRS__FEC_CRS,
173 MX35_PAD_FEC_RDATA1__FEC_RDATA_1,
174 MX35_PAD_FEC_TDATA1__FEC_TDATA_1,
175 MX35_PAD_FEC_RDATA2__FEC_RDATA_2,
176 MX35_PAD_FEC_TDATA2__FEC_TDATA_2,
177 MX35_PAD_FEC_RDATA3__FEC_RDATA_3,
178 MX35_PAD_FEC_TDATA3__FEC_TDATA_3,
179 /* I2C1 */
180 MX35_PAD_I2C1_CLK__I2C1_SCL,
181 MX35_PAD_I2C1_DAT__I2C1_SDA,
182 /* Display */
183 MX35_PAD_LD0__IPU_DISPB_DAT_0,
184 MX35_PAD_LD1__IPU_DISPB_DAT_1,
185 MX35_PAD_LD2__IPU_DISPB_DAT_2,
186 MX35_PAD_LD3__IPU_DISPB_DAT_3,
187 MX35_PAD_LD4__IPU_DISPB_DAT_4,
188 MX35_PAD_LD5__IPU_DISPB_DAT_5,
189 MX35_PAD_LD6__IPU_DISPB_DAT_6,
190 MX35_PAD_LD7__IPU_DISPB_DAT_7,
191 MX35_PAD_LD8__IPU_DISPB_DAT_8,
192 MX35_PAD_LD9__IPU_DISPB_DAT_9,
193 MX35_PAD_LD10__IPU_DISPB_DAT_10,
194 MX35_PAD_LD11__IPU_DISPB_DAT_11,
195 MX35_PAD_LD12__IPU_DISPB_DAT_12,
196 MX35_PAD_LD13__IPU_DISPB_DAT_13,
197 MX35_PAD_LD14__IPU_DISPB_DAT_14,
198 MX35_PAD_LD15__IPU_DISPB_DAT_15,
199 MX35_PAD_LD16__IPU_DISPB_DAT_16,
200 MX35_PAD_LD17__IPU_DISPB_DAT_17,
201 MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
202 MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
203 MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
204 MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
205 MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
206 MX35_PAD_D3_REV__IPU_DISPB_D3_REV,
207 MX35_PAD_D3_CLS__IPU_DISPB_D3_CLS,
Luotao Fu8d5c1ed2009-06-18 14:15:22 +0200208 /* gpio */
209 MX35_PAD_ATA_CS0__GPIO2_6,
Sascha Hauercb2dc112010-02-04 14:32:53 +0100210 /* USB host */
211 MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR,
212 MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC,
Sascha Hauerd2831d12010-02-09 11:04:36 +0100213 /* SSI */
214 MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS,
215 MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
216 MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
217 MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
218};
219
220#define AC97_GPIO_TXFS (1 * 32 + 31)
221#define AC97_GPIO_TXD (1 * 32 + 28)
222#define AC97_GPIO_RESET (1 * 32 + 0)
223
224static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97)
225{
226 struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
227 struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
228 int ret;
229
230 ret = gpio_request(AC97_GPIO_TXFS, "SSI");
231 if (ret) {
232 printk("failed to get GPIO_TXFS: %d\n", ret);
233 return;
234 }
235
236 mxc_iomux_v3_setup_pad(&txfs_gpio);
237
238 /* warm reset */
239 gpio_direction_output(AC97_GPIO_TXFS, 1);
240 udelay(2);
241 gpio_set_value(AC97_GPIO_TXFS, 0);
242
243 gpio_free(AC97_GPIO_TXFS);
244 mxc_iomux_v3_setup_pad(&txfs);
245}
246
247static void pcm043_ac97_cold_reset(struct snd_ac97 *ac97)
248{
249 struct pad_desc txfs_gpio = MX35_PAD_STXFS4__GPIO2_31;
250 struct pad_desc txfs = MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS;
251 struct pad_desc txd_gpio = MX35_PAD_STXD4__GPIO2_28;
252 struct pad_desc txd = MX35_PAD_STXD4__AUDMUX_AUD4_TXD;
253 struct pad_desc reset_gpio = MX35_PAD_SD2_CMD__GPIO2_0;
254 int ret;
255
256 ret = gpio_request(AC97_GPIO_TXFS, "SSI");
257 if (ret)
258 goto err1;
259
260 ret = gpio_request(AC97_GPIO_TXD, "SSI");
261 if (ret)
262 goto err2;
263
264 ret = gpio_request(AC97_GPIO_RESET, "SSI");
265 if (ret)
266 goto err3;
267
268 mxc_iomux_v3_setup_pad(&txfs_gpio);
269 mxc_iomux_v3_setup_pad(&txd_gpio);
270 mxc_iomux_v3_setup_pad(&reset_gpio);
271
272 gpio_direction_output(AC97_GPIO_TXFS, 0);
273 gpio_direction_output(AC97_GPIO_TXD, 0);
274
275 /* cold reset */
276 gpio_direction_output(AC97_GPIO_RESET, 0);
277 udelay(10);
278 gpio_direction_output(AC97_GPIO_RESET, 1);
279
280 mxc_iomux_v3_setup_pad(&txd);
281 mxc_iomux_v3_setup_pad(&txfs);
282
283 gpio_free(AC97_GPIO_RESET);
284err3:
285 gpio_free(AC97_GPIO_TXD);
286err2:
287 gpio_free(AC97_GPIO_TXFS);
288err1:
289 if (ret)
290 printk("%s failed with %d\n", __func__, ret);
291 mdelay(1);
292}
293
294static struct imx_ssi_platform_data pcm043_ssi_pdata = {
295 .ac97_reset = pcm043_ac97_cold_reset,
296 .ac97_warm_reset = pcm043_ac97_warm_reset,
297 .flags = IMX_SSI_USE_AC97,
Sascha Hauer54df5262009-02-06 15:42:26 +0100298};
299
Uwe Kleine-Könige2611ba2010-06-16 12:26:53 +0200300static const struct mxc_nand_platform_data
301pcm037_nand_board_info __initconst = {
Sascha Hauer4f43c2e2009-11-12 11:30:26 +0100302 .width = 1,
303 .hw_ecc = 1,
304};
305
Sascha Hauercb2dc112010-02-04 14:32:53 +0100306static struct mxc_usbh_platform_data otg_pdata = {
307 .portsc = MXC_EHCI_MODE_UTMI,
308 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
309};
310
311static struct mxc_usbh_platform_data usbh1_pdata = {
312 .portsc = MXC_EHCI_MODE_SERIAL,
313 .flags = MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY |
314 MXC_EHCI_IPPUE_DOWN,
315};
316
317static struct fsl_usb2_platform_data otg_device_pdata = {
318 .operating_mode = FSL_USB2_DR_DEVICE,
319 .phy_mode = FSL_USB2_PHY_UTMI,
320};
321
322static int otg_mode_host;
323
324static int __init pcm043_otg_mode(char *options)
325{
326 if (!strcmp(options, "host"))
327 otg_mode_host = 1;
328 else if (!strcmp(options, "device"))
329 otg_mode_host = 0;
330 else
331 pr_info("otg_mode neither \"host\" nor \"device\". "
332 "Defaulting to device\n");
333 return 0;
334}
335__setup("otg_mode=", pcm043_otg_mode);
336
Sascha Hauer54df5262009-02-06 15:42:26 +0100337/*
338 * Board specific initialization.
339 */
340static void __init mxc_board_init(void)
341{
342 mxc_iomux_v3_setup_multiple_pads(pcm043_pads, ARRAY_SIZE(pcm043_pads));
343
Sascha Hauerd2831d12010-02-09 11:04:36 +0100344 mxc_audmux_v2_configure_port(3,
345 MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
346 MXC_AUDMUX_V2_PTCR_TFSEL(0) |
347 MXC_AUDMUX_V2_PTCR_TFSDIR,
348 MXC_AUDMUX_V2_PDCR_RXDSEL(0));
349
350 mxc_audmux_v2_configure_port(0,
351 MXC_AUDMUX_V2_PTCR_SYN | /* 4wire mode */
352 MXC_AUDMUX_V2_PTCR_TCSEL(3) |
353 MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
354 MXC_AUDMUX_V2_PDCR_RXDSEL(3));
355
Sascha Hauer54df5262009-02-06 15:42:26 +0100356 platform_add_devices(devices, ARRAY_SIZE(devices));
357
358 mxc_register_device(&mxc_uart_device0, &uart_pdata);
Uwe Kleine-Könige2611ba2010-06-16 12:26:53 +0200359 imx35_add_mxc_nand(&pcm037_nand_board_info);
Sascha Hauerd2831d12010-02-09 11:04:36 +0100360 mxc_register_device(&imx_ssi_device0, &pcm043_ssi_pdata);
Sascha Hauer54df5262009-02-06 15:42:26 +0100361
362 mxc_register_device(&mxc_uart_device1, &uart_pdata);
363
364#if defined CONFIG_I2C_IMX || defined CONFIG_I2C_IMX_MODULE
365 i2c_register_board_info(0, pcm043_i2c_devices,
366 ARRAY_SIZE(pcm043_i2c_devices));
367
Uwe Kleine-König7cdc8fa2010-06-16 19:25:34 +0200368 imx35_add_imx_i2c0(&pcm043_i2c0_data);
Sascha Hauer54df5262009-02-06 15:42:26 +0100369#endif
370
371 mxc_register_device(&mx3_ipu, &mx3_ipu_data);
372 mxc_register_device(&mx3_fb, &mx3fb_pdata);
Sascha Hauercb2dc112010-02-04 14:32:53 +0100373
374#if defined(CONFIG_USB_ULPI)
375 if (otg_mode_host) {
376 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
377 USB_OTG_DRV_VBUS | USB_OTG_DRV_VBUS_EXT);
378
379 mxc_register_device(&mxc_otg_host, &otg_pdata);
380 }
381
382 mxc_register_device(&mxc_usbh1, &usbh1_pdata);
383#endif
384 if (!otg_mode_host)
385 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
386
Sascha Hauer54df5262009-02-06 15:42:26 +0100387}
388
389static void __init pcm043_timer_init(void)
390{
391 mx35_clocks_init();
392}
393
394struct sys_timer pcm043_timer = {
395 .init = pcm043_timer_init,
396};
397
398MACHINE_START(PCM043, "Phytec Phycore pcm043")
399 /* Maintainer: Pengutronix */
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +0100400 .phys_io = MX35_AIPS1_BASE_ADDR,
401 .io_pg_offst = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
Uwe Kleine-König34101232010-01-29 17:36:05 +0100402 .boot_params = MX3x_PHYS_OFFSET + 0x100,
Sascha Hauercd4a05f2009-04-02 22:32:10 +0200403 .map_io = mx35_map_io,
Sascha Hauerc5aa0ad2009-05-25 17:36:19 +0200404 .init_irq = mx35_init_irq,
Sascha Hauer54df5262009-02-06 15:42:26 +0100405 .init_machine = mxc_board_init,
406 .timer = &pcm043_timer,
407MACHINE_END
408