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 | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 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> |
Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 44 | #include <mach/spi.h> |
Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 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 | |
Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 54 | /* SMSC ethernet support */ |
| 55 | |
| 56 | static 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 | |
| 69 | static 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 | |
| 78 | static 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 | |
Daniel Mack | 38160e0 | 2009-05-20 19:54:38 +0200 | [diff] [blame] | 88 | /* NOR flash */ |
| 89 | static struct physmap_flash_data nor_flash_data = { |
| 90 | .width = 2, |
| 91 | }; |
| 92 | |
| 93 | static struct resource nor_flash_resource = { |
| 94 | .start = 0xa0000000, |
| 95 | .end = 0xa1ffffff, |
| 96 | .flags = IORESOURCE_MEM, |
| 97 | }; |
| 98 | |
| 99 | static 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 | |
Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 109 | static struct platform_device *devices[] __initdata = { |
| 110 | &smsc91x_device, |
Daniel Mack | 38160e0 | 2009-05-20 19:54:38 +0200 | [diff] [blame] | 111 | &physmap_flash_device, |
Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 112 | }; |
| 113 | |
Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 114 | static int spi_internal_chipselect[] = { |
| 115 | MXC_SPI_CS(0), |
| 116 | MXC_SPI_CS(1), |
| 117 | MXC_SPI_CS(2), |
| 118 | }; |
| 119 | |
| 120 | static struct spi_imx_master spi0_pdata = { |
| 121 | .chipselect = spi_internal_chipselect, |
| 122 | .num_chipselect = ARRAY_SIZE(spi_internal_chipselect), |
| 123 | }; |
| 124 | |
| 125 | static struct spi_imx_master spi1_pdata = { |
| 126 | .chipselect = spi_internal_chipselect, |
| 127 | .num_chipselect = ARRAY_SIZE(spi_internal_chipselect), |
| 128 | }; |
| 129 | |
Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 130 | static int mx31lilly_baseboard; |
| 131 | core_param(mx31lilly_baseboard, mx31lilly_baseboard, int, 0444); |
| 132 | |
| 133 | static void __init mx31lilly_board_init(void) |
| 134 | { |
| 135 | switch (mx31lilly_baseboard) { |
| 136 | case MX31LILLY_NOBOARD: |
| 137 | break; |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 138 | case MX31LILLY_DB: |
| 139 | mx31lilly_db_init(); |
| 140 | break; |
Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 141 | default: |
| 142 | printk(KERN_ERR "Illegal mx31lilly_baseboard type %d\n", |
| 143 | mx31lilly_baseboard); |
| 144 | } |
Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 145 | |
| 146 | mxc_iomux_alloc_pin(MX31_PIN_CS4__CS4, "Ethernet CS"); |
| 147 | |
Daniel Mack | 3ea2e1a | 2009-10-26 11:55:56 +0100 | [diff] [blame] | 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 | |
Daniel Mack | cbaa6ca | 2009-05-20 19:54:35 +0200 | [diff] [blame] | 168 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static void __init mx31lilly_timer_init(void) |
| 172 | { |
| 173 | mx31_clocks_init(26000000); |
| 174 | } |
| 175 | |
| 176 | static struct sys_timer mx31lilly_timer = { |
| 177 | .init = mx31lilly_timer_init, |
| 178 | }; |
| 179 | |
| 180 | MACHINE_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, |
Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 185 | .init_irq = mx31_init_irq, |
Daniel Mack | 65b1aa1 | 2009-05-20 19:54:33 +0200 | [diff] [blame] | 186 | .init_machine = mx31lilly_board_init, |
| 187 | .timer = &mx31lilly_timer, |
| 188 | MACHINE_END |
| 189 | |