Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 3 | * |
| 4 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file "COPYING" in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/mtd/physmap.h> |
| 15 | #include <linux/gpio.h> |
| 16 | #include <linux/interrupt.h> |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame^] | 17 | #include <linux/io.h> |
| 18 | #include <linux/delay.h> |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 19 | #include <asm/heartbeat.h> |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame^] | 20 | #include <asm/sh_eth.h> |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 21 | #include <cpu/sh7724.h> |
| 22 | |
| 23 | /* |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 24 | * Address Interface BusWidth |
| 25 | *----------------------------------------- |
| 26 | * 0x0000_0000 uboot 16bit |
| 27 | * 0x0004_0000 Linux romImage 16bit |
| 28 | * 0x0014_0000 MTD for Linux 16bit |
| 29 | * 0x0400_0000 Internal I/O 16/32bit |
| 30 | * 0x0800_0000 DRAM 32bit |
| 31 | * 0x1800_0000 MFI 16bit |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | /* Heartbeat */ |
| 35 | static unsigned char led_pos[] = { 0, 1, 2, 3 }; |
| 36 | static struct heartbeat_data heartbeat_data = { |
| 37 | .regsize = 8, |
| 38 | .nr_bits = 4, |
| 39 | .bit_pos = led_pos, |
| 40 | }; |
| 41 | |
| 42 | static struct resource heartbeat_resources[] = { |
| 43 | [0] = { |
| 44 | .start = 0xA405012C, /* PTG */ |
| 45 | .end = 0xA405012E - 1, |
| 46 | .flags = IORESOURCE_MEM, |
| 47 | }, |
| 48 | }; |
| 49 | |
| 50 | static struct platform_device heartbeat_device = { |
| 51 | .name = "heartbeat", |
| 52 | .id = -1, |
| 53 | .dev = { |
| 54 | .platform_data = &heartbeat_data, |
| 55 | }, |
| 56 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 57 | .resource = heartbeat_resources, |
| 58 | }; |
| 59 | |
| 60 | /* MTD */ |
| 61 | static struct mtd_partition nor_flash_partitions[] = { |
| 62 | { |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 63 | .name = "boot loader", |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 64 | .offset = 0, |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 65 | .size = (5 * 1024 * 1024), |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 66 | .mask_flags = MTD_CAP_ROM, |
| 67 | }, { |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 68 | .name = "free-area", |
| 69 | .offset = MTDPART_OFS_APPEND, |
| 70 | .size = MTDPART_SIZ_FULL, |
| 71 | }, |
| 72 | }; |
| 73 | |
| 74 | static struct physmap_flash_data nor_flash_data = { |
| 75 | .width = 2, |
| 76 | .parts = nor_flash_partitions, |
| 77 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 78 | }; |
| 79 | |
| 80 | static struct resource nor_flash_resources[] = { |
| 81 | [0] = { |
| 82 | .name = "NOR Flash", |
| 83 | .start = 0x00000000, |
| 84 | .end = 0x03ffffff, |
| 85 | .flags = IORESOURCE_MEM, |
| 86 | } |
| 87 | }; |
| 88 | |
| 89 | static struct platform_device nor_flash_device = { |
| 90 | .name = "physmap-flash", |
| 91 | .resource = nor_flash_resources, |
| 92 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 93 | .dev = { |
| 94 | .platform_data = &nor_flash_data, |
| 95 | }, |
| 96 | }; |
| 97 | |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame^] | 98 | /* SH Eth */ |
| 99 | #define SH_ETH_ADDR (0xA4600000) |
| 100 | #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0) |
| 101 | #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8) |
| 102 | static struct resource sh_eth_resources[] = { |
| 103 | [0] = { |
| 104 | .start = SH_ETH_ADDR, |
| 105 | .end = SH_ETH_ADDR + 0x1FC, |
| 106 | .flags = IORESOURCE_MEM, |
| 107 | }, |
| 108 | [1] = { |
| 109 | .start = 91, |
| 110 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, |
| 111 | }, |
| 112 | }; |
| 113 | |
| 114 | struct sh_eth_plat_data sh_eth_plat = { |
| 115 | .phy = 0x1f, /* SMSC LAN8700 */ |
| 116 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
| 117 | }; |
| 118 | |
| 119 | static struct platform_device sh_eth_device = { |
| 120 | .name = "sh-eth", |
| 121 | .id = 0, |
| 122 | .dev = { |
| 123 | .platform_data = &sh_eth_plat, |
| 124 | }, |
| 125 | .num_resources = ARRAY_SIZE(sh_eth_resources), |
| 126 | .resource = sh_eth_resources, |
| 127 | }; |
| 128 | |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 129 | static struct platform_device *ecovec_devices[] __initdata = { |
| 130 | &heartbeat_device, |
| 131 | &nor_flash_device, |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame^] | 132 | &sh_eth_device, |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | static int __init devices_setup(void) |
| 136 | { |
| 137 | /* enable SCIFA0 */ |
| 138 | gpio_request(GPIO_FN_SCIF0_TXD, NULL); |
| 139 | gpio_request(GPIO_FN_SCIF0_RXD, NULL); |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 140 | |
| 141 | /* enable debug LED */ |
| 142 | gpio_request(GPIO_PTG0, NULL); |
| 143 | gpio_request(GPIO_PTG1, NULL); |
| 144 | gpio_request(GPIO_PTG2, NULL); |
| 145 | gpio_request(GPIO_PTG3, NULL); |
Kuninori Morimoto | b7056bc | 2009-08-26 11:04:22 +0000 | [diff] [blame] | 146 | gpio_direction_output(GPIO_PTG0, 0); |
| 147 | gpio_direction_output(GPIO_PTG1, 0); |
| 148 | gpio_direction_output(GPIO_PTG2, 0); |
| 149 | gpio_direction_output(GPIO_PTG3, 0); |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 150 | |
Kuninori Morimoto | 35a3540 | 2009-08-26 11:04:26 +0000 | [diff] [blame^] | 151 | /* enable SH-Eth */ |
| 152 | gpio_request(GPIO_PTA1, NULL); |
| 153 | gpio_direction_output(GPIO_PTA1, 1); |
| 154 | mdelay(20); |
| 155 | |
| 156 | gpio_request(GPIO_FN_RMII_RXD0, NULL); |
| 157 | gpio_request(GPIO_FN_RMII_RXD1, NULL); |
| 158 | gpio_request(GPIO_FN_RMII_TXD0, NULL); |
| 159 | gpio_request(GPIO_FN_RMII_TXD1, NULL); |
| 160 | gpio_request(GPIO_FN_RMII_REF_CLK, NULL); |
| 161 | gpio_request(GPIO_FN_RMII_TX_EN, NULL); |
| 162 | gpio_request(GPIO_FN_RMII_RX_ER, NULL); |
| 163 | gpio_request(GPIO_FN_RMII_CRS_DV, NULL); |
| 164 | gpio_request(GPIO_FN_MDIO, NULL); |
| 165 | gpio_request(GPIO_FN_MDC, NULL); |
| 166 | gpio_request(GPIO_FN_LNKSTA, NULL); |
| 167 | |
Kuninori Morimoto | 4138b74 | 2009-08-19 12:08:33 +0000 | [diff] [blame] | 168 | return platform_add_devices(ecovec_devices, |
| 169 | ARRAY_SIZE(ecovec_devices)); |
| 170 | } |
| 171 | device_initcall(devices_setup); |
| 172 | |
| 173 | static struct sh_machine_vector mv_ecovec __initmv = { |
| 174 | .mv_name = "R0P7724 (EcoVec)", |
| 175 | }; |