Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * mackerel board support |
| 3 | * |
| 4 | * Copyright (C) 2010 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * based on ap4evb |
| 8 | * Copyright (C) 2010 Magnus Damm |
| 9 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; version 2 of the License. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | */ |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/irq.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/gpio.h> |
| 30 | #include <linux/input.h> |
| 31 | #include <linux/io.h> |
| 32 | #include <linux/mtd/mtd.h> |
| 33 | #include <linux/mtd/partitions.h> |
| 34 | #include <linux/mtd/physmap.h> |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame^] | 35 | #include <linux/smsc911x.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 36 | |
| 37 | #include <mach/common.h> |
| 38 | #include <mach/sh7372.h> |
| 39 | |
| 40 | #include <asm/mach/arch.h> |
| 41 | #include <asm/mach/time.h> |
| 42 | #include <asm/mach/map.h> |
| 43 | #include <asm/mach-types.h> |
| 44 | |
| 45 | /* |
| 46 | * Address Interface BusWidth note |
| 47 | * ------------------------------------------------------------------ |
| 48 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON |
| 49 | * 0x0800_0000 user area - |
| 50 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF |
| 51 | * 0x1400_0000 Ether (LAN9220) 16bit |
| 52 | * 0x1600_0000 user area - cannot use with NAND |
| 53 | * 0x1800_0000 user area - |
| 54 | * 0x1A00_0000 - |
| 55 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit |
| 56 | */ |
| 57 | |
| 58 | /* MTD */ |
| 59 | static struct mtd_partition nor_flash_partitions[] = { |
| 60 | { |
| 61 | .name = "loader", |
| 62 | .offset = 0x00000000, |
| 63 | .size = 512 * 1024, |
| 64 | .mask_flags = MTD_WRITEABLE, |
| 65 | }, |
| 66 | { |
| 67 | .name = "bootenv", |
| 68 | .offset = MTDPART_OFS_APPEND, |
| 69 | .size = 512 * 1024, |
| 70 | .mask_flags = MTD_WRITEABLE, |
| 71 | }, |
| 72 | { |
| 73 | .name = "kernel_ro", |
| 74 | .offset = MTDPART_OFS_APPEND, |
| 75 | .size = 8 * 1024 * 1024, |
| 76 | .mask_flags = MTD_WRITEABLE, |
| 77 | }, |
| 78 | { |
| 79 | .name = "kernel", |
| 80 | .offset = MTDPART_OFS_APPEND, |
| 81 | .size = 8 * 1024 * 1024, |
| 82 | }, |
| 83 | { |
| 84 | .name = "data", |
| 85 | .offset = MTDPART_OFS_APPEND, |
| 86 | .size = MTDPART_SIZ_FULL, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | static struct physmap_flash_data nor_flash_data = { |
| 91 | .width = 2, |
| 92 | .parts = nor_flash_partitions, |
| 93 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 94 | }; |
| 95 | |
| 96 | static struct resource nor_flash_resources[] = { |
| 97 | [0] = { |
| 98 | .start = 0x00000000, |
| 99 | .end = 0x08000000 - 1, |
| 100 | .flags = IORESOURCE_MEM, |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device nor_flash_device = { |
| 105 | .name = "physmap-flash", |
| 106 | .dev = { |
| 107 | .platform_data = &nor_flash_data, |
| 108 | }, |
| 109 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 110 | .resource = nor_flash_resources, |
| 111 | }; |
| 112 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame^] | 113 | /* SMSC */ |
| 114 | static struct resource smc911x_resources[] = { |
| 115 | { |
| 116 | .start = 0x14000000, |
| 117 | .end = 0x16000000 - 1, |
| 118 | .flags = IORESOURCE_MEM, |
| 119 | }, { |
| 120 | .start = evt2irq(0x02c0) /* IRQ6A */, |
| 121 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 122 | }, |
| 123 | }; |
| 124 | |
| 125 | static struct smsc911x_platform_config smsc911x_info = { |
| 126 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 127 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 128 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 129 | }; |
| 130 | |
| 131 | static struct platform_device smc911x_device = { |
| 132 | .name = "smsc911x", |
| 133 | .id = -1, |
| 134 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 135 | .resource = smc911x_resources, |
| 136 | .dev = { |
| 137 | .platform_data = &smsc911x_info, |
| 138 | }, |
| 139 | }; |
| 140 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 141 | static struct platform_device *mackerel_devices[] __initdata = { |
| 142 | &nor_flash_device, |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame^] | 143 | &smc911x_device, |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | static struct map_desc mackerel_io_desc[] __initdata = { |
| 147 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 148 | * used by CPGA, INTC and PFC. |
| 149 | */ |
| 150 | { |
| 151 | .virtual = 0xe6000000, |
| 152 | .pfn = __phys_to_pfn(0xe6000000), |
| 153 | .length = 256 << 20, |
| 154 | .type = MT_DEVICE_NONSHARED |
| 155 | }, |
| 156 | }; |
| 157 | |
| 158 | static void __init mackerel_map_io(void) |
| 159 | { |
| 160 | iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); |
| 161 | |
| 162 | /* setup early devices and console here as well */ |
| 163 | sh7372_add_early_devices(); |
| 164 | shmobile_setup_console(); |
| 165 | } |
| 166 | |
| 167 | static void __init mackerel_init(void) |
| 168 | { |
| 169 | sh7372_pinmux_init(); |
| 170 | |
| 171 | /* enable SCIFA0 */ |
| 172 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); |
| 173 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); |
| 174 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame^] | 175 | /* enable SMSC911X */ |
| 176 | gpio_request(GPIO_FN_CS5A, NULL); |
| 177 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 178 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 179 | sh7372_add_standard_devices(); |
| 180 | |
| 181 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); |
| 182 | } |
| 183 | |
| 184 | static void __init mackerel_timer_init(void) |
| 185 | { |
| 186 | sh7372_clock_init(); |
| 187 | shmobile_timer.init(); |
| 188 | } |
| 189 | |
| 190 | static struct sys_timer mackerel_timer = { |
| 191 | .init = mackerel_timer_init, |
| 192 | }; |
| 193 | |
| 194 | MACHINE_START(MACKEREL, "mackerel") |
| 195 | .map_io = mackerel_map_io, |
| 196 | .init_irq = sh7372_init_irq, |
| 197 | .init_machine = mackerel_init, |
| 198 | .timer = &mackerel_timer, |
| 199 | MACHINE_END |