| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 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> | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 30 | #include <linux/platform_device.h> | 
|  | 31 | #include <linux/interrupt.h> | 
|  | 32 | #include <linux/smsc911x.h> | 
| Daniel Mack | 38160e0 | 2009-05-20 19:54:38 +0200 | [diff] [blame] | 33 | #include <linux/mtd/physmap.h> | 
| Daniel Mack | 2cc3268 | 2009-11-21 18:40:40 +0100 | [diff] [blame] | 34 | #include <linux/spi/spi.h> | 
|  | 35 | #include <linux/mfd/mc13783.h> | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 36 |  | 
|  | 37 | #include <asm/mach-types.h> | 
|  | 38 | #include <asm/mach/arch.h> | 
|  | 39 | #include <asm/mach/time.h> | 
|  | 40 | #include <asm/mach/map.h> | 
|  | 41 |  | 
|  | 42 | #include <mach/hardware.h> | 
|  | 43 | #include <mach/common.h> | 
|  | 44 | #include <mach/iomux-mx3.h> | 
|  | 45 | #include <mach/board-mx31lilly.h> | 
| Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 46 | #include <mach/spi.h> | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 47 |  | 
|  | 48 | #include "devices.h" | 
|  | 49 |  | 
|  | 50 | /* | 
|  | 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. | 
|  | 54 | */ | 
|  | 55 |  | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 56 | /* SMSC ethernet support */ | 
|  | 57 |  | 
|  | 58 | static struct resource smsc91x_resources[] = { | 
|  | 59 | { | 
| Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 60 | .start	= MX31_CS4_BASE_ADDR, | 
|  | 61 | .end	= MX31_CS4_BASE_ADDR + 0xffff, | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 62 | .flags	= IORESOURCE_MEM, | 
|  | 63 | }, | 
|  | 64 | { | 
|  | 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, | 
|  | 68 | } | 
|  | 69 | }; | 
|  | 70 |  | 
|  | 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, | 
|  | 78 | }; | 
|  | 79 |  | 
|  | 80 | static struct platform_device smsc91x_device = { | 
|  | 81 | .name		= "smsc911x", | 
|  | 82 | .id		= -1, | 
|  | 83 | .num_resources	= ARRAY_SIZE(smsc91x_resources), | 
|  | 84 | .resource	= smsc91x_resources, | 
|  | 85 | .dev		= { | 
|  | 86 | .platform_data = &smsc911x_config, | 
|  | 87 | } | 
|  | 88 | }; | 
|  | 89 |  | 
| Daniel Mack | 38160e0 | 2009-05-20 19:54:38 +0200 | [diff] [blame] | 90 | /* NOR flash */ | 
|  | 91 | static struct physmap_flash_data nor_flash_data = { | 
|  | 92 | .width  = 2, | 
|  | 93 | }; | 
|  | 94 |  | 
|  | 95 | static struct resource nor_flash_resource = { | 
|  | 96 | .start	= 0xa0000000, | 
|  | 97 | .end	= 0xa1ffffff, | 
|  | 98 | .flags	= IORESOURCE_MEM, | 
|  | 99 | }; | 
|  | 100 |  | 
|  | 101 | static struct platform_device physmap_flash_device = { | 
|  | 102 | .name	= "physmap-flash", | 
|  | 103 | .id	= 0, | 
|  | 104 | .dev	= { | 
|  | 105 | .platform_data  = &nor_flash_data, | 
|  | 106 | }, | 
|  | 107 | .resource = &nor_flash_resource, | 
|  | 108 | .num_resources = 1, | 
|  | 109 | }; | 
|  | 110 |  | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 111 | static struct platform_device *devices[] __initdata = { | 
|  | 112 | &smsc91x_device, | 
| Daniel Mack | 38160e0 | 2009-05-20 19:54:38 +0200 | [diff] [blame] | 113 | &physmap_flash_device, | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 114 | }; | 
|  | 115 |  | 
| Daniel Mack | 2cc3268 | 2009-11-21 18:40:40 +0100 | [diff] [blame] | 116 | /* SPI */ | 
|  | 117 |  | 
| Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 118 | static int spi_internal_chipselect[] = { | 
|  | 119 | MXC_SPI_CS(0), | 
|  | 120 | MXC_SPI_CS(1), | 
|  | 121 | MXC_SPI_CS(2), | 
|  | 122 | }; | 
|  | 123 |  | 
|  | 124 | static struct spi_imx_master spi0_pdata = { | 
|  | 125 | .chipselect = spi_internal_chipselect, | 
|  | 126 | .num_chipselect = ARRAY_SIZE(spi_internal_chipselect), | 
|  | 127 | }; | 
|  | 128 |  | 
|  | 129 | static struct spi_imx_master spi1_pdata = { | 
|  | 130 | .chipselect = spi_internal_chipselect, | 
|  | 131 | .num_chipselect = ARRAY_SIZE(spi_internal_chipselect), | 
|  | 132 | }; | 
|  | 133 |  | 
| Daniel Mack | 2cc3268 | 2009-11-21 18:40:40 +0100 | [diff] [blame] | 134 | static struct mc13783_platform_data mc13783_pdata __initdata = { | 
|  | 135 | .flags = MC13783_USE_RTC | MC13783_USE_TOUCHSCREEN, | 
|  | 136 | }; | 
|  | 137 |  | 
|  | 138 | static struct spi_board_info mc13783_dev __initdata = { | 
|  | 139 | .modalias	= "mc13783", | 
|  | 140 | .max_speed_hz	= 1000000, | 
|  | 141 | .bus_num	= 1, | 
|  | 142 | .chip_select	= 0, | 
|  | 143 | .platform_data	= &mc13783_pdata, | 
|  | 144 | }; | 
|  | 145 |  | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 146 | static int mx31lilly_baseboard; | 
|  | 147 | core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444); | 
|  | 148 |  | 
|  | 149 | static void __init mx31lilly_board_init(void) | 
|  | 150 | { | 
|  | 151 | switch (mx31lilly_baseboard) { | 
|  | 152 | case MX31LILLY_NOBOARD: | 
|  | 153 | break; | 
| Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 154 | case MX31LILLY_DB: | 
|  | 155 | mx31lilly_db_init(); | 
|  | 156 | break; | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 157 | default: | 
|  | 158 | printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n", | 
|  | 159 | mx31lilly_baseboard); | 
|  | 160 | } | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 161 |  | 
|  | 162 | mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS"); | 
|  | 163 |  | 
| Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 164 | /* SPI */ | 
|  | 165 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SCLK__SCLK, "SPI1_CLK"); | 
|  | 166 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MOSI__MOSI, "SPI1_TX"); | 
|  | 167 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_MISO__MISO, "SPI1_RX"); | 
|  | 168 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SPI_RDY__SPI_RDY, "SPI1_RDY"); | 
|  | 169 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS0__SS0, "SPI1_SS0"); | 
|  | 170 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS1__SS1, "SPI1_SS1"); | 
|  | 171 | mxc_iomux_alloc_pin(MX31_PIN_CSPI1_SS2__SS2, "SPI1_SS2"); | 
|  | 172 |  | 
|  | 173 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SCLK__SCLK, "SPI2_CLK"); | 
|  | 174 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MOSI__MOSI, "SPI2_TX"); | 
|  | 175 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_MISO__MISO, "SPI2_RX"); | 
|  | 176 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SPI_RDY__SPI_RDY, "SPI2_RDY"); | 
|  | 177 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS0__SS0, "SPI2_SS0"); | 
|  | 178 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1"); | 
|  | 179 | mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2"); | 
|  | 180 |  | 
|  | 181 | mxc_register_device(&mxc_spi_device0, &spi0_pdata); | 
|  | 182 | mxc_register_device(&mxc_spi_device1, &spi1_pdata); | 
| Daniel Mack | 2cc3268 | 2009-11-21 18:40:40 +0100 | [diff] [blame] | 183 | spi_register_board_info(&mc13783_dev, 1); | 
| Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 184 |  | 
| Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 185 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 186 | } | 
|  | 187 |  | 
|  | 188 | static void __init mx31lilly_timer_init(void) | 
|  | 189 | { | 
|  | 190 | mx31_clocks_init(26000000); | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | static struct sys_timer mx31lilly_timer = { | 
|  | 194 | .init	= mx31lilly_timer_init, | 
|  | 195 | }; | 
|  | 196 |  | 
|  | 197 | MACHINE_START(LILLY1131, "INCO startec LILLY-1131") | 
| Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 198 | .phys_io	= MX31_AIPS1_BASE_ADDR, | 
| Uwe Kleine-König | 321ed16 | 2009-12-10 10:41:26 +0100 | [diff] [blame] | 199 | .io_pg_offst	= (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc, | 
| Uwe Kleine-König | 3410123 | 2010-01-29 17:36:05 +0100 | [diff] [blame] | 200 | .boot_params	= MX3x_PHYS_OFFSET + 0x100, | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 201 | .map_io		= mx31_map_io, | 
| Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 202 | .init_irq	= mx31_init_irq, | 
| Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 203 | .init_machine	= mx31lilly_board_init, | 
|  | 204 | .timer		= &mx31lilly_timer, | 
|  | 205 | MACHINE_END | 
|  | 206 |  |