aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/snapgear
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2006-09-27 03:43:28 -0400
committerPaul Mundt <lethal@linux-sh.org>2006-09-27 03:43:28 -0400
commit959f85f8a3223c116bbe95dd8a9b207790b5d4d3 (patch)
treee7da9ccf292f860bfa0ff9cc8b2682cd1d6bad4d /arch/sh/boards/snapgear
parente108b2ca2349f510ce7d7f910eda89f71d710d84 (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/snapgear')
-rw-r--r--arch/sh/boards/snapgear/io.c84
1 files changed, 21 insertions, 63 deletions
diff --git a/arch/sh/boards/snapgear/io.c b/arch/sh/boards/snapgear/io.c
index 9f700b8392bb..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,54 +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#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
39
40static inline void delay(void)
41{
42 ctrl_inw(0xa0000000);
43}
44
45static inline volatile __u16 *port2adr(unsigned int port) 22static inline volatile __u16 *port2adr(unsigned int port)
46{ 23{
47 maybebadio((unsigned long)port); 24 maybebadio((unsigned long)port);
48 return (volatile __u16*)port; 25 return (volatile __u16*)port;
49} 26}
50 27
51/* In case someone configures the kernel w/o PCI support: in that */
52/* scenario, don't ever bother to check for PCI-window addresses */
53
54/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
55#if defined(CONFIG_PCI)
56#define CHECK_SH7751_PCIIO(port) \
57 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
58#else
59#define CHECK_SH7751_PCIIO(port) (0)
60#endif
61
62/* 28/*
63 * General outline: remap really low stuff [eventually] to SuperIO, 29 * General outline: remap really low stuff [eventually] to SuperIO,
64 * 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)
@@ -66,39 +32,36 @@ static inline volatile __u16 *port2adr(unsigned int port)
66 * 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
67 * compatibility. 33 * compatibility.
68 */ 34 */
69
70unsigned char snapgear_inb(unsigned long port) 35unsigned char snapgear_inb(unsigned long port)
71{ 36{
72 if (PXSEG(port)) 37 if (PXSEG(port))
73 return *(volatile unsigned char *)port; 38 return *(volatile unsigned char *)port;
74 else if (CHECK_SH7751_PCIIO(port)) 39 else if (is_pci_ioaddr(port))
75 return *(volatile unsigned char *)PCI_IOMAP(port); 40 return *(volatile unsigned char *)pci_ioaddr(port);
76 else 41 else
77 return (*port2adr(port))&0xff; 42 return (*port2adr(port)) & 0xff;
78} 43}
79 44
80
81unsigned char snapgear_inb_p(unsigned long port) 45unsigned char snapgear_inb_p(unsigned long port)
82{ 46{
83 unsigned char v; 47 unsigned char v;
84 48
85 if (PXSEG(port)) 49 if (PXSEG(port))
86 v = *(volatile unsigned char *)port; 50 v = *(volatile unsigned char *)port;
87 else if (CHECK_SH7751_PCIIO(port)) 51 else if (is_pci_ioaddr(port))
88 v = *(volatile unsigned char *)PCI_IOMAP(port); 52 v = *(volatile unsigned char *)pci_ioaddr(port);
89 else 53 else
90 v = (*port2adr(port))&0xff; 54 v = (*port2adr(port))&0xff;
91 delay(); 55 ctrl_delay();
92 return v; 56 return v;
93} 57}
94 58
95
96unsigned short snapgear_inw(unsigned long port) 59unsigned short snapgear_inw(unsigned long port)
97{ 60{
98 if (PXSEG(port)) 61 if (PXSEG(port))
99 return *(volatile unsigned short *)port; 62 return *(volatile unsigned short *)port;
100 else if (CHECK_SH7751_PCIIO(port)) 63 else if (is_pci_ioaddr(port))
101 return *(volatile unsigned short *)PCI_IOMAP(port); 64 return *(volatile unsigned short *)pci_ioaddr(port);
102 else if (port >= 0x2000) 65 else if (port >= 0x2000)
103 return *port2adr(port); 66 return *port2adr(port);
104 else 67 else
@@ -106,13 +69,12 @@ unsigned short snapgear_inw(unsigned long port)
106 return 0; 69 return 0;
107} 70}
108 71
109
110unsigned int snapgear_inl(unsigned long port) 72unsigned int snapgear_inl(unsigned long port)
111{ 73{
112 if (PXSEG(port)) 74 if (PXSEG(port))
113 return *(volatile unsigned long *)port; 75 return *(volatile unsigned long *)port;
114 else if (CHECK_SH7751_PCIIO(port)) 76 else if (is_pci_ioaddr(port))
115 return *(volatile unsigned int *)PCI_IOMAP(port); 77 return *(volatile unsigned int *)pci_ioaddr(port);
116 else if (port >= 0x2000) 78 else if (port >= 0x2000)
117 return *port2adr(port); 79 return *port2adr(port);
118 else 80 else
@@ -120,50 +82,46 @@ unsigned int snapgear_inl(unsigned long port)
120 return 0; 82 return 0;
121} 83}
122 84
123
124void snapgear_outb(unsigned char value, unsigned long port) 85void snapgear_outb(unsigned char value, unsigned long port)
125{ 86{
126 87
127 if (PXSEG(port)) 88 if (PXSEG(port))
128 *(volatile unsigned char *)port = value; 89 *(volatile unsigned char *)port = value;
129 else if (CHECK_SH7751_PCIIO(port)) 90 else if (is_pci_ioaddr(port))
130 *((unsigned char*)PCI_IOMAP(port)) = value; 91 *((unsigned char*)pci_ioaddr(port)) = value;
131 else 92 else
132 *(port2adr(port)) = value; 93 *(port2adr(port)) = value;
133} 94}
134 95
135
136void snapgear_outb_p(unsigned char value, unsigned long port) 96void snapgear_outb_p(unsigned char value, unsigned long port)
137{ 97{
138 if (PXSEG(port)) 98 if (PXSEG(port))
139 *(volatile unsigned char *)port = value; 99 *(volatile unsigned char *)port = value;
140 else if (CHECK_SH7751_PCIIO(port)) 100 else if (is_pci_ioaddr(port))
141 *((unsigned char*)PCI_IOMAP(port)) = value; 101 *((unsigned char*)pci_ioaddr(port)) = value;
142 else 102 else
143 *(port2adr(port)) = value; 103 *(port2adr(port)) = value;
144 delay(); 104 ctrl_delay();
145} 105}
146 106
147
148void snapgear_outw(unsigned short value, unsigned long port) 107void snapgear_outw(unsigned short value, unsigned long port)
149{ 108{
150 if (PXSEG(port)) 109 if (PXSEG(port))
151 *(volatile unsigned short *)port = value; 110 *(volatile unsigned short *)port = value;
152 else if (CHECK_SH7751_PCIIO(port)) 111 else if (is_pci_ioaddr(port))
153 *((unsigned short *)PCI_IOMAP(port)) = value; 112 *((unsigned short *)pci_ioaddr(port)) = value;
154 else if (port >= 0x2000) 113 else if (port >= 0x2000)
155 *port2adr(port) = value; 114 *port2adr(port) = value;
156 else 115 else
157 maybebadio(port); 116 maybebadio(port);
158} 117}
159 118
160
161void snapgear_outl(unsigned int value, unsigned long port) 119void snapgear_outl(unsigned int value, unsigned long port)
162{ 120{
163 if (PXSEG(port)) 121 if (PXSEG(port))
164 *(volatile unsigned long *)port = value; 122 *(volatile unsigned long *)port = value;
165 else if (CHECK_SH7751_PCIIO(port)) 123 else if (is_pci_ioaddr(port))
166 *((unsigned long*)PCI_IOMAP(port)) = value; 124 *((unsigned long*)pci_ioaddr(port)) = value;
167 else 125 else
168 maybebadio(port); 126 maybebadio(port);
169} 127}