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 | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame^] | 38 | /* MTD */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 39 | static struct mtd_partition nor_flash_partitions[] = { |
| 40 | { |
| 41 | .name = "loader", |
| 42 | .offset = 0x00000000, |
| 43 | .size = 512 * 1024, |
| 44 | }, |
| 45 | { |
| 46 | .name = "bootenv", |
| 47 | .offset = MTDPART_OFS_APPEND, |
| 48 | .size = 512 * 1024, |
| 49 | }, |
| 50 | { |
| 51 | .name = "kernel_ro", |
| 52 | .offset = MTDPART_OFS_APPEND, |
| 53 | .size = 8 * 1024 * 1024, |
| 54 | .mask_flags = MTD_WRITEABLE, |
| 55 | }, |
| 56 | { |
| 57 | .name = "kernel", |
| 58 | .offset = MTDPART_OFS_APPEND, |
| 59 | .size = 8 * 1024 * 1024, |
| 60 | }, |
| 61 | { |
| 62 | .name = "data", |
| 63 | .offset = MTDPART_OFS_APPEND, |
| 64 | .size = MTDPART_SIZ_FULL, |
| 65 | }, |
| 66 | }; |
| 67 | |
| 68 | static struct physmap_flash_data nor_flash_data = { |
| 69 | .width = 2, |
| 70 | .parts = nor_flash_partitions, |
| 71 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 72 | }; |
| 73 | |
| 74 | static struct resource nor_flash_resources[] = { |
| 75 | [0] = { |
| 76 | .start = 0x00000000, |
| 77 | .end = 0x08000000 - 1, |
| 78 | .flags = IORESOURCE_MEM, |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | static struct platform_device nor_flash_device = { |
| 83 | .name = "physmap-flash", |
| 84 | .dev = { |
| 85 | .platform_data = &nor_flash_data, |
| 86 | }, |
| 87 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 88 | .resource = nor_flash_resources, |
| 89 | }; |
| 90 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame^] | 91 | /* SMSC 9220 */ |
| 92 | static struct resource smc911x_resources[] = { |
| 93 | { |
| 94 | .start = 0x14000000, |
| 95 | .end = 0x16000000 - 1, |
| 96 | .flags = IORESOURCE_MEM, |
| 97 | }, { |
| 98 | .start = 6, |
| 99 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 100 | }, |
| 101 | }; |
| 102 | |
| 103 | static struct smsc911x_platform_config smsc911x_info = { |
| 104 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 105 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 106 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 107 | }; |
| 108 | |
| 109 | static struct platform_device smc911x_device = { |
| 110 | .name = "smsc911x", |
| 111 | .id = -1, |
| 112 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 113 | .resource = smc911x_resources, |
| 114 | .dev = { |
| 115 | .platform_data = &smsc911x_info, |
| 116 | }, |
| 117 | }; |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 118 | |
| 119 | static struct platform_device *ap4evb_devices[] __initdata = { |
| 120 | &nor_flash_device, |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame^] | 121 | &smc911x_device, |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | static struct map_desc ap4evb_io_desc[] __initdata = { |
| 125 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 126 | * used by CPGA, INTC and PFC. |
| 127 | */ |
| 128 | { |
| 129 | .virtual = 0xe6000000, |
| 130 | .pfn = __phys_to_pfn(0xe6000000), |
| 131 | .length = 256 << 20, |
| 132 | .type = MT_DEVICE_NONSHARED |
| 133 | }, |
| 134 | }; |
| 135 | |
| 136 | static void __init ap4evb_map_io(void) |
| 137 | { |
| 138 | iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc)); |
| 139 | |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 140 | /* setup early devices, clocks and console here as well */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 141 | sh7372_add_early_devices(); |
| 142 | sh7367_clock_init(); /* use g3 clocks for now */ |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 143 | shmobile_setup_console(); |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | static void __init ap4evb_init(void) |
| 147 | { |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame^] | 148 | sh7372_pinmux_init(); |
| 149 | |
| 150 | /* enable SMSC911X */ |
| 151 | gpio_request(GPIO_FN_CS5A, NULL); |
| 152 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 153 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 154 | sh7372_add_standard_devices(); |
| 155 | |
| 156 | platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); |
| 157 | } |
| 158 | |
| 159 | MACHINE_START(AP4EVB, "ap4evb") |
| 160 | .phys_io = 0xe6000000, |
| 161 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, |
| 162 | .map_io = ap4evb_map_io, |
| 163 | .init_irq = sh7372_init_irq, |
| 164 | .init_machine = ap4evb_init, |
| 165 | .timer = &shmobile_timer, |
| 166 | MACHINE_END |