Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Sascha Hauer, Pengutronix |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/init.h> |
| 21 | |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/mtd/physmap.h> |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame^] | 24 | #include <linux/mtd/plat-ram.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 25 | #include <linux/memory.h> |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 26 | #include <linux/gpio.h> |
| 27 | #include <linux/smc911x.h> |
| 28 | #include <linux/interrupt.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 29 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | #include <mach/hardware.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/time.h> |
| 34 | #include <asm/mach/map.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | #include <mach/common.h> |
| 36 | #include <mach/imx-uart.h> |
| 37 | #include <mach/iomux-mx3.h> |
| 38 | #include <mach/board-pcm037.h> |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 39 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 40 | #include "devices.h" |
| 41 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 42 | static struct physmap_flash_data pcm037_flash_data = { |
| 43 | .width = 2, |
| 44 | }; |
| 45 | |
| 46 | static struct resource pcm037_flash_resource = { |
| 47 | .start = 0xa0000000, |
| 48 | .end = 0xa1ffffff, |
| 49 | .flags = IORESOURCE_MEM, |
| 50 | }; |
| 51 | |
| 52 | static struct platform_device pcm037_flash = { |
| 53 | .name = "physmap-flash", |
| 54 | .id = 0, |
| 55 | .dev = { |
| 56 | .platform_data = &pcm037_flash_data, |
| 57 | }, |
| 58 | .resource = &pcm037_flash_resource, |
| 59 | .num_resources = 1, |
| 60 | }; |
| 61 | |
| 62 | static struct imxuart_platform_data uart_pdata = { |
Sascha Hauer | a9b0623 | 2008-09-02 10:19:29 +0200 | [diff] [blame] | 63 | .flags = IMXUART_HAVE_RTSCTS, |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 64 | }; |
| 65 | |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 66 | static struct resource smc911x_resources[] = { |
| 67 | [0] = { |
| 68 | .start = CS1_BASE_ADDR + 0x300, |
| 69 | .end = CS1_BASE_ADDR + 0x300 + SZ_64K - 1, |
| 70 | .flags = IORESOURCE_MEM, |
| 71 | }, |
| 72 | [1] = { |
| 73 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
| 74 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO3_1), |
| 75 | .flags = IORESOURCE_IRQ, |
| 76 | }, |
| 77 | }; |
| 78 | |
| 79 | static struct smc911x_platdata smc911x_info = { |
| 80 | .flags = SMC911X_USE_32BIT, |
| 81 | .irq_flags = IRQF_SHARED | IRQF_TRIGGER_LOW, |
| 82 | }; |
| 83 | |
| 84 | static struct platform_device pcm037_eth = { |
| 85 | .name = "smc911x", |
| 86 | .id = -1, |
| 87 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 88 | .resource = smc911x_resources, |
| 89 | .dev = { |
| 90 | .platform_data = &smc911x_info, |
| 91 | }, |
| 92 | }; |
| 93 | |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame^] | 94 | static struct platdata_mtd_ram pcm038_sram_data = { |
| 95 | .bankwidth = 2, |
| 96 | }; |
| 97 | |
| 98 | static struct resource pcm038_sram_resource = { |
| 99 | .start = CS4_BASE_ADDR, |
| 100 | .end = CS4_BASE_ADDR + 512 * 1024 - 1, |
| 101 | .flags = IORESOURCE_MEM, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device pcm037_sram_device = { |
| 105 | .name = "mtd-ram", |
| 106 | .id = 0, |
| 107 | .dev = { |
| 108 | .platform_data = &pcm038_sram_data, |
| 109 | }, |
| 110 | .num_resources = 1, |
| 111 | .resource = &pcm038_sram_resource, |
| 112 | }; |
| 113 | |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 114 | static struct platform_device *devices[] __initdata = { |
| 115 | &pcm037_flash, |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 116 | &pcm037_eth, |
Sascha Hauer | 3dad21a | 2008-11-23 17:32:49 +0100 | [diff] [blame^] | 117 | &pcm037_sram_device, |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | /* |
| 121 | * Board specific initialization. |
| 122 | */ |
| 123 | static void __init mxc_board_init(void) |
| 124 | { |
| 125 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 126 | |
| 127 | mxc_iomux_mode(MX31_PIN_CTS1__CTS1); |
| 128 | mxc_iomux_mode(MX31_PIN_RTS1__RTS1); |
| 129 | mxc_iomux_mode(MX31_PIN_TXD1__TXD1); |
| 130 | mxc_iomux_mode(MX31_PIN_RXD1__RXD1); |
| 131 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 132 | mxc_register_device(&mxc_uart_device0, &uart_pdata); |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 133 | |
| 134 | mxc_iomux_mode(MX31_PIN_CSPI3_MOSI__RXD3); |
| 135 | mxc_iomux_mode(MX31_PIN_CSPI3_MISO__TXD3); |
| 136 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 137 | mxc_register_device(&mxc_uart_device2, &uart_pdata); |
Sascha Hauer | d517cab | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 138 | |
| 139 | mxc_iomux_mode(MX31_PIN_BATT_LINE__OWIRE); |
| 140 | mxc_register_device(&mxc_w1_master_device, NULL); |
Guennadi Liakhovetski | ba54b95 | 2008-11-11 15:12:00 +0100 | [diff] [blame] | 141 | |
| 142 | /* SMSC9215 IRQ pin */ |
| 143 | mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO3_1, IOMUX_CONFIG_GPIO)); |
| 144 | if (!gpio_request(MX31_PIN_GPIO3_1, "pcm037-eth")) |
| 145 | gpio_direction_input(MX31_PIN_GPIO3_1); |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /* |
| 149 | * This structure defines static mappings for the pcm037 board. |
| 150 | */ |
| 151 | static struct map_desc pcm037_io_desc[] __initdata = { |
| 152 | { |
| 153 | .virtual = AIPS1_BASE_ADDR_VIRT, |
| 154 | .pfn = __phys_to_pfn(AIPS1_BASE_ADDR), |
| 155 | .length = AIPS1_SIZE, |
Sascha Hauer | 6c1249e | 2008-09-18 15:48:23 +0200 | [diff] [blame] | 156 | .type = MT_DEVICE_NONSHARED |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 157 | }, { |
| 158 | .virtual = AIPS2_BASE_ADDR_VIRT, |
| 159 | .pfn = __phys_to_pfn(AIPS2_BASE_ADDR), |
| 160 | .length = AIPS2_SIZE, |
Sascha Hauer | 6c1249e | 2008-09-18 15:48:23 +0200 | [diff] [blame] | 161 | .type = MT_DEVICE_NONSHARED |
Sascha Hauer | ce8ffef | 2008-07-05 10:02:52 +0200 | [diff] [blame] | 162 | }, |
| 163 | }; |
| 164 | |
| 165 | /* |
| 166 | * Set up static virtual mappings. |
| 167 | */ |
| 168 | void __init pcm037_map_io(void) |
| 169 | { |
| 170 | mxc_map_io(); |
| 171 | iotable_init(pcm037_io_desc, ARRAY_SIZE(pcm037_io_desc)); |
| 172 | } |
| 173 | |
| 174 | static void __init pcm037_timer_init(void) |
| 175 | { |
| 176 | mxc_clocks_init(26000000); |
| 177 | mxc_timer_init("ipg_clk.0"); |
| 178 | } |
| 179 | |
| 180 | struct sys_timer pcm037_timer = { |
| 181 | .init = pcm037_timer_init, |
| 182 | }; |
| 183 | |
| 184 | MACHINE_START(PCM037, "Phytec Phycore pcm037") |
| 185 | /* Maintainer: Pengutronix */ |
| 186 | .phys_io = AIPS1_BASE_ADDR, |
| 187 | .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 188 | .boot_params = PHYS_OFFSET + 0x100, |
| 189 | .map_io = pcm037_map_io, |
| 190 | .init_irq = mxc_init_irq, |
| 191 | .init_machine = mxc_board_init, |
| 192 | .timer = &pcm037_timer, |
| 193 | MACHINE_END |
| 194 | |