]>
Commit | Line | Data |
---|---|---|
373e68b5 | 1 | /* |
1da177e4 LT |
2 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel |
3 | * Based largely on io_se.c. | |
4 | * | |
5 | * I/O routine for Hitachi 7751 SolutionEngine. | |
6 | * | |
7 | * Initial version only to support LAN access; some | |
8 | * placeholder code from io_se.c left in with the | |
9 | * expectation of later SuperIO and PCMCIA access. | |
10 | */ | |
1da177e4 LT |
11 | #include <linux/kernel.h> |
12 | #include <linux/types.h> | |
959f85f8 | 13 | #include <linux/pci.h> |
1da177e4 | 14 | #include <asm/io.h> |
939a24a6 | 15 | #include <mach-se/mach/se7751.h> |
1da177e4 LT |
16 | #include <asm/addrspace.h> |
17 | ||
959f85f8 | 18 | static inline volatile u16 *port2adr(unsigned int port) |
1da177e4 LT |
19 | { |
20 | if (port >= 0x2000) | |
21 | return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); | |
373e68b5 | 22 | maybebadio((unsigned long)port); |
1da177e4 LT |
23 | return (volatile __u16*)port; |
24 | } | |
25 | ||
1da177e4 LT |
26 | /* |
27 | * General outline: remap really low stuff [eventually] to SuperIO, | |
28 | * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) | |
29 | * is mapped through the PCI IO window. Stuff with high bits (PXSEG) | |
30 | * should be way beyond the window, and is used w/o translation for | |
31 | * compatibility. | |
32 | */ | |
33 | unsigned char sh7751se_inb(unsigned long port) | |
34 | { | |
35 | if (PXSEG(port)) | |
36 | return *(volatile unsigned char *)port; | |
1da177e4 | 37 | else |
959f85f8 | 38 | return (*port2adr(port)) & 0xff; |
1da177e4 LT |
39 | } |
40 | ||
41 | unsigned char sh7751se_inb_p(unsigned long port) | |
42 | { | |
43 | unsigned char v; | |
44 | ||
45 | if (PXSEG(port)) | |
46 | v = *(volatile unsigned char *)port; | |
1da177e4 | 47 | else |
959f85f8 PM |
48 | v = (*port2adr(port)) & 0xff; |
49 | ctrl_delay(); | |
1da177e4 LT |
50 | return v; |
51 | } | |
52 | ||
53 | unsigned short sh7751se_inw(unsigned long port) | |
54 | { | |
55 | if (PXSEG(port)) | |
56 | return *(volatile unsigned short *)port; | |
1da177e4 LT |
57 | else if (port >= 0x2000) |
58 | return *port2adr(port); | |
59 | else | |
373e68b5 | 60 | maybebadio(port); |
1da177e4 LT |
61 | return 0; |
62 | } | |
63 | ||
64 | unsigned int sh7751se_inl(unsigned long port) | |
65 | { | |
66 | if (PXSEG(port)) | |
67 | return *(volatile unsigned long *)port; | |
1da177e4 LT |
68 | else if (port >= 0x2000) |
69 | return *port2adr(port); | |
70 | else | |
373e68b5 | 71 | maybebadio(port); |
1da177e4 LT |
72 | return 0; |
73 | } | |
74 | ||
75 | void sh7751se_outb(unsigned char value, unsigned long port) | |
76 | { | |
77 | ||
78 | if (PXSEG(port)) | |
79 | *(volatile unsigned char *)port = value; | |
1da177e4 LT |
80 | else |
81 | *(port2adr(port)) = value; | |
82 | } | |
83 | ||
84 | void sh7751se_outb_p(unsigned char value, unsigned long port) | |
85 | { | |
86 | if (PXSEG(port)) | |
87 | *(volatile unsigned char *)port = value; | |
1da177e4 LT |
88 | else |
89 | *(port2adr(port)) = value; | |
959f85f8 | 90 | ctrl_delay(); |
1da177e4 LT |
91 | } |
92 | ||
93 | void sh7751se_outw(unsigned short value, unsigned long port) | |
94 | { | |
95 | if (PXSEG(port)) | |
96 | *(volatile unsigned short *)port = value; | |
1da177e4 LT |
97 | else if (port >= 0x2000) |
98 | *port2adr(port) = value; | |
99 | else | |
373e68b5 | 100 | maybebadio(port); |
1da177e4 LT |
101 | } |
102 | ||
103 | void sh7751se_outl(unsigned int value, unsigned long port) | |
104 | { | |
105 | if (PXSEG(port)) | |
106 | *(volatile unsigned long *)port = value; | |
1da177e4 | 107 | else |
373e68b5 | 108 | maybebadio(port); |
1da177e4 LT |
109 | } |
110 | ||
111 | void sh7751se_insl(unsigned long port, void *addr, unsigned long count) | |
112 | { | |
373e68b5 | 113 | maybebadio(port); |
1da177e4 LT |
114 | } |
115 | ||
116 | void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count) | |
117 | { | |
373e68b5 | 118 | maybebadio(port); |
1da177e4 | 119 | } |