blob: a9bd6e3ee10b9eabf5d5d5e72924ffcfacd47e00 [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>
Paul Mundtdea3cf12010-01-19 20:09:28 +09005 * Copyright (C) 2009, 2010 Paul Mundt
Kuninori Morimoto6e979382009-04-07 08:41:57 +00006 *
7 * Based on board-sh7785lcr.c
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +09008 * Copyright (C) 2008 Yoshihiro Shimoda
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/fb.h>
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +090017#include <linux/smc91x.h>
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090018#include <linux/mtd/physmap.h>
19#include <linux/delay.h>
20#include <linux/gpio.h>
21#include <linux/irq.h>
Paul Mundtdea3cf12010-01-19 20:09:28 +090022#include <linux/clk.h>
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090023#include <mach/urquell.h>
24#include <cpu/sh7786.h>
25#include <asm/heartbeat.h>
26#include <asm/sizes.h>
27
Kuninori Morimoto1bc57182009-04-10 13:35:28 -070028/*
29 * bit 1234 5678
Kuninori Morimoto6e979382009-04-07 08:41:57 +000030 *----------------------------
Kuninori Morimoto1bc57182009-04-10 13:35:28 -070031 * SW1 0101 0010 -> Pck 33MHz version
32 * (1101 0010) Pck 66MHz version
33 * SW2 0x1x xxxx -> little endian
Kuninori Morimoto6e979382009-04-07 08:41:57 +000034 * 29bit mode
Kuninori Morimoto1bc57182009-04-10 13:35:28 -070035 * SW47 0001 1000 -> CS0 : on-board flash
Kuninori Morimoto6e979382009-04-07 08:41:57 +000036 * CS1 : SRAM, registers, LAN, PCMCIA
Kuninori Morimoto1bc57182009-04-10 13:35:28 -070037 * 38400 bps for SCIF1
Kuninori Morimoto6e979382009-04-07 08:41:57 +000038 *
39 * Address
Kuninori Morimoto1bc57182009-04-10 13:35:28 -070040 * 0x00000000 - 0x04000000 (CS0) Nor Flash
41 * 0x04000000 - 0x04200000 (CS1) SRAM
42 * 0x05000000 - 0x05800000 (CS1) on board register
43 * 0x05800000 - 0x06000000 (CS1) LAN91C111
44 * 0x06000000 - 0x06400000 (CS1) PCMCIA
45 * 0x08000000 - 0x10000000 (CS2-CS3) DDR3
46 * 0x10000000 - 0x14000000 (CS4) PCIe
47 * 0x14000000 - 0x14800000 (CS5) Core0 LRAM/URAM
48 * 0x14800000 - 0x15000000 (CS5) Core1 LRAM/URAM
49 * 0x18000000 - 0x1C000000 (CS6) ATA/NAND-Flash
50 * 0x1C000000 - (CS7) SH7786 Control register
Kuninori Morimoto6e979382009-04-07 08:41:57 +000051 */
52
53/* HeartBeat */
Paul Mundta09d2832010-01-15 12:24:34 +090054static struct resource heartbeat_resource = {
55 .start = BOARDREG(SLEDR),
56 .end = BOARDREG(SLEDR),
57 .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090058};
59
60static struct platform_device heartbeat_device = {
61 .name = "heartbeat",
62 .id = -1,
Paul Mundt14965f12010-01-19 20:10:33 +090063 .num_resources = 1,
Paul Mundta09d2832010-01-15 12:24:34 +090064 .resource = &heartbeat_resource,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090065};
66
Kuninori Morimoto6e979382009-04-07 08:41:57 +000067/* LAN91C111 */
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +090068static struct smc91x_platdata smc91x_info = {
69 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
70};
71
72static struct resource smc91x_eth_resources[] = {
73 [0] = {
74 .name = "SMC91C111" ,
75 .start = 0x05800300,
76 .end = 0x0580030f,
77 .flags = IORESOURCE_MEM,
78 },
79 [1] = {
80 .start = 11,
81 .flags = IORESOURCE_IRQ,
82 },
83};
84
85static struct platform_device smc91x_eth_device = {
86 .name = "smc91x",
87 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
88 .resource = smc91x_eth_resources,
89 .dev = {
90 .platform_data = &smc91x_info,
91 },
92};
93
Kuninori Morimoto6e979382009-04-07 08:41:57 +000094/* Nor Flash */
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +090095static struct mtd_partition nor_flash_partitions[] = {
96 {
97 .name = "loader",
98 .offset = 0x00000000,
99 .size = SZ_512K,
100 .mask_flags = MTD_WRITEABLE, /* Read-only */
101 },
102 {
103 .name = "bootenv",
104 .offset = MTDPART_OFS_APPEND,
105 .size = SZ_512K,
106 .mask_flags = MTD_WRITEABLE, /* Read-only */
107 },
108 {
109 .name = "kernel",
110 .offset = MTDPART_OFS_APPEND,
111 .size = SZ_4M,
112 },
113 {
114 .name = "data",
115 .offset = MTDPART_OFS_APPEND,
116 .size = MTDPART_SIZ_FULL,
117 },
118};
119
120static struct physmap_flash_data nor_flash_data = {
121 .width = 2,
122 .parts = nor_flash_partitions,
123 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
124};
125
126static struct resource nor_flash_resources[] = {
127 [0] = {
128 .start = NOR_FLASH_ADDR,
129 .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
130 .flags = IORESOURCE_MEM,
131 }
132};
133
134static struct platform_device nor_flash_device = {
135 .name = "physmap-flash",
136 .dev = {
137 .platform_data = &nor_flash_data,
138 },
139 .num_resources = ARRAY_SIZE(nor_flash_resources),
140 .resource = nor_flash_resources,
141};
142
143static struct platform_device *urquell_devices[] __initdata = {
144 &heartbeat_device,
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900145 &smc91x_eth_device,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900146 &nor_flash_device,
147};
148
149static int __init urquell_devices_setup(void)
150{
151 /* USB */
152 gpio_request(GPIO_FN_USB_OVC0, NULL);
153 gpio_request(GPIO_FN_USB_PENC0, NULL);
154
Kuninori Morimoto71c1d192009-03-26 00:24:01 +0000155 /* enable LAN */
156 __raw_writew(__raw_readw(UBOARDREG(IRL2MSKR)) & ~0x00000001,
157 UBOARDREG(IRL2MSKR));
158
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900159 return platform_add_devices(urquell_devices,
160 ARRAY_SIZE(urquell_devices));
161}
162device_initcall(urquell_devices_setup);
163
164static void urquell_power_off(void)
165{
166 __raw_writew(0xa5a5, UBOARDREG(SRSTR));
167}
168
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900169static void __init urquell_init_irq(void)
170{
171 plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK);
172}
173
Paul Mundt5d0e9452009-06-15 19:02:37 +0900174static int urquell_mode_pins(void)
175{
176 return __raw_readw(UBOARDREG(MDSWMR));
177}
178
Paul Mundtdea3cf12010-01-19 20:09:28 +0900179static int urquell_clk_init(void)
180{
181 struct clk *clk;
182 int ret;
183
184 /*
185 * Only handle the EXTAL case, anyone interfacing a crystal
186 * resonator will need to provide their own input clock.
187 */
188 if (test_mode_pin(MODE_PIN9))
189 return -EINVAL;
190
191 clk = clk_get(NULL, "extal");
192 if (!clk || IS_ERR(clk))
193 return PTR_ERR(clk);
194 ret = clk_set_rate(clk, 33333333);
195 clk_put(clk);
196
197 return ret;
198}
199
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900200/* Initialize the board */
201static void __init urquell_setup(char **cmdline_p)
202{
203 printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n");
204
205 pm_power_off = urquell_power_off;
206}
207
208/*
209 * The Machine Vector
210 */
211static struct sh_machine_vector mv_urquell __initmv = {
212 .mv_name = "Urquell",
213 .mv_setup = urquell_setup,
Kuninori Morimoto929ef1a2009-03-05 17:37:12 +0900214 .mv_init_irq = urquell_init_irq,
Paul Mundt5d0e9452009-06-15 19:02:37 +0900215 .mv_mode_pins = urquell_mode_pins,
Paul Mundtdea3cf12010-01-19 20:09:28 +0900216 .mv_clk_init = urquell_clk_init,
Kuninori Morimoto5ac072e2009-03-03 16:22:00 +0900217};