aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/superh/microdev/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/superh/microdev/io.c')
-rw-r--r--arch/sh/boards/superh/microdev/io.c192
1 files changed, 95 insertions, 97 deletions
diff --git a/arch/sh/boards/superh/microdev/io.c b/arch/sh/boards/superh/microdev/io.c
index fe83b2c03076..1ed7f880b8c7 100644
--- a/arch/sh/boards/superh/microdev/io.c
+++ b/arch/sh/boards/superh/microdev/io.c
@@ -16,7 +16,7 @@
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/wait.h> 17#include <linux/wait.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/mach/io.h> 19#include <asm/microdev.h>
20 20
21 /* 21 /*
22 * we need to have a 'safe' address to re-direct all I/O requests 22 * we need to have a 'safe' address to re-direct all I/O requests
@@ -52,8 +52,90 @@
52#define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */ 52#define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */
53#define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */ 53#define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */
54 54
55#define PORT2ADDR(x) (microdev_isa_port2addr(x)) 55/*
56 * map I/O ports to memory-mapped addresses
57 */
58static unsigned long microdev_isa_port2addr(unsigned long offset)
59{
60 unsigned long result;
61
62 if ((offset >= IO_LAN91C111_BASE) &&
63 (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
64 /*
65 * SMSC LAN91C111 Ethernet chip
66 */
67 result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
68 } else if ((offset >= IO_SUPERIO_BASE) &&
69 (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
70 /*
71 * SMSC FDC37C93xAPM SuperIO chip
72 *
73 * Configuration Registers
74 */
75 result = IO_SUPERIO_PHYS + (offset << 1);
76#if 0
77 } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
78 offset == KBD_STATUS_REG) {
79 /*
80 * SMSC FDC37C93xAPM SuperIO chip
81 *
82 * PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
83 */
84 result = IO_SUPERIO_PHYS + (offset << 1);
85#endif
86 } else if (((offset >= IO_IDE1_BASE) &&
87 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
88 (offset == IO_IDE1_MISC)) {
89 /*
90 * SMSC FDC37C93xAPM SuperIO chip
91 *
92 * IDE #1
93 */
94 result = IO_SUPERIO_PHYS + (offset << 1);
95 } else if (((offset >= IO_IDE2_BASE) &&
96 (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) ||
97 (offset == IO_IDE2_MISC)) {
98 /*
99 * SMSC FDC37C93xAPM SuperIO chip
100 *
101 * IDE #2
102 */
103 result = IO_SUPERIO_PHYS + (offset << 1);
104 } else if ((offset >= IO_SERIAL1_BASE) &&
105 (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
106 /*
107 * SMSC FDC37C93xAPM SuperIO chip
108 *
109 * Serial #1
110 */
111 result = IO_SUPERIO_PHYS + (offset << 1);
112 } else if ((offset >= IO_SERIAL2_BASE) &&
113 (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
114 /*
115 * SMSC FDC37C93xAPM SuperIO chip
116 *
117 * Serial #2
118 */
119 result = IO_SUPERIO_PHYS + (offset << 1);
120 } else if ((offset >= IO_ISP1161_BASE) &&
121 (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
122 /*
123 * Philips USB ISP1161x chip
124 */
125 result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
126 } else {
127 /*
128 * safe default.
129 */
130 printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
131 __FUNCTION__, offset);
132 result = PVR;
133 }
134
135 return result;
136}
56 137
138#define PORT2ADDR(x) (microdev_isa_port2addr(x))
57 139
58static inline void delay(void) 140static inline void delay(void)
59{ 141{
@@ -94,6 +176,17 @@ unsigned int microdev_inl(unsigned long port)
94 return *(volatile unsigned int*)PORT2ADDR(port); 176 return *(volatile unsigned int*)PORT2ADDR(port);
95} 177}
96 178
179void microdev_outw(unsigned short b, unsigned long port)
180{
181#ifdef CONFIG_PCI
182 if (port >= PCIBIOS_MIN_IO) {
183 microdev_pci_outw(b, port);
184 return;
185 }
186#endif
187 *(volatile unsigned short*)PORT2ADDR(port) = b;
188}
189
97void microdev_outb(unsigned char b, unsigned long port) 190void microdev_outb(unsigned char b, unsigned long port)
98{ 191{
99#ifdef CONFIG_PCI 192#ifdef CONFIG_PCI
@@ -158,17 +251,6 @@ void microdev_outb(unsigned char b, unsigned long port)
158 } 251 }
159} 252}
160 253
161void microdev_outw(unsigned short b, unsigned long port)
162{
163#ifdef CONFIG_PCI
164 if (port >= PCIBIOS_MIN_IO) {
165 microdev_pci_outw(b, port);
166 return;
167 }
168#endif
169 *(volatile unsigned short*)PORT2ADDR(port) = b;
170}
171
172void microdev_outl(unsigned int b, unsigned long port) 254void microdev_outl(unsigned int b, unsigned long port)
173{ 255{
174#ifdef CONFIG_PCI 256#ifdef CONFIG_PCI
@@ -284,87 +366,3 @@ void microdev_outsl(unsigned long port, const void *buffer, unsigned long count)
284 while (count--) 366 while (count--)
285 *port_addr = *buf++; 367 *port_addr = *buf++;
286} 368}
287
288/*
289 * map I/O ports to memory-mapped addresses
290 */
291unsigned long microdev_isa_port2addr(unsigned long offset)
292{
293 unsigned long result;
294
295 if ((offset >= IO_LAN91C111_BASE) &&
296 (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
297 /*
298 * SMSC LAN91C111 Ethernet chip
299 */
300 result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
301 } else if ((offset >= IO_SUPERIO_BASE) &&
302 (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
303 /*
304 * SMSC FDC37C93xAPM SuperIO chip
305 *
306 * Configuration Registers
307 */
308 result = IO_SUPERIO_PHYS + (offset << 1);
309#if 0
310 } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
311 offset == KBD_STATUS_REG) {
312 /*
313 * SMSC FDC37C93xAPM SuperIO chip
314 *
315 * PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
316 */
317 result = IO_SUPERIO_PHYS + (offset << 1);
318#endif
319 } else if (((offset >= IO_IDE1_BASE) &&
320 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
321 (offset == IO_IDE1_MISC)) {
322 /*
323 * SMSC FDC37C93xAPM SuperIO chip
324 *
325 * IDE #1
326 */
327 result = IO_SUPERIO_PHYS + (offset << 1);
328 } else if (((offset >= IO_IDE2_BASE) &&
329 (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) ||
330 (offset == IO_IDE2_MISC)) {
331 /*
332 * SMSC FDC37C93xAPM SuperIO chip
333 *
334 * IDE #2
335 */
336 result = IO_SUPERIO_PHYS + (offset << 1);
337 } else if ((offset >= IO_SERIAL1_BASE) &&
338 (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
339 /*
340 * SMSC FDC37C93xAPM SuperIO chip
341 *
342 * Serial #1
343 */
344 result = IO_SUPERIO_PHYS + (offset << 1);
345 } else if ((offset >= IO_SERIAL2_BASE) &&
346 (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
347 /*
348 * SMSC FDC37C93xAPM SuperIO chip
349 *
350 * Serial #2
351 */
352 result = IO_SUPERIO_PHYS + (offset << 1);
353 } else if ((offset >= IO_ISP1161_BASE) &&
354 (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
355 /*
356 * Philips USB ISP1161x chip
357 */
358 result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
359 } else {
360 /*
361 * safe default.
362 */
363 printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
364 __FUNCTION__, offset);
365 result = PVR;
366 }
367
368 return result;
369}
370