sh: machvec rework.
[linux-2.6.git] / arch / sh / boards / renesas / r7780rp / setup.c
1 /*
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>
16 #include <asm/r7780rp/r7780rp.h>
17 #include <asm/clock.h>
18 #include <asm/io.h>
19
20 extern void heartbeat_r7780rp(void);
21 extern void init_r7780rp_IRQ(void);
22
23 static 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
36 static 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
47 static struct platform_device *r7780rp_devices[] __initdata = {
48         &m66596_usb_host_device,
49 };
50
51 static int __init r7780rp_devices_setup(void)
52 {
53         return platform_add_devices(r7780rp_devices,
54                                     ARRAY_SIZE(r7780rp_devices));
55 }
56
57 /*
58  * Platform specific clocks
59  */
60 static void ivdr_clk_enable(struct clk *clk)
61 {
62         ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
63 }
64
65 static void ivdr_clk_disable(struct clk *clk)
66 {
67         ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
68 }
69
70 static struct clk_ops ivdr_clk_ops = {
71         .enable         = ivdr_clk_enable,
72         .disable        = ivdr_clk_disable,
73 };
74
75 static struct clk ivdr_clk = {
76         .name           = "ivdr_clk",
77         .ops            = &ivdr_clk_ops,
78 };
79
80 static struct clk *r7780rp_clocks[] = {
81         &ivdr_clk,
82 };
83
84 static void r7780rp_power_off(void)
85 {
86 #ifdef CONFIG_SH_R7780MP
87         ctrl_outw(0x0001, PA_POFF);
88 #endif
89 }
90
91 /*
92  * Initialize the board
93  */
94 static void __init r7780rp_setup(char **cmdline_p)
95 {
96         u16 ver = ctrl_inw(PA_VERREG);
97         int i;
98
99         device_initcall(r7780rp_devices_setup);
100
101         printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
102
103         printk(KERN_INFO "Board version: %d (revision %d), "
104                          "FPGA version: %d (revision %d)\n",
105                          (ver >> 12) & 0xf, (ver >> 8) & 0xf,
106                          (ver >>  4) & 0xf, ver & 0xf);
107
108         /*
109          * Enable the important clocks right away..
110          */
111         for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
112                 struct clk *clk = r7780rp_clocks[i];
113
114                 clk_register(clk);
115                 clk_enable(clk);
116         }
117
118         ctrl_outw(0x0000, PA_OBLED);    /* Clear LED. */
119 #ifndef CONFIG_SH_R7780MP
120         ctrl_outw(0x0001, PA_SDPOW);    /* SD Power ON */
121 #endif
122         ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x0100, PA_IVDRCTL);   /* Si13112 */
123
124         pm_power_off = r7780rp_power_off;
125 }
126
127 /*
128  * The Machine Vector
129  */
130 struct sh_machine_vector mv_r7780rp __initmv = {
131         .mv_name                = "Highlander R7780RP-1",
132         .mv_setup               = r7780rp_setup,
133
134         .mv_nr_irqs             = 109,
135
136         .mv_inb                 = r7780rp_inb,
137         .mv_inw                 = r7780rp_inw,
138         .mv_inl                 = r7780rp_inl,
139         .mv_outb                = r7780rp_outb,
140         .mv_outw                = r7780rp_outw,
141         .mv_outl                = r7780rp_outl,
142
143         .mv_inb_p               = r7780rp_inb_p,
144         .mv_inw_p               = r7780rp_inw,
145         .mv_inl_p               = r7780rp_inl,
146         .mv_outb_p              = r7780rp_outb_p,
147         .mv_outw_p              = r7780rp_outw,
148         .mv_outl_p              = r7780rp_outl,
149
150         .mv_insb                = r7780rp_insb,
151         .mv_insw                = r7780rp_insw,
152         .mv_insl                = r7780rp_insl,
153         .mv_outsb               = r7780rp_outsb,
154         .mv_outsw               = r7780rp_outsw,
155         .mv_outsl               = r7780rp_outsl,
156
157         .mv_ioport_map          = r7780rp_ioport_map,
158         .mv_init_irq            = init_r7780rp_IRQ,
159 #ifdef CONFIG_HEARTBEAT
160         .mv_heartbeat           = heartbeat_r7780rp,
161 #endif
162 };
163 ALIAS_MV(r7780rp)