OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [sh/] [kernel/] [io_se.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* $Id: io_se.c,v 1.1.1.1 2004-04-15 01:17:43 phoenix Exp $
2
 *
3
 * linux/arch/sh/kernel/io_se.c
4
 *
5
 * Copyright (C) 2000  Kazumoto Kojima
6
 *
7
 * I/O routine for Hitachi SolutionEngine.
8
 *
9
 */
10
 
11
#include <linux/kernel.h>
12
#include <linux/types.h>
13
#include <asm/io.h>
14
#include <asm/hitachi_se.h>
15
 
16
/* SH pcmcia io window base, start and end.  */
17
int sh_pcic_io_wbase = 0xb8400000;
18
int sh_pcic_io_start;
19
int sh_pcic_io_stop;
20
int sh_pcic_io_type;
21
int sh_pcic_io_dummy;
22
 
23
static inline void delay(void)
24
{
25
        ctrl_inw(0xa0000000);
26
        ctrl_inw(0xa0000000);
27
}
28
 
29
/* MS7750 requires special versions of in*, out* routines, since
30
   PC-like io ports are located at upper half byte of 16-bit word which
31
   can be accessed only with 16-bit wide.  */
32
 
33
static inline volatile __u16 *
34
port2adr(unsigned int port)
35
{
36
        if (port >= 0x2000)
37
                return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
38
        else if (port >= 0x1000)
39
                return (volatile __u16 *) (PA_83902 + (port << 1));
40
        else if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
41
                return (volatile __u16 *) (sh_pcic_io_wbase + (port &~ 1));
42
        else
43
                return (volatile __u16 *) (PA_SUPERIO + (port << 1));
44
}
45
 
46
static inline int
47
shifted_port(unsigned long port)
48
{
49
        /* For IDE registers, value is not shifted */
50
        if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
51
                return 0;
52
        else
53
                return 1;
54
}
55
 
56
#define maybebadio(name,port) \
57
  printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
58
         #name, (port), (__u32) __builtin_return_address(0))
59
 
60
unsigned char se_inb(unsigned long port)
61
{
62
        if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
63
                return *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
64
        else if (shifted_port(port))
65
                return (*port2adr(port) >> 8);
66
        else
67
                return (*port2adr(port))&0xff;
68
}
69
 
70
unsigned char se_inb_p(unsigned long port)
71
{
72
        unsigned long v;
73
 
74
        if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
75
                v = *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
76
        else if (shifted_port(port))
77
                v = (*port2adr(port) >> 8);
78
        else
79
                v = (*port2adr(port))&0xff;
80
        delay();
81
        return v;
82
}
83
 
84
unsigned short se_inw(unsigned long port)
85
{
86
        if (port >= 0x2000 ||
87
            (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
88
                return *port2adr(port);
89
        else
90
                maybebadio(inw, port);
91
        return 0;
92
}
93
 
94
unsigned int se_inl(unsigned long port)
95
{
96
        maybebadio(inl, port);
97
        return 0;
98
}
99
 
100
void se_outb(unsigned char value, unsigned long port)
101
{
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;
106
        else
107
                *(port2adr(port)) = value;
108
}
109
 
110
void se_outb_p(unsigned char value, unsigned long port)
111
{
112
        if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
113
                *(__u8 *)(sh_pcic_io_wbase + port) = value;
114
        else if (shifted_port(port))
115
                *(port2adr(port)) = value << 8;
116
        else
117
                *(port2adr(port)) = value;
118
        delay();
119
}
120
 
121
void se_outw(unsigned short value, unsigned long port)
122
{
123
        if (port >= 0x2000 ||
124
            (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
125
                *port2adr(port) = value;
126
        else
127
                maybebadio(outw, port);
128
}
129
 
130
void se_outl(unsigned int value, unsigned long port)
131
{
132
        maybebadio(outl, port);
133
}
134
 
135
void se_insb(unsigned long port, void *addr, unsigned long count)
136
{
137
        volatile __u16 *p = port2adr(port);
138
 
139
        if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
140
                volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
141
                while (count--)
142
                        *((__u8 *) addr)++ = *bp;
143
        } else if (shifted_port(port)) {
144
                while (count--)
145
                        *((__u8 *) addr)++ = *p >> 8;
146
        } else {
147
                while (count--)
148
                        *((__u8 *) addr)++ = *p;
149
        }
150
}
151
 
152
void se_insw(unsigned long port, void *addr, unsigned long count)
153
{
154
        volatile __u16 *p = port2adr(port);
155
        while (count--)
156
                *((__u16 *) addr)++ = *p;
157
}
158
 
159
void se_insl(unsigned long port, void *addr, unsigned long count)
160
{
161
        maybebadio(insl, port);
162
}
163
 
164
void se_outsb(unsigned long port, const void *addr, unsigned long count)
165
{
166
        volatile __u16 *p = port2adr(port);
167
 
168
        if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
169
                volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + port);
170
                while (count--)
171
                        *bp = *((__u8 *) addr)++;
172
        } else if (shifted_port(port)) {
173
                while (count--)
174
                        *p = *((__u8 *) addr)++ << 8;
175
        } else {
176
                while (count--)
177
                        *p = *((__u8 *) addr)++;
178
        }
179
}
180
 
181
void se_outsw(unsigned long port, const void *addr, unsigned long count)
182
{
183
        volatile __u16 *p = port2adr(port);
184
        while (count--)
185
                *p = *((__u16 *) addr)++;
186
}
187
 
188
void se_outsl(unsigned long port, const void *addr, unsigned long count)
189
{
190
        maybebadio(outsw, port);
191
}
192
 
193
unsigned char se_readb(unsigned long addr)
194
{
195
        return *(volatile unsigned char*)addr;
196
}
197
 
198
unsigned short se_readw(unsigned long addr)
199
{
200
        return *(volatile unsigned short*)addr;
201
}
202
 
203
unsigned int se_readl(unsigned long addr)
204
{
205
        return *(volatile unsigned long*)addr;
206
}
207
 
208
void se_writeb(unsigned char b, unsigned long addr)
209
{
210
        *(volatile unsigned char*)addr = b;
211
}
212
 
213
void se_writew(unsigned short b, unsigned long addr)
214
{
215
        *(volatile unsigned short*)addr = b;
216
}
217
 
218
void se_writel(unsigned int b, unsigned long addr)
219
{
220
        *(volatile unsigned long*)addr = b;
221
}
222
 
223
/* Map ISA bus address to the real address. Only for PCMCIA.  */
224
 
225
/* ISA page descriptor.  */
226
static __u32 sh_isa_memmap[256];
227
 
228
static int
229
sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
230
{
231
        int idx;
232
 
233
        if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
234
                return -1;
235
 
236
        idx = start >> 12;
237
        sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
238
#if 0
239
        printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
240
               start, length, offset, idx, sh_isa_memmap[idx]);
241
#endif
242
        return 0;
243
}
244
 
245
unsigned long
246
se_isa_port2addr(unsigned long offset)
247
{
248
        int idx;
249
 
250
        idx = (offset >> 12) & 0xff;
251
        offset &= 0xfff;
252
        return sh_isa_memmap[idx] + offset;
253
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.