aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/snapgear/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/snapgear/io.c')
-rw-r--r--arch/sh/boards/snapgear/io.c145
1 files changed, 28 insertions, 117 deletions
diff --git a/arch/sh/boards/snapgear/io.c b/arch/sh/boards/snapgear/io.c
index e2eb78fc381d..0f4824264557 100644
--- a/arch/sh/boards/snapgear/io.c
+++ b/arch/sh/boards/snapgear/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_7751se.c
3 *
4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com> 2 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
5 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 3 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
6 * Based largely on io_se.c. 4 * Based largely on io_se.c.
@@ -11,67 +9,22 @@
11 * placeholder code from io_se.c left in with the 9 * placeholder code from io_se.c left in with the
12 * expectation of later SuperIO and PCMCIA access. 10 * expectation of later SuperIO and PCMCIA access.
13 */ 11 */
14
15#include <linux/kernel.h> 12#include <linux/kernel.h>
16#include <linux/types.h> 13#include <linux/types.h>
17#include <linux/pci.h> 14#include <linux/pci.h>
18#include <asm/io.h> 15#include <asm/io.h>
19#include <asm/addrspace.h> 16#include <asm/addrspace.h>
20 17
21#include <asm/pci.h>
22#include "../../drivers/pci/pci-sh7751.h"
23
24#ifdef CONFIG_SH_SECUREEDGE5410 18#ifdef CONFIG_SH_SECUREEDGE5410
25unsigned short secureedge5410_ioport; 19unsigned short secureedge5410_ioport;
26#endif 20#endif
27 21
28/*
29 * The SnapGear uses the built-in PCI controller (PCIC)
30 * of the 7751 processor
31 */
32
33#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
34#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
35#define PCI_IO_AREA SH7751_PCI_IO_BASE
36#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
37
38
39#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
40
41
42#define maybebadio(name,port) \
43 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
44 #name, (port), (__u32) __builtin_return_address(0))
45
46
47static inline void delay(void)
48{
49 ctrl_inw(0xa0000000);
50}
51
52
53static inline volatile __u16 *port2adr(unsigned int port) 22static inline volatile __u16 *port2adr(unsigned int port)
54{ 23{
55#if 0 24 maybebadio((unsigned long)port);
56 if (port >= 0x2000)
57 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
58#endif
59 maybebadio(name,(unsigned long)port);
60 return (volatile __u16*)port; 25 return (volatile __u16*)port;
61} 26}
62 27
63
64/* In case someone configures the kernel w/o PCI support: in that */
65/* scenario, don't ever bother to check for PCI-window addresses */
66
67/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
68#if defined(CONFIG_PCI)
69#define CHECK_SH7751_PCIIO(port) \
70 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
71#else
72#define CHECK_SH7751_PCIIO(port) (0)
73#endif
74
75/* 28/*
76 * General outline: remap really low stuff [eventually] to SuperIO, 29 * General outline: remap really low stuff [eventually] to SuperIO,
77 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 30 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -79,148 +32,106 @@ static inline volatile __u16 *port2adr(unsigned int port)
79 * should be way beyond the window, and is used w/o translation for 32 * should be way beyond the window, and is used w/o translation for
80 * compatibility. 33 * compatibility.
81 */ 34 */
82
83unsigned char snapgear_inb(unsigned long port) 35unsigned char snapgear_inb(unsigned long port)
84{ 36{
85 if (PXSEG(port)) 37 if (PXSEG(port))
86 return *(volatile unsigned char *)port; 38 return *(volatile unsigned char *)port;
87 else if (CHECK_SH7751_PCIIO(port)) 39 else if (is_pci_ioaddr(port))
88 return *(volatile unsigned char *)PCI_IOMAP(port); 40 return *(volatile unsigned char *)pci_ioaddr(port);
89 else 41 else
90 return (*port2adr(port))&0xff; 42 return (*port2adr(port)) & 0xff;
91} 43}
92 44
93
94unsigned char snapgear_inb_p(unsigned long port) 45unsigned char snapgear_inb_p(unsigned long port)
95{ 46{
96 unsigned char v; 47 unsigned char v;
97 48
98 if (PXSEG(port)) 49 if (PXSEG(port))
99 v = *(volatile unsigned char *)port; 50 v = *(volatile unsigned char *)port;
100 else if (CHECK_SH7751_PCIIO(port)) 51 else if (is_pci_ioaddr(port))
101 v = *(volatile unsigned char *)PCI_IOMAP(port); 52 v = *(volatile unsigned char *)pci_ioaddr(port);
102 else 53 else
103 v = (*port2adr(port))&0xff; 54 v = (*port2adr(port))&0xff;
104 delay(); 55 ctrl_delay();
105 return v; 56 return v;
106} 57}
107 58
108
109unsigned short snapgear_inw(unsigned long port) 59unsigned short snapgear_inw(unsigned long port)
110{ 60{
111 if (PXSEG(port)) 61 if (PXSEG(port))
112 return *(volatile unsigned short *)port; 62 return *(volatile unsigned short *)port;
113 else if (CHECK_SH7751_PCIIO(port)) 63 else if (is_pci_ioaddr(port))
114 return *(volatile unsigned short *)PCI_IOMAP(port); 64 return *(volatile unsigned short *)pci_ioaddr(port);
115 else if (port >= 0x2000) 65 else if (port >= 0x2000)
116 return *port2adr(port); 66 return *port2adr(port);
117 else 67 else
118 maybebadio(inw, port); 68 maybebadio(port);
119 return 0; 69 return 0;
120} 70}
121 71
122
123unsigned int snapgear_inl(unsigned long port) 72unsigned int snapgear_inl(unsigned long port)
124{ 73{
125 if (PXSEG(port)) 74 if (PXSEG(port))
126 return *(volatile unsigned long *)port; 75 return *(volatile unsigned long *)port;
127 else if (CHECK_SH7751_PCIIO(port)) 76 else if (is_pci_ioaddr(port))
128 return *(volatile unsigned int *)PCI_IOMAP(port); 77 return *(volatile unsigned int *)pci_ioaddr(port);
129 else if (port >= 0x2000) 78 else if (port >= 0x2000)
130 return *port2adr(port); 79 return *port2adr(port);
131 else 80 else
132 maybebadio(inl, port); 81 maybebadio(port);
133 return 0; 82 return 0;
134} 83}
135 84
136
137void snapgear_outb(unsigned char value, unsigned long port) 85void snapgear_outb(unsigned char value, unsigned long port)
138{ 86{
139 87
140 if (PXSEG(port)) 88 if (PXSEG(port))
141 *(volatile unsigned char *)port = value; 89 *(volatile unsigned char *)port = value;
142 else if (CHECK_SH7751_PCIIO(port)) 90 else if (is_pci_ioaddr(port))
143 *((unsigned char*)PCI_IOMAP(port)) = value; 91 *((unsigned char*)pci_ioaddr(port)) = value;
144 else 92 else
145 *(port2adr(port)) = value; 93 *(port2adr(port)) = value;
146} 94}
147 95
148
149void snapgear_outb_p(unsigned char value, unsigned long port) 96void snapgear_outb_p(unsigned char value, unsigned long port)
150{ 97{
151 if (PXSEG(port)) 98 if (PXSEG(port))
152 *(volatile unsigned char *)port = value; 99 *(volatile unsigned char *)port = value;
153 else if (CHECK_SH7751_PCIIO(port)) 100 else if (is_pci_ioaddr(port))
154 *((unsigned char*)PCI_IOMAP(port)) = value; 101 *((unsigned char*)pci_ioaddr(port)) = value;
155 else 102 else
156 *(port2adr(port)) = value; 103 *(port2adr(port)) = value;
157 delay(); 104 ctrl_delay();
158} 105}
159 106
160
161void snapgear_outw(unsigned short value, unsigned long port) 107void snapgear_outw(unsigned short value, unsigned long port)
162{ 108{
163 if (PXSEG(port)) 109 if (PXSEG(port))
164 *(volatile unsigned short *)port = value; 110 *(volatile unsigned short *)port = value;
165 else if (CHECK_SH7751_PCIIO(port)) 111 else if (is_pci_ioaddr(port))
166 *((unsigned short *)PCI_IOMAP(port)) = value; 112 *((unsigned short *)pci_ioaddr(port)) = value;
167 else if (port >= 0x2000) 113 else if (port >= 0x2000)
168 *port2adr(port) = value; 114 *port2adr(port) = value;
169 else 115 else
170 maybebadio(outw, port); 116 maybebadio(port);
171} 117}
172 118
173
174void snapgear_outl(unsigned int value, unsigned long port) 119void snapgear_outl(unsigned int value, unsigned long port)
175{ 120{
176 if (PXSEG(port)) 121 if (PXSEG(port))
177 *(volatile unsigned long *)port = value; 122 *(volatile unsigned long *)port = value;
178 else if (CHECK_SH7751_PCIIO(port)) 123 else if (is_pci_ioaddr(port))
179 *((unsigned long*)PCI_IOMAP(port)) = value; 124 *((unsigned long*)pci_ioaddr(port)) = value;
180 else 125 else
181 maybebadio(outl, port); 126 maybebadio(port);
182} 127}
183 128
184void snapgear_insl(unsigned long port, void *addr, unsigned long count) 129void snapgear_insl(unsigned long port, void *addr, unsigned long count)
185{ 130{
186 maybebadio(insl, port); 131 maybebadio(port);
187} 132}
188 133
189void snapgear_outsl(unsigned long port, const void *addr, unsigned long count) 134void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
190{ 135{
191 maybebadio(outsw, port); 136 maybebadio(port);
192}
193
194/* Map ISA bus address to the real address. Only for PCMCIA. */
195
196
197/* ISA page descriptor. */
198static __u32 sh_isa_memmap[256];
199
200
201#if 0
202static int sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
203{
204 int idx;
205
206 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
207 return -1;
208
209 idx = start >> 12;
210 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
211#if 0
212 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
213 start, length, offset, idx, sh_isa_memmap[idx]);
214#endif
215 return 0;
216}
217#endif
218
219unsigned long snapgear_isa_port2addr(unsigned long offset)
220{
221 int idx;
222
223 idx = (offset >> 12) & 0xff;
224 offset &= 0xfff;
225 return sh_isa_memmap[idx] + offset;
226} 137}