diff options
author | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 03:43:28 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 03:43:28 -0400 |
commit | 959f85f8a3223c116bbe95dd8a9b207790b5d4d3 (patch) | |
tree | e7da9ccf292f860bfa0ff9cc8b2682cd1d6bad4d /arch/sh/boards/renesas/systemh/io.c | |
parent | e108b2ca2349f510ce7d7f910eda89f71d710d84 (diff) |
sh: Consolidated SH7751/SH7780 PCI support.
This cleans up quite a lot of the PCI mess that we
currently have, and attempts to consolidate the
duplication in the SH7780 and SH7751 PCI controllers.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/renesas/systemh/io.c')
-rw-r--r-- | arch/sh/boards/renesas/systemh/io.c | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/arch/sh/boards/renesas/systemh/io.c b/arch/sh/boards/renesas/systemh/io.c index 0befd4f9894c..cde6e5d192c4 100644 --- a/arch/sh/boards/renesas/systemh/io.c +++ b/arch/sh/boards/renesas/systemh/io.c | |||
@@ -5,36 +5,16 @@ | |||
5 | * Based largely on io_se.c. | 5 | * Based largely on io_se.c. |
6 | * | 6 | * |
7 | * I/O routine for Hitachi 7751 Systemh. | 7 | * I/O routine for Hitachi 7751 Systemh. |
8 | * | ||
9 | */ | 8 | */ |
10 | |||
11 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
12 | #include <linux/types.h> | 10 | #include <linux/types.h> |
13 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
14 | #include <asm/systemh7751.h> | 12 | #include <asm/systemh7751.h> |
15 | #include <asm/addrspace.h> | 13 | #include <asm/addrspace.h> |
16 | #include <asm/io.h> | 14 | #include <asm/io.h> |
17 | #include "../../../drivers/pci/pci-sh7751.h" | ||
18 | |||
19 | /* | ||
20 | * The 7751 SystemH Engine uses the built-in PCI controller (PCIC) | ||
21 | * of the 7751 processor, and has a SuperIO accessible on its memory | ||
22 | * bus. | ||
23 | */ | ||
24 | |||
25 | #define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR) | ||
26 | #define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR) | ||
27 | #define PCI_IO_AREA SH7751_PCI_IO_BASE | ||
28 | #define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE | ||
29 | 15 | ||
30 | #define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK)) | ||
31 | #define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area | 16 | #define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area |
32 | of smc lan chip*/ | 17 | of smc lan chip*/ |
33 | static inline void delay(void) | ||
34 | { | ||
35 | ctrl_inw(0xa0000000); | ||
36 | } | ||
37 | |||
38 | static inline volatile __u16 * | 18 | static inline volatile __u16 * |
39 | port2adr(unsigned int port) | 19 | port2adr(unsigned int port) |
40 | { | 20 | { |
@@ -44,17 +24,6 @@ port2adr(unsigned int port) | |||
44 | return (volatile __u16*)port; | 24 | return (volatile __u16*)port; |
45 | } | 25 | } |
46 | 26 | ||
47 | /* In case someone configures the kernel w/o PCI support: in that */ | ||
48 | /* scenario, don't ever bother to check for PCI-window addresses */ | ||
49 | |||
50 | /* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */ | ||
51 | #if defined(CONFIG_PCI) | ||
52 | #define CHECK_SH7751_PCIIO(port) \ | ||
53 | ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE))) | ||
54 | #else | ||
55 | #define CHECK_SH7751_PCIIO(port) (0) | ||
56 | #endif | ||
57 | |||
58 | /* | 27 | /* |
59 | * General outline: remap really low stuff [eventually] to SuperIO, | 28 | * General outline: remap really low stuff [eventually] to SuperIO, |
60 | * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) | 29 | * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) |
@@ -66,8 +35,8 @@ unsigned char sh7751systemh_inb(unsigned long port) | |||
66 | { | 35 | { |
67 | if (PXSEG(port)) | 36 | if (PXSEG(port)) |
68 | return *(volatile unsigned char *)port; | 37 | return *(volatile unsigned char *)port; |
69 | else if (CHECK_SH7751_PCIIO(port)) | 38 | else if (is_pci_ioaddr(port)) |
70 | return *(volatile unsigned char *)PCI_IOMAP(port); | 39 | return *(volatile unsigned char *)pci_ioaddr(port); |
71 | else if (port <= 0x3F1) | 40 | else if (port <= 0x3F1) |
72 | return *(volatile unsigned char *)ETHER_IOMAP(port); | 41 | return *(volatile unsigned char *)ETHER_IOMAP(port); |
73 | else | 42 | else |
@@ -80,13 +49,13 @@ unsigned char sh7751systemh_inb_p(unsigned long port) | |||
80 | 49 | ||
81 | if (PXSEG(port)) | 50 | if (PXSEG(port)) |
82 | v = *(volatile unsigned char *)port; | 51 | v = *(volatile unsigned char *)port; |
83 | else if (CHECK_SH7751_PCIIO(port)) | 52 | else if (is_pci_ioaddr(port)) |
84 | v = *(volatile unsigned char *)PCI_IOMAP(port); | 53 | v = *(volatile unsigned char *)pci_ioaddr(port); |
85 | else if (port <= 0x3F1) | 54 | else if (port <= 0x3F1) |
86 | v = *(volatile unsigned char *)ETHER_IOMAP(port); | 55 | v = *(volatile unsigned char *)ETHER_IOMAP(port); |
87 | else | 56 | else |
88 | v = (*port2adr(port))&0xff; | 57 | v = (*port2adr(port))&0xff; |
89 | delay(); | 58 | ctrl_delay(); |
90 | return v; | 59 | return v; |
91 | } | 60 | } |
92 | 61 | ||
@@ -94,8 +63,8 @@ unsigned short sh7751systemh_inw(unsigned long port) | |||
94 | { | 63 | { |
95 | if (PXSEG(port)) | 64 | if (PXSEG(port)) |
96 | return *(volatile unsigned short *)port; | 65 | return *(volatile unsigned short *)port; |
97 | else if (CHECK_SH7751_PCIIO(port)) | 66 | else if (is_pci_ioaddr(port)) |
98 | return *(volatile unsigned short *)PCI_IOMAP(port); | 67 | return *(volatile unsigned short *)pci_ioaddr(port); |
99 | else if (port >= 0x2000) | 68 | else if (port >= 0x2000) |
100 | return *port2adr(port); | 69 | return *port2adr(port); |
101 | else if (port <= 0x3F1) | 70 | else if (port <= 0x3F1) |
@@ -109,8 +78,8 @@ unsigned int sh7751systemh_inl(unsigned long port) | |||
109 | { | 78 | { |
110 | if (PXSEG(port)) | 79 | if (PXSEG(port)) |
111 | return *(volatile unsigned long *)port; | 80 | return *(volatile unsigned long *)port; |
112 | else if (CHECK_SH7751_PCIIO(port)) | 81 | else if (is_pci_ioaddr(port)) |
113 | return *(volatile unsigned int *)PCI_IOMAP(port); | 82 | return *(volatile unsigned int *)pci_ioaddr(port); |
114 | else if (port >= 0x2000) | 83 | else if (port >= 0x2000) |
115 | return *port2adr(port); | 84 | return *port2adr(port); |
116 | else if (port <= 0x3F1) | 85 | else if (port <= 0x3F1) |
@@ -125,8 +94,8 @@ void sh7751systemh_outb(unsigned char value, unsigned long port) | |||
125 | 94 | ||
126 | if (PXSEG(port)) | 95 | if (PXSEG(port)) |
127 | *(volatile unsigned char *)port = value; | 96 | *(volatile unsigned char *)port = value; |
128 | else if (CHECK_SH7751_PCIIO(port)) | 97 | else if (is_pci_ioaddr(port)) |
129 | *((unsigned char*)PCI_IOMAP(port)) = value; | 98 | *((unsigned char*)pci_ioaddr(port)) = value; |
130 | else if (port <= 0x3F1) | 99 | else if (port <= 0x3F1) |
131 | *(volatile unsigned char *)ETHER_IOMAP(port) = value; | 100 | *(volatile unsigned char *)ETHER_IOMAP(port) = value; |
132 | else | 101 | else |
@@ -137,21 +106,21 @@ void sh7751systemh_outb_p(unsigned char value, unsigned long port) | |||
137 | { | 106 | { |
138 | if (PXSEG(port)) | 107 | if (PXSEG(port)) |
139 | *(volatile unsigned char *)port = value; | 108 | *(volatile unsigned char *)port = value; |
140 | else if (CHECK_SH7751_PCIIO(port)) | 109 | else if (is_pci_ioaddr(port)) |
141 | *((unsigned char*)PCI_IOMAP(port)) = value; | 110 | *((unsigned char*)pci_ioaddr(port)) = value; |
142 | else if (port <= 0x3F1) | 111 | else if (port <= 0x3F1) |
143 | *(volatile unsigned char *)ETHER_IOMAP(port) = value; | 112 | *(volatile unsigned char *)ETHER_IOMAP(port) = value; |
144 | else | 113 | else |
145 | *(port2adr(port)) = value; | 114 | *(port2adr(port)) = value; |
146 | delay(); | 115 | ctrl_delay(); |
147 | } | 116 | } |
148 | 117 | ||
149 | void sh7751systemh_outw(unsigned short value, unsigned long port) | 118 | void sh7751systemh_outw(unsigned short value, unsigned long port) |
150 | { | 119 | { |
151 | if (PXSEG(port)) | 120 | if (PXSEG(port)) |
152 | *(volatile unsigned short *)port = value; | 121 | *(volatile unsigned short *)port = value; |
153 | else if (CHECK_SH7751_PCIIO(port)) | 122 | else if (is_pci_ioaddr(port)) |
154 | *((unsigned short *)PCI_IOMAP(port)) = value; | 123 | *((unsigned short *)pci_ioaddr(port)) = value; |
155 | else if (port >= 0x2000) | 124 | else if (port >= 0x2000) |
156 | *port2adr(port) = value; | 125 | *port2adr(port) = value; |
157 | else if (port <= 0x3F1) | 126 | else if (port <= 0x3F1) |
@@ -164,8 +133,8 @@ void sh7751systemh_outl(unsigned int value, unsigned long port) | |||
164 | { | 133 | { |
165 | if (PXSEG(port)) | 134 | if (PXSEG(port)) |
166 | *(volatile unsigned long *)port = value; | 135 | *(volatile unsigned long *)port = value; |
167 | else if (CHECK_SH7751_PCIIO(port)) | 136 | else if (is_pci_ioaddr(port)) |
168 | *((unsigned long*)PCI_IOMAP(port)) = value; | 137 | *((unsigned long*)pci_ioaddr(port)) = value; |
169 | else | 138 | else |
170 | maybebadio(port); | 139 | maybebadio(port); |
171 | } | 140 | } |