aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh64/mach-cayman
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/sh64/mach-cayman
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/sh64/mach-cayman')
-rw-r--r--arch/sh64/mach-cayman/Makefile11
-rw-r--r--arch/sh64/mach-cayman/iomap.c24
-rw-r--r--arch/sh64/mach-cayman/irq.c196
-rw-r--r--arch/sh64/mach-cayman/led.c51
-rw-r--r--arch/sh64/mach-cayman/setup.c246
5 files changed, 528 insertions, 0 deletions
diff --git a/arch/sh64/mach-cayman/Makefile b/arch/sh64/mach-cayman/Makefile
new file mode 100644
index 000000000000..67a2258bf8c4
--- /dev/null
+++ b/arch/sh64/mach-cayman/Makefile
@@ -0,0 +1,11 @@
1#
2# Makefile for the Hitachi Cayman specific parts of the kernel
3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8
9obj-y := setup.o irq.o iomap.o
10obj-$(CONFIG_HEARTBEAT) += led.o
11
diff --git a/arch/sh64/mach-cayman/iomap.c b/arch/sh64/mach-cayman/iomap.c
new file mode 100644
index 000000000000..d6a538c70709
--- /dev/null
+++ b/arch/sh64/mach-cayman/iomap.c
@@ -0,0 +1,24 @@
1/*
2 * arch/sh64/mach-cayman/iomap.c
3 *
4 * Cayman iomap interface
5 *
6 * Copyright (C) 2004 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/config.h>
13#include <linux/pci.h>
14#include <asm/io.h>
15#include <asm/cayman.h>
16
17void __iomem *ioport_map(unsigned long port, unsigned int len)
18{
19 if (port < 0x400)
20 return (void __iomem *)((port << 2) | smsc_superio_virt);
21
22 return (void __iomem *)port;
23}
24
diff --git a/arch/sh64/mach-cayman/irq.c b/arch/sh64/mach-cayman/irq.c
new file mode 100644
index 000000000000..f797c84bfdd1
--- /dev/null
+++ b/arch/sh64/mach-cayman/irq.c
@@ -0,0 +1,196 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/kernel/irq_cayman.c
7 *
8 * SH-5 Cayman Interrupt Support
9 *
10 * This file handles the board specific parts of the Cayman interrupt system
11 *
12 * Copyright (C) 2002 Stuart Menefy
13 */
14
15#include <linux/config.h>
16#include <asm/irq.h>
17#include <asm/page.h>
18#include <asm/io.h>
19#include <linux/irq.h>
20#include <linux/interrupt.h>
21#include <linux/signal.h>
22#include <asm/cayman.h>
23
24unsigned long epld_virt;
25
26#define EPLD_BASE 0x04002000
27#define EPLD_STATUS_BASE (epld_virt + 0x10)
28#define EPLD_MASK_BASE (epld_virt + 0x20)
29
30/* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto
31 the same SH-5 interrupt */
32
33static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id, struct pt_regs *regs)
34{
35 printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n");
36 return IRQ_NONE;
37}
38
39static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id, struct pt_regs *regs)
40{
41 printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq);
42 return IRQ_NONE;
43}
44
45static struct irqaction cayman_action_smsc = {
46 .name = "Cayman SMSC Mux",
47 .handler = cayman_interrupt_smsc,
48 .flags = SA_INTERRUPT,
49};
50
51static struct irqaction cayman_action_pci2 = {
52 .name = "Cayman PCI2 Mux",
53 .handler = cayman_interrupt_pci2,
54 .flags = SA_INTERRUPT,
55};
56
57static void enable_cayman_irq(unsigned int irq)
58{
59 unsigned long flags;
60 unsigned long mask;
61 unsigned int reg;
62 unsigned char bit;
63
64 irq -= START_EXT_IRQS;
65 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
66 bit = 1<<(irq % 8);
67 local_irq_save(flags);
68 mask = ctrl_inl(reg);
69 mask |= bit;
70 ctrl_outl(mask, reg);
71 local_irq_restore(flags);
72}
73
74void disable_cayman_irq(unsigned int irq)
75{
76 unsigned long flags;
77 unsigned long mask;
78 unsigned int reg;
79 unsigned char bit;
80
81 irq -= START_EXT_IRQS;
82 reg = EPLD_MASK_BASE + ((irq / 8) << 2);
83 bit = 1<<(irq % 8);
84 local_irq_save(flags);
85 mask = ctrl_inl(reg);
86 mask &= ~bit;
87 ctrl_outl(mask, reg);
88 local_irq_restore(flags);
89}
90
91static void ack_cayman_irq(unsigned int irq)
92{
93 disable_cayman_irq(irq);
94}
95
96static void end_cayman_irq(unsigned int irq)
97{
98 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
99 enable_cayman_irq(irq);
100}
101
102static unsigned int startup_cayman_irq(unsigned int irq)
103{
104 enable_cayman_irq(irq);
105 return 0; /* never anything pending */
106}
107
108static void shutdown_cayman_irq(unsigned int irq)
109{
110 disable_cayman_irq(irq);
111}
112
113struct hw_interrupt_type cayman_irq_type = {
114 .typename = "Cayman-IRQ",
115 .startup = startup_cayman_irq,
116 .shutdown = shutdown_cayman_irq,
117 .enable = enable_cayman_irq,
118 .disable = disable_cayman_irq,
119 .ack = ack_cayman_irq,
120 .end = end_cayman_irq,
121};
122
123int cayman_irq_demux(int evt)
124{
125 int irq = intc_evt_to_irq[evt];
126
127 if (irq == SMSC_IRQ) {
128 unsigned long status;
129 int i;
130
131 status = ctrl_inl(EPLD_STATUS_BASE) &
132 ctrl_inl(EPLD_MASK_BASE) & 0xff;
133 if (status == 0) {
134 irq = -1;
135 } else {
136 for (i=0; i<8; i++) {
137 if (status & (1<<i))
138 break;
139 }
140 irq = START_EXT_IRQS + i;
141 }
142 }
143
144 if (irq == PCI2_IRQ) {
145 unsigned long status;
146 int i;
147
148 status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) &
149 ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff;
150 if (status == 0) {
151 irq = -1;
152 } else {
153 for (i=0; i<8; i++) {
154 if (status & (1<<i))
155 break;
156 }
157 irq = START_EXT_IRQS + (3 * 8) + i;
158 }
159 }
160
161 return irq;
162}
163
164#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
165int cayman_irq_describe(char* p, int irq)
166{
167 if (irq < NR_INTC_IRQS) {
168 return intc_irq_describe(p, irq);
169 } else if (irq < NR_INTC_IRQS + 8) {
170 return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS);
171 } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) {
172 return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24));
173 }
174
175 return 0;
176}
177#endif
178
179void init_cayman_irq(void)
180{
181 int i;
182
183 epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD");
184 if (!epld_virt) {
185 printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n");
186 return;
187 }
188
189 for (i=0; i<NR_EXT_IRQS; i++) {
190 irq_desc[START_EXT_IRQS + i].handler = &cayman_irq_type;
191 }
192
193 /* Setup the SMSC interrupt */
194 setup_irq(SMSC_IRQ, &cayman_action_smsc);
195 setup_irq(PCI2_IRQ, &cayman_action_pci2);
196}
diff --git a/arch/sh64/mach-cayman/led.c b/arch/sh64/mach-cayman/led.c
new file mode 100644
index 000000000000..8b3cc4c78870
--- /dev/null
+++ b/arch/sh64/mach-cayman/led.c
@@ -0,0 +1,51 @@
1/*
2 * arch/sh64/kernel/led_cayman.c
3 *
4 * Copyright (C) 2002 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 * Flash the LEDs
10 */
11#include <asm/io.h>
12
13/*
14** It is supposed these functions to be used for a low level
15** debugging (via Cayman LEDs), hence to be available as soon
16** as possible.
17** Unfortunately Cayman LEDs relies on Cayman EPLD to be mapped
18** (this happen when IRQ are initialized... quite late).
19** These triky dependencies should be removed. Temporary, it
20** may be enough to NOP until EPLD is mapped.
21*/
22
23extern unsigned long epld_virt;
24
25#define LED_ADDR (epld_virt + 0x008)
26#define HDSP2534_ADDR (epld_virt + 0x100)
27
28void mach_led(int position, int value)
29{
30 if (!epld_virt)
31 return;
32
33 if (value)
34 ctrl_outl(0, LED_ADDR);
35 else
36 ctrl_outl(1, LED_ADDR);
37
38}
39
40void mach_alphanum(int position, unsigned char value)
41{
42 if (!epld_virt)
43 return;
44
45 ctrl_outb(value, HDSP2534_ADDR + 0xe0 + (position << 2));
46}
47
48void mach_alphanum_brightness(int setting)
49{
50 ctrl_outb(setting & 7, HDSP2534_ADDR + 0xc0);
51}
diff --git a/arch/sh64/mach-cayman/setup.c b/arch/sh64/mach-cayman/setup.c
new file mode 100644
index 000000000000..c793245629ad
--- /dev/null
+++ b/arch/sh64/mach-cayman/setup.c
@@ -0,0 +1,246 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * arch/sh64/mach-cayman/setup.c
7 *
8 * SH5 Cayman support
9 *
10 * This file handles the architecture-dependent parts of initialization
11 *
12 * Copyright David J. Mckay.
13 * Needs major work!
14 *
15 * benedict.gaster@superh.com: 3rd May 2002
16 * Added support for ramdisk, removing statically linked romfs at the same time.
17 *
18 * lethal@linux-sh.org: 15th May 2003
19 * Use the generic procfs cpuinfo interface, just return a valid board name.
20 */
21
22#include <linux/stddef.h>
23#include <linux/init.h>
24#include <linux/config.h>
25#include <linux/mm.h>
26#include <linux/bootmem.h>
27#include <linux/delay.h>
28#include <linux/kernel.h>
29#include <linux/seq_file.h>
30#include <asm/processor.h>
31#include <asm/platform.h>
32#include <asm/io.h>
33#include <asm/irq.h>
34#include <asm/page.h>
35
36/*
37 * Platform Dependent Interrupt Priorities.
38 */
39
40/* Using defaults defined in irq.h */
41#define RES NO_PRIORITY /* Disabled */
42#define IR0 IRL0_PRIORITY /* IRLs */
43#define IR1 IRL1_PRIORITY
44#define IR2 IRL2_PRIORITY
45#define IR3 IRL3_PRIORITY
46#define PCA INTA_PRIORITY /* PCI Ints */
47#define PCB INTB_PRIORITY
48#define PCC INTC_PRIORITY
49#define PCD INTD_PRIORITY
50#define SER TOP_PRIORITY
51#define ERR TOP_PRIORITY
52#define PW0 TOP_PRIORITY
53#define PW1 TOP_PRIORITY
54#define PW2 TOP_PRIORITY
55#define PW3 TOP_PRIORITY
56#define DM0 NO_PRIORITY /* DMA Ints */
57#define DM1 NO_PRIORITY
58#define DM2 NO_PRIORITY
59#define DM3 NO_PRIORITY
60#define DAE NO_PRIORITY
61#define TU0 TIMER_PRIORITY /* TMU Ints */
62#define TU1 NO_PRIORITY
63#define TU2 NO_PRIORITY
64#define TI2 NO_PRIORITY
65#define ATI NO_PRIORITY /* RTC Ints */
66#define PRI NO_PRIORITY
67#define CUI RTC_PRIORITY
68#define ERI SCIF_PRIORITY /* SCIF Ints */
69#define RXI SCIF_PRIORITY
70#define BRI SCIF_PRIORITY
71#define TXI SCIF_PRIORITY
72#define ITI TOP_PRIORITY /* WDT Ints */
73
74/* Setup for the SMSC FDC37C935 */
75#define SMSC_SUPERIO_BASE 0x04000000
76#define SMSC_CONFIG_PORT_ADDR 0x3f0
77#define SMSC_INDEX_PORT_ADDR SMSC_CONFIG_PORT_ADDR
78#define SMSC_DATA_PORT_ADDR 0x3f1
79
80#define SMSC_ENTER_CONFIG_KEY 0x55
81#define SMSC_EXIT_CONFIG_KEY 0xaa
82
83#define SMCS_LOGICAL_DEV_INDEX 0x07
84#define SMSC_DEVICE_ID_INDEX 0x20
85#define SMSC_DEVICE_REV_INDEX 0x21
86#define SMSC_ACTIVATE_INDEX 0x30
87#define SMSC_PRIMARY_BASE_INDEX 0x60
88#define SMSC_SECONDARY_BASE_INDEX 0x62
89#define SMSC_PRIMARY_INT_INDEX 0x70
90#define SMSC_SECONDARY_INT_INDEX 0x72
91
92#define SMSC_IDE1_DEVICE 1
93#define SMSC_KEYBOARD_DEVICE 7
94#define SMSC_CONFIG_REGISTERS 8
95
96#define SMSC_SUPERIO_READ_INDEXED(index) ({ \
97 outb((index), SMSC_INDEX_PORT_ADDR); \
98 inb(SMSC_DATA_PORT_ADDR); })
99#define SMSC_SUPERIO_WRITE_INDEXED(val, index) ({ \
100 outb((index), SMSC_INDEX_PORT_ADDR); \
101 outb((val), SMSC_DATA_PORT_ADDR); })
102
103#define IDE1_PRIMARY_BASE 0x01f0
104#define IDE1_SECONDARY_BASE 0x03f6
105
106unsigned long smsc_superio_virt;
107
108/*
109 * Platform dependent structures: maps and parms block.
110 */
111struct resource io_resources[] = {
112 /* To be updated with external devices */
113};
114
115struct resource kram_resources[] = {
116 { "Kernel code", 0, 0 }, /* These must be last in the array */
117 { "Kernel data", 0, 0 } /* These must be last in the array */
118};
119
120struct resource xram_resources[] = {
121 /* To be updated with external devices */
122};
123
124struct resource rom_resources[] = {
125 /* To be updated with external devices */
126};
127
128struct sh64_platform platform_parms = {
129 .readonly_rootfs = 1,
130 .initial_root_dev = 0x0100,
131 .loader_type = 1,
132 .io_res_p = io_resources,
133 .io_res_count = ARRAY_SIZE(io_resources),
134 .kram_res_p = kram_resources,
135 .kram_res_count = ARRAY_SIZE(kram_resources),
136 .xram_res_p = xram_resources,
137 .xram_res_count = ARRAY_SIZE(xram_resources),
138 .rom_res_p = rom_resources,
139 .rom_res_count = ARRAY_SIZE(rom_resources),
140};
141
142int platform_int_priority[NR_INTC_IRQS] = {
143 IR0, IR1, IR2, IR3, PCA, PCB, PCC, PCD, /* IRQ 0- 7 */
144 RES, RES, RES, RES, SER, ERR, PW3, PW2, /* IRQ 8-15 */
145 PW1, PW0, DM0, DM1, DM2, DM3, DAE, RES, /* IRQ 16-23 */
146 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 24-31 */
147 TU0, TU1, TU2, TI2, ATI, PRI, CUI, ERI, /* IRQ 32-39 */
148 RXI, BRI, TXI, RES, RES, RES, RES, RES, /* IRQ 40-47 */
149 RES, RES, RES, RES, RES, RES, RES, RES, /* IRQ 48-55 */
150 RES, RES, RES, RES, RES, RES, RES, ITI, /* IRQ 56-63 */
151};
152
153static int __init smsc_superio_setup(void)
154{
155 unsigned char devid, devrev;
156
157 smsc_superio_virt = onchip_remap(SMSC_SUPERIO_BASE, 1024, "SMSC SuperIO");
158 if (!smsc_superio_virt) {
159 panic("Unable to remap SMSC SuperIO\n");
160 }
161
162 /* Initially the chip is in run state */
163 /* Put it into configuration state */
164 outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
165 outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
166
167 /* Read device ID info */
168 devid = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
169 devrev = SMSC_SUPERIO_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
170 printk("SMSC SuperIO devid %02x rev %02x\n", devid, devrev);
171
172 /* Select the keyboard device */
173 SMSC_SUPERIO_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
174
175 /* enable it */
176 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
177
178 /* Select the interrupts */
179 /* On a PC keyboard is IRQ1, mouse is IRQ12 */
180 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_PRIMARY_INT_INDEX);
181 SMSC_SUPERIO_WRITE_INDEXED(12, SMSC_SECONDARY_INT_INDEX);
182
183#ifdef CONFIG_IDE
184 /*
185 * Only IDE1 exists on the Cayman
186 */
187
188 /* Power it on */
189 SMSC_SUPERIO_WRITE_INDEXED(1 << SMSC_IDE1_DEVICE, 0x22);
190
191 SMSC_SUPERIO_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
192 SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
193
194 SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE >> 8,
195 SMSC_PRIMARY_BASE_INDEX + 0);
196 SMSC_SUPERIO_WRITE_INDEXED(IDE1_PRIMARY_BASE & 0xff,
197 SMSC_PRIMARY_BASE_INDEX + 1);
198
199 SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE >> 8,
200 SMSC_SECONDARY_BASE_INDEX + 0);
201 SMSC_SUPERIO_WRITE_INDEXED(IDE1_SECONDARY_BASE & 0xff,
202 SMSC_SECONDARY_BASE_INDEX + 1);
203
204 SMSC_SUPERIO_WRITE_INDEXED(14, SMSC_PRIMARY_INT_INDEX);
205
206 SMSC_SUPERIO_WRITE_INDEXED(SMSC_CONFIG_REGISTERS,
207 SMCS_LOGICAL_DEV_INDEX);
208
209 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc2); /* GP42 = nIDE1_OE */
210 SMSC_SUPERIO_WRITE_INDEXED(0x01, 0xc5); /* GP45 = IDE1_IRQ */
211 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc6); /* GP46 = nIOROP */
212 SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc7); /* GP47 = nIOWOP */
213#endif
214
215 /* Exit the configuraton state */
216 outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
217
218 return 0;
219}
220
221/* This is grotty, but, because kernel is always referenced on the link line
222 * before any devices, this is safe.
223 */
224__initcall(smsc_superio_setup);
225
226void __init platform_setup(void)
227{
228 /* Cayman platform leaves the decision to head.S, for now */
229 platform_parms.fpu_flags = fpu_in_use;
230}
231
232void __init platform_monitor(void)
233{
234 /* Nothing yet .. */
235}
236
237void __init platform_reserve(void)
238{
239 /* Nothing yet .. */
240}
241
242const char *get_system_type(void)
243{
244 return "Hitachi Cayman";
245}
246