2 * arch/sh/boards/landisk/io.c
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
7 * I/O routine for I-O Data Device, Inc. LANDISK.
9 * Initial version only to support LAN access; some
10 * placeholder code from io_landisk.c left in with the
11 * expectation of later SuperIO and PCMCIA access.
14 * modifed by kogiidena
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/pci.h>
20 #include <asm/landisk/iodata_landisk.h>
21 #include <asm/addrspace.h>
24 extern void *area5_io_base; /* Area 5 I/O Base address */
25 extern void *area6_io_base; /* Area 6 I/O Base address */
27 static inline unsigned long port2adr(unsigned int port)
29 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
31 return ((unsigned long)area5_io_base + 0x2c);
33 return ((unsigned long)area5_io_base + PA_PIDE_OFFSET +
34 ((port - 0x1f0) << 1));
35 else if ((0x170 <= port && port < 0x178) || port == 0x376)
37 return ((unsigned long)area6_io_base + 0x2c);
39 return ((unsigned long)area6_io_base + PA_SIDE_OFFSET +
40 ((port - 0x170) << 1));
42 maybebadio((unsigned long)port);
48 * General outline: remap really low stuff [eventually] to SuperIO,
49 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
50 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
51 * should be way beyond the window, and is used w/o translation for
54 u8 landisk_inb(unsigned long port)
57 return ctrl_inb(port);
58 else if (is_pci_ioaddr(port))
59 return ctrl_inb(pci_ioaddr(port));
61 return ctrl_inw(port2adr(port)) & 0xff;
64 u8 landisk_inb_p(unsigned long port)
70 else if (is_pci_ioaddr(port))
71 v = ctrl_inb(pci_ioaddr(port));
73 v = ctrl_inw(port2adr(port)) & 0xff;
80 u16 landisk_inw(unsigned long port)
83 return ctrl_inw(port);
84 else if (is_pci_ioaddr(port))
85 return ctrl_inw(pci_ioaddr(port));
92 u32 landisk_inl(unsigned long port)
95 return ctrl_inl(port);
96 else if (is_pci_ioaddr(port))
97 return ctrl_inl(pci_ioaddr(port));
104 void landisk_outb(u8 value, unsigned long port)
107 ctrl_outb(value, port);
108 else if (is_pci_ioaddr(port))
109 ctrl_outb(value, pci_ioaddr(port));
111 ctrl_outw(value, port2adr(port));
114 void landisk_outb_p(u8 value, unsigned long port)
117 ctrl_outb(value, port);
118 else if (is_pci_ioaddr(port))
119 ctrl_outb(value, pci_ioaddr(port));
121 ctrl_outw(value, port2adr(port));
125 void landisk_outw(u16 value, unsigned long port)
128 ctrl_outw(value, port);
129 else if (is_pci_ioaddr(port))
130 ctrl_outw(value, pci_ioaddr(port));
135 void landisk_outl(u32 value, unsigned long port)
138 ctrl_outl(value, port);
139 else if (is_pci_ioaddr(port))
140 ctrl_outl(value, pci_ioaddr(port));
145 void landisk_insb(unsigned long port, void *dst, unsigned long count)
152 *buf++ = *(volatile u8 *)port;
153 } else if (is_pci_ioaddr(port)) {
154 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
159 p = (volatile u16 *)port2adr(port);
165 void landisk_insw(unsigned long port, void *dst, unsigned long count)
171 p = (volatile u16 *)port;
172 else if (is_pci_ioaddr(port))
173 p = (volatile u16 *)pci_ioaddr(port);
175 p = (volatile u16 *)port2adr(port);
180 void landisk_insl(unsigned long port, void *dst, unsigned long count)
184 if (is_pci_ioaddr(port)) {
185 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
193 void landisk_outsb(unsigned long port, const void *src, unsigned long count)
200 ctrl_outb(*buf++, port);
201 else if (is_pci_ioaddr(port)) {
202 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
207 p = (volatile u16 *)port2adr(port);
213 void landisk_outsw(unsigned long port, const void *src, unsigned long count)
216 const u16 *buf = src;
219 p = (volatile u16 *)port;
220 else if (is_pci_ioaddr(port))
221 p = (volatile u16 *)pci_ioaddr(port);
223 p = (volatile u16 *)port2adr(port);
229 void landisk_outsl(unsigned long port, const void *src, unsigned long count)
231 const u32 *buf = src;
233 if (is_pci_ioaddr(port)) {
234 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
242 void __iomem *landisk_ioport_map(unsigned long port, unsigned int size)
245 return (void __iomem *)port;
246 else if (is_pci_ioaddr(port))
247 return (void __iomem *)pci_ioaddr(port);
249 return (void __iomem *)port2adr(port);