aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/renesas/r7780rp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/renesas/r7780rp')
-rw-r--r--arch/sh/boards/renesas/r7780rp/Makefile1
-rw-r--r--arch/sh/boards/renesas/r7780rp/io.c152
-rw-r--r--arch/sh/boards/renesas/r7780rp/led.c43
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c49
4 files changed, 79 insertions, 166 deletions
diff --git a/arch/sh/boards/renesas/r7780rp/Makefile b/arch/sh/boards/renesas/r7780rp/Makefile
index 574b0316ed56..3c93012e91a3 100644
--- a/arch/sh/boards/renesas/r7780rp/Makefile
+++ b/arch/sh/boards/renesas/r7780rp/Makefile
@@ -4,5 +4,4 @@
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o io.o irq.o
6 6
7obj-$(CONFIG_HEARTBEAT) += led.o
8obj-$(CONFIG_PUSH_SWITCH) += psw.o 7obj-$(CONFIG_PUSH_SWITCH) += psw.o
diff --git a/arch/sh/boards/renesas/r7780rp/io.c b/arch/sh/boards/renesas/r7780rp/io.c
index 311ccccba718..f74d2ffb3851 100644
--- a/arch/sh/boards/renesas/r7780rp/io.c
+++ b/arch/sh/boards/renesas/r7780rp/io.c
@@ -11,22 +11,9 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/io.h>
14#include <asm/r7780rp.h> 15#include <asm/r7780rp.h>
15#include <asm/addrspace.h> 16#include <asm/addrspace.h>
16#include <asm/io.h>
17
18static inline unsigned long port2adr(unsigned int port)
19{
20 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
21 if (port == 0x3f6)
22 return (PA_AREA5_IO + 0x80c);
23 else
24 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1));
25 else
26 maybebadio((unsigned long)port);
27
28 return port;
29}
30 17
31static inline unsigned long port88796l(unsigned int port, int flag) 18static inline unsigned long port88796l(unsigned int port, int flag)
32{ 19{
@@ -40,18 +27,6 @@ static inline unsigned long port88796l(unsigned int port, int flag)
40 return addr; 27 return addr;
41} 28}
42 29
43/* The 7780 R7780RP-1 seems to have everything hooked */
44/* up pretty normally (nothing on high-bytes only...) so this */
45/* shouldn't be needed */
46static inline int shifted_port(unsigned long port)
47{
48 /* For IDE registers, value is not shifted */
49 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
50 return 0;
51 else
52 return 1;
53}
54
55#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) 30#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
56#define CHECK_AX88796L_PORT(port) \ 31#define CHECK_AX88796L_PORT(port) \
57 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) 32 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
@@ -70,12 +45,10 @@ u8 r7780rp_inb(unsigned long port)
70{ 45{
71 if (CHECK_AX88796L_PORT(port)) 46 if (CHECK_AX88796L_PORT(port))
72 return ctrl_inw(port88796l(port, 0)) & 0xff; 47 return ctrl_inw(port88796l(port, 0)) & 0xff;
73 else if (PXSEG(port)) 48 else if (is_pci_ioaddr(port))
74 return ctrl_inb(port);
75 else if (is_pci_ioaddr(port) || shifted_port(port))
76 return ctrl_inb(pci_ioaddr(port)); 49 return ctrl_inb(pci_ioaddr(port));
77 50
78 return ctrl_inw(port2adr(port)) & 0xff; 51 return ctrl_inw(port) & 0xff;
79} 52}
80 53
81u8 r7780rp_inb_p(unsigned long port) 54u8 r7780rp_inb_p(unsigned long port)
@@ -84,12 +57,10 @@ u8 r7780rp_inb_p(unsigned long port)
84 57
85 if (CHECK_AX88796L_PORT(port)) 58 if (CHECK_AX88796L_PORT(port))
86 v = ctrl_inw(port88796l(port, 0)) & 0xff; 59 v = ctrl_inw(port88796l(port, 0)) & 0xff;
87 else if (PXSEG(port)) 60 else if (is_pci_ioaddr(port))
88 v = ctrl_inb(port);
89 else if (is_pci_ioaddr(port) || shifted_port(port))
90 v = ctrl_inb(pci_ioaddr(port)); 61 v = ctrl_inb(pci_ioaddr(port));
91 else 62 else
92 v = ctrl_inw(port2adr(port)) & 0xff; 63 v = ctrl_inw(port) & 0xff;
93 64
94 ctrl_delay(); 65 ctrl_delay();
95 66
@@ -98,80 +69,56 @@ u8 r7780rp_inb_p(unsigned long port)
98 69
99u16 r7780rp_inw(unsigned long port) 70u16 r7780rp_inw(unsigned long port)
100{ 71{
101 if (CHECK_AX88796L_PORT(port)) 72 if (is_pci_ioaddr(port))
102 maybebadio(port);
103 else if (PXSEG(port))
104 return ctrl_inw(port);
105 else if (is_pci_ioaddr(port) || shifted_port(port))
106 return ctrl_inw(pci_ioaddr(port)); 73 return ctrl_inw(pci_ioaddr(port));
107 else
108 maybebadio(port);
109 74
110 return 0; 75 return ctrl_inw(port);
111} 76}
112 77
113u32 r7780rp_inl(unsigned long port) 78u32 r7780rp_inl(unsigned long port)
114{ 79{
115 if (CHECK_AX88796L_PORT(port)) 80 if (is_pci_ioaddr(port))
116 maybebadio(port);
117 else if (PXSEG(port))
118 return ctrl_inl(port);
119 else if (is_pci_ioaddr(port) || shifted_port(port))
120 return ctrl_inl(pci_ioaddr(port)); 81 return ctrl_inl(pci_ioaddr(port));
121 else
122 maybebadio(port);
123 82
124 return 0; 83 return ctrl_inl(port);
125} 84}
126 85
127void r7780rp_outb(u8 value, unsigned long port) 86void r7780rp_outb(u8 value, unsigned long port)
128{ 87{
129 if (CHECK_AX88796L_PORT(port)) 88 if (CHECK_AX88796L_PORT(port))
130 ctrl_outw(value, port88796l(port, 0)); 89 ctrl_outw(value, port88796l(port, 0));
131 else if (PXSEG(port)) 90 else if (is_pci_ioaddr(port))
132 ctrl_outb(value, port);
133 else if (is_pci_ioaddr(port) || shifted_port(port))
134 ctrl_outb(value, pci_ioaddr(port)); 91 ctrl_outb(value, pci_ioaddr(port));
135 else 92 else
136 ctrl_outw(value, port2adr(port)); 93 ctrl_outb(value, port);
137} 94}
138 95
139void r7780rp_outb_p(u8 value, unsigned long port) 96void r7780rp_outb_p(u8 value, unsigned long port)
140{ 97{
141 if (CHECK_AX88796L_PORT(port)) 98 if (CHECK_AX88796L_PORT(port))
142 ctrl_outw(value, port88796l(port, 0)); 99 ctrl_outw(value, port88796l(port, 0));
143 else if (PXSEG(port)) 100 else if (is_pci_ioaddr(port))
144 ctrl_outb(value, port);
145 else if (is_pci_ioaddr(port) || shifted_port(port))
146 ctrl_outb(value, pci_ioaddr(port)); 101 ctrl_outb(value, pci_ioaddr(port));
147 else 102 else
148 ctrl_outw(value, port2adr(port)); 103 ctrl_outb(value, port);
149 104
150 ctrl_delay(); 105 ctrl_delay();
151} 106}
152 107
153void r7780rp_outw(u16 value, unsigned long port) 108void r7780rp_outw(u16 value, unsigned long port)
154{ 109{
155 if (CHECK_AX88796L_PORT(port)) 110 if (is_pci_ioaddr(port))
156 maybebadio(port);
157 else if (PXSEG(port))
158 ctrl_outw(value, port);
159 else if (is_pci_ioaddr(port) || shifted_port(port))
160 ctrl_outw(value, pci_ioaddr(port)); 111 ctrl_outw(value, pci_ioaddr(port));
161 else 112 else
162 maybebadio(port); 113 ctrl_outw(value, port);
163} 114}
164 115
165void r7780rp_outl(u32 value, unsigned long port) 116void r7780rp_outl(u32 value, unsigned long port)
166{ 117{
167 if (CHECK_AX88796L_PORT(port)) 118 if (is_pci_ioaddr(port))
168 maybebadio(port);
169 else if (PXSEG(port))
170 ctrl_outl(value, port);
171 else if (is_pci_ioaddr(port) || shifted_port(port))
172 ctrl_outl(value, pci_ioaddr(port)); 119 ctrl_outl(value, pci_ioaddr(port));
173 else 120 else
174 maybebadio(port); 121 ctrl_outl(value, port);
175} 122}
176 123
177void r7780rp_insb(unsigned long port, void *dst, unsigned long count) 124void r7780rp_insb(unsigned long port, void *dst, unsigned long count)
@@ -183,16 +130,13 @@ void r7780rp_insb(unsigned long port, void *dst, unsigned long count)
183 p = (volatile u16 *)port88796l(port, 0); 130 p = (volatile u16 *)port88796l(port, 0);
184 while (count--) 131 while (count--)
185 *buf++ = *p & 0xff; 132 *buf++ = *p & 0xff;
186 } else if (PXSEG(port)) { 133 } else if (is_pci_ioaddr(port)) {
187 while (count--)
188 *buf++ = *(volatile u8 *)port;
189 } else if (is_pci_ioaddr(port) || shifted_port(port)) {
190 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); 134 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
191 135
192 while (count--) 136 while (count--)
193 *buf++ = *bp; 137 *buf++ = *bp;
194 } else { 138 } else {
195 p = (volatile u16 *)port2adr(port); 139 p = (volatile u16 *)port;
196 while (count--) 140 while (count--)
197 *buf++ = *p & 0xff; 141 *buf++ = *p & 0xff;
198 } 142 }
@@ -205,30 +149,26 @@ void r7780rp_insw(unsigned long port, void *dst, unsigned long count)
205 149
206 if (CHECK_AX88796L_PORT(port)) 150 if (CHECK_AX88796L_PORT(port))
207 p = (volatile u16 *)port88796l(port, 1); 151 p = (volatile u16 *)port88796l(port, 1);
208 else if (PXSEG(port)) 152 else if (is_pci_ioaddr(port))
209 p = (volatile u16 *)port;
210 else if (is_pci_ioaddr(port) || shifted_port(port))
211 p = (volatile u16 *)pci_ioaddr(port); 153 p = (volatile u16 *)pci_ioaddr(port);
212 else 154 else
213 p = (volatile u16 *)port2adr(port); 155 p = (volatile u16 *)port;
214 156
215 while (count--) 157 while (count--)
216 *buf++ = *p; 158 *buf++ = *p;
159
160 flush_dcache_all();
217} 161}
218 162
219void r7780rp_insl(unsigned long port, void *dst, unsigned long count) 163void r7780rp_insl(unsigned long port, void *dst, unsigned long count)
220{ 164{
221 u32 *buf = dst; 165 if (is_pci_ioaddr(port)) {
222
223 if (CHECK_AX88796L_PORT(port))
224 maybebadio(port);
225 else if (is_pci_ioaddr(port) || shifted_port(port)) {
226 volatile u32 *p = (volatile u32 *)pci_ioaddr(port); 166 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
167 u32 *buf = dst;
227 168
228 while (count--) 169 while (count--)
229 *buf++ = *p; 170 *buf++ = *p;
230 } else 171 }
231 maybebadio(port);
232} 172}
233 173
234void r7780rp_outsb(unsigned long port, const void *src, unsigned long count) 174void r7780rp_outsb(unsigned long port, const void *src, unsigned long count)
@@ -240,19 +180,14 @@ void r7780rp_outsb(unsigned long port, const void *src, unsigned long count)
240 p = (volatile u16 *)port88796l(port, 0); 180 p = (volatile u16 *)port88796l(port, 0);
241 while (count--) 181 while (count--)
242 *p = *buf++; 182 *p = *buf++;
243 } else if (PXSEG(port)) 183 } else if (is_pci_ioaddr(port)) {
244 while (count--)
245 ctrl_outb(*buf++, port);
246 else if (is_pci_ioaddr(port) || shifted_port(port)) {
247 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); 184 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
248 185
249 while (count--) 186 while (count--)
250 *bp = *buf++; 187 *bp = *buf++;
251 } else { 188 } else
252 p = (volatile u16 *)port2adr(port);
253 while (count--) 189 while (count--)
254 *p = *buf++; 190 ctrl_outb(*buf++, port);
255 }
256} 191}
257 192
258void r7780rp_outsw(unsigned long port, const void *src, unsigned long count) 193void r7780rp_outsw(unsigned long port, const void *src, unsigned long count)
@@ -262,40 +197,37 @@ void r7780rp_outsw(unsigned long port, const void *src, unsigned long count)
262 197
263 if (CHECK_AX88796L_PORT(port)) 198 if (CHECK_AX88796L_PORT(port))
264 p = (volatile u16 *)port88796l(port, 1); 199 p = (volatile u16 *)port88796l(port, 1);
265 else if (PXSEG(port)) 200 else if (is_pci_ioaddr(port))
266 p = (volatile u16 *)port;
267 else if (is_pci_ioaddr(port) || shifted_port(port))
268 p = (volatile u16 *)pci_ioaddr(port); 201 p = (volatile u16 *)pci_ioaddr(port);
269 else 202 else
270 p = (volatile u16 *)port2adr(port); 203 p = (volatile u16 *)port;
271 204
272 while (count--) 205 while (count--)
273 *p = *buf++; 206 *p = *buf++;
207
208 flush_dcache_all();
274} 209}
275 210
276void r7780rp_outsl(unsigned long port, const void *src, unsigned long count) 211void r7780rp_outsl(unsigned long port, const void *src, unsigned long count)
277{ 212{
278 const u32 *buf = src; 213 const u32 *buf = src;
214 u32 *p;
279 215
280 if (CHECK_AX88796L_PORT(port)) 216 if (is_pci_ioaddr(port))
281 maybebadio(port); 217 p = (u32 *)pci_ioaddr(port);
282 else if (is_pci_ioaddr(port) || shifted_port(port)) { 218 else
283 volatile u32 *p = (volatile u32 *)pci_ioaddr(port); 219 p = (u32 *)port;
284 220
285 while (count--) 221 while (count--)
286 *p = *buf++; 222 ctrl_outl(*buf++, (unsigned long)p);
287 } else
288 maybebadio(port);
289} 223}
290 224
291void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size) 225void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size)
292{ 226{
293 if (CHECK_AX88796L_PORT(port)) 227 if (CHECK_AX88796L_PORT(port))
294 return (void __iomem *)port88796l(port, size > 1); 228 return (void __iomem *)port88796l(port, size > 1);
295 else if (PXSEG(port)) 229 else if (is_pci_ioaddr(port))
296 return (void __iomem *)port;
297 else if (is_pci_ioaddr(port) || shifted_port(port))
298 return (void __iomem *)pci_ioaddr(port); 230 return (void __iomem *)pci_ioaddr(port);
299 231
300 return (void __iomem *)port2adr(port); 232 return (void __iomem *)port;
301} 233}
diff --git a/arch/sh/boards/renesas/r7780rp/led.c b/arch/sh/boards/renesas/r7780rp/led.c
deleted file mode 100644
index 6a00a257afd2..000000000000
--- a/arch/sh/boards/renesas/r7780rp/led.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) Atom Create Engineering Co., Ltd.
3 *
4 * May be copied or modified under the terms of GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file contains Renesas Solutions HIGHLANDER R7780RP-1 specific LED code.
8 */
9#include <linux/sched.h>
10#include <asm/io.h>
11#include <asm/r7780rp/r7780rp.h>
12
13/* Cycle the LED's in the clasic Knightriger/Sun pattern */
14void heartbeat_r7780rp(void)
15{
16 static unsigned int cnt = 0, period = 0;
17 volatile unsigned short *p = (volatile unsigned short *)PA_OBLED;
18 static unsigned bit = 0, up = 1;
19 unsigned bit_pos[] = {2, 1, 0, 3, 6, 5, 4, 7};
20
21 cnt += 1;
22 if (cnt < period)
23 return;
24
25 cnt = 0;
26
27 /* Go through the points (roughly!):
28 * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
29 */
30 period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
31
32 *p = 1 << bit_pos[bit];
33 if (up)
34 if (bit == 7) {
35 bit--;
36 up = 0;
37 } else
38 bit++;
39 else if (bit == 0)
40 up = 1;
41 else
42 bit--;
43}
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index 9f89c8de9db9..0d74db9f1792 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -2,7 +2,7 @@
2 * arch/sh/boards/renesas/r7780rp/setup.c 2 * arch/sh/boards/renesas/r7780rp/setup.c
3 * 3 *
4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd. 4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2005, 2006 Paul Mundt 5 * Copyright (C) 2005 - 2007 Paul Mundt
6 * 6 *
7 * Renesas Solutions Highlander R7780RP-1 Support. 7 * Renesas Solutions Highlander R7780RP-1 Support.
8 * 8 *
@@ -12,12 +12,12 @@
12 */ 12 */
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/pata_platform.h>
15#include <asm/machvec.h> 16#include <asm/machvec.h>
16#include <asm/r7780rp.h> 17#include <asm/r7780rp.h>
17#include <asm/clock.h> 18#include <asm/clock.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20extern void heartbeat_r7780rp(void);
21extern void init_r7780rp_IRQ(void); 21extern void init_r7780rp_IRQ(void);
22 22
23static struct resource m66596_usb_host_resources[] = { 23static struct resource m66596_usb_host_resources[] = {
@@ -46,14 +46,14 @@ static struct platform_device m66596_usb_host_device = {
46 46
47static struct resource cf_ide_resources[] = { 47static struct resource cf_ide_resources[] = {
48 [0] = { 48 [0] = {
49 .start = 0x1f0, 49 .start = PA_AREA5_IO + 0x1000,
50 .end = 0x1f0 + 8, 50 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
51 .flags = IORESOURCE_IO, 51 .flags = IORESOURCE_MEM,
52 }, 52 },
53 [1] = { 53 [1] = {
54 .start = 0x1f0 + 0x206, 54 .start = PA_AREA5_IO + 0x80c,
55 .end = 0x1f0 + 8 + 0x206 + 8, 55 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
56 .flags = IORESOURCE_IO, 56 .flags = IORESOURCE_MEM,
57 }, 57 },
58 [2] = { 58 [2] = {
59#ifdef CONFIG_SH_R7780MP 59#ifdef CONFIG_SH_R7780MP
@@ -65,16 +65,44 @@ static struct resource cf_ide_resources[] = {
65 }, 65 },
66}; 66};
67 67
68static struct pata_platform_info pata_info = {
69 .ioport_shift = 1,
70};
71
68static struct platform_device cf_ide_device = { 72static struct platform_device cf_ide_device = {
69 .name = "pata_platform", 73 .name = "pata_platform",
70 .id = -1, 74 .id = -1,
71 .num_resources = ARRAY_SIZE(cf_ide_resources), 75 .num_resources = ARRAY_SIZE(cf_ide_resources),
72 .resource = cf_ide_resources, 76 .resource = cf_ide_resources,
77 .dev = {
78 .platform_data = &pata_info,
79 },
80};
81
82static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
83
84static 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
92static 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,
73}; 100};
74 101
75static struct platform_device *r7780rp_devices[] __initdata = { 102static struct platform_device *r7780rp_devices[] __initdata = {
76 &m66596_usb_host_device, 103 &m66596_usb_host_device,
77 &cf_ide_device, 104 &cf_ide_device,
105 &heartbeat_device,
78}; 106};
79 107
80static int __init r7780rp_devices_setup(void) 108static int __init r7780rp_devices_setup(void)
@@ -148,7 +176,7 @@ static void __init r7780rp_setup(char **cmdline_p)
148#ifndef CONFIG_SH_R7780MP 176#ifndef CONFIG_SH_R7780MP
149 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */ 177 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
150#endif 178#endif
151 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x0100, PA_IVDRCTL); /* Si13112 */ 179 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
152 180
153 pm_power_off = r7780rp_power_off; 181 pm_power_off = r7780rp_power_off;
154} 182}
@@ -185,8 +213,5 @@ struct sh_machine_vector mv_r7780rp __initmv = {
185 213
186 .mv_ioport_map = r7780rp_ioport_map, 214 .mv_ioport_map = r7780rp_ioport_map,
187 .mv_init_irq = init_r7780rp_IRQ, 215 .mv_init_irq = init_r7780rp_IRQ,
188#ifdef CONFIG_HEARTBEAT
189 .mv_heartbeat = heartbeat_r7780rp,
190#endif
191}; 216};
192ALIAS_MV(r7780rp) 217ALIAS_MV(r7780rp)