blob: 0d74db9f179298fcd4c86e5333d39dcf76131082 [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.
Paul Mundt71074d32007-02-14 14:49:04 +09005 * Copyright (C) 2005 - 2007 Paul Mundt
Paul Mundt5283ecb2006-09-27 15:59:17 +09006 *
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>
Paul Mundt71074d32007-02-14 14:49:04 +090015#include <linux/pata_platform.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090016#include <asm/machvec.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090017#include <asm/r7780rp.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090018#include <asm/clock.h>
19#include <asm/io.h>
20
Paul Mundt5283ecb2006-09-27 15:59:17 +090021extern void init_r7780rp_IRQ(void);
22
Paul Mundt5283ecb2006-09-27 15:59:17 +090023static struct resource m66596_usb_host_resources[] = {
24 [0] = {
25 .start = 0xa4800000,
26 .end = 0xa4ffffff,
27 .flags = IORESOURCE_MEM,
28 },
29 [1] = {
30 .start = 6, /* irq number */
31 .end = 6,
32 .flags = IORESOURCE_IRQ,
33 },
34};
35
36static struct platform_device m66596_usb_host_device = {
37 .name = "m66596-hcd",
38 .id = 0,
39 .dev = {
40 .dma_mask = NULL, /* don't use dma */
41 .coherent_dma_mask = 0xffffffff,
42 },
43 .num_resources = ARRAY_SIZE(m66596_usb_host_resources),
44 .resource = m66596_usb_host_resources,
45};
46
Paul Mundt0c020e32006-12-06 10:43:44 +090047static struct resource cf_ide_resources[] = {
48 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090049 .start = PA_AREA5_IO + 0x1000,
50 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
51 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090052 },
53 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090054 .start = PA_AREA5_IO + 0x80c,
55 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
56 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090057 },
58 [2] = {
59#ifdef CONFIG_SH_R7780MP
60 .start = 1,
61#else
62 .start = 4,
63#endif
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
Paul Mundt71074d32007-02-14 14:49:04 +090068static struct pata_platform_info pata_info = {
69 .ioport_shift = 1,
70};
71
Paul Mundt0c020e32006-12-06 10:43:44 +090072static struct platform_device cf_ide_device = {
73 .name = "pata_platform",
74 .id = -1,
75 .num_resources = ARRAY_SIZE(cf_ide_resources),
76 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +090077 .dev = {
78 .platform_data = &pata_info,
79 },
Paul Mundt0c020e32006-12-06 10:43:44 +090080};
81
Paul Mundt3b4d9532007-02-13 15:42:28 +090082static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
83
84static struct resource heartbeat_resources[] = {
85 [0] = {
86 .start = PA_OBLED,
87 .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
88 .flags = IORESOURCE_MEM,
89 },
90};
91
92static struct platform_device heartbeat_device = {
93 .name = "heartbeat",
94 .id = -1,
95 .dev = {
96 .platform_data = heartbeat_bit_pos,
97 },
98 .num_resources = ARRAY_SIZE(heartbeat_resources),
99 .resource = heartbeat_resources,
100};
101
Paul Mundt5283ecb2006-09-27 15:59:17 +0900102static struct platform_device *r7780rp_devices[] __initdata = {
103 &m66596_usb_host_device,
Paul Mundt0c020e32006-12-06 10:43:44 +0900104 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900105 &heartbeat_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +0900106};
107
108static int __init r7780rp_devices_setup(void)
109{
110 return platform_add_devices(r7780rp_devices,
111 ARRAY_SIZE(r7780rp_devices));
112}
Paul Mundt5283ecb2006-09-27 15:59:17 +0900113
114/*
115 * Platform specific clocks
116 */
117static void ivdr_clk_enable(struct clk *clk)
118{
119 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
120}
121
122static void ivdr_clk_disable(struct clk *clk)
123{
124 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
125}
126
127static struct clk_ops ivdr_clk_ops = {
128 .enable = ivdr_clk_enable,
129 .disable = ivdr_clk_disable,
130};
131
132static struct clk ivdr_clk = {
133 .name = "ivdr_clk",
134 .ops = &ivdr_clk_ops,
135};
136
137static struct clk *r7780rp_clocks[] = {
138 &ivdr_clk,
139};
140
Paul Mundt5283ecb2006-09-27 15:59:17 +0900141static void r7780rp_power_off(void)
142{
143#ifdef CONFIG_SH_R7780MP
144 ctrl_outw(0x0001, PA_POFF);
145#endif
146}
147
148/*
149 * Initialize the board
150 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900151static void __init r7780rp_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900152{
153 u16 ver = ctrl_inw(PA_VERREG);
154 int i;
155
Paul Mundt2c7834a2006-09-27 18:17:31 +0900156 device_initcall(r7780rp_devices_setup);
157
Paul Mundt5283ecb2006-09-27 15:59:17 +0900158 printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
159
160 printk(KERN_INFO "Board version: %d (revision %d), "
161 "FPGA version: %d (revision %d)\n",
162 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
163 (ver >> 4) & 0xf, ver & 0xf);
164
165 /*
166 * Enable the important clocks right away..
167 */
168 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
169 struct clk *clk = r7780rp_clocks[i];
170
171 clk_register(clk);
172 clk_enable(clk);
173 }
174
175 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
176#ifndef CONFIG_SH_R7780MP
177 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
178#endif
Paul Mundt2c081e72006-12-25 18:28:33 +0900179 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900180
181 pm_power_off = r7780rp_power_off;
182}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900183
184/*
185 * The Machine Vector
186 */
187struct sh_machine_vector mv_r7780rp __initmv = {
188 .mv_name = "Highlander R7780RP-1",
189 .mv_setup = r7780rp_setup,
190
191 .mv_nr_irqs = 109,
192
193 .mv_inb = r7780rp_inb,
194 .mv_inw = r7780rp_inw,
195 .mv_inl = r7780rp_inl,
196 .mv_outb = r7780rp_outb,
197 .mv_outw = r7780rp_outw,
198 .mv_outl = r7780rp_outl,
199
200 .mv_inb_p = r7780rp_inb_p,
201 .mv_inw_p = r7780rp_inw,
202 .mv_inl_p = r7780rp_inl,
203 .mv_outb_p = r7780rp_outb_p,
204 .mv_outw_p = r7780rp_outw,
205 .mv_outl_p = r7780rp_outl,
206
207 .mv_insb = r7780rp_insb,
208 .mv_insw = r7780rp_insw,
209 .mv_insl = r7780rp_insl,
210 .mv_outsb = r7780rp_outsb,
211 .mv_outsw = r7780rp_outsw,
212 .mv_outsl = r7780rp_outsl,
213
214 .mv_ioport_map = r7780rp_ioport_map,
215 .mv_init_irq = init_r7780rp_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900216};
217ALIAS_MV(r7780rp)