Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-shmobile/board-ag5evm.c |
| 3 | * |
| 4 | * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com> |
| 5 | * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> |
| 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 | */ |
| 21 | |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/irq.h> |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/io.h> |
| 29 | #include <linux/dma-mapping.h> |
| 30 | #include <linux/serial_sci.h> |
| 31 | #include <linux/smsc911x.h> |
| 32 | #include <linux/gpio.h> |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 33 | #include <linux/input.h> |
| 34 | #include <linux/input/sh_keysc.h> |
| 35 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 36 | #include <sound/sh_fsi.h> |
| 37 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 38 | #include <mach/hardware.h> |
| 39 | #include <mach/sh73a0.h> |
| 40 | #include <mach/common.h> |
| 41 | #include <asm/mach-types.h> |
| 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/map.h> |
| 44 | #include <asm/mach/time.h> |
| 45 | #include <asm/hardware/gic.h> |
| 46 | #include <asm/hardware/cache-l2x0.h> |
| 47 | #include <asm/traps.h> |
| 48 | |
| 49 | static struct resource smsc9220_resources[] = { |
| 50 | [0] = { |
| 51 | .start = 0x14000000, |
| 52 | .end = 0x14000000 + SZ_64K - 1, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | [1] = { |
| 56 | .start = gic_spi(33), /* PINT1 */ |
| 57 | .flags = IORESOURCE_IRQ, |
| 58 | }, |
| 59 | }; |
| 60 | |
| 61 | static struct smsc911x_platform_config smsc9220_platdata = { |
| 62 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 63 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 64 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 65 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 66 | }; |
| 67 | |
| 68 | static struct platform_device eth_device = { |
| 69 | .name = "smsc911x", |
| 70 | .id = 0, |
| 71 | .dev = { |
| 72 | .platform_data = &smsc9220_platdata, |
| 73 | }, |
| 74 | .resource = smsc9220_resources, |
| 75 | .num_resources = ARRAY_SIZE(smsc9220_resources), |
| 76 | }; |
| 77 | |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 78 | static struct sh_keysc_info keysc_platdata = { |
| 79 | .mode = SH_KEYSC_MODE_6, |
| 80 | .scan_timing = 3, |
| 81 | .delay = 100, |
| 82 | .keycodes = { |
| 83 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, |
| 84 | KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, |
| 85 | KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, |
| 86 | KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP, |
| 87 | KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \ |
| 88 | KEY_COFFEE, |
| 89 | KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP, |
| 90 | KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \ |
| 91 | KEY_COMPUTER, |
| 92 | }, |
| 93 | }; |
| 94 | |
| 95 | static struct resource keysc_resources[] = { |
| 96 | [0] = { |
| 97 | .name = "KEYSC", |
| 98 | .start = 0xe61b0000, |
| 99 | .end = 0xe61b0098 - 1, |
| 100 | .flags = IORESOURCE_MEM, |
| 101 | }, |
| 102 | [1] = { |
| 103 | .start = gic_spi(71), |
| 104 | .flags = IORESOURCE_IRQ, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct platform_device keysc_device = { |
| 109 | .name = "sh_keysc", |
| 110 | .id = 0, |
| 111 | .num_resources = ARRAY_SIZE(keysc_resources), |
| 112 | .resource = keysc_resources, |
| 113 | .dev = { |
| 114 | .platform_data = &keysc_platdata, |
| 115 | }, |
| 116 | }; |
| 117 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 118 | /* FSI A */ |
| 119 | static struct sh_fsi_platform_info fsi_info = { |
| 120 | .porta_flags = SH_FSI_OUT_SLAVE_MODE | |
| 121 | SH_FSI_IN_SLAVE_MODE | |
| 122 | SH_FSI_OFMT(I2S) | |
| 123 | SH_FSI_IFMT(I2S), |
| 124 | }; |
| 125 | |
| 126 | static struct resource fsi_resources[] = { |
| 127 | [0] = { |
| 128 | .name = "FSI", |
| 129 | .start = 0xEC230000, |
| 130 | .end = 0xEC230400 - 1, |
| 131 | .flags = IORESOURCE_MEM, |
| 132 | }, |
| 133 | [1] = { |
| 134 | .start = gic_spi(146), |
| 135 | .flags = IORESOURCE_IRQ, |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | static struct platform_device fsi_device = { |
| 140 | .name = "sh_fsi2", |
| 141 | .id = -1, |
| 142 | .num_resources = ARRAY_SIZE(fsi_resources), |
| 143 | .resource = fsi_resources, |
| 144 | .dev = { |
| 145 | .platform_data = &fsi_info, |
| 146 | }, |
| 147 | }; |
| 148 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 149 | static struct platform_device *ag5evm_devices[] __initdata = { |
| 150 | ð_device, |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 151 | &keysc_device, |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 152 | &fsi_device, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 153 | }; |
| 154 | |
| 155 | static struct map_desc ag5evm_io_desc[] __initdata = { |
| 156 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 157 | * used by CPGA, INTC and PFC. |
| 158 | */ |
| 159 | { |
| 160 | .virtual = 0xe6000000, |
| 161 | .pfn = __phys_to_pfn(0xe6000000), |
| 162 | .length = 256 << 20, |
| 163 | .type = MT_DEVICE_NONSHARED |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | static void __init ag5evm_map_io(void) |
| 168 | { |
| 169 | iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc)); |
| 170 | |
| 171 | /* setup early devices and console here as well */ |
| 172 | sh73a0_add_early_devices(); |
| 173 | shmobile_setup_console(); |
| 174 | } |
| 175 | |
| 176 | #define PINTC_ADDR 0xe6900000 |
| 177 | #define PINTER0A (PINTC_ADDR + 0xa0) |
| 178 | #define PINTCR0A (PINTC_ADDR + 0xb0) |
| 179 | |
| 180 | void __init ag5evm_init_irq(void) |
| 181 | { |
Magnus Damm | 5f53a56 | 2010-12-21 08:37:32 +0000 | [diff] [blame] | 182 | sh73a0_init_irq(); |
| 183 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 184 | /* setup PINT: enable PINTA2 as active low */ |
| 185 | __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A); |
| 186 | __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 189 | static void __init ag5evm_init(void) |
| 190 | { |
Takashi YOSHII | 3256c78 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 191 | sh73a0_pinmux_init(); |
| 192 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 193 | /* enable SCIFA2 */ |
Takashi YOSHII | 3256c78 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 194 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); |
| 195 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); |
| 196 | gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL); |
| 197 | gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 198 | |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 199 | /* enable KEYSC */ |
Takashi YOSHII | 5d78147 | 2010-12-22 06:30:19 +0000 | [diff] [blame^] | 200 | gpio_request(GPIO_FN_KEYIN0_PU, NULL); |
| 201 | gpio_request(GPIO_FN_KEYIN1_PU, NULL); |
| 202 | gpio_request(GPIO_FN_KEYIN2_PU, NULL); |
| 203 | gpio_request(GPIO_FN_KEYIN3_PU, NULL); |
| 204 | gpio_request(GPIO_FN_KEYIN4_PU, NULL); |
| 205 | gpio_request(GPIO_FN_KEYIN5_PU, NULL); |
| 206 | gpio_request(GPIO_FN_KEYIN6_PU, NULL); |
| 207 | gpio_request(GPIO_FN_KEYIN7_PU, NULL); |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 208 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 209 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 210 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 211 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 212 | gpio_request(GPIO_FN_KEYOUT4, NULL); |
| 213 | gpio_request(GPIO_FN_KEYOUT5, NULL); |
| 214 | gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL); |
| 215 | gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL); |
| 216 | gpio_request(GPIO_FN_KEYOUT8, NULL); |
| 217 | gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL); |
| 218 | |
Yoshii Takashi | 8e67b22 | 2010-11-19 13:21:32 +0000 | [diff] [blame] | 219 | /* enable IC2 2 and 3 */ |
| 220 | gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL); |
| 221 | gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL); |
| 222 | gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL); |
| 223 | gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL); |
| 224 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 225 | /* enable SMSC911X */ |
Takashi YOSHII | 3256c78 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 226 | gpio_request(GPIO_PORT144, NULL); /* PINTA2 */ |
| 227 | gpio_direction_input(GPIO_PORT144); |
| 228 | gpio_request(GPIO_PORT145, NULL); /* RESET */ |
| 229 | gpio_direction_output(GPIO_PORT145, 1); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 230 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 231 | /* FSI A */ |
| 232 | gpio_request(GPIO_FN_FSIACK, NULL); |
| 233 | gpio_request(GPIO_FN_FSIAILR, NULL); |
| 234 | gpio_request(GPIO_FN_FSIAIBT, NULL); |
| 235 | gpio_request(GPIO_FN_FSIAISLD, NULL); |
| 236 | gpio_request(GPIO_FN_FSIAOSLD, NULL); |
| 237 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 238 | #ifdef CONFIG_CACHE_L2X0 |
| 239 | /* Shared attribute override enable, 64K*8way */ |
| 240 | l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff); |
| 241 | #endif |
| 242 | sh73a0_add_standard_devices(); |
| 243 | platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices)); |
| 244 | } |
| 245 | |
| 246 | static void __init ag5evm_timer_init(void) |
| 247 | { |
| 248 | sh73a0_clock_init(); |
| 249 | shmobile_timer.init(); |
| 250 | return; |
| 251 | } |
| 252 | |
| 253 | struct sys_timer ag5evm_timer = { |
| 254 | .init = ag5evm_timer_init, |
| 255 | }; |
| 256 | |
| 257 | MACHINE_START(AG5EVM, "ag5evm") |
| 258 | .map_io = ag5evm_map_io, |
| 259 | .init_irq = ag5evm_init_irq, |
| 260 | .init_machine = ag5evm_init, |
| 261 | .timer = &ag5evm_timer, |
| 262 | MACHINE_END |