Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mach-mx31lilly.c
Go to the documentation of this file.
1 /*
2  * LILLY-1131 module support
3  *
4  * Copyright (c) 2009 Daniel Mack <[email protected]>
5  *
6  * based on code for other MX31 boards,
7  *
8  * Copyright 2005-2007 Freescale Semiconductor
9  * Copyright (c) 2009 Alberto Panizzo <[email protected]>
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.
21  */
22 
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/moduleparam.h>
31 #include <linux/smsc911x.h>
32 #include <linux/mtd/physmap.h>
33 #include <linux/spi/spi.h>
34 #include <linux/mfd/mc13783.h>
35 #include <linux/usb/otg.h>
36 #include <linux/usb/ulpi.h>
38 #include <linux/regulator/fixed.h>
39 
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/time.h>
43 #include <asm/mach/map.h>
44 
45 #include <mach/hardware.h>
46 #include <mach/common.h>
47 #include <mach/iomux-mx3.h>
48 #include <mach/board-mx31lilly.h>
49 #include <mach/ulpi.h>
50 
51 #include "devices-imx31.h"
52 
53 /*
54  * This file contains module-specific initialization routines for LILLY-1131.
55  * Initialization of peripherals found on the baseboard is implemented in the
56  * appropriate baseboard support code.
57  */
58 
59 /* SMSC ethernet support */
60 
61 static struct resource smsc91x_resources[] = {
62  {
63  .start = MX31_CS4_BASE_ADDR,
64  .end = MX31_CS4_BASE_ADDR + 0xffff,
65  .flags = IORESOURCE_MEM,
66  },
67  {
68  /* irq number is run-time assigned */
70  }
71 };
72 
73 static struct smsc911x_platform_config smsc911x_config = {
74  .phy_interface = PHY_INTERFACE_MODE_MII,
75  .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
76  .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
77  .flags = SMSC911X_USE_32BIT |
80 };
81 
82 static struct platform_device smsc91x_device = {
83  .name = "smsc911x",
84  .id = -1,
85  .num_resources = ARRAY_SIZE(smsc91x_resources),
86  .resource = smsc91x_resources,
87  .dev = {
88  .platform_data = &smsc911x_config,
89  }
90 };
91 
92 /* NOR flash */
93 static struct physmap_flash_data nor_flash_data = {
94  .width = 2,
95 };
96 
97 static struct resource nor_flash_resource = {
98  .start = 0xa0000000,
99  .end = 0xa1ffffff,
100  .flags = IORESOURCE_MEM,
101 };
102 
103 static struct platform_device physmap_flash_device = {
104  .name = "physmap-flash",
105  .id = 0,
106  .dev = {
107  .platform_data = &nor_flash_data,
108  },
109  .resource = &nor_flash_resource,
110  .num_resources = 1,
111 };
112 
113 /* USB */
114 
115 #define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
116  PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
117 
118 static int usbh1_init(struct platform_device *pdev)
119 {
120  int pins[] = {
128  };
129 
130  mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H1");
131 
139 
141 
142  mdelay(10);
143 
146 }
147 
148 static int usbh2_init(struct platform_device *pdev)
149 {
150  int pins[] = {
157  };
158 
159  mxc_iomux_setup_multiple_pins(pins, ARRAY_SIZE(pins), "USB H2");
160 
173 
175 
176  /* chip select */
178  "USBH2_CS");
181 
182  mdelay(10);
183 
185 }
186 
187 static const struct mxc_usbh_platform_data usbh1_pdata __initconst = {
188  .init = usbh1_init,
190 };
191 
192 static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
193  .init = usbh2_init,
195 };
196 
197 static void __init lilly1131_usb_init(void)
198 {
199  imx31_add_mxc_ehci_hs(1, &usbh1_pdata);
200 
201  usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
203  if (usbh2_pdata.otg)
204  imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
205 }
206 
207 /* SPI */
208 
209 static int spi_internal_chipselect[] = {
210  MXC_SPI_CS(0),
211  MXC_SPI_CS(1),
212  MXC_SPI_CS(2),
213 };
214 
215 static const struct spi_imx_master spi0_pdata __initconst = {
216  .chipselect = spi_internal_chipselect,
217  .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
218 };
219 
220 static const struct spi_imx_master spi1_pdata __initconst = {
221  .chipselect = spi_internal_chipselect,
222  .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
223 };
224 
225 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
227 };
228 
229 static struct spi_board_info mc13783_dev __initdata = {
230  .modalias = "mc13783",
231  .max_speed_hz = 1000000,
232  .bus_num = 1,
233  .chip_select = 0,
234  .platform_data = &mc13783_pdata,
235  /* irq number is run-time assigned */
236 };
237 
238 static struct platform_device *devices[] __initdata = {
239  &smsc91x_device,
240  &physmap_flash_device,
241 };
242 
243 static int mx31lilly_baseboard;
244 core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
245 
246 static struct regulator_consumer_supply dummy_supplies[] = {
247  REGULATOR_SUPPLY("vdd33a", "smsc911x"),
248  REGULATOR_SUPPLY("vddvario", "smsc911x"),
249 };
250 
251 static void __init mx31lilly_board_init(void)
252 {
253  imx31_soc_init();
254 
255  switch (mx31lilly_baseboard) {
256  case MX31LILLY_NOBOARD:
257  break;
258  case MX31LILLY_DB:
260  break;
261  default:
262  printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
263  mx31lilly_baseboard);
264  }
265 
266  mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
267 
268  /* SPI */
276 
284 
285  imx31_add_spi_imx0(&spi0_pdata);
286  imx31_add_spi_imx1(&spi1_pdata);
287  mc13783_dev.irq = gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_3));
288  spi_register_board_info(&mc13783_dev, 1);
289 
290  regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
291 
292  smsc91x_resources[1].start =
294  smsc91x_resources[1].end =
296  platform_add_devices(devices, ARRAY_SIZE(devices));
297 
298  /* USB */
299  lilly1131_usb_init();
300 }
301 
302 static void __init mx31lilly_timer_init(void)
303 {
304  mx31_clocks_init(26000000);
305 }
306 
307 static struct sys_timer mx31lilly_timer = {
308  .init = mx31lilly_timer_init,
309 };
310 
311 MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
312  .atag_offset = 0x100,
313  .map_io = mx31_map_io,
314  .init_early = imx31_init_early,
315  .init_irq = mx31_init_irq,
316  .handle_irq = imx31_handle_irq,
317  .timer = &mx31lilly_timer,
318  .init_machine = mx31lilly_board_init,
319  .restart = mxc_restart,