blob: c40f85cc3e5e460552e864eab2bec98df00414b5 [file] [log] [blame]
Paul Mundt5283ecb2006-09-27 15:59:17 +09001/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2005, 2006 Paul Mundt
6 *
7 * Renesas Solutions Highlander R7780RP-1 Support.
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 <asm/machvec.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090016#include <asm/r7780rp.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090017#include <asm/clock.h>
18#include <asm/io.h>
19
Paul Mundt5283ecb2006-09-27 15:59:17 +090020extern void init_r7780rp_IRQ(void);
21
Paul Mundt5283ecb2006-09-27 15:59:17 +090022static struct resource m66596_usb_host_resources[] = {
23 [0] = {
24 .start = 0xa4800000,
25 .end = 0xa4ffffff,
26 .flags = IORESOURCE_MEM,
27 },
28 [1] = {
29 .start = 6, /* irq number */
30 .end = 6,
31 .flags = IORESOURCE_IRQ,
32 },
33};
34
35static struct platform_device m66596_usb_host_device = {
36 .name = "m66596-hcd",
37 .id = 0,
38 .dev = {
39 .dma_mask = NULL, /* don't use dma */
40 .coherent_dma_mask = 0xffffffff,
41 },
42 .num_resources = ARRAY_SIZE(m66596_usb_host_resources),
43 .resource = m66596_usb_host_resources,
44};
45
Paul Mundt0c020e32006-12-06 10:43:44 +090046static struct resource cf_ide_resources[] = {
47 [0] = {
48 .start = 0x1f0,
49 .end = 0x1f0 + 8,
50 .flags = IORESOURCE_IO,
51 },
52 [1] = {
53 .start = 0x1f0 + 0x206,
54 .end = 0x1f0 + 8 + 0x206 + 8,
55 .flags = IORESOURCE_IO,
56 },
57 [2] = {
58#ifdef CONFIG_SH_R7780MP
59 .start = 1,
60#else
61 .start = 4,
62#endif
63 .flags = IORESOURCE_IRQ,
64 },
65};
66
67static struct platform_device cf_ide_device = {
68 .name = "pata_platform",
69 .id = -1,
70 .num_resources = ARRAY_SIZE(cf_ide_resources),
71 .resource = cf_ide_resources,
72};
73
Paul Mundt3b4d9532007-02-13 15:42:28 +090074static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
75
76static struct resource heartbeat_resources[] = {
77 [0] = {
78 .start = PA_OBLED,
79 .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
80 .flags = IORESOURCE_MEM,
81 },
82};
83
84static struct platform_device heartbeat_device = {
85 .name = "heartbeat",
86 .id = -1,
87 .dev = {
88 .platform_data = heartbeat_bit_pos,
89 },
90 .num_resources = ARRAY_SIZE(heartbeat_resources),
91 .resource = heartbeat_resources,
92};
93
Paul Mundt5283ecb2006-09-27 15:59:17 +090094static struct platform_device *r7780rp_devices[] __initdata = {
95 &m66596_usb_host_device,
Paul Mundt0c020e32006-12-06 10:43:44 +090096 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +090097 &heartbeat_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +090098};
99
100static int __init r7780rp_devices_setup(void)
101{
102 return platform_add_devices(r7780rp_devices,
103 ARRAY_SIZE(r7780rp_devices));
104}
Paul Mundt5283ecb2006-09-27 15:59:17 +0900105
106/*
107 * Platform specific clocks
108 */
109static void ivdr_clk_enable(struct clk *clk)
110{
111 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
112}
113
114static void ivdr_clk_disable(struct clk *clk)
115{
116 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
117}
118
119static struct clk_ops ivdr_clk_ops = {
120 .enable = ivdr_clk_enable,
121 .disable = ivdr_clk_disable,
122};
123
124static struct clk ivdr_clk = {
125 .name = "ivdr_clk",
126 .ops = &ivdr_clk_ops,
127};
128
129static struct clk *r7780rp_clocks[] = {
130 &ivdr_clk,
131};
132
Paul Mundt5283ecb2006-09-27 15:59:17 +0900133static void r7780rp_power_off(void)
134{
135#ifdef CONFIG_SH_R7780MP
136 ctrl_outw(0x0001, PA_POFF);
137#endif
138}
139
140/*
141 * Initialize the board
142 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900143static void __init r7780rp_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900144{
145 u16 ver = ctrl_inw(PA_VERREG);
146 int i;
147
Paul Mundt2c7834a2006-09-27 18:17:31 +0900148 device_initcall(r7780rp_devices_setup);
149
Paul Mundt5283ecb2006-09-27 15:59:17 +0900150 printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
151
152 printk(KERN_INFO "Board version: %d (revision %d), "
153 "FPGA version: %d (revision %d)\n",
154 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
155 (ver >> 4) & 0xf, ver & 0xf);
156
157 /*
158 * Enable the important clocks right away..
159 */
160 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
161 struct clk *clk = r7780rp_clocks[i];
162
163 clk_register(clk);
164 clk_enable(clk);
165 }
166
167 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
168#ifndef CONFIG_SH_R7780MP
169 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
170#endif
Paul Mundt2c081e72006-12-25 18:28:33 +0900171 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900172
173 pm_power_off = r7780rp_power_off;
174}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900175
176/*
177 * The Machine Vector
178 */
179struct sh_machine_vector mv_r7780rp __initmv = {
180 .mv_name = "Highlander R7780RP-1",
181 .mv_setup = r7780rp_setup,
182
183 .mv_nr_irqs = 109,
184
185 .mv_inb = r7780rp_inb,
186 .mv_inw = r7780rp_inw,
187 .mv_inl = r7780rp_inl,
188 .mv_outb = r7780rp_outb,
189 .mv_outw = r7780rp_outw,
190 .mv_outl = r7780rp_outl,
191
192 .mv_inb_p = r7780rp_inb_p,
193 .mv_inw_p = r7780rp_inw,
194 .mv_inl_p = r7780rp_inl,
195 .mv_outb_p = r7780rp_outb_p,
196 .mv_outw_p = r7780rp_outw,
197 .mv_outl_p = r7780rp_outl,
198
199 .mv_insb = r7780rp_insb,
200 .mv_insw = r7780rp_insw,
201 .mv_insl = r7780rp_insl,
202 .mv_outsb = r7780rp_outsb,
203 .mv_outsw = r7780rp_outsw,
204 .mv_outsl = r7780rp_outsl,
205
206 .mv_ioport_map = r7780rp_ioport_map,
207 .mv_init_irq = init_r7780rp_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900208};
209ALIAS_MV(r7780rp)