aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/se/7751/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/se/7751/io.c')
-rw-r--r--arch/sh/boards/se/7751/io.c145
1 files changed, 22 insertions, 123 deletions
diff --git a/arch/sh/boards/se/7751/io.c b/arch/sh/boards/se/7751/io.c
index 0e8a3ba48316..e8d846cec89d 100644
--- a/arch/sh/boards/se/7751/io.c
+++ b/arch/sh/boards/se/7751/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_7751se.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c. 3 * Based largely on io_se.c.
6 * 4 *
@@ -10,55 +8,14 @@
10 * placeholder code from io_se.c left in with the 8 * placeholder code from io_se.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 9 * expectation of later SuperIO and PCMCIA access.
12 */ 10 */
13
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/pci.h>
16#include <asm/io.h> 14#include <asm/io.h>
17#include <asm/se7751.h> 15#include <asm/se7751.h>
18#include <asm/addrspace.h> 16#include <asm/addrspace.h>
19 17
20#include <linux/pci.h> 18static inline volatile u16 *port2adr(unsigned int port)
21#include "../../../drivers/pci/pci-sh7751.h"
22
23#if 0
24/******************************************************************
25 * Variables from io_se.c, related to PCMCIA (not PCI); we're not
26 * compiling them in, and have removed references from functions
27 * which follow. [Many checked for IO ports in the range bounded
28 * by sh_pcic_io_start/stop, and used sh_pcic_io_wbase as offset.
29 * As start/stop are uninitialized, only port 0x0 would match?]
30 * When used, remember to adjust names to avoid clash with io_se?
31 *****************************************************************/
32/* SH pcmcia io window base, start and end. */
33int sh_pcic_io_wbase = 0xb8400000;
34int sh_pcic_io_start;
35int sh_pcic_io_stop;
36int sh_pcic_io_type;
37int sh_pcic_io_dummy;
38/*************************************************************/
39#endif
40
41/*
42 * The 7751 Solution Engine uses the built-in PCI controller (PCIC)
43 * of the 7751 processor, and has a SuperIO accessible via the PCI.
44 * The board also includes a PCMCIA controller on its memory bus,
45 * like the other Solution Engine boards.
46 */
47
48#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
49#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
50#define PCI_IO_AREA SH7751_PCI_IO_BASE
51#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
52
53#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
54
55static inline void delay(void)
56{
57 ctrl_inw(0xa0000000);
58}
59
60static inline volatile __u16 *
61port2adr(unsigned int port)
62{ 19{
63 if (port >= 0x2000) 20 if (port >= 0x2000)
64 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); 21 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
@@ -66,32 +23,6 @@ port2adr(unsigned int port)
66 return (volatile __u16*)port; 23 return (volatile __u16*)port;
67} 24}
68 25
69#if 0
70/* The 7751 Solution Engine seems to have everything hooked */
71/* up pretty normally (nothing on high-bytes only...) so this */
72/* shouldn't be needed */
73static inline int
74shifted_port(unsigned long port)
75{
76 /* For IDE registers, value is not shifted */
77 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
78 return 0;
79 else
80 return 1;
81}
82#endif
83
84/* In case someone configures the kernel w/o PCI support: in that */
85/* scenario, don't ever bother to check for PCI-window addresses */
86
87/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
88#if defined(CONFIG_PCI)
89#define CHECK_SH7751_PCIIO(port) \
90 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
91#else
92#define CHECK_SH7751_PCIIO(port) (0)
93#endif
94
95/* 26/*
96 * General outline: remap really low stuff [eventually] to SuperIO, 27 * General outline: remap really low stuff [eventually] to SuperIO,
97 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 28 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -103,10 +34,10 @@ unsigned char sh7751se_inb(unsigned long port)
103{ 34{
104 if (PXSEG(port)) 35 if (PXSEG(port))
105 return *(volatile unsigned char *)port; 36 return *(volatile unsigned char *)port;
106 else if (CHECK_SH7751_PCIIO(port)) 37 else if (is_pci_ioaddr(port))
107 return *(volatile unsigned char *)PCI_IOMAP(port); 38 return *(volatile unsigned char *)pci_ioaddr(port);
108 else 39 else
109 return (*port2adr(port))&0xff; 40 return (*port2adr(port)) & 0xff;
110} 41}
111 42
112unsigned char sh7751se_inb_p(unsigned long port) 43unsigned char sh7751se_inb_p(unsigned long port)
@@ -115,11 +46,11 @@ unsigned char sh7751se_inb_p(unsigned long port)
115 46
116 if (PXSEG(port)) 47 if (PXSEG(port))
117 v = *(volatile unsigned char *)port; 48 v = *(volatile unsigned char *)port;
118 else if (CHECK_SH7751_PCIIO(port)) 49 else if (is_pci_ioaddr(port))
119 v = *(volatile unsigned char *)PCI_IOMAP(port); 50 v = *(volatile unsigned char *)pci_ioaddr(port);
120 else 51 else
121 v = (*port2adr(port))&0xff; 52 v = (*port2adr(port)) & 0xff;
122 delay(); 53 ctrl_delay();
123 return v; 54 return v;
124} 55}
125 56
@@ -127,8 +58,8 @@ unsigned short sh7751se_inw(unsigned long port)
127{ 58{
128 if (PXSEG(port)) 59 if (PXSEG(port))
129 return *(volatile unsigned short *)port; 60 return *(volatile unsigned short *)port;
130 else if (CHECK_SH7751_PCIIO(port)) 61 else if (is_pci_ioaddr(port))
131 return *(volatile unsigned short *)PCI_IOMAP(port); 62 return *(volatile unsigned short *)pci_ioaddr(port);
132 else if (port >= 0x2000) 63 else if (port >= 0x2000)
133 return *port2adr(port); 64 return *port2adr(port);
134 else 65 else
@@ -140,8 +71,8 @@ unsigned int sh7751se_inl(unsigned long port)
140{ 71{
141 if (PXSEG(port)) 72 if (PXSEG(port))
142 return *(volatile unsigned long *)port; 73 return *(volatile unsigned long *)port;
143 else if (CHECK_SH7751_PCIIO(port)) 74 else if (is_pci_ioaddr(port))
144 return *(volatile unsigned int *)PCI_IOMAP(port); 75 return *(volatile unsigned int *)pci_ioaddr(port);
145 else if (port >= 0x2000) 76 else if (port >= 0x2000)
146 return *port2adr(port); 77 return *port2adr(port);
147 else 78 else
@@ -154,8 +85,8 @@ void sh7751se_outb(unsigned char value, unsigned long port)
154 85
155 if (PXSEG(port)) 86 if (PXSEG(port))
156 *(volatile unsigned char *)port = value; 87 *(volatile unsigned char *)port = value;
157 else if (CHECK_SH7751_PCIIO(port)) 88 else if (is_pci_ioaddr(port))
158 *((unsigned char*)PCI_IOMAP(port)) = value; 89 *((unsigned char*)pci_ioaddr(port)) = value;
159 else 90 else
160 *(port2adr(port)) = value; 91 *(port2adr(port)) = value;
161} 92}
@@ -164,19 +95,19 @@ void sh7751se_outb_p(unsigned char value, unsigned long port)
164{ 95{
165 if (PXSEG(port)) 96 if (PXSEG(port))
166 *(volatile unsigned char *)port = value; 97 *(volatile unsigned char *)port = value;
167 else if (CHECK_SH7751_PCIIO(port)) 98 else if (is_pci_ioaddr(port))
168 *((unsigned char*)PCI_IOMAP(port)) = value; 99 *((unsigned char*)pci_ioaddr(port)) = value;
169 else 100 else
170 *(port2adr(port)) = value; 101 *(port2adr(port)) = value;
171 delay(); 102 ctrl_delay();
172} 103}
173 104
174void sh7751se_outw(unsigned short value, unsigned long port) 105void sh7751se_outw(unsigned short value, unsigned long port)
175{ 106{
176 if (PXSEG(port)) 107 if (PXSEG(port))
177 *(volatile unsigned short *)port = value; 108 *(volatile unsigned short *)port = value;
178 else if (CHECK_SH7751_PCIIO(port)) 109 else if (is_pci_ioaddr(port))
179 *((unsigned short *)PCI_IOMAP(port)) = value; 110 *((unsigned short *)pci_ioaddr(port)) = value;
180 else if (port >= 0x2000) 111 else if (port >= 0x2000)
181 *port2adr(port) = value; 112 *port2adr(port) = value;
182 else 113 else
@@ -187,8 +118,8 @@ void sh7751se_outl(unsigned int value, unsigned long port)
187{ 118{
188 if (PXSEG(port)) 119 if (PXSEG(port))
189 *(volatile unsigned long *)port = value; 120 *(volatile unsigned long *)port = value;
190 else if (CHECK_SH7751_PCIIO(port)) 121 else if (is_pci_ioaddr(port))
191 *((unsigned long*)PCI_IOMAP(port)) = value; 122 *((unsigned long*)pci_ioaddr(port)) = value;
192 else 123 else
193 maybebadio(port); 124 maybebadio(port);
194} 125}
@@ -202,35 +133,3 @@ void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count)
202{ 133{
203 maybebadio(port); 134 maybebadio(port);
204} 135}
205
206/* Map ISA bus address to the real address. Only for PCMCIA. */
207
208/* ISA page descriptor. */
209static __u32 sh_isa_memmap[256];
210
211#if 0
212static int
213sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
214{
215 int idx;
216
217 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
218 return -1;
219
220 idx = start >> 12;
221 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
222 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
223 start, length, offset, idx, sh_isa_memmap[idx]);
224 return 0;
225}
226#endif
227
228unsigned long
229sh7751se_isa_port2addr(unsigned long offset)
230{
231 int idx;
232
233 idx = (offset >> 12) & 0xff;
234 offset &= 0xfff;
235 return sh_isa_memmap[idx] + offset;
236}