blob: 9f89c8de9db98ba9f5a4e0ad3f6478520af515a0 [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
20extern void heartbeat_r7780rp(void);
21extern 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] = {
49 .start = 0x1f0,
50 .end = 0x1f0 + 8,
51 .flags = IORESOURCE_IO,
52 },
53 [1] = {
54 .start = 0x1f0 + 0x206,
55 .end = 0x1f0 + 8 + 0x206 + 8,
56 .flags = IORESOURCE_IO,
57 },
58 [2] = {
59#ifdef CONFIG_SH_R7780MP
60 .start = 1,
61#else
62 .start = 4,
63#endif
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct platform_device cf_ide_device = {
69 .name = "pata_platform",
70 .id = -1,
71 .num_resources = ARRAY_SIZE(cf_ide_resources),
72 .resource = cf_ide_resources,
73};
74
Paul Mundt5283ecb2006-09-27 15:59:17 +090075static struct platform_device *r7780rp_devices[] __initdata = {
76 &m66596_usb_host_device,
Paul Mundt0c020e32006-12-06 10:43:44 +090077 &cf_ide_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +090078};
79
80static int __init r7780rp_devices_setup(void)
81{
82 return platform_add_devices(r7780rp_devices,
83 ARRAY_SIZE(r7780rp_devices));
84}
Paul Mundt5283ecb2006-09-27 15:59:17 +090085
86/*
87 * Platform specific clocks
88 */
89static void ivdr_clk_enable(struct clk *clk)
90{
91 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
92}
93
94static void ivdr_clk_disable(struct clk *clk)
95{
96 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
97}
98
99static struct clk_ops ivdr_clk_ops = {
100 .enable = ivdr_clk_enable,
101 .disable = ivdr_clk_disable,
102};
103
104static struct clk ivdr_clk = {
105 .name = "ivdr_clk",
106 .ops = &ivdr_clk_ops,
107};
108
109static struct clk *r7780rp_clocks[] = {
110 &ivdr_clk,
111};
112
Paul Mundt5283ecb2006-09-27 15:59:17 +0900113static void r7780rp_power_off(void)
114{
115#ifdef CONFIG_SH_R7780MP
116 ctrl_outw(0x0001, PA_POFF);
117#endif
118}
119
120/*
121 * Initialize the board
122 */
Paul Mundt2c7834a2006-09-27 18:17:31 +0900123static void __init r7780rp_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900124{
125 u16 ver = ctrl_inw(PA_VERREG);
126 int i;
127
Paul Mundt2c7834a2006-09-27 18:17:31 +0900128 device_initcall(r7780rp_devices_setup);
129
Paul Mundt5283ecb2006-09-27 15:59:17 +0900130 printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
131
132 printk(KERN_INFO "Board version: %d (revision %d), "
133 "FPGA version: %d (revision %d)\n",
134 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
135 (ver >> 4) & 0xf, ver & 0xf);
136
137 /*
138 * Enable the important clocks right away..
139 */
140 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
141 struct clk *clk = r7780rp_clocks[i];
142
143 clk_register(clk);
144 clk_enable(clk);
145 }
146
147 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
148#ifndef CONFIG_SH_R7780MP
149 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
150#endif
151 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x0100, PA_IVDRCTL); /* Si13112 */
152
153 pm_power_off = r7780rp_power_off;
154}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900155
156/*
157 * The Machine Vector
158 */
159struct sh_machine_vector mv_r7780rp __initmv = {
160 .mv_name = "Highlander R7780RP-1",
161 .mv_setup = r7780rp_setup,
162
163 .mv_nr_irqs = 109,
164
165 .mv_inb = r7780rp_inb,
166 .mv_inw = r7780rp_inw,
167 .mv_inl = r7780rp_inl,
168 .mv_outb = r7780rp_outb,
169 .mv_outw = r7780rp_outw,
170 .mv_outl = r7780rp_outl,
171
172 .mv_inb_p = r7780rp_inb_p,
173 .mv_inw_p = r7780rp_inw,
174 .mv_inl_p = r7780rp_inl,
175 .mv_outb_p = r7780rp_outb_p,
176 .mv_outw_p = r7780rp_outw,
177 .mv_outl_p = r7780rp_outl,
178
179 .mv_insb = r7780rp_insb,
180 .mv_insw = r7780rp_insw,
181 .mv_insl = r7780rp_insl,
182 .mv_outsb = r7780rp_outsb,
183 .mv_outsw = r7780rp_outsw,
184 .mv_outsl = r7780rp_outsl,
185
186 .mv_ioport_map = r7780rp_ioport_map,
187 .mv_init_irq = init_r7780rp_IRQ,
188#ifdef CONFIG_HEARTBEAT
189 .mv_heartbeat = heartbeat_r7780rp,
190#endif
191};
192ALIAS_MV(r7780rp)