2 * LILLY-1131 module support
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6 * based on code for other MX31 boards,
8 * Copyright 2005-2007 Freescale Semiconductor
9 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
10 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
23 #include <linux/types.h>
24 #include <linux/init.h>
25 #include <linux/clk.h>
26 #include <linux/gpio.h>
27 #include <linux/delay.h>
28 #include <linux/platform_device.h>
29 #include <linux/interrupt.h>
30 #include <linux/smsc911x.h>
31 #include <linux/mtd/physmap.h>
32 #include <linux/spi/spi.h>
33 #include <linux/mfd/mc13783.h>
34 #include <linux/usb/otg.h>
35 #include <linux/usb/ulpi.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/time.h>
40 #include <asm/mach/map.h>
42 #include <mach/hardware.h>
43 #include <mach/common.h>
44 #include <mach/iomux-mx3.h>
45 #include <mach/board-mx31lilly.h>
46 #include <mach/ulpi.h>
48 #include "devices-imx31.h"
51 * This file contains module-specific initialization routines for LILLY-1131.
52 * Initialization of peripherals found on the baseboard is implemented in the
53 * appropriate baseboard support code.
56 /* SMSC ethernet support */
58 static struct resource smsc91x_resources
[] = {
60 .start
= MX31_CS4_BASE_ADDR
,
61 .end
= MX31_CS4_BASE_ADDR
+ 0xffff,
62 .flags
= IORESOURCE_MEM
,
65 .start
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_0
),
66 .end
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_0
),
67 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_FALLING
,
71 static struct smsc911x_platform_config smsc911x_config
= {
72 .phy_interface
= PHY_INTERFACE_MODE_MII
,
73 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
74 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
75 .flags
= SMSC911X_USE_32BIT
|
76 SMSC911X_SAVE_MAC_ADDRESS
|
77 SMSC911X_FORCE_INTERNAL_PHY
,
80 static struct platform_device smsc91x_device
= {
83 .num_resources
= ARRAY_SIZE(smsc91x_resources
),
84 .resource
= smsc91x_resources
,
86 .platform_data
= &smsc911x_config
,
91 static struct physmap_flash_data nor_flash_data
= {
95 static struct resource nor_flash_resource
= {
98 .flags
= IORESOURCE_MEM
,
101 static struct platform_device physmap_flash_device
= {
102 .name
= "physmap-flash",
105 .platform_data
= &nor_flash_data
,
107 .resource
= &nor_flash_resource
,
113 #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
114 PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
116 static int usbh1_init(struct platform_device
*pdev
)
119 MX31_PIN_CSPI1_MOSI__USBH1_RXDM
,
120 MX31_PIN_CSPI1_MISO__USBH1_RXDP
,
121 MX31_PIN_CSPI1_SS0__USBH1_TXDM
,
122 MX31_PIN_CSPI1_SS1__USBH1_TXDP
,
123 MX31_PIN_CSPI1_SS2__USBH1_RCV
,
124 MX31_PIN_CSPI1_SCLK__USBH1_OEB
,
125 MX31_PIN_CSPI1_SPI_RDY__USBH1_FS
,
128 mxc_iomux_setup_multiple_pins(pins
, ARRAY_SIZE(pins
), "USB H1");
130 mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI
, USB_PAD_CFG
);
131 mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO
, USB_PAD_CFG
);
132 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0
, USB_PAD_CFG
);
133 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1
, USB_PAD_CFG
);
134 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2
, USB_PAD_CFG
);
135 mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK
, USB_PAD_CFG
);
136 mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY
, USB_PAD_CFG
);
138 mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND
, true);
142 return mx31_initialize_usb_hw(pdev
->id
, MXC_EHCI_POWER_PINS_ENABLED
|
143 MXC_EHCI_INTERFACE_SINGLE_UNI
);
146 static int usbh2_init(struct platform_device
*pdev
)
149 MX31_PIN_USBH2_DATA0__USBH2_DATA0
,
150 MX31_PIN_USBH2_DATA1__USBH2_DATA1
,
151 MX31_PIN_USBH2_CLK__USBH2_CLK
,
152 MX31_PIN_USBH2_DIR__USBH2_DIR
,
153 MX31_PIN_USBH2_NXT__USBH2_NXT
,
154 MX31_PIN_USBH2_STP__USBH2_STP
,
157 mxc_iomux_setup_multiple_pins(pins
, ARRAY_SIZE(pins
), "USB H2");
159 mxc_iomux_set_pad(MX31_PIN_USBH2_CLK
, USB_PAD_CFG
);
160 mxc_iomux_set_pad(MX31_PIN_USBH2_DIR
, USB_PAD_CFG
);
161 mxc_iomux_set_pad(MX31_PIN_USBH2_NXT
, USB_PAD_CFG
);
162 mxc_iomux_set_pad(MX31_PIN_USBH2_STP
, USB_PAD_CFG
);
163 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0
, USB_PAD_CFG
);
164 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1
, USB_PAD_CFG
);
165 mxc_iomux_set_pad(MX31_PIN_SRXD6
, USB_PAD_CFG
);
166 mxc_iomux_set_pad(MX31_PIN_STXD6
, USB_PAD_CFG
);
167 mxc_iomux_set_pad(MX31_PIN_SFS3
, USB_PAD_CFG
);
168 mxc_iomux_set_pad(MX31_PIN_SCK3
, USB_PAD_CFG
);
169 mxc_iomux_set_pad(MX31_PIN_SRXD3
, USB_PAD_CFG
);
170 mxc_iomux_set_pad(MX31_PIN_STXD3
, USB_PAD_CFG
);
172 mxc_iomux_set_gpr(MUX_PGP_UH2
, true);
175 mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1
, IOMUX_CONFIG_GPIO
),
177 gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1
), "USBH2 CS");
178 gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1
), 0);
182 return mx31_initialize_usb_hw(pdev
->id
, MXC_EHCI_POWER_PINS_ENABLED
);
185 static const struct mxc_usbh_platform_data usbh1_pdata __initconst
= {
187 .portsc
= MXC_EHCI_MODE_UTMI
| MXC_EHCI_SERIAL
,
190 static struct mxc_usbh_platform_data usbh2_pdata __initdata
= {
192 .portsc
= MXC_EHCI_MODE_ULPI
| MXC_EHCI_UTMI_8BIT
,
195 static void __init
lilly1131_usb_init(void)
197 imx31_add_mxc_ehci_hs(1, &usbh1_pdata
);
199 usbh2_pdata
.otg
= imx_otg_ulpi_create(ULPI_OTG_DRVVBUS
|
200 ULPI_OTG_DRVVBUS_EXT
);
202 imx31_add_mxc_ehci_hs(2, &usbh2_pdata
);
207 static int spi_internal_chipselect
[] = {
213 static const struct spi_imx_master spi0_pdata __initconst
= {
214 .chipselect
= spi_internal_chipselect
,
215 .num_chipselect
= ARRAY_SIZE(spi_internal_chipselect
),
218 static const struct spi_imx_master spi1_pdata __initconst
= {
219 .chipselect
= spi_internal_chipselect
,
220 .num_chipselect
= ARRAY_SIZE(spi_internal_chipselect
),
223 static struct mc13xxx_platform_data mc13783_pdata __initdata
= {
224 .flags
= MC13XXX_USE_RTC
| MC13XXX_USE_TOUCHSCREEN
,
227 static struct spi_board_info mc13783_dev __initdata
= {
228 .modalias
= "mc13783",
229 .max_speed_hz
= 1000000,
232 .platform_data
= &mc13783_pdata
,
233 .irq
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_3
),
236 static struct platform_device
*devices
[] __initdata
= {
238 &physmap_flash_device
,
241 static int mx31lilly_baseboard
;
242 core_param(mx31lilly_baseboard
, mx31lilly_baseboard
, int, 0444);
244 static void __init
mx31lilly_board_init(void)
248 switch (mx31lilly_baseboard
) {
249 case MX31LILLY_NOBOARD
:
255 printk(KERN_ERR
"Illegal mx31lilly_baseboard type %d\n",
256 mx31lilly_baseboard
);
259 mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4
, "Ethernet CS");
262 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK
, "SPI1_CLK");
263 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI
, "SPI1_TX");
264 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO
, "SPI1_RX");
265 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY
, "SPI1_RDY");
266 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0
, "SPI1_SS0");
267 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1
, "SPI1_SS1");
268 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2
, "SPI1_SS2");
270 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK
, "SPI2_CLK");
271 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI
, "SPI2_TX");
272 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO
, "SPI2_RX");
273 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY
, "SPI2_RDY");
274 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0
, "SPI2_SS0");
275 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1
, "SPI2_SS1");
276 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2
, "SPI2_SS2");
278 imx31_add_spi_imx0(&spi0_pdata
);
279 imx31_add_spi_imx1(&spi1_pdata
);
280 spi_register_board_info(&mc13783_dev
, 1);
282 platform_add_devices(devices
, ARRAY_SIZE(devices
));
285 lilly1131_usb_init();
288 static void __init
mx31lilly_timer_init(void)
290 mx31_clocks_init(26000000);
293 static struct sys_timer mx31lilly_timer
= {
294 .init
= mx31lilly_timer_init
,
297 MACHINE_START(LILLY1131
, "INCO startec LILLY-1131")
298 .boot_params
= MX3x_PHYS_OFFSET
+ 0x100,
299 .map_io
= mx31_map_io
,
300 .init_early
= imx31_init_early
,
301 .init_irq
= mx31_init_irq
,
302 .timer
= &mx31lilly_timer
,
303 .init_machine
= mx31lilly_board_init
,