blob: 102ec99357ccb99bec5e83551d3d0f1303b6a25f [file] [log] [blame]
Daniel Mack65b1aa12009-05-20 19:54:33 +02001/*
2 * LILLY-1131 module support
3 *
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
5 *
6 * based on code for other MX31 boards,
7 *
8 * Copyright 2005-2007 Freescale Semiconductor
9 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
10 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
11 *
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.
16 *
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.
Daniel Mack65b1aa12009-05-20 19:54:33 +020021 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/clk.h>
Daniel Mack066fb842010-04-13 20:11:37 +020026#include <linux/gpio.h>
Sascha Hauer4bd597b2011-01-03 11:30:28 +010027#include <linux/delay.h>
Daniel Mackcbaa6ca2009-05-20 19:54:35 +020028#include <linux/platform_device.h>
29#include <linux/interrupt.h>
Paul Gortmaker9e907412011-07-31 19:01:27 -040030#include <linux/moduleparam.h>
Daniel Mackcbaa6ca2009-05-20 19:54:35 +020031#include <linux/smsc911x.h>
Daniel Mack38160e02009-05-20 19:54:38 +020032#include <linux/mtd/physmap.h>
Daniel Mack2cc32682009-11-21 18:40:40 +010033#include <linux/spi/spi.h>
34#include <linux/mfd/mc13783.h>
Daniel Mack066fb842010-04-13 20:11:37 +020035#include <linux/usb/otg.h>
36#include <linux/usb/ulpi.h>
Daniel Mack65b1aa12009-05-20 19:54:33 +020037
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
40#include <asm/mach/time.h>
41#include <asm/mach/map.h>
42
43#include <mach/hardware.h>
44#include <mach/common.h>
45#include <mach/iomux-mx3.h>
46#include <mach/board-mx31lilly.h>
Daniel Mack066fb842010-04-13 20:11:37 +020047#include <mach/ulpi.h>
Daniel Mack65b1aa12009-05-20 19:54:33 +020048
Uwe Kleine-König06606ff2010-06-22 10:09:14 +020049#include "devices-imx31.h"
Daniel Mack65b1aa12009-05-20 19:54:33 +020050
51/*
52 * This file contains module-specific initialization routines for LILLY-1131.
53 * Initialization of peripherals found on the baseboard is implemented in the
54 * appropriate baseboard support code.
55 */
56
Daniel Mackcbaa6ca2009-05-20 19:54:35 +020057/* SMSC ethernet support */
58
59static struct resource smsc91x_resources[] = {
60 {
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +010061 .start = MX31_CS4_BASE_ADDR,
62 .end = MX31_CS4_BASE_ADDR + 0xffff,
Daniel Mackcbaa6ca2009-05-20 19:54:35 +020063 .flags = IORESOURCE_MEM,
64 },
65 {
66 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
67 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
68 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
69 }
70};
71
72static struct smsc911x_platform_config smsc911x_config = {
73 .phy_interface = PHY_INTERFACE_MODE_MII,
74 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
75 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
76 .flags = SMSC911X_USE_32BIT |
77 SMSC911X_SAVE_MAC_ADDRESS |
78 SMSC911X_FORCE_INTERNAL_PHY,
79};
80
81static struct platform_device smsc91x_device = {
82 .name = "smsc911x",
83 .id = -1,
84 .num_resources = ARRAY_SIZE(smsc91x_resources),
85 .resource = smsc91x_resources,
86 .dev = {
87 .platform_data = &smsc911x_config,
88 }
89};
90
Daniel Mack38160e02009-05-20 19:54:38 +020091/* NOR flash */
92static struct physmap_flash_data nor_flash_data = {
93 .width = 2,
94};
95
96static struct resource nor_flash_resource = {
97 .start = 0xa0000000,
98 .end = 0xa1ffffff,
99 .flags = IORESOURCE_MEM,
100};
101
102static struct platform_device physmap_flash_device = {
103 .name = "physmap-flash",
104 .id = 0,
105 .dev = {
106 .platform_data = &nor_flash_data,
107 },
108 .resource = &nor_flash_resource,
109 .num_resources = 1,
110};
111
Daniel Mack066fb842010-04-13 20:11:37 +0200112/* USB */
113
114#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
115 PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
116
Daniel Mack066fb842010-04-13 20:11:37 +0200117static int usbh1_init(struct platform_device *pdev)
118{
119 int pins[] = {
120 MX31_PIN_CSPI1_MOSI__USBH1_RXDM,
121 MX31_PIN_CSPI1_MISO__USBH1_RXDP,
122 MX31_PIN_CSPI1_SS0__USBH1_TXDM,
123 MX31_PIN_CSPI1_SS1__USBH1_TXDP,
124 MX31_PIN_CSPI1_SS2__USBH1_RCV,
125 MX31_PIN_CSPI1_SCLK__USBH1_OEB,
126 MX31_PIN_CSPI1_SPI_RDY__USBH1_FS,
127 };
128
129 mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");
130
131 mxc_iomux_set_pad(MX31_PIN_CSPI1_MOSI, USB_PAD_CFG);
132 mxc_iomux_set_pad(MX31_PIN_CSPI1_MISO, USB_PAD_CFG);
133 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS0, USB_PAD_CFG);
134 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS1, USB_PAD_CFG);
135 mxc_iomux_set_pad(MX31_PIN_CSPI1_SS2, USB_PAD_CFG);
136 mxc_iomux_set_pad(MX31_PIN_CSPI1_SCLK, USB_PAD_CFG);
137 mxc_iomux_set_pad(MX31_PIN_CSPI1_SPI_RDY, USB_PAD_CFG);
138
139 mxc_iomux_set_gpr(MUX_PGP_USB_SUSPEND, true);
140
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100141 mdelay(10);
142
143 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
144 MXC_EHCI_INTERFACE_SINGLE_UNI);
Daniel Mack066fb842010-04-13 20:11:37 +0200145}
146
147static int usbh2_init(struct platform_device *pdev)
148{
149 int pins[] = {
150 MX31_PIN_USBH2_DATA0__USBH2_DATA0,
151 MX31_PIN_USBH2_DATA1__USBH2_DATA1,
152 MX31_PIN_USBH2_CLK__USBH2_CLK,
153 MX31_PIN_USBH2_DIR__USBH2_DIR,
154 MX31_PIN_USBH2_NXT__USBH2_NXT,
155 MX31_PIN_USBH2_STP__USBH2_STP,
156 };
157
158 mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
159
160 mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
161 mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
162 mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
163 mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
164 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
165 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
166 mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
167 mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
168 mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
169 mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
170 mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
171 mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
172
173 mxc_iomux_set_gpr(MUX_PGP_UH2, true);
174
175 /* chip select */
176 mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_DTR_DCE1, IOMUX_CONFIG_GPIO),
177 "USBH2_CS");
178 gpio_request(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), "USBH2 CS");
179 gpio_direction_output(IOMUX_TO_GPIO(MX31_PIN_DTR_DCE1), 0);
180
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100181 mdelay(10);
182
183 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED);
Daniel Mack066fb842010-04-13 20:11:37 +0200184}
185
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100186static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {
Daniel Mack066fb842010-04-13 20:11:37 +0200187 .init = usbh1_init,
188 .portsc = MXC_EHCI_MODE_UTMI | MXC_EHCI_SERIAL,
Daniel Mack066fb842010-04-13 20:11:37 +0200189};
190
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100191static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
Daniel Mack066fb842010-04-13 20:11:37 +0200192 .init = usbh2_init,
193 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Daniel Mack066fb842010-04-13 20:11:37 +0200194};
195
Fabio Estevamf07c7d62011-06-14 15:42:50 -0300196static void __init lilly1131_usb_init(void)
Daniel Mack4d5d8592010-05-25 16:46:55 +0200197{
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100198 imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
Daniel Mack4d5d8592010-05-25 16:46:55 +0200199
Sascha Hauer48f6b092011-03-02 09:27:42 +0100200 usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
201 ULPI_OTG_DRVVBUS_EXT);
202 if (usbh2_pdata.otg)
203 imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
204}
Daniel Mackcbaa6ca2009-05-20 19:54:35 +0200205
Daniel Mack2cc32682009-11-21 18:40:40 +0100206/* SPI */
207
Daniel Mack3ea2e1a2009-10-26 11:55:56 +0100208static int spi_internal_chipselect[] = {
209 MXC_SPI_CS(0),
210 MXC_SPI_CS(1),
211 MXC_SPI_CS(2),
212};
213
Uwe Kleine-König06606ff2010-06-22 10:09:14 +0200214static const struct spi_imx_master spi0_pdata __initconst = {
Daniel Mack3ea2e1a2009-10-26 11:55:56 +0100215 .chipselect = spi_internal_chipselect,
216 .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
217};
218
Uwe Kleine-König06606ff2010-06-22 10:09:14 +0200219static const struct spi_imx_master spi1_pdata __initconst = {
Daniel Mack3ea2e1a2009-10-26 11:55:56 +0100220 .chipselect = spi_internal_chipselect,
221 .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
222};
223
David Jander58363722011-02-10 10:59:44 +0100224static struct mc13xxx_platform_data mc13783_pdata __initdata = {
225 .flags = MC13XXX_USE_RTC | MC13XXX_USE_TOUCHSCREEN,
Daniel Mack2cc32682009-11-21 18:40:40 +0100226};
227
228static struct spi_board_info mc13783_dev __initdata = {
229 .modalias = "mc13783",
230 .max_speed_hz = 1000000,
231 .bus_num = 1,
232 .chip_select = 0,
233 .platform_data = &mc13783_pdata,
Daniel Mack21b07342010-05-25 16:46:56 +0200234 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
Daniel Mack2cc32682009-11-21 18:40:40 +0100235};
236
Daniel Mack4d5d8592010-05-25 16:46:55 +0200237static struct platform_device *devices[] __initdata = {
238 &smsc91x_device,
239 &physmap_flash_device,
240};
241
Daniel Mack65b1aa12009-05-20 19:54:33 +0200242static int mx31lilly_baseboard;
243core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
244
245static void __init mx31lilly_board_init(void)
246{
Shawn Guob78d8e52011-06-06 00:07:55 +0800247 imx31_soc_init();
248
Daniel Mack65b1aa12009-05-20 19:54:33 +0200249 switch (mx31lilly_baseboard) {
250 case MX31LILLY_NOBOARD:
251 break;
Daniel Mack1bc34f72009-05-20 19:54:34 +0200252 case MX31LILLY_DB:
253 mx31lilly_db_init();
254 break;
Daniel Mack65b1aa12009-05-20 19:54:33 +0200255 default:
256 printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
257 mx31lilly_baseboard);
258 }
Daniel Mackcbaa6ca2009-05-20 19:54:35 +0200259
260 mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
261
Daniel Mack3ea2e1a2009-10-26 11:55:56 +0100262 /* SPI */
263 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
264 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
265 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
266 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
267 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
268 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
269 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
270
271 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
272 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
273 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
274 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
275 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
276 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
277 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
278
Uwe Kleine-König06606ff2010-06-22 10:09:14 +0200279 imx31_add_spi_imx0(&spi0_pdata);
280 imx31_add_spi_imx1(&spi1_pdata);
Daniel Mack2cc32682009-11-21 18:40:40 +0100281 spi_register_board_info(&mc13783_dev, 1);
Daniel Mack3ea2e1a2009-10-26 11:55:56 +0100282
Daniel Mackcbaa6ca2009-05-20 19:54:35 +0200283 platform_add_devices(devices, ARRAY_SIZE(devices));
Daniel Mack066fb842010-04-13 20:11:37 +0200284
285 /* USB */
Daniel Mack4d5d8592010-05-25 16:46:55 +0200286 lilly1131_usb_init();
Daniel Mack65b1aa12009-05-20 19:54:33 +0200287}
288
289static void __init mx31lilly_timer_init(void)
290{
291 mx31_clocks_init(26000000);
292}
293
294static struct sys_timer mx31lilly_timer = {
295 .init = mx31lilly_timer_init,
296};
297
298MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400299 .atag_offset = 0x100,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100300 .map_io = mx31_map_io,
301 .init_early = imx31_init_early,
302 .init_irq = mx31_init_irq,
Sascha Hauerffa2ea32011-09-20 14:31:24 +0200303 .handle_irq = imx31_handle_irq,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100304 .timer = &mx31lilly_timer,
305 .init_machine = mx31lilly_board_init,
Daniel Mack65b1aa12009-05-20 19:54:33 +0200306MACHINE_END