aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/se/770x
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/se/770x
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/se/770x')
-rw-r--r--arch/sh/boards/se/770x/Makefile6
-rw-r--r--arch/sh/boards/se/770x/io.c226
-rw-r--r--arch/sh/boards/se/770x/irq.c80
-rw-r--r--arch/sh/boards/se/770x/led.c68
-rw-r--r--arch/sh/boards/se/770x/mach.c68
-rw-r--r--arch/sh/boards/se/770x/setup.c85
6 files changed, 533 insertions, 0 deletions
diff --git a/arch/sh/boards/se/770x/Makefile b/arch/sh/boards/se/770x/Makefile
new file mode 100644
index 000000000000..be89a73cc418
--- /dev/null
+++ b/arch/sh/boards/se/770x/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the 770x SolutionEngine specific parts of the kernel
3#
4
5obj-y := mach.o setup.o io.o irq.o led.o
6
diff --git a/arch/sh/boards/se/770x/io.c b/arch/sh/boards/se/770x/io.c
new file mode 100644
index 000000000000..9a39ee963143
--- /dev/null
+++ b/arch/sh/boards/se/770x/io.c
@@ -0,0 +1,226 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
2 *
3 * linux/arch/sh/kernel/io_se.c
4 *
5 * Copyright (C) 2000 Kazumoto Kojima
6 *
7 * I/O routine for Hitachi SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se/se.h>
15
16/* SH pcmcia io window base, start and end. */
17int sh_pcic_io_wbase = 0xb8400000;
18int sh_pcic_io_start;
19int sh_pcic_io_stop;
20int sh_pcic_io_type;
21int sh_pcic_io_dummy;
22
23static inline void delay(void)
24{
25 ctrl_inw(0xa0000000);
26}
27
28/* MS7750 requires special versions of in*, out* routines, since
29 PC-like io ports are located at upper half byte of 16-bit word which
30 can be accessed only with 16-bit wide. */
31
32static inline volatile __u16 *
33port2adr(unsigned int port)
34{
35 if (port >= 0x2000)
36 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
37 else if (port >= 0x1000)
38 return (volatile __u16 *) (PA_83902 + (port << 1));
39 else if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
40 return (volatile __u16 *) (sh_pcic_io_wbase + (port &~ 1));
41 else
42 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
43}
44
45static inline int
46shifted_port(unsigned long port)
47{
48 /* For IDE registers, value is not shifted */
49 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
50 return 0;
51 else
52 return 1;
53}
54
55#define maybebadio(name,port) \
56 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
57 #name, (port), (__u32) __builtin_return_address(0))
58
59unsigned char se_inb(unsigned long port)
60{
61 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
62 return *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
63 else if (shifted_port(port))
64 return (*port2adr(port) >> 8);
65 else
66 return (*port2adr(port))&0xff;
67}
68
69unsigned char se_inb_p(unsigned long port)
70{
71 unsigned long v;
72
73 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
74 v = *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
75 else if (shifted_port(port))
76 v = (*port2adr(port) >> 8);
77 else
78 v = (*port2adr(port))&0xff;
79 delay();
80 return v;
81}
82
83unsigned short se_inw(unsigned long port)
84{
85 if (port >= 0x2000 ||
86 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
87 return *port2adr(port);
88 else
89 maybebadio(inw, port);
90 return 0;
91}
92
93unsigned int se_inl(unsigned long port)
94{
95 maybebadio(inl, port);
96 return 0;
97}
98
99void se_outb(unsigned char value, unsigned long port)
100{
101 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
102 *(__u8 *)(sh_pcic_io_wbase + port) = value;
103 else if (shifted_port(port))
104 *(port2adr(port)) = value << 8;
105 else
106 *(port2adr(port)) = value;
107}
108
109void se_outb_p(unsigned char value, unsigned long port)
110{
111 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
112 *(__u8 *)(sh_pcic_io_wbase + port) = value;
113 else if (shifted_port(port))
114 *(port2adr(port)) = value << 8;
115 else
116 *(port2adr(port)) = value;
117 delay();
118}
119
120void se_outw(unsigned short value, unsigned long port)
121{
122 if (port >= 0x2000 ||
123 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
124 *port2adr(port) = value;
125 else
126 maybebadio(outw, port);
127}
128
129void se_outl(unsigned int value, unsigned long port)
130{
131 maybebadio(outl, port);
132}
133
134void se_insb(unsigned long port, void *addr, unsigned long count)
135{
136 volatile __u16 *p = port2adr(port);
137 __u8 *ap = addr;
138
139 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
140 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
141 while (count--)
142 *ap++ = *bp;
143 } else if (shifted_port(port)) {
144 while (count--)
145 *ap++ = *p >> 8;
146 } else {
147 while (count--)
148 *ap++ = *p;
149 }
150}
151
152void se_insw(unsigned long port, void *addr, unsigned long count)
153{
154 volatile __u16 *p = port2adr(port);
155 __u16 *ap = addr;
156 while (count--)
157 *ap++ = *p;
158}
159
160void se_insl(unsigned long port, void *addr, unsigned long count)
161{
162 maybebadio(insl, port);
163}
164
165void se_outsb(unsigned long port, const void *addr, unsigned long count)
166{
167 volatile __u16 *p = port2adr(port);
168 const __u8 *ap = addr;
169
170 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) {
171 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + port);
172 while (count--)
173 *bp = *ap++;
174 } else if (shifted_port(port)) {
175 while (count--)
176 *p = *ap++ << 8;
177 } else {
178 while (count--)
179 *p = *ap++;
180 }
181}
182
183void se_outsw(unsigned long port, const void *addr, unsigned long count)
184{
185 volatile __u16 *p = port2adr(port);
186 const __u16 *ap = addr;
187 while (count--)
188 *p = *ap++;
189}
190
191void se_outsl(unsigned long port, const void *addr, unsigned long count)
192{
193 maybebadio(outsw, port);
194}
195
196/* Map ISA bus address to the real address. Only for PCMCIA. */
197
198/* ISA page descriptor. */
199static __u32 sh_isa_memmap[256];
200
201static int
202sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
203{
204 int idx;
205
206 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
207 return -1;
208
209 idx = start >> 12;
210 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
211#if 0
212 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
213 start, length, offset, idx, sh_isa_memmap[idx]);
214#endif
215 return 0;
216}
217
218unsigned long
219se_isa_port2addr(unsigned long offset)
220{
221 int idx;
222
223 idx = (offset >> 12) & 0xff;
224 offset &= 0xfff;
225 return sh_isa_memmap[idx] + offset;
226}
diff --git a/arch/sh/boards/se/770x/irq.c b/arch/sh/boards/se/770x/irq.c
new file mode 100644
index 000000000000..210897b315f4
--- /dev/null
+++ b/arch/sh/boards/se/770x/irq.c
@@ -0,0 +1,80 @@
1/*
2 * linux/arch/sh/boards/se/770x/irq.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 */
9
10#include <linux/config.h>
11#include <linux/init.h>
12#include <linux/irq.h>
13#include <asm/irq.h>
14#include <asm/io.h>
15#include <asm/se/se.h>
16
17/*
18 * Initialize IRQ setting
19 */
20void __init init_se_IRQ(void)
21{
22 /*
23 * Super I/O (Just mimic PC):
24 * 1: keyboard
25 * 3: serial 0
26 * 4: serial 1
27 * 5: printer
28 * 6: floppy
29 * 8: rtc
30 * 12: mouse
31 * 14: ide0
32 */
33#if defined(CONFIG_CPU_SUBTYPE_SH7705)
34 /* Disable all interrupts */
35 ctrl_outw(0, BCR_ILCRA);
36 ctrl_outw(0, BCR_ILCRB);
37 ctrl_outw(0, BCR_ILCRC);
38 ctrl_outw(0, BCR_ILCRD);
39 ctrl_outw(0, BCR_ILCRE);
40 ctrl_outw(0, BCR_ILCRF);
41 ctrl_outw(0, BCR_ILCRG);
42 /* This is default value */
43 make_ipr_irq(0xf-0x2, BCR_ILCRA, 2, 0x2);
44 make_ipr_irq(0xf-0xa, BCR_ILCRA, 1, 0xa);
45 make_ipr_irq(0xf-0x5, BCR_ILCRB, 0, 0x5);
46 make_ipr_irq(0xf-0x8, BCR_ILCRC, 1, 0x8);
47 make_ipr_irq(0xf-0xc, BCR_ILCRC, 0, 0xc);
48 make_ipr_irq(0xf-0xe, BCR_ILCRD, 3, 0xe);
49 make_ipr_irq(0xf-0x3, BCR_ILCRD, 1, 0x3); /* LAN */
50 make_ipr_irq(0xf-0xd, BCR_ILCRE, 2, 0xd);
51 make_ipr_irq(0xf-0x9, BCR_ILCRE, 1, 0x9);
52 make_ipr_irq(0xf-0x1, BCR_ILCRE, 0, 0x1);
53 make_ipr_irq(0xf-0xf, BCR_ILCRF, 3, 0xf);
54 make_ipr_irq(0xf-0xb, BCR_ILCRF, 1, 0xb);
55 make_ipr_irq(0xf-0x7, BCR_ILCRG, 3, 0x7);
56 make_ipr_irq(0xf-0x6, BCR_ILCRG, 2, 0x6);
57 make_ipr_irq(0xf-0x4, BCR_ILCRG, 1, 0x4);
58#else
59 make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14);
60 make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12);
61 make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8);
62 make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6);
63 make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5);
64 make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4);
65 make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3);
66 make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1);
67
68 make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */
69
70 make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */
71 make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */
72 make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */
73 make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */
74
75 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
76 /* NOTE: #2 and #13 are not used on PC */
77 make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */
78 make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */
79#endif
80}
diff --git a/arch/sh/boards/se/770x/led.c b/arch/sh/boards/se/770x/led.c
new file mode 100644
index 000000000000..5c64e8ab2cfb
--- /dev/null
+++ b/arch/sh/boards/se/770x/led.c
@@ -0,0 +1,68 @@
1/*
2 * linux/arch/sh/kernel/led_se.c
3 *
4 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * This file contains Solution Engine specific LED code.
10 */
11
12#include <linux/config.h>
13#include <asm/se/se.h>
14
15static void mach_led(int position, int value)
16{
17 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
18
19 if (value) {
20 *p |= (1<<8);
21 } else {
22 *p &= ~(1<<8);
23 }
24}
25
26#ifdef CONFIG_HEARTBEAT
27
28#include <linux/sched.h>
29
30/* Cycle the LED's in the clasic Knightrider/Sun pattern */
31void heartbeat_se(void)
32{
33 static unsigned int cnt = 0, period = 0;
34 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
35 static unsigned bit = 0, up = 1;
36
37 cnt += 1;
38 if (cnt < period) {
39 return;
40 }
41
42 cnt = 0;
43
44 /* Go through the points (roughly!):
45 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
46 */
47 period = 110 - ( (300<<FSHIFT)/
48 ((avenrun[0]/5) + (3<<FSHIFT)) );
49
50 if (up) {
51 if (bit == 7) {
52 bit--;
53 up=0;
54 } else {
55 bit ++;
56 }
57 } else {
58 if (bit == 0) {
59 bit++;
60 up=1;
61 } else {
62 bit--;
63 }
64 }
65 *p = 1<<(bit+8);
66
67}
68#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
new file mode 100644
index 000000000000..f9b4c56cc47e
--- /dev/null
+++ b/arch/sh/boards/se/770x/mach.c
@@ -0,0 +1,68 @@
1/*
2 * linux/arch/sh/kernel/mach_se.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the Hitachi SolutionEngine
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14
15#include <asm/machvec.h>
16#include <asm/rtc.h>
17#include <asm/machvec_init.h>
18
19#include <asm/se/io.h>
20
21void heartbeat_se(void);
22void setup_se(void);
23void init_se_IRQ(void);
24
25/*
26 * The Machine Vector
27 */
28
29struct sh_machine_vector mv_se __initmv = {
30#if defined(CONFIG_CPU_SH4)
31 .mv_nr_irqs = 48,
32#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
33 .mv_nr_irqs = 32,
34#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
35 .mv_nr_irqs = 61,
36#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
37 .mv_nr_irqs = 86,
38#endif
39
40 .mv_inb = se_inb,
41 .mv_inw = se_inw,
42 .mv_inl = se_inl,
43 .mv_outb = se_outb,
44 .mv_outw = se_outw,
45 .mv_outl = se_outl,
46
47 .mv_inb_p = se_inb_p,
48 .mv_inw_p = se_inw,
49 .mv_inl_p = se_inl,
50 .mv_outb_p = se_outb_p,
51 .mv_outw_p = se_outw,
52 .mv_outl_p = se_outl,
53
54 .mv_insb = se_insb,
55 .mv_insw = se_insw,
56 .mv_insl = se_insl,
57 .mv_outsb = se_outsb,
58 .mv_outsw = se_outsw,
59 .mv_outsl = se_outsl,
60
61 .mv_isa_port2addr = se_isa_port2addr,
62
63 .mv_init_irq = init_se_IRQ,
64#ifdef CONFIG_HEARTBEAT
65 .mv_heartbeat = heartbeat_se,
66#endif
67};
68ALIAS_MV(se)
diff --git a/arch/sh/boards/se/770x/setup.c b/arch/sh/boards/se/770x/setup.c
new file mode 100644
index 000000000000..2bed46fb607d
--- /dev/null
+++ b/arch/sh/boards/se/770x/setup.c
@@ -0,0 +1,85 @@
1/* $Id: setup.c,v 1.1.2.4 2002/03/02 21:57:07 lethal Exp $
2 *
3 * linux/arch/sh/boards/se/770x/setup.c
4 *
5 * Copyright (C) 2000 Kazumoto Kojima
6 *
7 * Hitachi SolutionEngine Support.
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/irq.h>
14
15#include <linux/hdreg.h>
16#include <linux/ide.h>
17#include <asm/io.h>
18#include <asm/se/se.h>
19#include <asm/se/smc37c93x.h>
20
21/*
22 * Configure the Super I/O chip
23 */
24static void __init smsc_config(int index, int data)
25{
26 outb_p(index, INDEX_PORT);
27 outb_p(data, DATA_PORT);
28}
29
30static void __init init_smsc(void)
31{
32 outb_p(CONFIG_ENTER, CONFIG_PORT);
33 outb_p(CONFIG_ENTER, CONFIG_PORT);
34
35 /* FDC */
36 smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
37 smsc_config(ACTIVATE_INDEX, 0x01);
38 smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
39
40 /* IDE1 */
41 smsc_config(CURRENT_LDN_INDEX, LDN_IDE1);
42 smsc_config(ACTIVATE_INDEX, 0x01);
43 smsc_config(IRQ_SELECT_INDEX, 14); /* IRQ14 */
44
45 /* AUXIO (GPIO): to use IDE1 */
46 smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
47 smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
48 smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
49
50 /* COM1 */
51 smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
52 smsc_config(ACTIVATE_INDEX, 0x01);
53 smsc_config(IO_BASE_HI_INDEX, 0x03);
54 smsc_config(IO_BASE_LO_INDEX, 0xf8);
55 smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
56
57 /* COM2 */
58 smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
59 smsc_config(ACTIVATE_INDEX, 0x01);
60 smsc_config(IO_BASE_HI_INDEX, 0x02);
61 smsc_config(IO_BASE_LO_INDEX, 0xf8);
62 smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
63
64 /* RTC */
65 smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
66 smsc_config(ACTIVATE_INDEX, 0x01);
67 smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
68
69 /* XXX: PARPORT, KBD, and MOUSE will come here... */
70 outb_p(CONFIG_EXIT, CONFIG_PORT);
71}
72
73const char *get_system_type(void)
74{
75 return "SolutionEngine";
76}
77
78/*
79 * Initialize the board
80 */
81void __init platform_setup(void)
82{
83 init_smsc();
84 /* XXX: RTC setting comes here */
85}