aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/renesas/systemh
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/boards/renesas/systemh
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sh/boards/renesas/systemh')
-rw-r--r--arch/sh/boards/renesas/systemh/Makefile13
-rw-r--r--arch/sh/boards/renesas/systemh/io.c283
-rw-r--r--arch/sh/boards/renesas/systemh/irq.c111
-rw-r--r--arch/sh/boards/renesas/systemh/setup.c80
4 files changed, 487 insertions, 0 deletions
diff --git a/arch/sh/boards/renesas/systemh/Makefile b/arch/sh/boards/renesas/systemh/Makefile
new file mode 100644
index 000000000000..2cc6a23d9d39
--- /dev/null
+++ b/arch/sh/boards/renesas/systemh/Makefile
@@ -0,0 +1,13 @@
1#
2# Makefile for the SystemH specific parts of the kernel
3#
4
5obj-y := setup.o irq.o io.o
6
7# XXX: This wants to be consolidated in arch/sh/drivers/pci, and more
8# importantly, with the generic sh7751_pcic_init() code. For now, we'll
9# just abuse the hell out of kbuild, because we can..
10
11obj-$(CONFIG_PCI) += pci.o
12pci-y := ../../se/7751/pci.o
13
diff --git a/arch/sh/boards/renesas/systemh/io.c b/arch/sh/boards/renesas/systemh/io.c
new file mode 100644
index 000000000000..cf979011aa94
--- /dev/null
+++ b/arch/sh/boards/renesas/systemh/io.c
@@ -0,0 +1,283 @@
1/*
2 * linux/arch/sh/boards/systemh/io.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
6 *
7 * I/O routine for Hitachi 7751 Systemh.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/systemh/7751systemh.h>
14#include <asm/addrspace.h>
15#include <asm/io.h>
16
17#include <linux/pci.h>
18#include "../../drivers/pci/pci-sh7751.h"
19
20/*
21 * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
22 * of the 7751 processor, and has a SuperIO accessible on its memory
23 * bus.
24 */
25
26#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
27#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
28#define PCI_IO_AREA SH7751_PCI_IO_BASE
29#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
30
31#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
32#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
33 of smc lan chip*/
34
35#define maybebadio(name,port) \
36 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
37 #name, (port), (__u32) __builtin_return_address(0))
38
39static inline void delay(void)
40{
41 ctrl_inw(0xa0000000);
42}
43
44static inline volatile __u16 *
45port2adr(unsigned int port)
46{
47 if (port >= 0x2000)
48 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
49#if 0
50 else
51 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
52#endif
53 maybebadio(name,(unsigned long)port);
54 return (volatile __u16*)port;
55}
56
57/* In case someone configures the kernel w/o PCI support: in that */
58/* scenario, don't ever bother to check for PCI-window addresses */
59
60/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
61#if defined(CONFIG_PCI)
62#define CHECK_SH7751_PCIIO(port) \
63 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
64#else
65#define CHECK_SH7751_PCIIO(port) (0)
66#endif
67
68/*
69 * General outline: remap really low stuff [eventually] to SuperIO,
70 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
71 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
72 * should be way beyond the window, and is used w/o translation for
73 * compatibility.
74 */
75unsigned char sh7751systemh_inb(unsigned long port)
76{
77 if (PXSEG(port))
78 return *(volatile unsigned char *)port;
79 else if (CHECK_SH7751_PCIIO(port))
80 return *(volatile unsigned char *)PCI_IOMAP(port);
81 else if (port <= 0x3F1)
82 return *(volatile unsigned char *)ETHER_IOMAP(port);
83 else
84 return (*port2adr(port))&0xff;
85}
86
87unsigned char sh7751systemh_inb_p(unsigned long port)
88{
89 unsigned char v;
90
91 if (PXSEG(port))
92 v = *(volatile unsigned char *)port;
93 else if (CHECK_SH7751_PCIIO(port))
94 v = *(volatile unsigned char *)PCI_IOMAP(port);
95 else if (port <= 0x3F1)
96 v = *(volatile unsigned char *)ETHER_IOMAP(port);
97 else
98 v = (*port2adr(port))&0xff;
99 delay();
100 return v;
101}
102
103unsigned short sh7751systemh_inw(unsigned long port)
104{
105 if (PXSEG(port))
106 return *(volatile unsigned short *)port;
107 else if (CHECK_SH7751_PCIIO(port))
108 return *(volatile unsigned short *)PCI_IOMAP(port);
109 else if (port >= 0x2000)
110 return *port2adr(port);
111 else if (port <= 0x3F1)
112 return *(volatile unsigned int *)ETHER_IOMAP(port);
113 else
114 maybebadio(inw, port);
115 return 0;
116}
117
118unsigned int sh7751systemh_inl(unsigned long port)
119{
120 if (PXSEG(port))
121 return *(volatile unsigned long *)port;
122 else if (CHECK_SH7751_PCIIO(port))
123 return *(volatile unsigned int *)PCI_IOMAP(port);
124 else if (port >= 0x2000)
125 return *port2adr(port);
126 else if (port <= 0x3F1)
127 return *(volatile unsigned int *)ETHER_IOMAP(port);
128 else
129 maybebadio(inl, port);
130 return 0;
131}
132
133void sh7751systemh_outb(unsigned char value, unsigned long port)
134{
135
136 if (PXSEG(port))
137 *(volatile unsigned char *)port = value;
138 else if (CHECK_SH7751_PCIIO(port))
139 *((unsigned char*)PCI_IOMAP(port)) = value;
140 else if (port <= 0x3F1)
141 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
142 else
143 *(port2adr(port)) = value;
144}
145
146void sh7751systemh_outb_p(unsigned char value, unsigned long port)
147{
148 if (PXSEG(port))
149 *(volatile unsigned char *)port = value;
150 else if (CHECK_SH7751_PCIIO(port))
151 *((unsigned char*)PCI_IOMAP(port)) = value;
152 else if (port <= 0x3F1)
153 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
154 else
155 *(port2adr(port)) = value;
156 delay();
157}
158
159void sh7751systemh_outw(unsigned short value, unsigned long port)
160{
161 if (PXSEG(port))
162 *(volatile unsigned short *)port = value;
163 else if (CHECK_SH7751_PCIIO(port))
164 *((unsigned short *)PCI_IOMAP(port)) = value;
165 else if (port >= 0x2000)
166 *port2adr(port) = value;
167 else if (port <= 0x3F1)
168 *(volatile unsigned short *)ETHER_IOMAP(port) = value;
169 else
170 maybebadio(outw, port);
171}
172
173void sh7751systemh_outl(unsigned int value, unsigned long port)
174{
175 if (PXSEG(port))
176 *(volatile unsigned long *)port = value;
177 else if (CHECK_SH7751_PCIIO(port))
178 *((unsigned long*)PCI_IOMAP(port)) = value;
179 else
180 maybebadio(outl, port);
181}
182
183void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
184{
185 unsigned char *p = addr;
186 while (count--) *p++ = sh7751systemh_inb(port);
187}
188
189void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
190{
191 unsigned short *p = addr;
192 while (count--) *p++ = sh7751systemh_inw(port);
193}
194
195void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
196{
197 maybebadio(insl, port);
198}
199
200void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
201{
202 unsigned char *p = (unsigned char*)addr;
203 while (count--) sh7751systemh_outb(*p++, port);
204}
205
206void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count)
207{
208 unsigned short *p = (unsigned short*)addr;
209 while (count--) sh7751systemh_outw(*p++, port);
210}
211
212void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
213{
214 maybebadio(outsw, port);
215}
216
217/* For read/write calls, just copy generic (pass-thru); PCIMBR is */
218/* already set up. For a larger memory space, these would need to */
219/* reset PCIMBR as needed on a per-call basis... */
220
221unsigned char sh7751systemh_readb(unsigned long addr)
222{
223 return *(volatile unsigned char*)addr;
224}
225
226unsigned short sh7751systemh_readw(unsigned long addr)
227{
228 return *(volatile unsigned short*)addr;
229}
230
231unsigned int sh7751systemh_readl(unsigned long addr)
232{
233 return *(volatile unsigned long*)addr;
234}
235
236void sh7751systemh_writeb(unsigned char b, unsigned long addr)
237{
238 *(volatile unsigned char*)addr = b;
239}
240
241void sh7751systemh_writew(unsigned short b, unsigned long addr)
242{
243 *(volatile unsigned short*)addr = b;
244}
245
246void sh7751systemh_writel(unsigned int b, unsigned long addr)
247{
248 *(volatile unsigned long*)addr = b;
249}
250
251
252
253/* Map ISA bus address to the real address. Only for PCMCIA. */
254
255/* ISA page descriptor. */
256static __u32 sh_isa_memmap[256];
257
258#if 0
259static int
260sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
261{
262 int idx;
263
264 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
265 return -1;
266
267 idx = start >> 12;
268 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
269 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
270 start, length, offset, idx, sh_isa_memmap[idx]);
271 return 0;
272}
273#endif
274
275unsigned long
276sh7751systemh_isa_port2addr(unsigned long offset)
277{
278 int idx;
279
280 idx = (offset >> 12) & 0xff;
281 offset &= 0xfff;
282 return sh_isa_memmap[idx] + offset;
283}
diff --git a/arch/sh/boards/renesas/systemh/irq.c b/arch/sh/boards/renesas/systemh/irq.c
new file mode 100644
index 000000000000..5675a4134eee
--- /dev/null
+++ b/arch/sh/boards/renesas/systemh/irq.c
@@ -0,0 +1,111 @@
1/*
2 * linux/arch/sh/boards/systemh/irq.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Hitachi SystemH Support.
7 *
8 * Modified for 7751 SystemH by
9 * Jonathan Short.
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14#include <linux/irq.h>
15
16#include <linux/hdreg.h>
17#include <linux/ide.h>
18#include <asm/io.h>
19#include <asm/mach/7751systemh.h>
20#include <asm/smc37c93x.h>
21
22/* address of external interrupt mask register
23 * address must be set prior to use these (maybe in init_XXX_irq())
24 * XXX : is it better to use .config than specifying it in code? */
25static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
26static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
27
28/* forward declaration */
29static unsigned int startup_systemh_irq(unsigned int irq);
30static void shutdown_systemh_irq(unsigned int irq);
31static void enable_systemh_irq(unsigned int irq);
32static void disable_systemh_irq(unsigned int irq);
33static void mask_and_ack_systemh(unsigned int);
34static void end_systemh_irq(unsigned int irq);
35
36/* hw_interrupt_type */
37static struct hw_interrupt_type systemh_irq_type = {
38 " SystemH Register",
39 startup_systemh_irq,
40 shutdown_systemh_irq,
41 enable_systemh_irq,
42 disable_systemh_irq,
43 mask_and_ack_systemh,
44 end_systemh_irq
45};
46
47static unsigned int startup_systemh_irq(unsigned int irq)
48{
49 enable_systemh_irq(irq);
50 return 0; /* never anything pending */
51}
52
53static void shutdown_systemh_irq(unsigned int irq)
54{
55 disable_systemh_irq(irq);
56}
57
58static void disable_systemh_irq(unsigned int irq)
59{
60 if (systemh_irq_mask_register) {
61 unsigned long flags;
62 unsigned long val, mask = 0x01 << 1;
63
64 /* Clear the "irq"th bit in the mask and set it in the request */
65 local_irq_save(flags);
66
67 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
68 val &= ~mask;
69 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
70
71 val = ctrl_inl((unsigned long)systemh_irq_request_register);
72 val |= mask;
73 ctrl_outl(val, (unsigned long)systemh_irq_request_register);
74
75 local_irq_restore(flags);
76 }
77}
78
79static void enable_systemh_irq(unsigned int irq)
80{
81 if (systemh_irq_mask_register) {
82 unsigned long flags;
83 unsigned long val, mask = 0x01 << 1;
84
85 /* Set "irq"th bit in the mask register */
86 local_irq_save(flags);
87 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
88 val |= mask;
89 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
90 local_irq_restore(flags);
91 }
92}
93
94static void mask_and_ack_systemh(unsigned int irq)
95{
96 disable_systemh_irq(irq);
97}
98
99static void end_systemh_irq(unsigned int irq)
100{
101 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
102 enable_systemh_irq(irq);
103}
104
105void make_systemh_irq(unsigned int irq)
106{
107 disable_irq_nosync(irq);
108 irq_desc[irq].handler = &systemh_irq_type;
109 disable_systemh_irq(irq);
110}
111
diff --git a/arch/sh/boards/renesas/systemh/setup.c b/arch/sh/boards/renesas/systemh/setup.c
new file mode 100644
index 000000000000..826fa3d7669c
--- /dev/null
+++ b/arch/sh/boards/renesas/systemh/setup.c
@@ -0,0 +1,80 @@
1/*
2 * linux/arch/sh/boards/systemh/setup.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 * Copyright (C) 2003 Paul Mundt
6 *
7 * Hitachi SystemH Support.
8 *
9 * Modified for 7751 SystemH by Jonathan Short.
10 *
11 * Rewritten for 2.6 by Paul Mundt.
12 *
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
16 */
17#include <linux/init.h>
18#include <asm/mach/7751systemh.h>
19#include <asm/mach/io.h>
20#include <asm/machvec.h>
21
22extern void make_systemh_irq(unsigned int irq);
23
24const char *get_system_type(void)
25{
26 return "7751 SystemH";
27}
28
29/*
30 * Initialize IRQ setting
31 */
32void __init init_7751systemh_IRQ(void)
33{
34/* make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); LAN */
35/* make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-4); */
36 make_systemh_irq(0xb); /* Ethernet interrupt */
37}
38
39struct sh_machine_vector mv_7751systemh __initmv = {
40 .mv_nr_irqs = 72,
41
42 .mv_inb = sh7751systemh_inb,
43 .mv_inw = sh7751systemh_inw,
44 .mv_inl = sh7751systemh_inl,
45 .mv_outb = sh7751systemh_outb,
46 .mv_outw = sh7751systemh_outw,
47 .mv_outl = sh7751systemh_outl,
48
49 .mv_inb_p = sh7751systemh_inb_p,
50 .mv_inw_p = sh7751systemh_inw,
51 .mv_inl_p = sh7751systemh_inl,
52 .mv_outb_p = sh7751systemh_outb_p,
53 .mv_outw_p = sh7751systemh_outw,
54 .mv_outl_p = sh7751systemh_outl,
55
56 .mv_insb = sh7751systemh_insb,
57 .mv_insw = sh7751systemh_insw,
58 .mv_insl = sh7751systemh_insl,
59 .mv_outsb = sh7751systemh_outsb,
60 .mv_outsw = sh7751systemh_outsw,
61 .mv_outsl = sh7751systemh_outsl,
62
63 .mv_readb = sh7751systemh_readb,
64 .mv_readw = sh7751systemh_readw,
65 .mv_readl = sh7751systemh_readl,
66 .mv_writeb = sh7751systemh_writeb,
67 .mv_writew = sh7751systemh_writew,
68 .mv_writel = sh7751systemh_writel,
69
70 .mv_isa_port2addr = sh7751systemh_isa_port2addr,
71
72 .mv_init_irq = init_7751systemh_IRQ,
73};
74ALIAS_MV(7751systemh)
75
76int __init platform_setup(void)
77{
78 return 0;
79}
80