aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/mach-snapgear
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/mach-snapgear')
-rw-r--r--arch/sh/boards/mach-snapgear/Makefile5
-rw-r--r--arch/sh/boards/mach-snapgear/io.c137
-rw-r--r--arch/sh/boards/mach-snapgear/setup.c95
3 files changed, 237 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-snapgear/Makefile b/arch/sh/boards/mach-snapgear/Makefile
new file mode 100644
index 000000000000..d2d2f4b6a502
--- /dev/null
+++ b/arch/sh/boards/mach-snapgear/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the SnapGear specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/mach-snapgear/io.c b/arch/sh/boards/mach-snapgear/io.c
new file mode 100644
index 000000000000..0f4824264557
--- /dev/null
+++ b/arch/sh/boards/mach-snapgear/io.c
@@ -0,0 +1,137 @@
1/*
2 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
3 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
4 * Based largely on io_se.c.
5 *
6 * I/O routine for Hitachi 7751 SolutionEngine.
7 *
8 * Initial version only to support LAN access; some
9 * placeholder code from io_se.c left in with the
10 * expectation of later SuperIO and PCMCIA access.
11 */
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/pci.h>
15#include <asm/io.h>
16#include <asm/addrspace.h>
17
18#ifdef CONFIG_SH_SECUREEDGE5410
19unsigned short secureedge5410_ioport;
20#endif
21
22static inline volatile __u16 *port2adr(unsigned int port)
23{
24 maybebadio((unsigned long)port);
25 return (volatile __u16*)port;
26}
27
28/*
29 * General outline: remap really low stuff [eventually] to SuperIO,
30 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
31 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
32 * should be way beyond the window, and is used w/o translation for
33 * compatibility.
34 */
35unsigned char snapgear_inb(unsigned long port)
36{
37 if (PXSEG(port))
38 return *(volatile unsigned char *)port;
39 else if (is_pci_ioaddr(port))
40 return *(volatile unsigned char *)pci_ioaddr(port);
41 else
42 return (*port2adr(port)) & 0xff;
43}
44
45unsigned char snapgear_inb_p(unsigned long port)
46{
47 unsigned char v;
48
49 if (PXSEG(port))
50 v = *(volatile unsigned char *)port;
51 else if (is_pci_ioaddr(port))
52 v = *(volatile unsigned char *)pci_ioaddr(port);
53 else
54 v = (*port2adr(port))&0xff;
55 ctrl_delay();
56 return v;
57}
58
59unsigned short snapgear_inw(unsigned long port)
60{
61 if (PXSEG(port))
62 return *(volatile unsigned short *)port;
63 else if (is_pci_ioaddr(port))
64 return *(volatile unsigned short *)pci_ioaddr(port);
65 else if (port >= 0x2000)
66 return *port2adr(port);
67 else
68 maybebadio(port);
69 return 0;
70}
71
72unsigned int snapgear_inl(unsigned long port)
73{
74 if (PXSEG(port))
75 return *(volatile unsigned long *)port;
76 else if (is_pci_ioaddr(port))
77 return *(volatile unsigned int *)pci_ioaddr(port);
78 else if (port >= 0x2000)
79 return *port2adr(port);
80 else
81 maybebadio(port);
82 return 0;
83}
84
85void snapgear_outb(unsigned char value, unsigned long port)
86{
87
88 if (PXSEG(port))
89 *(volatile unsigned char *)port = value;
90 else if (is_pci_ioaddr(port))
91 *((unsigned char*)pci_ioaddr(port)) = value;
92 else
93 *(port2adr(port)) = value;
94}
95
96void snapgear_outb_p(unsigned char value, unsigned long port)
97{
98 if (PXSEG(port))
99 *(volatile unsigned char *)port = value;
100 else if (is_pci_ioaddr(port))
101 *((unsigned char*)pci_ioaddr(port)) = value;
102 else
103 *(port2adr(port)) = value;
104 ctrl_delay();
105}
106
107void snapgear_outw(unsigned short value, unsigned long port)
108{
109 if (PXSEG(port))
110 *(volatile unsigned short *)port = value;
111 else if (is_pci_ioaddr(port))
112 *((unsigned short *)pci_ioaddr(port)) = value;
113 else if (port >= 0x2000)
114 *port2adr(port) = value;
115 else
116 maybebadio(port);
117}
118
119void snapgear_outl(unsigned int value, unsigned long port)
120{
121 if (PXSEG(port))
122 *(volatile unsigned long *)port = value;
123 else if (is_pci_ioaddr(port))
124 *((unsigned long*)pci_ioaddr(port)) = value;
125 else
126 maybebadio(port);
127}
128
129void snapgear_insl(unsigned long port, void *addr, unsigned long count)
130{
131 maybebadio(port);
132}
133
134void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
135{
136 maybebadio(port);
137}
diff --git a/arch/sh/boards/mach-snapgear/setup.c b/arch/sh/boards/mach-snapgear/setup.c
new file mode 100644
index 000000000000..a5e349d3dda2
--- /dev/null
+++ b/arch/sh/boards/mach-snapgear/setup.c
@@ -0,0 +1,95 @@
1/*
2 * linux/arch/sh/boards/snapgear/setup.c
3 *
4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
5 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
6 *
7 * Based on files with the following comments:
8 *
9 * Copyright (C) 2000 Kazumoto Kojima
10 *
11 * Modified for 7751 Solution Engine by
12 * Ian da Silva and Jeremy Siegel, 2001.
13 */
14#include <linux/init.h>
15#include <linux/irq.h>
16#include <linux/interrupt.h>
17#include <linux/timer.h>
18#include <linux/delay.h>
19#include <linux/module.h>
20#include <linux/sched.h>
21#include <asm/machvec.h>
22#include <asm/snapgear.h>
23#include <asm/irq.h>
24#include <asm/io.h>
25#include <cpu/timer.h>
26
27/*
28 * EraseConfig handling functions
29 */
30
31static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id)
32{
33 (void)ctrl_inb(0xb8000000); /* dummy read */
34
35 printk("SnapGear: erase switch interrupt!\n");
36
37 return IRQ_HANDLED;
38}
39
40static int __init eraseconfig_init(void)
41{
42 printk("SnapGear: EraseConfig init\n");
43 /* Setup "EraseConfig" switch on external IRQ 0 */
44 if (request_irq(IRL0_IRQ, eraseconfig_interrupt, IRQF_DISABLED,
45 "Erase Config", NULL))
46 printk("SnapGear: failed to register IRQ%d for Reset witch\n",
47 IRL0_IRQ);
48 else
49 printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
50 IRL0_IRQ);
51 return(0);
52}
53
54module_init(eraseconfig_init);
55
56/****************************************************************************/
57/*
58 * Initialize IRQ setting
59 *
60 * IRL0 = erase switch
61 * IRL1 = eth0
62 * IRL2 = eth1
63 * IRL3 = crypto
64 */
65
66static void __init init_snapgear_IRQ(void)
67{
68 printk("Setup SnapGear IRQ/IPR ...\n");
69 /* enable individual interrupt mode for externals */
70 plat_irq_setup_pins(IRQ_MODE_IRQ);
71}
72
73/*
74 * The Machine Vector
75 */
76static struct sh_machine_vector mv_snapgear __initmv = {
77 .mv_name = "SnapGear SecureEdge5410",
78 .mv_nr_irqs = 72,
79
80 .mv_inb = snapgear_inb,
81 .mv_inw = snapgear_inw,
82 .mv_inl = snapgear_inl,
83 .mv_outb = snapgear_outb,
84 .mv_outw = snapgear_outw,
85 .mv_outl = snapgear_outl,
86
87 .mv_inb_p = snapgear_inb_p,
88 .mv_inw_p = snapgear_inw,
89 .mv_inl_p = snapgear_inl,
90 .mv_outb_p = snapgear_outb_p,
91 .mv_outw_p = snapgear_outw,
92 .mv_outl_p = snapgear_outl,
93
94 .mv_init_irq = init_snapgear_IRQ,
95};