Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * G3EVM 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> |
Magnus Damm | 7fdda67 | 2010-02-10 20:10:55 +0900 | [diff] [blame^] | 30 | #include <linux/gpio.h> |
| 31 | #include <mach/sh7367.h> |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 32 | #include <mach/common.h> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | |
| 37 | static struct mtd_partition nor_flash_partitions[] = { |
| 38 | { |
| 39 | .name = "loader", |
| 40 | .offset = 0x00000000, |
| 41 | .size = 512 * 1024, |
| 42 | }, |
| 43 | { |
| 44 | .name = "bootenv", |
| 45 | .offset = MTDPART_OFS_APPEND, |
| 46 | .size = 512 * 1024, |
| 47 | }, |
| 48 | { |
| 49 | .name = "kernel_ro", |
| 50 | .offset = MTDPART_OFS_APPEND, |
| 51 | .size = 8 * 1024 * 1024, |
| 52 | .mask_flags = MTD_WRITEABLE, |
| 53 | }, |
| 54 | { |
| 55 | .name = "kernel", |
| 56 | .offset = MTDPART_OFS_APPEND, |
| 57 | .size = 8 * 1024 * 1024, |
| 58 | }, |
| 59 | { |
| 60 | .name = "data", |
| 61 | .offset = MTDPART_OFS_APPEND, |
| 62 | .size = MTDPART_SIZ_FULL, |
| 63 | }, |
| 64 | }; |
| 65 | |
| 66 | static struct physmap_flash_data nor_flash_data = { |
| 67 | .width = 2, |
| 68 | .parts = nor_flash_partitions, |
| 69 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 70 | }; |
| 71 | |
| 72 | static struct resource nor_flash_resources[] = { |
| 73 | [0] = { |
| 74 | .start = 0x00000000, |
| 75 | .end = 0x08000000 - 1, |
| 76 | .flags = IORESOURCE_MEM, |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | static struct platform_device nor_flash_device = { |
| 81 | .name = "physmap-flash", |
| 82 | .dev = { |
| 83 | .platform_data = &nor_flash_data, |
| 84 | }, |
| 85 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 86 | .resource = nor_flash_resources, |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | static struct platform_device *g3evm_devices[] __initdata = { |
| 91 | &nor_flash_device, |
| 92 | }; |
| 93 | |
| 94 | static struct map_desc g3evm_io_desc[] __initdata = { |
| 95 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 96 | * used by CPGA, INTC and PFC. |
| 97 | */ |
| 98 | { |
| 99 | .virtual = 0xe6000000, |
| 100 | .pfn = __phys_to_pfn(0xe6000000), |
| 101 | .length = 256 << 20, |
| 102 | .type = MT_DEVICE_NONSHARED |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | static void __init g3evm_map_io(void) |
| 107 | { |
| 108 | iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc)); |
| 109 | |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 110 | /* setup early devices, clocks and console here as well */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 111 | sh7367_add_early_devices(); |
| 112 | sh7367_clock_init(); |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 113 | shmobile_setup_console(); |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static void __init g3evm_init(void) |
| 117 | { |
Magnus Damm | 7fdda67 | 2010-02-10 20:10:55 +0900 | [diff] [blame^] | 118 | sh7367_pinmux_init(); |
| 119 | |
| 120 | /* Lit DS4 LED */ |
| 121 | gpio_request(GPIO_PORT22, NULL); |
| 122 | gpio_direction_output(GPIO_PORT22, 1); |
| 123 | gpio_export(GPIO_PORT22, 0); |
| 124 | |
| 125 | /* Lit DS8 LED */ |
| 126 | gpio_request(GPIO_PORT23, NULL); |
| 127 | gpio_direction_output(GPIO_PORT23, 1); |
| 128 | gpio_export(GPIO_PORT23, 0); |
| 129 | |
| 130 | /* Lit DS3 LED */ |
| 131 | gpio_request(GPIO_PORT24, NULL); |
| 132 | gpio_direction_output(GPIO_PORT24, 1); |
| 133 | gpio_export(GPIO_PORT24, 0); |
| 134 | |
| 135 | /* SCIFA1 */ |
| 136 | gpio_request(GPIO_FN_SCIFA1_TXD, NULL); |
| 137 | gpio_request(GPIO_FN_SCIFA1_RXD, NULL); |
| 138 | gpio_request(GPIO_FN_SCIFA1_CTS, NULL); |
| 139 | gpio_request(GPIO_FN_SCIFA1_RTS, NULL); |
| 140 | |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 141 | sh7367_add_standard_devices(); |
| 142 | |
| 143 | platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices)); |
| 144 | } |
| 145 | |
| 146 | MACHINE_START(G3EVM, "g3evm") |
| 147 | .phys_io = 0xe6000000, |
| 148 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, |
| 149 | .map_io = g3evm_map_io, |
| 150 | .init_irq = sh7367_init_irq, |
| 151 | .init_machine = g3evm_init, |
| 152 | .timer = &shmobile_timer, |
| 153 | MACHINE_END |