Merge master.kernel.org:/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.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 - 2007 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 <linux/pata_platform.h>
16 #include <asm/machvec.h>
17 #include <asm/r7780rp.h>
18 #include <asm/clock.h>
19 #include <asm/io.h>
20
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 resource cf_ide_resources[] = {
48         [0] = {
49                 .start  = PA_AREA5_IO + 0x1000,
50                 .end    = PA_AREA5_IO + 0x1000 + 0x08 - 1,
51                 .flags  = IORESOURCE_MEM,
52         },
53         [1] = {
54                 .start  = PA_AREA5_IO + 0x80c,
55                 .end    = PA_AREA5_IO + 0x80c + 0x16 - 1,
56                 .flags  = IORESOURCE_MEM,
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
68 static struct pata_platform_info pata_info = {
69         .ioport_shift   = 1,
70 };
71
72 static 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,
77         .dev    = {
78                 .platform_data  = &pata_info,
79         },
80 };
81
82 static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
83
84 static 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
92 static 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
102 static struct platform_device *r7780rp_devices[] __initdata = {
103         &m66596_usb_host_device,
104         &cf_ide_device,
105         &heartbeat_device,
106 };
107
108 static int __init r7780rp_devices_setup(void)
109 {
110         return platform_add_devices(r7780rp_devices,
111                                     ARRAY_SIZE(r7780rp_devices));
112 }
113
114 /*
115  * Platform specific clocks
116  */
117 static void ivdr_clk_enable(struct clk *clk)
118 {
119         ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
120 }
121
122 static void ivdr_clk_disable(struct clk *clk)
123 {
124         ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
125 }
126
127 static struct clk_ops ivdr_clk_ops = {
128         .enable         = ivdr_clk_enable,
129         .disable        = ivdr_clk_disable,
130 };
131
132 static struct clk ivdr_clk = {
133         .name           = "ivdr_clk",
134         .ops            = &ivdr_clk_ops,
135 };
136
137 static struct clk *r7780rp_clocks[] = {
138         &ivdr_clk,
139 };
140
141 static 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  */
151 static void __init r7780rp_setup(char **cmdline_p)
152 {
153         u16 ver = ctrl_inw(PA_VERREG);
154         int i;
155
156         device_initcall(r7780rp_devices_setup);
157
158         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
179         ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL);     /* Si13112 */
180
181         pm_power_off = r7780rp_power_off;
182 }
183
184 /*
185  * The Machine Vector
186  */
187 struct 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,
216 };
217 ALIAS_MV(r7780rp)