sh: rts7751r2d board updates.
[linux-2.6.git] / arch / sh / boards / renesas / rts7751r2d / setup.c
1 /*
2  * Renesas Technology Sales RTS7751R2D Support.
3  *
4  * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
5  * Copyright (C) 2004 - 2007 Paul Mundt
6  *
7  * This file is subject to the terms and conditions of the GNU General Public
8  * License.  See the file "COPYING" in the main directory of this archive
9  * for more details.
10  */
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/pata_platform.h>
14 #include <linux/serial_8250.h>
15 #include <linux/pm.h>
16 #include <asm/machvec.h>
17 #include <asm/rts7751r2d.h>
18 #include <asm/voyagergx.h>
19 #include <asm/io.h>
20
21 static void __init voyagergx_serial_init(void)
22 {
23         unsigned long val;
24
25         /*
26          * GPIO Control
27          */
28         val = readl((void __iomem *)GPIO_MUX_HIGH);
29         val |= 0x00001fe0;
30         writel(val, (void __iomem *)GPIO_MUX_HIGH);
31
32         /*
33          * Power Mode Gate
34          */
35         val = readl((void __iomem *)POWER_MODE0_GATE);
36         val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
37         writel(val, (void __iomem *)POWER_MODE0_GATE);
38
39         val = readl((void __iomem *)POWER_MODE1_GATE);
40         val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
41         writel(val, (void __iomem *)POWER_MODE1_GATE);
42 }
43
44 static struct resource cf_ide_resources[] = {
45         [0] = {
46                 .start  = PA_AREA5_IO + 0x1000,
47                 .end    = PA_AREA5_IO + 0x1000 + 0x08 - 1,
48                 .flags  = IORESOURCE_MEM,
49         },
50         [1] = {
51                 .start  = PA_AREA5_IO + 0x80c,
52                 .end    = PA_AREA5_IO + 0x80c + 0x16 - 1,
53                 .flags  = IORESOURCE_MEM,
54         },
55         [2] = {
56 #ifdef CONFIG_RTS7751R2D_REV11
57                 .start  = 1,
58 #else
59                 .start  = 2,
60 #endif
61                 .flags  = IORESOURCE_IRQ,
62         },
63 };
64
65 static struct pata_platform_info pata_info = {
66         .ioport_shift   = 1,
67 };
68
69 static struct platform_device cf_ide_device  = {
70         .name           = "pata_platform",
71         .id             = -1,
72         .num_resources  = ARRAY_SIZE(cf_ide_resources),
73         .resource       = cf_ide_resources,
74         .dev    = {
75                 .platform_data  = &pata_info,
76         },
77 };
78
79 static struct plat_serial8250_port uart_platform_data[] = {
80         {
81                 .membase        = (void __iomem *)VOYAGER_UART_BASE,
82                 .mapbase        = VOYAGER_UART_BASE,
83                 .iotype         = UPIO_MEM,
84                 .irq            = VOYAGER_UART0_IRQ,
85                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
86                 .regshift       = 2,
87                 .uartclk        = (9600 * 16),
88         }
89 };
90
91 static struct platform_device uart_device = {
92         .name           = "serial8250",
93         .id             = PLAT8250_DEV_PLATFORM,
94         .dev            = {
95                 .platform_data  = uart_platform_data,
96         },
97 };
98
99 static struct resource heartbeat_resources[] = {
100         [0] = {
101                 .start  = PA_OUTPORT,
102                 .end    = PA_OUTPORT + 8 - 1,
103                 .flags  = IORESOURCE_MEM,
104         },
105 };
106
107 static struct platform_device heartbeat_device = {
108         .name           = "heartbeat",
109         .id             = -1,
110         .num_resources  = ARRAY_SIZE(heartbeat_resources),
111         .resource       = heartbeat_resources,
112 };
113
114 static struct platform_device *rts7751r2d_devices[] __initdata = {
115         &uart_device,
116         &heartbeat_device,
117         &cf_ide_device,
118 };
119
120 static int __init rts7751r2d_devices_setup(void)
121 {
122         return platform_add_devices(rts7751r2d_devices,
123                                     ARRAY_SIZE(rts7751r2d_devices));
124 }
125 __initcall(rts7751r2d_devices_setup);
126
127 static void rts7751r2d_power_off(void)
128 {
129         ctrl_outw(0x0001, PA_POWOFF);
130 }
131
132 /*
133  * Initialize the board
134  */
135 static void __init rts7751r2d_setup(char **cmdline_p)
136 {
137         u16 ver = ctrl_inw(PA_VERREG);
138
139         printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
140
141         printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
142                                         (ver >> 4) & 0xf, ver & 0xf);
143
144         ctrl_outw(0x0000, PA_OUTPORT);
145         pm_power_off = rts7751r2d_power_off;
146
147         voyagergx_serial_init();
148 }
149
150 /*
151  * The Machine Vector
152  */
153 struct sh_machine_vector mv_rts7751r2d __initmv = {
154         .mv_name                = "RTS7751R2D",
155         .mv_setup               = rts7751r2d_setup,
156         .mv_nr_irqs             = 72,
157
158         .mv_init_irq            = init_rts7751r2d_IRQ,
159         .mv_irq_demux           = rts7751r2d_irq_demux,
160
161 #ifdef CONFIG_USB_SM501
162         .mv_consistent_alloc    = voyagergx_consistent_alloc,
163         .mv_consistent_free     = voyagergx_consistent_free,
164 #endif
165 };
166 ALIAS_MV(rts7751r2d)