blob: 03762a36d29fb97aed1784adfd5085d04f6989e0 [file] [log] [blame]
Daniel Mack9a4cd7a2008-07-05 10:02:53 +02001/*
2 * Copyright (C) 2000 Deep Blue Solutions Ltd
3 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
4 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
Daniel Mack84677d12009-11-19 12:02:08 +01005 * Copyright (C) 2009 Daniel Mack <daniel@caiaq.de>
Daniel Mack9a4cd7a2008-07-05 10:02:53 +02006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/types.h>
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/memory.h>
Magnus Lilja32117052009-04-14 22:00:07 +020026#include <linux/platform_device.h>
27#include <linux/gpio.h>
28#include <linux/smsc911x.h>
Daniel Mack84677d12009-11-19 12:02:08 +010029#include <linux/mfd/mc13783.h>
30#include <linux/spi/spi.h>
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020031
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020032#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
Juergen Beisert9e8a30d2008-07-05 10:02:53 +020034#include <asm/mach/time.h>
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020035#include <asm/mach/map.h>
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020036#include <asm/page.h>
37#include <asm/setup.h>
Daniel Mack84677d12009-11-19 12:02:08 +010038
39#include <mach/hardware.h>
40#include <mach/common.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/board-mx31lite.h>
Magnus Liljaa854b8a2009-04-14 22:00:03 +020042#include <mach/imx-uart.h>
43#include <mach/iomux-mx3.h>
Magnus Lilja32117052009-04-14 22:00:07 +020044#include <mach/irqs.h>
Magnus Lilja183c7ff2009-05-04 22:18:09 +020045#include <mach/mxc_nand.h>
Daniel Mack84677d12009-11-19 12:02:08 +010046#include <mach/spi.h>
47
Magnus Liljaa854b8a2009-04-14 22:00:03 +020048#include "devices.h"
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020049
50/*
Daniel Mackb7d91a62009-11-19 12:02:06 +010051 * This file contains the module-specific initialization routines.
Daniel Mack9a4cd7a2008-07-05 10:02:53 +020052 */
53
Magnus Liljaa854b8a2009-04-14 22:00:03 +020054static unsigned int mx31lite_pins[] = {
Magnus Lilja32117052009-04-14 22:00:07 +020055 /* LAN9117 IRQ pin */
56 IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO),
Daniel Mack84677d12009-11-19 12:02:08 +010057 /* SPI 1 */
58 MX31_PIN_CSPI2_SCLK__SCLK,
59 MX31_PIN_CSPI2_MOSI__MOSI,
60 MX31_PIN_CSPI2_MISO__MISO,
61 MX31_PIN_CSPI2_SPI_RDY__SPI_RDY,
62 MX31_PIN_CSPI2_SS0__SS0,
63 MX31_PIN_CSPI2_SS1__SS1,
64 MX31_PIN_CSPI2_SS2__SS2,
Magnus Liljaa854b8a2009-04-14 22:00:03 +020065};
66
Magnus Lilja183c7ff2009-05-04 22:18:09 +020067static struct mxc_nand_platform_data mx31lite_nand_board_info = {
68 .width = 1,
69 .hw_ecc = 1,
70};
71
Magnus Lilja32117052009-04-14 22:00:07 +020072static struct smsc911x_platform_config smsc911x_config = {
73 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
74 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
75 .flags = SMSC911X_USE_16BIT,
76};
77
78static struct resource smsc911x_resources[] = {
Sascha Hauer3f4f54b2009-06-23 12:12:00 +020079 {
Magnus Lilja32117052009-04-14 22:00:07 +020080 .start = CS4_BASE_ADDR,
81 .end = CS4_BASE_ADDR + 0x100,
82 .flags = IORESOURCE_MEM,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +020083 }, {
Magnus Lilja32117052009-04-14 22:00:07 +020084 .start = IOMUX_TO_IRQ(MX31_PIN_SFS6),
85 .end = IOMUX_TO_IRQ(MX31_PIN_SFS6),
86 .flags = IORESOURCE_IRQ,
87 },
88};
89
90static struct platform_device smsc911x_device = {
91 .name = "smsc911x",
92 .id = -1,
93 .num_resources = ARRAY_SIZE(smsc911x_resources),
94 .resource = smsc911x_resources,
95 .dev = {
96 .platform_data = &smsc911x_config,
97 },
98};
99
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200100/*
Daniel Mack84677d12009-11-19 12:02:08 +0100101 * SPI
102 *
103 * The MC13783 is the only hard-wired SPI device on the module.
104 */
105
106static int spi_internal_chipselect[] = {
107 MXC_SPI_CS(0),
108};
109
110static struct spi_imx_master spi1_pdata = {
111 .chipselect = spi_internal_chipselect,
112 .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
113};
114
115static struct mc13783_platform_data mc13783_pdata __initdata = {
116 .flags = MC13783_USE_RTC |
117 MC13783_USE_REGULATOR,
118};
119
120static struct spi_board_info mc13783_spi_dev __initdata = {
121 .modalias = "mc13783",
122 .max_speed_hz = 1000000,
123 .bus_num = 1,
124 .chip_select = 0,
125 .platform_data = &mc13783_pdata,
126 .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
127};
128
129/*
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200130 * This structure defines the MX31 memory map.
131 */
132static struct map_desc mx31lite_io_desc[] __initdata = {
133 {
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200134 .virtual = SPBA0_BASE_ADDR_VIRT,
135 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
136 .length = SPBA0_SIZE,
Russell King9b727ab2008-09-07 12:45:01 +0100137 .type = MT_DEVICE_NONSHARED
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200138 }, {
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200139 .virtual = CS4_BASE_ADDR_VIRT,
140 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
141 .length = CS4_SIZE,
142 .type = MT_DEVICE
143 }
144};
145
146/*
147 * Set up static virtual mappings.
148 */
149void __init mx31lite_map_io(void)
150{
Sascha Hauercd4a05f2009-04-02 22:32:10 +0200151 mx31_map_io();
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200152 iotable_init(mx31lite_io_desc, ARRAY_SIZE(mx31lite_io_desc));
153}
154
Daniel Mackb7d91a62009-11-19 12:02:06 +0100155static int mx31lite_baseboard;
156core_param(mx31lite_baseboard, mx31lite_baseboard, int, 0444);
157
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200158static void __init mxc_board_init(void)
159{
Sascha Hauer4f163eb2009-05-06 12:55:50 +0200160 int ret;
161
Daniel Mackb7d91a62009-11-19 12:02:06 +0100162 switch (mx31lite_baseboard) {
163 case MX31LITE_NOBOARD:
164 break;
165 case MX31LITE_DB:
166 mx31lite_db_init();
167 break;
168 default:
169 printk(KERN_ERR "Illegal mx31lite_baseboard type %d\n",
170 mx31lite_baseboard);
171 }
172
Magnus Liljaa854b8a2009-04-14 22:00:03 +0200173 mxc_iomux_setup_multiple_pins(mx31lite_pins, ARRAY_SIZE(mx31lite_pins),
174 "mx31lite");
175
Magnus Lilja183c7ff2009-05-04 22:18:09 +0200176 mxc_register_device(&mxc_nand_device, &mx31lite_nand_board_info);
Daniel Mack84677d12009-11-19 12:02:08 +0100177 mxc_register_device(&mxc_spi_device1, &spi1_pdata);
178 spi_register_board_info(&mc13783_spi_dev, 1);
Magnus Lilja32117052009-04-14 22:00:07 +0200179
180 /* SMSC9117 IRQ pin */
Sascha Hauer4f163eb2009-05-06 12:55:50 +0200181 ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_SFS6), "sms9117-irq");
182 if (ret)
183 pr_warning("could not get LAN irq gpio\n");
184 else {
185 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6));
186 platform_device_register(&smsc911x_device);
187 }
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200188}
189
Juergen Beisert9e8a30d2008-07-05 10:02:53 +0200190static void __init mx31lite_timer_init(void)
191{
Sascha Hauer30c730f2009-02-16 14:36:49 +0100192 mx31_clocks_init(26000000);
Juergen Beisert9e8a30d2008-07-05 10:02:53 +0200193}
194
195struct sys_timer mx31lite_timer = {
196 .init = mx31lite_timer_init,
197};
198
Daniel Mackb7d91a62009-11-19 12:02:06 +0100199MACHINE_START(MX31LITE, "LogicPD i.MX31 SOM")
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200200 /* Maintainer: Freescale Semiconductor, Inc. */
201 .phys_io = AIPS1_BASE_ADDR,
202 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
203 .boot_params = PHYS_OFFSET + 0x100,
204 .map_io = mx31lite_map_io,
Sascha Hauerc5aa0ad2009-05-25 17:36:19 +0200205 .init_irq = mx31_init_irq,
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200206 .init_machine = mxc_board_init,
Juergen Beisert9e8a30d2008-07-05 10:02:53 +0200207 .timer = &mx31lite_timer,
Daniel Mack9a4cd7a2008-07-05 10:02:53 +0200208MACHINE_END