]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/sh/boards/renesas/rts7751r2d/setup.c
6f7029d33241db4beeb46395968c24b81e0403e0
[karo-tx-linux.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/sm501.h>
16 #include <linux/pm.h>
17 #include <asm/machvec.h>
18 #include <asm/rts7751r2d.h>
19 #include <asm/voyagergx.h>
20 #include <asm/io.h>
21
22 static void __init voyagergx_serial_init(void)
23 {
24         unsigned long val;
25
26         /*
27          * GPIO Control
28          */
29         val = readl((void __iomem *)GPIO_MUX_HIGH);
30         val |= 0x00001fe0;
31         writel(val, (void __iomem *)GPIO_MUX_HIGH);
32
33         /*
34          * Power Mode Gate
35          */
36         val = readl((void __iomem *)POWER_MODE0_GATE);
37         val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
38         writel(val, (void __iomem *)POWER_MODE0_GATE);
39
40         val = readl((void __iomem *)POWER_MODE1_GATE);
41         val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
42         writel(val, (void __iomem *)POWER_MODE1_GATE);
43 }
44
45 static struct resource cf_ide_resources[] = {
46         [0] = {
47                 .start  = PA_AREA5_IO + 0x1000,
48                 .end    = PA_AREA5_IO + 0x1000 + 0x08 - 1,
49                 .flags  = IORESOURCE_MEM,
50         },
51         [1] = {
52                 .start  = PA_AREA5_IO + 0x80c,
53                 .end    = PA_AREA5_IO + 0x80c + 0x16 - 1,
54                 .flags  = IORESOURCE_MEM,
55         },
56         [2] = {
57 #ifdef CONFIG_RTS7751R2D_REV11
58                 .start  = 1,
59 #else
60                 .start  = 2,
61 #endif
62                 .flags  = IORESOURCE_IRQ,
63         },
64 };
65
66 static struct pata_platform_info pata_info = {
67         .ioport_shift   = 1,
68 };
69
70 static struct platform_device cf_ide_device  = {
71         .name           = "pata_platform",
72         .id             = -1,
73         .num_resources  = ARRAY_SIZE(cf_ide_resources),
74         .resource       = cf_ide_resources,
75         .dev    = {
76                 .platform_data  = &pata_info,
77         },
78 };
79
80 static struct plat_serial8250_port uart_platform_data[] = {
81         {
82                 .membase        = (void __iomem *)VOYAGER_UART_BASE,
83                 .mapbase        = VOYAGER_UART_BASE,
84                 .iotype         = UPIO_MEM,
85                 .irq            = VOYAGER_UART0_IRQ,
86                 .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
87                 .regshift       = 2,
88                 .uartclk        = (9600 * 16),
89         },
90         { 0 },
91 };
92
93 static struct platform_device uart_device = {
94         .name           = "serial8250",
95         .id             = PLAT8250_DEV_PLATFORM,
96         .dev            = {
97                 .platform_data  = uart_platform_data,
98         },
99 };
100
101 static struct resource heartbeat_resources[] = {
102         [0] = {
103                 .start  = PA_OUTPORT,
104                 .end    = PA_OUTPORT + 8 - 1,
105                 .flags  = IORESOURCE_MEM,
106         },
107 };
108
109 static struct platform_device heartbeat_device = {
110         .name           = "heartbeat",
111         .id             = -1,
112         .num_resources  = ARRAY_SIZE(heartbeat_resources),
113         .resource       = heartbeat_resources,
114 };
115
116 static struct resource sm501_resources[] = {
117         [0]     = {
118                 .start  = 0x10000000,
119                 .end    = 0x13e00000 - 1,
120                 .flags  = IORESOURCE_MEM,
121         },
122         [1]     = {
123                 .start  = 0x13e00000,
124                 .end    = 0x13ffffff,
125                 .flags  = IORESOURCE_MEM,
126         },
127         [2]     = {
128                 .start  = 32,
129                 .flags  = IORESOURCE_IRQ,
130         },
131 };
132
133 static struct platform_device sm501_device = {
134         .name           = "sm501",
135         .id             = -1,
136         .num_resources  = ARRAY_SIZE(sm501_resources),
137         .resource       = sm501_resources,
138 };
139
140 static struct platform_device *rts7751r2d_devices[] __initdata = {
141         &uart_device,
142         &heartbeat_device,
143         &sm501_device,
144 };
145
146 static int __init rts7751r2d_devices_setup(void)
147 {
148         int ret;
149
150         if (ctrl_inw(PA_BVERREG) == 0x10) { /* only working on R2D-PLUS */
151                 ret = platform_device_register(&cf_ide_device);
152                 if (ret)
153                         return ret;
154         }
155
156         return platform_add_devices(rts7751r2d_devices,
157                                     ARRAY_SIZE(rts7751r2d_devices));
158 }
159 __initcall(rts7751r2d_devices_setup);
160
161 static void rts7751r2d_power_off(void)
162 {
163         ctrl_outw(0x0001, PA_POWOFF);
164 }
165
166 /*
167  * Initialize the board
168  */
169 static void __init rts7751r2d_setup(char **cmdline_p)
170 {
171         u16 ver = ctrl_inw(PA_VERREG);
172
173         printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
174
175         printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
176                                         (ver >> 4) & 0xf, ver & 0xf);
177
178         ctrl_outw(0x0000, PA_OUTPORT);
179         pm_power_off = rts7751r2d_power_off;
180
181         voyagergx_serial_init();
182 }
183
184 /*
185  * The Machine Vector
186  */
187 static struct sh_machine_vector mv_rts7751r2d __initmv = {
188         .mv_name                = "RTS7751R2D",
189         .mv_setup               = rts7751r2d_setup,
190         .mv_nr_irqs             = 72,
191
192         .mv_init_irq            = init_rts7751r2d_IRQ,
193         .mv_irq_demux           = rts7751r2d_irq_demux,
194
195 #ifdef CONFIG_USB_SM501
196         .mv_consistent_alloc    = voyagergx_consistent_alloc,
197         .mv_consistent_free     = voyagergx_consistent_free,
198 #endif
199 };