aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/harp
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/harp
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/harp')
-rw-r--r--arch/sh/boards/harp/Makefile8
-rw-r--r--arch/sh/boards/harp/irq.c148
-rw-r--r--arch/sh/boards/harp/led.c52
-rw-r--r--arch/sh/boards/harp/mach.c62
-rw-r--r--arch/sh/boards/harp/pcidma.c42
-rw-r--r--arch/sh/boards/harp/setup.c91
6 files changed, 403 insertions, 0 deletions
diff --git a/arch/sh/boards/harp/Makefile b/arch/sh/boards/harp/Makefile
new file mode 100644
index 000000000000..eb753d31812e
--- /dev/null
+++ b/arch/sh/boards/harp/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for STMicroelectronics board specific parts of the kernel
3#
4
5obj-y := irq.o setup.o mach.o led.o
6
7obj-$(CONFIG_PCI) += pcidma.o
8
diff --git a/arch/sh/boards/harp/irq.c b/arch/sh/boards/harp/irq.c
new file mode 100644
index 000000000000..acd58489970f
--- /dev/null
+++ b/arch/sh/boards/harp/irq.c
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Looks after interrupts on the HARP board.
8 *
9 * Bases on the IPR irq system
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14#include <linux/irq.h>
15
16#include <asm/system.h>
17#include <asm/io.h>
18#include <asm/harp/harp.h>
19
20
21#define NUM_EXTERNAL_IRQS 16
22
23// Early versions of the STB1 Overdrive required this nasty frig
24//#define INVERT_INTMASK_WRITES
25
26static void enable_harp_irq(unsigned int irq);
27static void disable_harp_irq(unsigned int irq);
28
29/* shutdown is same as "disable" */
30#define shutdown_harp_irq disable_harp_irq
31
32static void mask_and_ack_harp(unsigned int);
33static void end_harp_irq(unsigned int irq);
34
35static unsigned int startup_harp_irq(unsigned int irq)
36{
37 enable_harp_irq(irq);
38 return 0; /* never anything pending */
39}
40
41static struct hw_interrupt_type harp_irq_type = {
42 "Harp-IRQ",
43 startup_harp_irq,
44 shutdown_harp_irq,
45 enable_harp_irq,
46 disable_harp_irq,
47 mask_and_ack_harp,
48 end_harp_irq
49};
50
51static void disable_harp_irq(unsigned int irq)
52{
53 unsigned val, flags;
54 unsigned maskReg;
55 unsigned mask;
56 int pri;
57
58 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
59 return;
60
61 pri = 15 - irq;
62
63 if (pri < 8) {
64 maskReg = EPLD_INTMASK0;
65 } else {
66 maskReg = EPLD_INTMASK1;
67 pri -= 8;
68 }
69
70 local_irq_save(flags);
71 mask = ctrl_inl(maskReg);
72 mask &= (~(1 << pri));
73#if defined(INVERT_INTMASK_WRITES)
74 mask ^= 0xff;
75#endif
76 ctrl_outl(mask, maskReg);
77 local_irq_restore(flags);
78}
79
80static void enable_harp_irq(unsigned int irq)
81{
82 unsigned flags;
83 unsigned maskReg;
84 unsigned mask;
85 int pri;
86
87 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
88 return;
89
90 pri = 15 - irq;
91
92 if (pri < 8) {
93 maskReg = EPLD_INTMASK0;
94 } else {
95 maskReg = EPLD_INTMASK1;
96 pri -= 8;
97 }
98
99 local_irq_save(flags);
100 mask = ctrl_inl(maskReg);
101
102
103 mask |= (1 << pri);
104
105#if defined(INVERT_INTMASK_WRITES)
106 mask ^= 0xff;
107#endif
108 ctrl_outl(mask, maskReg);
109
110 local_irq_restore(flags);
111}
112
113/* This functions sets the desired irq handler to be an overdrive type */
114static void __init make_harp_irq(unsigned int irq)
115{
116 disable_irq_nosync(irq);
117 irq_desc[irq].handler = &harp_irq_type;
118 disable_harp_irq(irq);
119}
120
121static void mask_and_ack_harp(unsigned int irq)
122{
123 disable_harp_irq(irq);
124}
125
126static void end_harp_irq(unsigned int irq)
127{
128 enable_harp_irq(irq);
129}
130
131void __init init_harp_irq(void)
132{
133 int i;
134
135#if !defined(INVERT_INTMASK_WRITES)
136 // On the harp these are set to enable an interrupt
137 ctrl_outl(0x00, EPLD_INTMASK0);
138 ctrl_outl(0x00, EPLD_INTMASK1);
139#else
140 // On the Overdrive the data is inverted before being stored in the reg
141 ctrl_outl(0xff, EPLD_INTMASK0);
142 ctrl_outl(0xff, EPLD_INTMASK1);
143#endif
144
145 for (i = 0; i < NUM_EXTERNAL_IRQS; i++) {
146 make_harp_irq(i);
147 }
148}
diff --git a/arch/sh/boards/harp/led.c b/arch/sh/boards/harp/led.c
new file mode 100644
index 000000000000..76ca4ccac703
--- /dev/null
+++ b/arch/sh/boards/harp/led.c
@@ -0,0 +1,52 @@
1/*
2 * linux/arch/sh/stboards/led.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 ST40STB1 HARP and compatible code.
10 */
11
12#include <linux/config.h>
13#include <asm/io.h>
14#include <asm/harp/harp.h>
15
16/* Harp: Flash LD10 (front pannel) connected to EPLD (IC8) */
17/* Overdrive: Flash LD1 (front panel) connected to EPLD (IC4) */
18/* Works for HARP and overdrive */
19static void mach_led(int position, int value)
20{
21 if (value) {
22 ctrl_outl(EPLD_LED_ON, EPLD_LED);
23 } else {
24 ctrl_outl(EPLD_LED_OFF, EPLD_LED);
25 }
26}
27
28#ifdef CONFIG_HEARTBEAT
29
30#include <linux/sched.h>
31
32/* acts like an actual heart beat -- ie thump-thump-pause... */
33void heartbeat_harp(void)
34{
35 static unsigned cnt = 0, period = 0, dist = 0;
36
37 if (cnt == 0 || cnt == dist)
38 mach_led( -1, 1);
39 else if (cnt == 7 || cnt == dist+7)
40 mach_led( -1, 0);
41
42 if (++cnt > period) {
43 cnt = 0;
44 /* The hyperbolic function below modifies the heartbeat period
45 * length in dependency of the current (5min) load. It goes
46 * through the points f(0)=126, f(1)=86, f(5)=51,
47 * f(inf)->30. */
48 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
49 dist = period / 4;
50 }
51}
52#endif
diff --git a/arch/sh/boards/harp/mach.c b/arch/sh/boards/harp/mach.c
new file mode 100644
index 000000000000..a946dd1674ca
--- /dev/null
+++ b/arch/sh/boards/harp/mach.c
@@ -0,0 +1,62 @@
1/*
2 * linux/arch/sh/boards/harp/mach.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 STMicroelectronics STB1 HARP and compatible boards
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/machvec_init.h>
17#include <asm/hd64465/io.h>
18#include <asm/hd64465/hd64465.h>
19
20void setup_harp(void);
21void init_harp_irq(void);
22void heartbeat_harp(void);
23
24/*
25 * The Machine Vector
26 */
27
28struct sh_machine_vector mv_harp __initmv = {
29 .mv_nr_irqs = 89 + HD64465_IRQ_NUM,
30
31 .mv_inb = hd64465_inb,
32 .mv_inw = hd64465_inw,
33 .mv_inl = hd64465_inl,
34 .mv_outb = hd64465_outb,
35 .mv_outw = hd64465_outw,
36 .mv_outl = hd64465_outl,
37
38 .mv_inb_p = hd64465_inb_p,
39 .mv_inw_p = hd64465_inw,
40 .mv_inl_p = hd64465_inl,
41 .mv_outb_p = hd64465_outb_p,
42 .mv_outw_p = hd64465_outw,
43 .mv_outl_p = hd64465_outl,
44
45 .mv_insb = hd64465_insb,
46 .mv_insw = hd64465_insw,
47 .mv_insl = hd64465_insl,
48 .mv_outsb = hd64465_outsb,
49 .mv_outsw = hd64465_outsw,
50 .mv_outsl = hd64465_outsl,
51
52 .mv_isa_port2addr = hd64465_isa_port2addr,
53
54#ifdef CONFIG_PCI
55 .mv_init_irq = init_harp_irq,
56#endif
57#ifdef CONFIG_HEARTBEAT
58 .mv_heartbeat = heartbeat_harp,
59#endif
60};
61
62ALIAS_MV(harp)
diff --git a/arch/sh/boards/harp/pcidma.c b/arch/sh/boards/harp/pcidma.c
new file mode 100644
index 000000000000..475311390fd6
--- /dev/null
+++ b/arch/sh/boards/harp/pcidma.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Dynamic DMA mapping support.
8 */
9
10#include <linux/types.h>
11#include <linux/mm.h>
12#include <linux/string.h>
13#include <linux/pci.h>
14#include <asm/io.h>
15#include <asm/addrspace.h>
16
17
18void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
19 dma_addr_t * dma_handle)
20{
21 void *ret;
22 int gfp = GFP_ATOMIC;
23
24 ret = (void *) __get_free_pages(gfp, get_order(size));
25
26 if (ret != NULL) {
27 /* Is it neccessary to do the memset? */
28 memset(ret, 0, size);
29 *dma_handle = virt_to_bus(ret);
30 }
31 /* We must flush the cache before we pass it on to the device */
32 flush_cache_all();
33 return P2SEGADDR(ret);
34}
35
36void pci_free_consistent(struct pci_dev *hwdev, size_t size,
37 void *vaddr, dma_addr_t dma_handle)
38{
39 unsigned long p1addr=P1SEGADDR((unsigned long)vaddr);
40
41 free_pages(p1addr, get_order(size));
42}
diff --git a/arch/sh/boards/harp/setup.c b/arch/sh/boards/harp/setup.c
new file mode 100644
index 000000000000..05b01b8f40aa
--- /dev/null
+++ b/arch/sh/boards/harp/setup.c
@@ -0,0 +1,91 @@
1/*
2 * arch/sh/stboard/setup.c
3 *
4 * Copyright (C) 2001 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 * STMicroelectronics ST40STB1 HARP and compatible support.
10 */
11
12#include <linux/config.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <asm/io.h>
16#include <asm/harp/harp.h>
17
18const char *get_system_type(void)
19{
20 return "STB1 Harp";
21}
22
23/*
24 * Initialize the board
25 */
26int __init platform_setup(void)
27{
28#ifdef CONFIG_SH_STB1_HARP
29 unsigned long ic8_version, ic36_version;
30
31 ic8_version = ctrl_inl(EPLD_REVID2);
32 ic36_version = ctrl_inl(EPLD_REVID1);
33
34 printk("STMicroelectronics STB1 HARP initialisaton\n");
35 printk("EPLD versions: IC8: %d.%02d, IC36: %d.%02d\n",
36 (ic8_version >> 4) & 0xf, ic8_version & 0xf,
37 (ic36_version >> 4) & 0xf, ic36_version & 0xf);
38#elif defined(CONFIG_SH_STB1_OVERDRIVE)
39 unsigned long version;
40
41 version = ctrl_inl(EPLD_REVID);
42
43 printk("STMicroelectronics STB1 Overdrive initialisaton\n");
44 printk("EPLD version: %d.%02d\n",
45 (version >> 4) & 0xf, version & 0xf);
46#else
47#error Undefined machine
48#endif
49
50 /* Currently all STB1 chips have problems with the sleep instruction,
51 * so disable it here.
52 */
53 disable_hlt();
54
55 return 0;
56}
57
58/*
59 * pcibios_map_platform_irq
60 *
61 * This is board specific and returns the IRQ for a given PCI device.
62 * It is used by the PCI code (arch/sh/kernel/st40_pci*)
63 *
64 */
65
66#define HARP_PCI_IRQ 1
67#define HARP_BRIDGE_IRQ 2
68#define OVERDRIVE_SLOT0_IRQ 0
69
70
71int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
72{
73 switch (slot) {
74#ifdef CONFIG_SH_STB1_HARP
75 case 2: /*This is the PCI slot on the */
76 return HARP_PCI_IRQ;
77 case 1: /* this is the bridge */
78 return HARP_BRIDGE_IRQ;
79#elif defined(CONFIG_SH_STB1_OVERDRIVE)
80 case 1:
81 case 2:
82 case 3:
83 return slot - 1;
84#else
85#error Unknown board
86#endif
87 default:
88 return -1;
89 }
90}
91