blob: f217f3553626546372d546bae91a1dc0d4a372d7 [file] [log] [blame]
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +09001/*
2 * Renesas Technology Corp. SH7786 Urquell Support.
3 *
4 * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com>
Kuninori Morimoto6e979382009-04-07 08:41:57 +00005 *
6 * Based on board-sh7785lcr.c
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +09007 * Copyright (C) 2008 Yoshihiro Shimoda
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/fb.h>
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +090016#include <linux/smc91x.h>
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090017#include <linux/mtd/physmap.h>
18#include <linux/delay.h>
19#include <linux/gpio.h>
20#include <linux/irq.h>
21#include <mach/urquell.h>
22#include <cpu/sh7786.h>
23#include <asm/heartbeat.h>
24#include <asm/sizes.h>
25
Kuninori Morimoto6e979382009-04-07 08:41:57 +000026/* SWx 8765 4321
27 *----------------------------
28 * SW1 1101 0010 -> Pck 66MHz version
29 * (0101 0010) Pck 33MHz version (check CS1BCR)
30 * SW2 xxxx x1x0 -> little endian
31 * 29bit mode
32 * SW47 0001 1000 -> CS0 : nor flash
33 * CS1 : SRAM, registers, LAN, PCMCIA
34 * 38400 bps
35 *
36 * Address
37 * 0x00000000 Nor Flash
38 * 0x04000000 SRAM
39 * 0x05000000 FPGA register
40 * 0x05800000 LAN91C111
41 * 0x06000000 PCMCIA
42 * 0x10000000 PCIe
43 * 0x14000000 LRAM/URAM
44 * 0x18000000 ATA/NAND-Flash
45 * 0x1C000000 SH7786 Control register
46 */
47
48/* HeartBeat */
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090049static struct resource heartbeat_resources[] = {
50 [0] = {
51 .start = BOARDREG(SLEDR),
52 .end = BOARDREG(SLEDR),
53 .flags = IORESOURCE_MEM,
54 },
55};
56
57static struct heartbeat_data heartbeat_data = {
58 .regsize = 16,
59};
60
61static struct platform_device heartbeat_device = {
62 .name = "heartbeat",
63 .id = -1,
64 .dev = {
65 .platform_data = &heartbeat_data,
66 },
67 .num_resources = ARRAY_SIZE(heartbeat_resources),
68 .resource = heartbeat_resources,
69};
70
Kuninori Morimoto6e979382009-04-07 08:41:57 +000071/* LAN91C111 */
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +090072static struct smc91x_platdata smc91x_info = {
73 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
74};
75
76static struct resource smc91x_eth_resources[] = {
77 [0] = {
78 .name = "SMC91C111" ,
79 .start = 0x05800300,
80 .end = 0x0580030f,
81 .flags = IORESOURCE_MEM,
82 },
83 [1] = {
84 .start = 11,
85 .flags = IORESOURCE_IRQ,
86 },
87};
88
89static struct platform_device smc91x_eth_device = {
90 .name = "smc91x",
91 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
92 .resource = smc91x_eth_resources,
93 .dev = {
94 .platform_data = &smc91x_info,
95 },
96};
97
Kuninori Morimoto6e979382009-04-07 08:41:57 +000098/* Nor Flash */
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090099static struct mtd_partition nor_flash_partitions[] = {
100 {
101 .name = "loader",
102 .offset = 0x00000000,
103 .size = SZ_512K,
104 .mask_flags = MTD_WRITEABLE, /* Read-only */
105 },
106 {
107 .name = "bootenv",
108 .offset = MTDPART_OFS_APPEND,
109 .size = SZ_512K,
110 .mask_flags = MTD_WRITEABLE, /* Read-only */
111 },
112 {
113 .name = "kernel",
114 .offset = MTDPART_OFS_APPEND,
115 .size = SZ_4M,
116 },
117 {
118 .name = "data",
119 .offset = MTDPART_OFS_APPEND,
120 .size = MTDPART_SIZ_FULL,
121 },
122};
123
124static struct physmap_flash_data nor_flash_data = {
125 .width = 2,
126 .parts = nor_flash_partitions,
127 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
128};
129
130static struct resource nor_flash_resources[] = {
131 [0] = {
132 .start = NOR_FLASH_ADDR,
133 .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
134 .flags = IORESOURCE_MEM,
135 }
136};
137
138static struct platform_device nor_flash_device = {
139 .name = "physmap-flash",
140 .dev = {
141 .platform_data = &nor_flash_data,
142 },
143 .num_resources = ARRAY_SIZE(nor_flash_resources),
144 .resource = nor_flash_resources,
145};
146
147static struct platform_device *urquell_devices[] __initdata = {
148 &heartbeat_device,
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900149 &smc91x_eth_device,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900150 &nor_flash_device,
151};
152
153static int __init urquell_devices_setup(void)
154{
155 /* USB */
156 gpio_request(GPIO_FN_USB_OVC0, NULL);
157 gpio_request(GPIO_FN_USB_PENC0, NULL);
158
Kuninori Morimoto71c1d192009-03-26 00:24:01 +0000159 /* enable LAN */
160 __raw_writew(__raw_readw(UBOARDREG(IRL2MSKR)) & ~0x00000001,
161 UBOARDREG(IRL2MSKR));
162
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900163 return platform_add_devices(urquell_devices,
164 ARRAY_SIZE(urquell_devices));
165}
166device_initcall(urquell_devices_setup);
167
168static void urquell_power_off(void)
169{
170 __raw_writew(0xa5a5, UBOARDREG(SRSTR));
171}
172
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900173static void __init urquell_init_irq(void)
174{
175 plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK);
176}
177
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900178/* Initialize the board */
179static void __init urquell_setup(char **cmdline_p)
180{
181 printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n");
182
183 pm_power_off = urquell_power_off;
184}
185
186/*
187 * The Machine Vector
188 */
189static struct sh_machine_vector mv_urquell __initmv = {
190 .mv_name = "Urquell",
191 .mv_setup = urquell_setup,
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900192 .mv_init_irq = urquell_init_irq,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900193};