RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / sh / boards / renesas / r7780rp / setup.c
blob0727ef92f2b37431cb4f3de3ab3234b360eeef02
1 /*
2 * arch/sh/boards/renesas/r7780rp/setup.c
4 * Renesas Solutions Highlander Support.
6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
7 * Copyright (C) 2005 - 2007 Paul Mundt
9 * This contains support for the R7780RP-1, R7780MP, and R7785RP
10 * Highlander modules.
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
14 * for more details.
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/pata_platform.h>
19 #include <asm/machvec.h>
20 #include <asm/r7780rp.h>
21 #include <asm/clock.h>
22 #include <asm/io.h>
24 static struct resource cf_ide_resources[] = {
25 [0] = {
26 .start = PA_AREA5_IO + 0x1000,
27 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
28 .flags = IORESOURCE_MEM,
30 [1] = {
31 .start = PA_AREA5_IO + 0x80c,
32 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
33 .flags = IORESOURCE_MEM,
35 [2] = {
36 #ifdef CONFIG_SH_R7780RP
37 .start = 4,
38 #else
39 .start = 1,
40 #endif
41 .flags = IORESOURCE_IRQ,
45 static struct pata_platform_info pata_info = {
46 .ioport_shift = 1,
49 static struct platform_device cf_ide_device = {
50 .name = "pata_platform",
51 .id = -1,
52 .num_resources = ARRAY_SIZE(cf_ide_resources),
53 .resource = cf_ide_resources,
54 .dev = {
55 .platform_data = &pata_info,
59 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
61 static struct resource heartbeat_resources[] = {
62 [0] = {
63 .start = PA_OBLED,
64 .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
65 .flags = IORESOURCE_MEM,
69 static struct platform_device heartbeat_device = {
70 .name = "heartbeat",
71 .id = -1,
73 /* R7785RP has a slightly more sensible FPGA.. */
74 #ifndef CONFIG_SH_R7785RP
75 .dev = {
76 .platform_data = heartbeat_bit_pos,
78 #endif
79 .num_resources = ARRAY_SIZE(heartbeat_resources),
80 .resource = heartbeat_resources,
83 static struct platform_device *r7780rp_devices[] __initdata = {
84 &cf_ide_device,
85 &heartbeat_device,
88 static int __init r7780rp_devices_setup(void)
90 return platform_add_devices(r7780rp_devices,
91 ARRAY_SIZE(r7780rp_devices));
93 device_initcall(r7780rp_devices_setup);
96 * Platform specific clocks
98 static void ivdr_clk_enable(struct clk *clk)
100 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
103 static void ivdr_clk_disable(struct clk *clk)
105 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
108 static struct clk_ops ivdr_clk_ops = {
109 .enable = ivdr_clk_enable,
110 .disable = ivdr_clk_disable,
113 static struct clk ivdr_clk = {
114 .name = "ivdr_clk",
115 .ops = &ivdr_clk_ops,
118 static struct clk *r7780rp_clocks[] = {
119 &ivdr_clk,
122 static void r7780rp_power_off(void)
124 if (mach_is_r7780mp() || mach_is_r7785rp())
125 ctrl_outw(0x0001, PA_POFF);
129 * Initialize the board
131 static void __init highlander_setup(char **cmdline_p)
133 u16 ver = ctrl_inw(PA_VERREG);
134 int i;
136 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
137 mach_is_r7780rp() ? "R7780RP-1" :
138 mach_is_r7780mp() ? "R7780MP" :
139 "R7785RP");
141 printk(KERN_INFO "Board version: %d (revision %d), "
142 "FPGA version: %d (revision %d)\n",
143 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
144 (ver >> 4) & 0xf, ver & 0xf);
147 * Enable the important clocks right away..
149 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
150 struct clk *clk = r7780rp_clocks[i];
152 clk_register(clk);
153 clk_enable(clk);
156 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
158 if (mach_is_r7780rp())
159 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
161 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
163 pm_power_off = r7780rp_power_off;
167 * The Machine Vector
169 struct sh_machine_vector mv_highlander __initmv = {
170 .mv_name = "Highlander",
171 .mv_nr_irqs = 109,
172 .mv_setup = highlander_setup,
173 .mv_init_irq = highlander_init_irq,
175 ALIAS_MV(highlander)