]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/arm/mach-mx3/mx31lilly.c
ARM: MX3: add SPI functions for lilly1131-db
[mirror_ubuntu-bionic-kernel.git] / arch / arm / mach-mx3 / mx31lilly.c
CommitLineData
65b1aa13
DM
1/*
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.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <linux/types.h>
28#include <linux/init.h>
29#include <linux/clk.h>
cbaa6ca1
DM
30#include <linux/platform_device.h>
31#include <linux/interrupt.h>
32#include <linux/smsc911x.h>
38160e0b 33#include <linux/mtd/physmap.h>
65b1aa13
DM
34
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/time.h>
38#include <asm/mach/map.h>
39
40#include <mach/hardware.h>
41#include <mach/common.h>
42#include <mach/iomux-mx3.h>
43#include <mach/board-mx31lilly.h>
3ea2e1a4 44#include <mach/spi.h>
65b1aa13
DM
45
46#include "devices.h"
47
48/*
49 * This file contains module-specific initialization routines for LILLY-1131.
50 * Initialization of peripherals found on the baseboard is implemented in the
51 * appropriate baseboard support code.
52 */
53
cbaa6ca1
DM
54/* SMSC ethernet support */
55
56static struct resource smsc91x_resources[] = {
57 {
58 .start = CS4_BASE_ADDR,
59 .end = CS4_BASE_ADDR + 0xffff,
60 .flags = IORESOURCE_MEM,
61 },
62 {
63 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
64 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
65 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
66 }
67};
68
69static struct smsc911x_platform_config smsc911x_config = {
70 .phy_interface = PHY_INTERFACE_MODE_MII,
71 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
72 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
73 .flags = SMSC911X_USE_32BIT |
74 SMSC911X_SAVE_MAC_ADDRESS |
75 SMSC911X_FORCE_INTERNAL_PHY,
76};
77
78static struct platform_device smsc91x_device = {
79 .name = "smsc911x",
80 .id = -1,
81 .num_resources = ARRAY_SIZE(smsc91x_resources),
82 .resource = smsc91x_resources,
83 .dev = {
84 .platform_data = &smsc911x_config,
85 }
86};
87
38160e0b
DM
88/* NOR flash */
89static struct physmap_flash_data nor_flash_data = {
90 .width = 2,
91};
92
93static struct resource nor_flash_resource = {
94 .start = 0xa0000000,
95 .end = 0xa1ffffff,
96 .flags = IORESOURCE_MEM,
97};
98
99static struct platform_device physmap_flash_device = {
100 .name = "physmap-flash",
101 .id = 0,
102 .dev = {
103 .platform_data = &nor_flash_data,
104 },
105 .resource = &nor_flash_resource,
106 .num_resources = 1,
107};
108
cbaa6ca1
DM
109static struct platform_device *devices[] __initdata = {
110 &smsc91x_device,
38160e0b 111 &physmap_flash_device,
cbaa6ca1
DM
112};
113
3ea2e1a4
DM
114static int spi_internal_chipselect[] = {
115 MXC_SPI_CS(0),
116 MXC_SPI_CS(1),
117 MXC_SPI_CS(2),
118};
119
120static struct spi_imx_master spi0_pdata = {
121 .chipselect = spi_internal_chipselect,
122 .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
123};
124
125static struct spi_imx_master spi1_pdata = {
126 .chipselect = spi_internal_chipselect,
127 .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
128};
129
65b1aa13
DM
130static int mx31lilly_baseboard;
131core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444);
132
133static void __init mx31lilly_board_init(void)
134{
135 switch (mx31lilly_baseboard) {
136 case MX31LILLY_NOBOARD:
137 break;
1bc34f79
DM
138 case MX31LILLY_DB:
139 mx31lilly_db_init();
140 break;
65b1aa13
DM
141 default:
142 printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n",
143 mx31lilly_baseboard);
144 }
cbaa6ca1
DM
145
146 mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS");
147
3ea2e1a4
DM
148 /* SPI */
149 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK");
150 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX");
151 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX");
152 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY");
153 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0");
154 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1");
155 mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2");
156
157 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK");
158 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX");
159 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX");
160 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY");
161 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0");
162 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1");
163 mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2");
164
165 mxc_register_device(&mxc_spi_device0, &spi0_pdata);
166 mxc_register_device(&mxc_spi_device1, &spi1_pdata);
167
cbaa6ca1 168 platform_add_devices(devices, ARRAY_SIZE(devices));
65b1aa13
DM
169}
170
171static void __init mx31lilly_timer_init(void)
172{
173 mx31_clocks_init(26000000);
174}
175
176static struct sys_timer mx31lilly_timer = {
177 .init = mx31lilly_timer_init,
178};
179
180MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
181 .phys_io = AIPS1_BASE_ADDR,
182 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
183 .boot_params = PHYS_OFFSET + 0x100,
184 .map_io = mx31_map_io,
c5aa0ad0 185 .init_irq = mx31_init_irq,
65b1aa13
DM
186 .init_machine = mx31lilly_board_init,
187 .timer = &mx31lilly_timer,
188MACHINE_END
189