blob: 8c0c8453d08976537e267ffbaae23fcfef347929 [file] [log] [blame]
Kuninori Morimoto4138b742009-08-19 12:08:33 +00001/*
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 Morimoto35a35402009-08-26 11:04:26 +000017#include <linux/io.h>
18#include <linux/delay.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000019#include <asm/heartbeat.h>
Kuninori Morimoto35a35402009-08-26 11:04:26 +000020#include <asm/sh_eth.h>
Kuninori Morimoto4138b742009-08-19 12:08:33 +000021#include <cpu/sh7724.h>
22
23/*
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000024 * 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 Morimoto4138b742009-08-19 12:08:33 +000032 */
33
34/* Heartbeat */
35static unsigned char led_pos[] = { 0, 1, 2, 3 };
36static struct heartbeat_data heartbeat_data = {
37 .regsize = 8,
38 .nr_bits = 4,
39 .bit_pos = led_pos,
40};
41
42static struct resource heartbeat_resources[] = {
43 [0] = {
44 .start = 0xA405012C, /* PTG */
45 .end = 0xA405012E - 1,
46 .flags = IORESOURCE_MEM,
47 },
48};
49
50static 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 */
61static struct mtd_partition nor_flash_partitions[] = {
62 {
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000063 .name = "boot loader",
Kuninori Morimoto4138b742009-08-19 12:08:33 +000064 .offset = 0,
Kuninori Morimotob7056bc2009-08-26 11:04:22 +000065 .size = (5 * 1024 * 1024),
Kuninori Morimoto4138b742009-08-19 12:08:33 +000066 .mask_flags = MTD_CAP_ROM,
67 }, {
Kuninori Morimoto4138b742009-08-19 12:08:33 +000068 .name = "free-area",
69 .offset = MTDPART_OFS_APPEND,
70 .size = MTDPART_SIZ_FULL,
71 },
72};
73
74static 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
80static struct resource nor_flash_resources[] = {
81 [0] = {
82 .name = "NOR Flash",
83 .start = 0x00000000,
84 .end = 0x03ffffff,
85 .flags = IORESOURCE_MEM,
86 }
87};
88
89static 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 Morimoto35a35402009-08-26 11:04:26 +000098/* 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)
102static 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
114struct sh_eth_plat_data sh_eth_plat = {
115 .phy = 0x1f, /* SMSC LAN8700 */
116 .edmac_endian = EDMAC_LITTLE_ENDIAN,
117};
118
119static 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 Morimoto4138b742009-08-19 12:08:33 +0000129static struct platform_device *ecovec_devices[] __initdata = {
130 &heartbeat_device,
131 &nor_flash_device,
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000132 &sh_eth_device,
Kuninori Morimoto4138b742009-08-19 12:08:33 +0000133};
134
135static 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 Morimoto4138b742009-08-19 12:08:33 +0000140
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 Morimotob7056bc2009-08-26 11:04:22 +0000146 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 Morimoto4138b742009-08-19 12:08:33 +0000150
Kuninori Morimoto35a35402009-08-26 11:04:26 +0000151 /* 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 Morimoto4138b742009-08-19 12:08:33 +0000168 return platform_add_devices(ecovec_devices,
169 ARRAY_SIZE(ecovec_devices));
170}
171device_initcall(devices_setup);
172
173static struct sh_machine_vector mv_ecovec __initmv = {
174 .mv_name = "R0P7724 (EcoVec)",
175};