Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * AP4EVB board support |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 6 | * |
| 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; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/mtd/mtd.h> |
| 27 | #include <linux/mtd/partitions.h> |
| 28 | #include <linux/mtd/physmap.h> |
| 29 | #include <linux/io.h> |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 30 | #include <linux/smsc911x.h> |
| 31 | #include <linux/gpio.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 32 | #include <mach/common.h> |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 33 | #include <mach/sh7372.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/map.h> |
| 37 | |
Kuninori Morimoto | 02624a1 | 2010-02-18 17:58:19 +0900 | [diff] [blame] | 38 | /* |
| 39 | * Address Interface BusWidth note |
| 40 | * ------------------------------------------------------------------ |
| 41 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON |
| 42 | * 0x0800_0000 user area - |
| 43 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF |
| 44 | * 0x1400_0000 Ether (LAN9220) 16bit |
| 45 | * 0x1600_0000 user area - cannot use with NAND |
| 46 | * 0x1800_0000 user area - |
| 47 | * 0x1A00_0000 - |
| 48 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit |
| 49 | */ |
| 50 | |
| 51 | /* |
| 52 | * NOR Flash ROM |
| 53 | * |
| 54 | * SW1 | SW2 | SW7 | NOR Flash ROM |
| 55 | * bit1 | bit1 bit2 | bit1 | Memory allocation |
| 56 | * ------+------------+------+------------------ |
| 57 | * OFF | ON OFF | ON | Area 0 |
| 58 | * OFF | ON OFF | OFF | Area 4 |
| 59 | */ |
| 60 | |
| 61 | /* |
| 62 | * NAND Flash ROM |
| 63 | * |
| 64 | * SW1 | SW2 | SW7 | NAND Flash ROM |
| 65 | * bit1 | bit1 bit2 | bit2 | Memory allocation |
| 66 | * ------+------------+------+------------------ |
| 67 | * OFF | ON OFF | ON | FCE 0 |
| 68 | * OFF | ON OFF | OFF | FCE 1 |
| 69 | */ |
| 70 | |
| 71 | /* |
| 72 | * SMSC 9220 |
| 73 | * |
| 74 | * SW1 SMSC 9220 |
| 75 | * ----------------------- |
| 76 | * ON access disable |
| 77 | * OFF access enable |
| 78 | */ |
| 79 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 80 | /* MTD */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 81 | static struct mtd_partition nor_flash_partitions[] = { |
| 82 | { |
| 83 | .name = "loader", |
| 84 | .offset = 0x00000000, |
| 85 | .size = 512 * 1024, |
| 86 | }, |
| 87 | { |
| 88 | .name = "bootenv", |
| 89 | .offset = MTDPART_OFS_APPEND, |
| 90 | .size = 512 * 1024, |
| 91 | }, |
| 92 | { |
| 93 | .name = "kernel_ro", |
| 94 | .offset = MTDPART_OFS_APPEND, |
| 95 | .size = 8 * 1024 * 1024, |
| 96 | .mask_flags = MTD_WRITEABLE, |
| 97 | }, |
| 98 | { |
| 99 | .name = "kernel", |
| 100 | .offset = MTDPART_OFS_APPEND, |
| 101 | .size = 8 * 1024 * 1024, |
| 102 | }, |
| 103 | { |
| 104 | .name = "data", |
| 105 | .offset = MTDPART_OFS_APPEND, |
| 106 | .size = MTDPART_SIZ_FULL, |
| 107 | }, |
| 108 | }; |
| 109 | |
| 110 | static struct physmap_flash_data nor_flash_data = { |
| 111 | .width = 2, |
| 112 | .parts = nor_flash_partitions, |
| 113 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 114 | }; |
| 115 | |
| 116 | static struct resource nor_flash_resources[] = { |
| 117 | [0] = { |
| 118 | .start = 0x00000000, |
| 119 | .end = 0x08000000 - 1, |
| 120 | .flags = IORESOURCE_MEM, |
| 121 | } |
| 122 | }; |
| 123 | |
| 124 | static struct platform_device nor_flash_device = { |
| 125 | .name = "physmap-flash", |
| 126 | .dev = { |
| 127 | .platform_data = &nor_flash_data, |
| 128 | }, |
| 129 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 130 | .resource = nor_flash_resources, |
| 131 | }; |
| 132 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 133 | /* SMSC 9220 */ |
| 134 | static struct resource smc911x_resources[] = { |
| 135 | { |
| 136 | .start = 0x14000000, |
| 137 | .end = 0x16000000 - 1, |
| 138 | .flags = IORESOURCE_MEM, |
| 139 | }, { |
| 140 | .start = 6, |
| 141 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 142 | }, |
| 143 | }; |
| 144 | |
| 145 | static struct smsc911x_platform_config smsc911x_info = { |
| 146 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 147 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 148 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 149 | }; |
| 150 | |
| 151 | static struct platform_device smc911x_device = { |
| 152 | .name = "smsc911x", |
| 153 | .id = -1, |
| 154 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 155 | .resource = smc911x_resources, |
| 156 | .dev = { |
| 157 | .platform_data = &smsc911x_info, |
| 158 | }, |
| 159 | }; |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 160 | |
| 161 | static struct platform_device *ap4evb_devices[] __initdata = { |
| 162 | &nor_flash_device, |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 163 | &smc911x_device, |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | static struct map_desc ap4evb_io_desc[] __initdata = { |
| 167 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 168 | * used by CPGA, INTC and PFC. |
| 169 | */ |
| 170 | { |
| 171 | .virtual = 0xe6000000, |
| 172 | .pfn = __phys_to_pfn(0xe6000000), |
| 173 | .length = 256 << 20, |
| 174 | .type = MT_DEVICE_NONSHARED |
| 175 | }, |
| 176 | }; |
| 177 | |
| 178 | static void __init ap4evb_map_io(void) |
| 179 | { |
| 180 | iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc)); |
| 181 | |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 182 | /* setup early devices, clocks and console here as well */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 183 | sh7372_add_early_devices(); |
| 184 | sh7367_clock_init(); /* use g3 clocks for now */ |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 185 | shmobile_setup_console(); |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | static void __init ap4evb_init(void) |
| 189 | { |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 190 | sh7372_pinmux_init(); |
| 191 | |
Kuninori Morimoto | b228b48 | 2010-02-18 16:44:41 +0900 | [diff] [blame] | 192 | /* enable SCIFA0 */ |
| 193 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); |
| 194 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); |
| 195 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 196 | /* enable SMSC911X */ |
| 197 | gpio_request(GPIO_FN_CS5A, NULL); |
| 198 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 199 | |
Kuninori Morimoto | 5098280 | 2010-02-22 09:20:39 +0000 | [diff] [blame] | 200 | /* enable LED 1 - 4 */ |
| 201 | gpio_request(GPIO_PORT185, NULL); |
| 202 | gpio_request(GPIO_PORT186, NULL); |
| 203 | gpio_request(GPIO_PORT187, NULL); |
| 204 | gpio_request(GPIO_PORT188, NULL); |
| 205 | gpio_direction_output(GPIO_PORT185, 1); |
| 206 | gpio_direction_output(GPIO_PORT186, 1); |
| 207 | gpio_direction_output(GPIO_PORT187, 1); |
| 208 | gpio_direction_output(GPIO_PORT188, 1); |
| 209 | gpio_export(GPIO_PORT185, 0); |
| 210 | gpio_export(GPIO_PORT186, 0); |
| 211 | gpio_export(GPIO_PORT187, 0); |
| 212 | gpio_export(GPIO_PORT188, 0); |
| 213 | |
Kuninori Morimoto | 8cb3a2e | 2010-02-22 09:30:12 +0000 | [diff] [blame^] | 214 | /* enable Debug switch (S6) */ |
| 215 | gpio_request(GPIO_PORT32, NULL); |
| 216 | gpio_request(GPIO_PORT33, NULL); |
| 217 | gpio_request(GPIO_PORT34, NULL); |
| 218 | gpio_request(GPIO_PORT35, NULL); |
| 219 | gpio_direction_input(GPIO_PORT32); |
| 220 | gpio_direction_input(GPIO_PORT33); |
| 221 | gpio_direction_input(GPIO_PORT34); |
| 222 | gpio_direction_input(GPIO_PORT35); |
| 223 | gpio_export(GPIO_PORT32, 0); |
| 224 | gpio_export(GPIO_PORT33, 0); |
| 225 | gpio_export(GPIO_PORT34, 0); |
| 226 | gpio_export(GPIO_PORT35, 0); |
| 227 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 228 | sh7372_add_standard_devices(); |
| 229 | |
| 230 | platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); |
| 231 | } |
| 232 | |
| 233 | MACHINE_START(AP4EVB, "ap4evb") |
| 234 | .phys_io = 0xe6000000, |
| 235 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, |
| 236 | .map_io = ap4evb_map_io, |
| 237 | .init_irq = sh7372_init_irq, |
| 238 | .init_machine = ap4evb_init, |
| 239 | .timer = &shmobile_timer, |
| 240 | MACHINE_END |