1 /* $Id: io.c,v 1.7 2006/02/05 21:55:29 lethal Exp $
3 * linux/arch/sh/kernel/io_se.c
5 * Copyright (C) 2000 Kazumoto Kojima
7 * I/O routine for Hitachi SolutionEngine.
11 #include <linux/kernel.h>
12 #include <linux/types.h>
16 /* SH pcmcia io window base, start and end. */
17 int sh_pcic_io_wbase = 0xb8400000;
23 /* MS7750 requires special versions of in*, out* routines, since
24 PC-like io ports are located at upper half byte of 16-bit word which
25 can be accessed only with 16-bit wide. */
27 static inline volatile __u16 *
28 port2adr(unsigned int port)
31 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
32 else if (port >= 0x1000)
33 return (volatile __u16 *) (PA_83902 + (port << 1));
34 else if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
35 return (volatile __u16 *) (sh_pcic_io_wbase + (port &~ 1));
37 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
41 shifted_port(unsigned long port)
43 /* For IDE registers, value is not shifted */
44 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
50 unsigned char se_inb(unsigned long port)
52 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
53 return *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
54 else if (shifted_port(port))
55 return (*port2adr(port) >> 8);
57 return (*port2adr(port))&0xff;
60 unsigned char se_inb_p(unsigned long port)
64 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
65 v = *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
66 else if (shifted_port(port))
67 v = (*port2adr(port) >> 8);
69 v = (*port2adr(port))&0xff;
74 unsigned short se_inw(unsigned long port)
77 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
78 return *port2adr(port);
84 unsigned int se_inl(unsigned long port)
90 void se_outb(unsigned char value, unsigned long port)
92 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
93 *(__u8 *)(sh_pcic_io_wbase + port) = value;
94 else if (shifted_port(port))
95 *(port2adr(port)) = value << 8;
97 *(port2adr(port)) = value;
100 void se_outb_p(unsigned char value, unsigned long port)
102 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
103 *(__u8 *)(sh_pcic_io_wbase + port) = value;
104 else if (shifted_port(port))
105 *(port2adr(port)) = value << 8;
107 *(port2adr(port)) = value;
111 void se_outw(unsigned short value, unsigned long port)
113 if (port >= 0x2000 ||
114 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
115 *port2adr(port) = value;
120 void se_outl(unsigned int value, unsigned long port)
125 void se_insb(unsigned long port, void *addr, unsigned long count)
127 volatile __u16 *p = port2adr(port);
130 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
131 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
134 } else if (shifted_port(port)) {
143 void se_insw(unsigned long port, void *addr, unsigned long count)
145 volatile __u16 *p = port2adr(port);
151 void se_insl(unsigned long port, void *addr, unsigned long count)
156 void se_outsb(unsigned long port, const void *addr, unsigned long count)
158 volatile __u16 *p = port2adr(port);
159 const __u8 *ap = addr;
161 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
162 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + port);
165 } else if (shifted_port(port)) {
174 void se_outsw(unsigned long port, const void *addr, unsigned long count)
176 volatile __u16 *p = port2adr(port);
177 const __u16 *ap = addr;
182 void se_outsl(unsigned long port, const void *addr, unsigned long count)