aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/mach-se/7206
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2008-07-29 08:01:19 -0400
committerPaul Mundt <lethal@linux-sh.org>2008-07-29 08:01:19 -0400
commitda2014a2b080e7f3024a4eb6917d47069ad9620b (patch)
treecfde12c6d4b5baa222966b14a676f107992cf786 /arch/sh/boards/mach-se/7206
parent71b8064e7df5698520d73b4c1566a3dbc98eb9ef (diff)
sh: Shuffle the board directories in to mach groups.
This flattens out the board directories in to individual mach groups, we will use this for getting rid of unneeded directories, simplifying the build system, and becoming more coherent with the refactored arch/sh/include topology. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/mach-se/7206')
-rw-r--r--arch/sh/boards/mach-se/7206/Makefile5
-rw-r--r--arch/sh/boards/mach-se/7206/io.c104
-rw-r--r--arch/sh/boards/mach-se/7206/irq.c146
-rw-r--r--arch/sh/boards/mach-se/7206/setup.c108
4 files changed, 363 insertions, 0 deletions
diff --git a/arch/sh/boards/mach-se/7206/Makefile b/arch/sh/boards/mach-se/7206/Makefile
new file mode 100644
index 00000000000..63e7ed699f3
--- /dev/null
+++ b/arch/sh/boards/mach-se/7206/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the 7206 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
diff --git a/arch/sh/boards/mach-se/7206/io.c b/arch/sh/boards/mach-se/7206/io.c
new file mode 100644
index 00000000000..1308e618e04
--- /dev/null
+++ b/arch/sh/boards/mach-se/7206/io.c
@@ -0,0 +1,104 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
2 *
3 * linux/arch/sh/boards/se/7206/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7206 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7206.h>
15
16
17static inline void delay(void)
18{
19 ctrl_inw(0x20000000); /* P2 ROM Area */
20}
21
22/* MS7750 requires special versions of in*, out* routines, since
23 PC-like io ports are located at upper half byte of 16-bit word which
24 can be accessed only with 16-bit wide. */
25
26static inline volatile __u16 *
27port2adr(unsigned int port)
28{
29 if (port >= 0x2000 && port < 0x2020)
30 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
31 else if (port >= 0x300 && port < 0x310)
32 return (volatile __u16 *) (PA_SMSC + (port - 0x300));
33
34 return (volatile __u16 *)port;
35}
36
37unsigned char se7206_inb(unsigned long port)
38{
39 return (*port2adr(port)) & 0xff;
40}
41
42unsigned char se7206_inb_p(unsigned long port)
43{
44 unsigned long v;
45
46 v = (*port2adr(port)) & 0xff;
47 delay();
48 return v;
49}
50
51unsigned short se7206_inw(unsigned long port)
52{
53 return *port2adr(port);;
54}
55
56void se7206_outb(unsigned char value, unsigned long port)
57{
58 *(port2adr(port)) = value;
59}
60
61void se7206_outb_p(unsigned char value, unsigned long port)
62{
63 *(port2adr(port)) = value;
64 delay();
65}
66
67void se7206_outw(unsigned short value, unsigned long port)
68{
69 *port2adr(port) = value;
70}
71
72void se7206_insb(unsigned long port, void *addr, unsigned long count)
73{
74 volatile __u16 *p = port2adr(port);
75 __u8 *ap = addr;
76
77 while (count--)
78 *ap++ = *p;
79}
80
81void se7206_insw(unsigned long port, void *addr, unsigned long count)
82{
83 volatile __u16 *p = port2adr(port);
84 __u16 *ap = addr;
85 while (count--)
86 *ap++ = *p;
87}
88
89void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
90{
91 volatile __u16 *p = port2adr(port);
92 const __u8 *ap = addr;
93
94 while (count--)
95 *p = *ap++;
96}
97
98void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
99{
100 volatile __u16 *p = port2adr(port);
101 const __u16 *ap = addr;
102 while (count--)
103 *p = *ap++;
104}
diff --git a/arch/sh/boards/mach-se/7206/irq.c b/arch/sh/boards/mach-se/7206/irq.c
new file mode 100644
index 00000000000..9d5bfc77d0d
--- /dev/null
+++ b/arch/sh/boards/mach-se/7206/irq.c
@@ -0,0 +1,146 @@
1/*
2 * linux/arch/sh/boards/se/7206/irq.c
3 *
4 * Copyright (C) 2005,2006 Yoshinori Sato
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 */
9#include <linux/init.h>
10#include <linux/irq.h>
11#include <linux/io.h>
12#include <linux/interrupt.h>
13#include <asm/se7206.h>
14
15#define INTSTS0 0x31800000
16#define INTSTS1 0x31800002
17#define INTMSK0 0x31800004
18#define INTMSK1 0x31800006
19#define INTSEL 0x31800008
20
21#define IRQ0_IRQ 64
22#define IRQ1_IRQ 65
23#define IRQ3_IRQ 67
24
25#define INTC_IPR01 0xfffe0818
26#define INTC_ICR1 0xfffe0802
27
28static void disable_se7206_irq(unsigned int irq)
29{
30 unsigned short val;
31 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
32 unsigned short msk0,msk1;
33
34 /* Set the priority in IPR to 0 */
35 val = ctrl_inw(INTC_IPR01);
36 val &= mask;
37 ctrl_outw(val, INTC_IPR01);
38 /* FPGA mask set */
39 msk0 = ctrl_inw(INTMSK0);
40 msk1 = ctrl_inw(INTMSK1);
41
42 switch (irq) {
43 case IRQ0_IRQ:
44 msk0 |= 0x0010;
45 break;
46 case IRQ1_IRQ:
47 msk0 |= 0x000f;
48 break;
49 case IRQ3_IRQ:
50 msk0 |= 0x0f00;
51 msk1 |= 0x00ff;
52 break;
53 }
54 ctrl_outw(msk0, INTMSK0);
55 ctrl_outw(msk1, INTMSK1);
56}
57
58static void enable_se7206_irq(unsigned int irq)
59{
60 unsigned short val;
61 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
62 unsigned short msk0,msk1;
63
64 /* Set priority in IPR back to original value */
65 val = ctrl_inw(INTC_IPR01);
66 val |= value;
67 ctrl_outw(val, INTC_IPR01);
68
69 /* FPGA mask reset */
70 msk0 = ctrl_inw(INTMSK0);
71 msk1 = ctrl_inw(INTMSK1);
72
73 switch (irq) {
74 case IRQ0_IRQ:
75 msk0 &= ~0x0010;
76 break;
77 case IRQ1_IRQ:
78 msk0 &= ~0x000f;
79 break;
80 case IRQ3_IRQ:
81 msk0 &= ~0x0f00;
82 msk1 &= ~0x00ff;
83 break;
84 }
85 ctrl_outw(msk0, INTMSK0);
86 ctrl_outw(msk1, INTMSK1);
87}
88
89static void eoi_se7206_irq(unsigned int irq)
90{
91 unsigned short sts0,sts1;
92
93 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
94 enable_se7206_irq(irq);
95 /* FPGA isr clear */
96 sts0 = ctrl_inw(INTSTS0);
97 sts1 = ctrl_inw(INTSTS1);
98
99 switch (irq) {
100 case IRQ0_IRQ:
101 sts0 &= ~0x0010;
102 break;
103 case IRQ1_IRQ:
104 sts0 &= ~0x000f;
105 break;
106 case IRQ3_IRQ:
107 sts0 &= ~0x0f00;
108 sts1 &= ~0x00ff;
109 break;
110 }
111 ctrl_outw(sts0, INTSTS0);
112 ctrl_outw(sts1, INTSTS1);
113}
114
115static struct irq_chip se7206_irq_chip __read_mostly = {
116 .name = "SE7206-FPGA",
117 .mask = disable_se7206_irq,
118 .unmask = enable_se7206_irq,
119 .mask_ack = disable_se7206_irq,
120 .eoi = eoi_se7206_irq,
121};
122
123static void make_se7206_irq(unsigned int irq)
124{
125 disable_irq_nosync(irq);
126 set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
127 handle_level_irq, "level");
128 disable_se7206_irq(irq);
129}
130
131/*
132 * Initialize IRQ setting
133 */
134void __init init_se7206_IRQ(void)
135{
136 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
137 make_se7206_irq(IRQ1_IRQ); /* ATA */
138 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
139 ctrl_outw(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */
140
141 /* FPGA System register setup*/
142 ctrl_outw(0x0000,INTSTS0); /* Clear INTSTS0 */
143 ctrl_outw(0x0000,INTSTS1); /* Clear INTSTS1 */
144 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
145 ctrl_outw(0x0001,INTSEL);
146}
diff --git a/arch/sh/boards/mach-se/7206/setup.c b/arch/sh/boards/mach-se/7206/setup.c
new file mode 100644
index 00000000000..4fe84cc0840
--- /dev/null
+++ b/arch/sh/boards/mach-se/7206/setup.c
@@ -0,0 +1,108 @@
1/*
2 *
3 * linux/arch/sh/boards/se/7206/setup.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 * Copyright (C) 2007 - 2008 Paul Mundt
7 *
8 * Hitachi 7206 SolutionEngine Support.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/smc91x.h>
13#include <asm/se7206.h>
14#include <asm/io.h>
15#include <asm/machvec.h>
16#include <asm/heartbeat.h>
17
18static struct resource smc91x_resources[] = {
19 [0] = {
20 .name = "smc91x-regs",
21 .start = PA_SMSC + 0x300,
22 .end = PA_SMSC + 0x300 + 0x020 - 1,
23 .flags = IORESOURCE_MEM,
24 },
25 [1] = {
26 .start = 64,
27 .end = 64,
28 .flags = IORESOURCE_IRQ,
29 },
30};
31
32static struct smc91x_platdata smc91x_info = {
33 .flags = SMC91X_USE_16BIT,
34};
35
36static struct platform_device smc91x_device = {
37 .name = "smc91x",
38 .id = -1,
39 .dev = {
40 .dma_mask = NULL,
41 .coherent_dma_mask = 0xffffffff,
42 .platform_data = &smc91x_info,
43 },
44 .num_resources = ARRAY_SIZE(smc91x_resources),
45 .resource = smc91x_resources,
46};
47
48static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
49
50static struct heartbeat_data heartbeat_data = {
51 .bit_pos = heartbeat_bit_pos,
52 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
53 .regsize = 32,
54};
55
56static struct resource heartbeat_resources[] = {
57 [0] = {
58 .start = PA_LED,
59 .end = PA_LED,
60 .flags = IORESOURCE_MEM,
61 },
62};
63
64static struct platform_device heartbeat_device = {
65 .name = "heartbeat",
66 .id = -1,
67 .dev = {
68 .platform_data = &heartbeat_data,
69 },
70 .num_resources = ARRAY_SIZE(heartbeat_resources),
71 .resource = heartbeat_resources,
72};
73
74static struct platform_device *se7206_devices[] __initdata = {
75 &smc91x_device,
76 &heartbeat_device,
77};
78
79static int __init se7206_devices_setup(void)
80{
81 return platform_add_devices(se7206_devices, ARRAY_SIZE(se7206_devices));
82}
83__initcall(se7206_devices_setup);
84
85/*
86 * The Machine Vector
87 */
88
89static struct sh_machine_vector mv_se __initmv = {
90 .mv_name = "SolutionEngine",
91 .mv_nr_irqs = 256,
92 .mv_inb = se7206_inb,
93 .mv_inw = se7206_inw,
94 .mv_outb = se7206_outb,
95 .mv_outw = se7206_outw,
96
97 .mv_inb_p = se7206_inb_p,
98 .mv_inw_p = se7206_inw,
99 .mv_outb_p = se7206_outb_p,
100 .mv_outw_p = se7206_outw,
101
102 .mv_insb = se7206_insb,
103 .mv_insw = se7206_insw,
104 .mv_outsb = se7206_outsb,
105 .mv_outsw = se7206_outsw,
106
107 .mv_init_irq = init_se7206_IRQ,
108};