2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
3 * Based largely on io_se.c.
5 * I/O routine for Renesas Solutions Highlander R7780RP-1
7 * Initial version only to support LAN access; some
8 * placeholder code from io_r7780rp.c left in with the
9 * expectation of later SuperIO and PCMCIA access.
11 #include <linux/pci.h>
12 #include <linux/kernel.h>
13 #include <linux/types.h>
15 #include <asm/r7780rp.h>
16 #include <asm/addrspace.h>
18 static inline unsigned long port88796l(unsigned int port, int flag)
23 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1);
25 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1) + 0x1000;
30 #if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
31 #define CHECK_AX88796L_PORT(port) \
32 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
34 #define CHECK_AX88796L_PORT(port) (0)
38 * General outline: remap really low stuff [eventually] to SuperIO,
39 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
40 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
41 * should be way beyond the window, and is used w/o translation for
44 u8 r7780rp_inb(unsigned long port)
46 if (CHECK_AX88796L_PORT(port))
47 return ctrl_inw(port88796l(port, 0)) & 0xff;
48 else if (is_pci_ioaddr(port))
49 return ctrl_inb(pci_ioaddr(port));
51 return ctrl_inw(port) & 0xff;
54 u8 r7780rp_inb_p(unsigned long port)
58 if (CHECK_AX88796L_PORT(port))
59 v = ctrl_inw(port88796l(port, 0)) & 0xff;
60 else if (is_pci_ioaddr(port))
61 v = ctrl_inb(pci_ioaddr(port));
63 v = ctrl_inw(port) & 0xff;
70 u16 r7780rp_inw(unsigned long port)
72 if (is_pci_ioaddr(port))
73 return ctrl_inw(pci_ioaddr(port));
75 return ctrl_inw(port);
78 u32 r7780rp_inl(unsigned long port)
80 if (is_pci_ioaddr(port))
81 return ctrl_inl(pci_ioaddr(port));
83 return ctrl_inl(port);
86 void r7780rp_outb(u8 value, unsigned long port)
88 if (CHECK_AX88796L_PORT(port))
89 ctrl_outw(value, port88796l(port, 0));
90 else if (is_pci_ioaddr(port))
91 ctrl_outb(value, pci_ioaddr(port));
93 ctrl_outb(value, port);
96 void r7780rp_outb_p(u8 value, unsigned long port)
98 if (CHECK_AX88796L_PORT(port))
99 ctrl_outw(value, port88796l(port, 0));
100 else if (is_pci_ioaddr(port))
101 ctrl_outb(value, pci_ioaddr(port));
103 ctrl_outb(value, port);
108 void r7780rp_outw(u16 value, unsigned long port)
110 if (is_pci_ioaddr(port))
111 ctrl_outw(value, pci_ioaddr(port));
113 ctrl_outw(value, port);
116 void r7780rp_outl(u32 value, unsigned long port)
118 if (is_pci_ioaddr(port))
119 ctrl_outl(value, pci_ioaddr(port));
121 ctrl_outl(value, port);
124 void r7780rp_insb(unsigned long port, void *dst, unsigned long count)
129 if (CHECK_AX88796L_PORT(port)) {
130 p = (volatile u16 *)port88796l(port, 0);
133 } else if (is_pci_ioaddr(port)) {
134 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
139 p = (volatile u16 *)port;
145 void r7780rp_insw(unsigned long port, void *dst, unsigned long count)
150 if (CHECK_AX88796L_PORT(port))
151 p = (volatile u16 *)port88796l(port, 1);
152 else if (is_pci_ioaddr(port))
153 p = (volatile u16 *)pci_ioaddr(port);
155 p = (volatile u16 *)port;
163 void r7780rp_insl(unsigned long port, void *dst, unsigned long count)
165 if (is_pci_ioaddr(port)) {
166 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
174 void r7780rp_outsb(unsigned long port, const void *src, unsigned long count)
179 if (CHECK_AX88796L_PORT(port)) {
180 p = (volatile u16 *)port88796l(port, 0);
183 } else if (is_pci_ioaddr(port)) {
184 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
190 ctrl_outb(*buf++, port);
193 void r7780rp_outsw(unsigned long port, const void *src, unsigned long count)
196 const u16 *buf = src;
198 if (CHECK_AX88796L_PORT(port))
199 p = (volatile u16 *)port88796l(port, 1);
200 else if (is_pci_ioaddr(port))
201 p = (volatile u16 *)pci_ioaddr(port);
203 p = (volatile u16 *)port;
211 void r7780rp_outsl(unsigned long port, const void *src, unsigned long count)
213 const u32 *buf = src;
216 if (is_pci_ioaddr(port))
217 p = (u32 *)pci_ioaddr(port);
222 ctrl_outl(*buf++, (unsigned long)p);
225 void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size)
227 if (CHECK_AX88796L_PORT(port))
228 return (void __iomem *)port88796l(port, size > 1);
229 else if (is_pci_ioaddr(port))
230 return (void __iomem *)pci_ioaddr(port);
232 return (void __iomem *)port;