diff options
-rw-r--r-- | Documentation/sh/new-machine.txt | 4 | ||||
-rw-r--r-- | arch/sh/cchips/Kconfig | 33 | ||||
-rw-r--r-- | arch/sh/cchips/hd6446x/Makefile | 1 | ||||
-rw-r--r-- | arch/sh/cchips/hd6446x/hd64465/Makefile | 6 | ||||
-rw-r--r-- | arch/sh/cchips/hd6446x/hd64465/gpio.c | 196 | ||||
-rw-r--r-- | arch/sh/cchips/hd6446x/hd64465/io.c | 211 | ||||
-rw-r--r-- | arch/sh/cchips/hd6446x/hd64465/setup.c | 181 | ||||
-rw-r--r-- | arch/sh/include/asm/hd64465/gpio.h | 46 | ||||
-rw-r--r-- | arch/sh/include/asm/hd64465/hd64465.h | 256 | ||||
-rw-r--r-- | arch/sh/include/asm/hd64465/io.h | 44 | ||||
-rw-r--r-- | arch/sh/include/asm/serial.h | 17 | ||||
-rw-r--r-- | arch/sh/tools/mach-types | 1 | ||||
-rw-r--r-- | drivers/pcmcia/Kconfig | 4 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 1 | ||||
-rw-r--r-- | drivers/pcmcia/hd64465_ss.c | 939 |
15 files changed, 1 insertions, 1939 deletions
diff --git a/Documentation/sh/new-machine.txt b/Documentation/sh/new-machine.txt index 5482bf5d005b..f0354164cb0e 100644 --- a/Documentation/sh/new-machine.txt +++ b/Documentation/sh/new-machine.txt | |||
@@ -47,9 +47,7 @@ Next, for companion chips: | |||
47 | `-- sh | 47 | `-- sh |
48 | `-- cchips | 48 | `-- cchips |
49 | `-- hd6446x | 49 | `-- hd6446x |
50 | |-- hd64461 | 50 | `-- hd64461 |
51 | | `-- cchip-specific files | ||
52 | `-- hd64465 | ||
53 | `-- cchip-specific files | 51 | `-- cchip-specific files |
54 | 52 | ||
55 | ... and so on. Headers for the companion chips are treated the same way as | 53 | ... and so on. Headers for the companion chips are treated the same way as |
diff --git a/arch/sh/cchips/Kconfig b/arch/sh/cchips/Kconfig index 7892361eedc8..f43d18373f22 100644 --- a/arch/sh/cchips/Kconfig +++ b/arch/sh/cchips/Kconfig | |||
@@ -22,20 +22,6 @@ config HD64461 | |||
22 | Say Y if you want support for the HD64461. | 22 | Say Y if you want support for the HD64461. |
23 | Otherwise, say N. | 23 | Otherwise, say N. |
24 | 24 | ||
25 | config HD64465 | ||
26 | bool "Hitachi HD64465 companion chip support" | ||
27 | ---help--- | ||
28 | The Hitachi HD64465 provides an interface for | ||
29 | the SH7750 CPU, supporting a LCD controller, | ||
30 | CRT color controller, IrDA, USB, PCMCIA, | ||
31 | keyboard controller, and a printer interface. | ||
32 | |||
33 | More information is available at | ||
34 | <http://global.hitachi.com/New/cnews/E/1998/981019B.html>. | ||
35 | |||
36 | Say Y if you want support for the HD64465. | ||
37 | Otherwise, say N. | ||
38 | |||
39 | endchoice | 25 | endchoice |
40 | 26 | ||
41 | # These will also be split into the Kconfig's below | 27 | # These will also be split into the Kconfig's below |
@@ -61,23 +47,4 @@ config HD64461_ENABLER | |||
61 | via the HD64461 companion chip. | 47 | via the HD64461 companion chip. |
62 | Otherwise, say N. | 48 | Otherwise, say N. |
63 | 49 | ||
64 | config HD64465_IOBASE | ||
65 | hex "HD64465 start address" | ||
66 | depends on HD64465 | ||
67 | default "0xb0000000" | ||
68 | help | ||
69 | The default setting of the HD64465 IO base address is 0xb0000000. | ||
70 | |||
71 | Do not change this unless you know what you are doing. | ||
72 | |||
73 | config HD64465_IRQ | ||
74 | int "HD64465 IRQ" | ||
75 | depends on HD64465 | ||
76 | default "5" | ||
77 | help | ||
78 | The default setting of the HD64465 IRQ is 5. | ||
79 | |||
80 | Do not change this unless you know what you are doing. | ||
81 | |||
82 | endmenu | 50 | endmenu |
83 | |||
diff --git a/arch/sh/cchips/hd6446x/Makefile b/arch/sh/cchips/hd6446x/Makefile index f7de4076e242..9682e3ab668f 100644 --- a/arch/sh/cchips/hd6446x/Makefile +++ b/arch/sh/cchips/hd6446x/Makefile | |||
@@ -1,4 +1,3 @@ | |||
1 | obj-$(CONFIG_HD64461) += hd64461.o | 1 | obj-$(CONFIG_HD64461) += hd64461.o |
2 | obj-$(CONFIG_HD64465) += hd64465/ | ||
3 | 2 | ||
4 | EXTRA_CFLAGS += -Werror | 3 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/sh/cchips/hd6446x/hd64465/Makefile b/arch/sh/cchips/hd6446x/hd64465/Makefile deleted file mode 100644 index f66edcb52c5b..000000000000 --- a/arch/sh/cchips/hd6446x/hd64465/Makefile +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the HD64465 | ||
3 | # | ||
4 | |||
5 | obj-y := setup.o io.o gpio.o | ||
6 | |||
diff --git a/arch/sh/cchips/hd6446x/hd64465/gpio.c b/arch/sh/cchips/hd6446x/hd64465/gpio.c deleted file mode 100644 index 43431855ec86..000000000000 --- a/arch/sh/cchips/hd6446x/hd64465/gpio.c +++ /dev/null | |||
@@ -1,196 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: gpio.c,v 1.4 2003/05/19 22:24:18 lethal Exp $ | ||
3 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
4 | * (c) 2000 PocketPenguins Inc | ||
5 | * | ||
6 | * GPIO pin support for HD64465 companion chip. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/sched.h> | ||
13 | #include <linux/ioport.h> | ||
14 | #include <asm/io.h> | ||
15 | #include <asm/hd64465/gpio.h> | ||
16 | |||
17 | #define _PORTOF(portpin) (((portpin)>>3)&0x7) | ||
18 | #define _PINOF(portpin) ((portpin)&0x7) | ||
19 | |||
20 | /* Register addresses parametrised on port */ | ||
21 | #define GPIO_CR(port) (HD64465_REG_GPACR+((port)<<1)) | ||
22 | #define GPIO_DR(port) (HD64465_REG_GPADR+((port)<<1)) | ||
23 | #define GPIO_ICR(port) (HD64465_REG_GPAICR+((port)<<1)) | ||
24 | #define GPIO_ISR(port) (HD64465_REG_GPAISR+((port)<<1)) | ||
25 | |||
26 | #define GPIO_NPORTS 5 | ||
27 | |||
28 | #define MODNAME "hd64465_gpio" | ||
29 | |||
30 | EXPORT_SYMBOL(hd64465_gpio_configure); | ||
31 | EXPORT_SYMBOL(hd64465_gpio_get_pin); | ||
32 | EXPORT_SYMBOL(hd64465_gpio_get_port); | ||
33 | EXPORT_SYMBOL(hd64465_gpio_register_irq); | ||
34 | EXPORT_SYMBOL(hd64465_gpio_set_pin); | ||
35 | EXPORT_SYMBOL(hd64465_gpio_set_port); | ||
36 | EXPORT_SYMBOL(hd64465_gpio_unregister_irq); | ||
37 | |||
38 | /* TODO: each port should be protected with a spinlock */ | ||
39 | |||
40 | |||
41 | void hd64465_gpio_configure(int portpin, int direction) | ||
42 | { | ||
43 | unsigned short cr; | ||
44 | unsigned int shift = (_PINOF(portpin)<<1); | ||
45 | |||
46 | cr = inw(GPIO_CR(_PORTOF(portpin))); | ||
47 | cr &= ~(3<<shift); | ||
48 | cr |= direction<<shift; | ||
49 | outw(cr, GPIO_CR(_PORTOF(portpin))); | ||
50 | } | ||
51 | |||
52 | void hd64465_gpio_set_pin(int portpin, unsigned int value) | ||
53 | { | ||
54 | unsigned short d; | ||
55 | unsigned short mask = 1<<(_PINOF(portpin)); | ||
56 | |||
57 | d = inw(GPIO_DR(_PORTOF(portpin))); | ||
58 | if (value) | ||
59 | d |= mask; | ||
60 | else | ||
61 | d &= ~mask; | ||
62 | outw(d, GPIO_DR(_PORTOF(portpin))); | ||
63 | } | ||
64 | |||
65 | unsigned int hd64465_gpio_get_pin(int portpin) | ||
66 | { | ||
67 | return inw(GPIO_DR(_PORTOF(portpin))) & (1<<(_PINOF(portpin))); | ||
68 | } | ||
69 | |||
70 | /* TODO: for cleaner atomicity semantics, add a mask to this routine */ | ||
71 | |||
72 | void hd64465_gpio_set_port(int port, unsigned int value) | ||
73 | { | ||
74 | outw(value, GPIO_DR(port)); | ||
75 | } | ||
76 | |||
77 | unsigned int hd64465_gpio_get_port(int port) | ||
78 | { | ||
79 | return inw(GPIO_DR(port)); | ||
80 | } | ||
81 | |||
82 | |||
83 | static struct { | ||
84 | void (*func)(int portpin, void *dev); | ||
85 | void *dev; | ||
86 | } handlers[GPIO_NPORTS * 8]; | ||
87 | |||
88 | static irqreturn_t hd64465_gpio_interrupt(int irq, void *dev) | ||
89 | { | ||
90 | unsigned short port, pin, isr, mask, portpin; | ||
91 | |||
92 | for (port=0 ; port<GPIO_NPORTS ; port++) { | ||
93 | isr = inw(GPIO_ISR(port)); | ||
94 | |||
95 | for (pin=0 ; pin<8 ; pin++) { | ||
96 | mask = 1<<pin; | ||
97 | if (isr & mask) { | ||
98 | portpin = (port<<3)|pin; | ||
99 | if (handlers[portpin].func != 0) | ||
100 | handlers[portpin].func(portpin, handlers[portpin].dev); | ||
101 | else | ||
102 | printk(KERN_NOTICE "unexpected GPIO interrupt, pin %c%d\n", | ||
103 | port+'A', (int)pin); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | /* Write 1s back to ISR to clear it? That's what the manual says.. */ | ||
108 | outw(isr, GPIO_ISR(port)); | ||
109 | } | ||
110 | |||
111 | return IRQ_HANDLED; | ||
112 | } | ||
113 | |||
114 | void hd64465_gpio_register_irq(int portpin, int mode, | ||
115 | void (*handler)(int portpin, void *dev), void *dev) | ||
116 | { | ||
117 | unsigned long flags; | ||
118 | unsigned short icr, mask; | ||
119 | |||
120 | if (handler == 0) | ||
121 | return; | ||
122 | |||
123 | local_irq_save(flags); | ||
124 | |||
125 | handlers[portpin].func = handler; | ||
126 | handlers[portpin].dev = dev; | ||
127 | |||
128 | /* | ||
129 | * Configure Interrupt Control Register | ||
130 | */ | ||
131 | icr = inw(GPIO_ICR(_PORTOF(portpin))); | ||
132 | mask = (1<<_PINOF(portpin)); | ||
133 | |||
134 | /* unmask interrupt */ | ||
135 | icr &= ~mask; | ||
136 | |||
137 | /* set TS bit */ | ||
138 | mask <<= 8; | ||
139 | icr &= ~mask; | ||
140 | if (mode == HD64465_GPIO_RISING) | ||
141 | icr |= mask; | ||
142 | |||
143 | outw(icr, GPIO_ICR(_PORTOF(portpin))); | ||
144 | |||
145 | local_irq_restore(flags); | ||
146 | } | ||
147 | |||
148 | void hd64465_gpio_unregister_irq(int portpin) | ||
149 | { | ||
150 | unsigned long flags; | ||
151 | unsigned short icr; | ||
152 | |||
153 | local_irq_save(flags); | ||
154 | |||
155 | /* | ||
156 | * Configure Interrupt Control Register | ||
157 | */ | ||
158 | icr = inw(GPIO_ICR(_PORTOF(portpin))); | ||
159 | icr |= (1<<_PINOF(portpin)); /* mask interrupt */ | ||
160 | outw(icr, GPIO_ICR(_PORTOF(portpin))); | ||
161 | |||
162 | handlers[portpin].func = 0; | ||
163 | handlers[portpin].dev = 0; | ||
164 | |||
165 | local_irq_restore(flags); | ||
166 | } | ||
167 | |||
168 | static int __init hd64465_gpio_init(void) | ||
169 | { | ||
170 | if (!request_region(HD64465_REG_GPACR, 0x1000, MODNAME)) | ||
171 | return -EBUSY; | ||
172 | if (request_irq(HD64465_IRQ_GPIO, hd64465_gpio_interrupt, | ||
173 | IRQF_DISABLED, MODNAME, 0)) | ||
174 | goto out_irqfailed; | ||
175 | |||
176 | printk("HD64465 GPIO layer on irq %d\n", HD64465_IRQ_GPIO); | ||
177 | |||
178 | return 0; | ||
179 | |||
180 | out_irqfailed: | ||
181 | release_region(HD64465_REG_GPACR, 0x1000); | ||
182 | |||
183 | return -EINVAL; | ||
184 | } | ||
185 | |||
186 | static void __exit hd64465_gpio_exit(void) | ||
187 | { | ||
188 | release_region(HD64465_REG_GPACR, 0x1000); | ||
189 | free_irq(HD64465_IRQ_GPIO, 0); | ||
190 | } | ||
191 | |||
192 | module_init(hd64465_gpio_init); | ||
193 | module_exit(hd64465_gpio_exit); | ||
194 | |||
195 | MODULE_LICENSE("GPL"); | ||
196 | |||
diff --git a/arch/sh/cchips/hd6446x/hd64465/io.c b/arch/sh/cchips/hd6446x/hd64465/io.c deleted file mode 100644 index 58704d066ae2..000000000000 --- a/arch/sh/cchips/hd6446x/hd64465/io.c +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: io.c,v 1.4 2003/08/03 03:05:10 lethal Exp $ | ||
3 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
4 | * (c) 2000 PocketPenguins Inc | ||
5 | * | ||
6 | * Derived from io_hd64461.c, which bore the message: | ||
7 | * Copyright (C) 2000 YAEGASHI Takeshi | ||
8 | * | ||
9 | * Typical I/O routines for HD64465 system. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <asm/io.h> | ||
15 | #include <asm/hd64465/hd64465.h> | ||
16 | |||
17 | |||
18 | #define HD64465_DEBUG 0 | ||
19 | |||
20 | #if HD64465_DEBUG | ||
21 | #define DPRINTK(args...) printk(args) | ||
22 | #define DIPRINTK(n, args...) if (hd64465_io_debug>(n)) printk(args) | ||
23 | #else | ||
24 | #define DPRINTK(args...) | ||
25 | #define DIPRINTK(n, args...) | ||
26 | #endif | ||
27 | |||
28 | |||
29 | |||
30 | /* This is a hack suitable only for debugging IO port problems */ | ||
31 | int hd64465_io_debug; | ||
32 | EXPORT_SYMBOL(hd64465_io_debug); | ||
33 | |||
34 | /* Low iomap maps port 0-1K to addresses in 8byte chunks */ | ||
35 | #define HD64465_IOMAP_LO_THRESH 0x400 | ||
36 | #define HD64465_IOMAP_LO_SHIFT 3 | ||
37 | #define HD64465_IOMAP_LO_MASK ((1<<HD64465_IOMAP_LO_SHIFT)-1) | ||
38 | #define HD64465_IOMAP_LO_NMAP (HD64465_IOMAP_LO_THRESH>>HD64465_IOMAP_LO_SHIFT) | ||
39 | static unsigned long hd64465_iomap_lo[HD64465_IOMAP_LO_NMAP]; | ||
40 | static unsigned char hd64465_iomap_lo_shift[HD64465_IOMAP_LO_NMAP]; | ||
41 | |||
42 | /* High iomap maps port 1K-64K to addresses in 1K chunks */ | ||
43 | #define HD64465_IOMAP_HI_THRESH 0x10000 | ||
44 | #define HD64465_IOMAP_HI_SHIFT 10 | ||
45 | #define HD64465_IOMAP_HI_MASK ((1<<HD64465_IOMAP_HI_SHIFT)-1) | ||
46 | #define HD64465_IOMAP_HI_NMAP (HD64465_IOMAP_HI_THRESH>>HD64465_IOMAP_HI_SHIFT) | ||
47 | static unsigned long hd64465_iomap_hi[HD64465_IOMAP_HI_NMAP]; | ||
48 | static unsigned char hd64465_iomap_hi_shift[HD64465_IOMAP_HI_NMAP]; | ||
49 | |||
50 | #define PORT2ADDR(x) (sh_mv.mv_isa_port2addr(x)) | ||
51 | |||
52 | void hd64465_port_map(unsigned short baseport, unsigned int nports, | ||
53 | unsigned long addr, unsigned char shift) | ||
54 | { | ||
55 | unsigned int port, endport = baseport + nports; | ||
56 | |||
57 | DPRINTK("hd64465_port_map(base=0x%04hx, n=0x%04hx, addr=0x%08lx,endport=0x%04x)\n", | ||
58 | baseport, nports, addr,endport); | ||
59 | |||
60 | for (port = baseport ; | ||
61 | port < endport && port < HD64465_IOMAP_LO_THRESH ; | ||
62 | port += (1<<HD64465_IOMAP_LO_SHIFT)) { | ||
63 | DPRINTK(" maplo[0x%x] = 0x%08lx\n", port, addr); | ||
64 | hd64465_iomap_lo[port>>HD64465_IOMAP_LO_SHIFT] = addr; | ||
65 | hd64465_iomap_lo_shift[port>>HD64465_IOMAP_LO_SHIFT] = shift; | ||
66 | addr += (1<<(HD64465_IOMAP_LO_SHIFT)); | ||
67 | } | ||
68 | |||
69 | for (port = max_t(unsigned int, baseport, HD64465_IOMAP_LO_THRESH); | ||
70 | port < endport && port < HD64465_IOMAP_HI_THRESH ; | ||
71 | port += (1<<HD64465_IOMAP_HI_SHIFT)) { | ||
72 | DPRINTK(" maphi[0x%x] = 0x%08lx\n", port, addr); | ||
73 | hd64465_iomap_hi[port>>HD64465_IOMAP_HI_SHIFT] = addr; | ||
74 | hd64465_iomap_hi_shift[port>>HD64465_IOMAP_HI_SHIFT] = shift; | ||
75 | addr += (1<<(HD64465_IOMAP_HI_SHIFT)); | ||
76 | } | ||
77 | } | ||
78 | EXPORT_SYMBOL(hd64465_port_map); | ||
79 | |||
80 | void hd64465_port_unmap(unsigned short baseport, unsigned int nports) | ||
81 | { | ||
82 | unsigned int port, endport = baseport + nports; | ||
83 | |||
84 | DPRINTK("hd64465_port_unmap(base=0x%04hx, n=0x%04hx)\n", | ||
85 | baseport, nports); | ||
86 | |||
87 | for (port = baseport ; | ||
88 | port < endport && port < HD64465_IOMAP_LO_THRESH ; | ||
89 | port += (1<<HD64465_IOMAP_LO_SHIFT)) { | ||
90 | hd64465_iomap_lo[port>>HD64465_IOMAP_LO_SHIFT] = 0; | ||
91 | } | ||
92 | |||
93 | for (port = max_t(unsigned int, baseport, HD64465_IOMAP_LO_THRESH); | ||
94 | port < endport && port < HD64465_IOMAP_HI_THRESH ; | ||
95 | port += (1<<HD64465_IOMAP_HI_SHIFT)) { | ||
96 | hd64465_iomap_hi[port>>HD64465_IOMAP_HI_SHIFT] = 0; | ||
97 | } | ||
98 | } | ||
99 | EXPORT_SYMBOL(hd64465_port_unmap); | ||
100 | |||
101 | unsigned long hd64465_isa_port2addr(unsigned long port) | ||
102 | { | ||
103 | unsigned long addr = 0; | ||
104 | unsigned char shift; | ||
105 | |||
106 | /* handle remapping of low IO ports */ | ||
107 | if (port < HD64465_IOMAP_LO_THRESH) { | ||
108 | addr = hd64465_iomap_lo[port >> HD64465_IOMAP_LO_SHIFT]; | ||
109 | shift = hd64465_iomap_lo_shift[port >> HD64465_IOMAP_LO_SHIFT]; | ||
110 | if (addr != 0) | ||
111 | addr += (port & HD64465_IOMAP_LO_MASK) << shift; | ||
112 | else | ||
113 | printk(KERN_NOTICE "io_hd64465: access to un-mapped port %lx\n", port); | ||
114 | } else if (port < HD64465_IOMAP_HI_THRESH) { | ||
115 | addr = hd64465_iomap_hi[port >> HD64465_IOMAP_HI_SHIFT]; | ||
116 | shift = hd64465_iomap_hi_shift[port >> HD64465_IOMAP_HI_SHIFT]; | ||
117 | if (addr != 0) | ||
118 | addr += (port & HD64465_IOMAP_HI_MASK) << shift; | ||
119 | else | ||
120 | printk(KERN_NOTICE "io_hd64465: access to un-mapped port %lx\n", port); | ||
121 | } | ||
122 | |||
123 | /* HD64465 internal devices (0xb0000000) */ | ||
124 | else if (port < 0x20000) | ||
125 | addr = CONFIG_HD64465_IOBASE + port - 0x10000; | ||
126 | |||
127 | /* Whole physical address space (0xa0000000) */ | ||
128 | else | ||
129 | addr = P2SEGADDR(port); | ||
130 | |||
131 | DIPRINTK(2, "PORT2ADDR(0x%08lx) = 0x%08lx\n", port, addr); | ||
132 | |||
133 | return addr; | ||
134 | } | ||
135 | |||
136 | static inline void delay(void) | ||
137 | { | ||
138 | ctrl_inw(0xa0000000); | ||
139 | } | ||
140 | |||
141 | unsigned char hd64465_inb(unsigned long port) | ||
142 | { | ||
143 | unsigned long addr = PORT2ADDR(port); | ||
144 | unsigned long b = (addr == 0 ? 0 : *(volatile unsigned char*)addr); | ||
145 | |||
146 | DIPRINTK(0, "inb(%08lx) = %02x\n", addr, (unsigned)b); | ||
147 | return b; | ||
148 | } | ||
149 | |||
150 | unsigned char hd64465_inb_p(unsigned long port) | ||
151 | { | ||
152 | unsigned long v; | ||
153 | unsigned long addr = PORT2ADDR(port); | ||
154 | |||
155 | v = (addr == 0 ? 0 : *(volatile unsigned char*)addr); | ||
156 | delay(); | ||
157 | DIPRINTK(0, "inb_p(%08lx) = %02x\n", addr, (unsigned)v); | ||
158 | return v; | ||
159 | } | ||
160 | |||
161 | unsigned short hd64465_inw(unsigned long port) | ||
162 | { | ||
163 | unsigned long addr = PORT2ADDR(port); | ||
164 | unsigned long b = (addr == 0 ? 0 : *(volatile unsigned short*)addr); | ||
165 | DIPRINTK(0, "inw(%08lx) = %04lx\n", addr, b); | ||
166 | return b; | ||
167 | } | ||
168 | |||
169 | unsigned int hd64465_inl(unsigned long port) | ||
170 | { | ||
171 | unsigned long addr = PORT2ADDR(port); | ||
172 | unsigned int b = (addr == 0 ? 0 : *(volatile unsigned long*)addr); | ||
173 | DIPRINTK(0, "inl(%08lx) = %08x\n", addr, b); | ||
174 | return b; | ||
175 | } | ||
176 | |||
177 | void hd64465_outb(unsigned char b, unsigned long port) | ||
178 | { | ||
179 | unsigned long addr = PORT2ADDR(port); | ||
180 | |||
181 | DIPRINTK(0, "outb(%02x, %08lx)\n", (unsigned)b, addr); | ||
182 | if (addr != 0) | ||
183 | *(volatile unsigned char*)addr = b; | ||
184 | } | ||
185 | |||
186 | void hd64465_outb_p(unsigned char b, unsigned long port) | ||
187 | { | ||
188 | unsigned long addr = PORT2ADDR(port); | ||
189 | |||
190 | DIPRINTK(0, "outb_p(%02x, %08lx)\n", (unsigned)b, addr); | ||
191 | if (addr != 0) | ||
192 | *(volatile unsigned char*)addr = b; | ||
193 | delay(); | ||
194 | } | ||
195 | |||
196 | void hd64465_outw(unsigned short b, unsigned long port) | ||
197 | { | ||
198 | unsigned long addr = PORT2ADDR(port); | ||
199 | DIPRINTK(0, "outw(%04x, %08lx)\n", (unsigned)b, addr); | ||
200 | if (addr != 0) | ||
201 | *(volatile unsigned short*)addr = b; | ||
202 | } | ||
203 | |||
204 | void hd64465_outl(unsigned int b, unsigned long port) | ||
205 | { | ||
206 | unsigned long addr = PORT2ADDR(port); | ||
207 | DIPRINTK(0, "outl(%08x, %08lx)\n", b, addr); | ||
208 | if (addr != 0) | ||
209 | *(volatile unsigned long*)addr = b; | ||
210 | } | ||
211 | |||
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c deleted file mode 100644 index 9b8820c36701..000000000000 --- a/arch/sh/cchips/hd6446x/hd64465/setup.c +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: setup.c,v 1.4 2003/08/03 03:05:10 lethal Exp $ | ||
3 | * | ||
4 | * Setup and IRQ handling code for the HD64465 companion chip. | ||
5 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
6 | * Copyright (c) 2000 PocketPenguins Inc | ||
7 | * | ||
8 | * Derived from setup_hd64461.c which bore the message: | ||
9 | * Copyright (C) 2000 YAEGASHI Takeshi | ||
10 | */ | ||
11 | |||
12 | #include <linux/sched.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/param.h> | ||
16 | #include <linux/ioport.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/irq.h> | ||
20 | #include <asm/io.h> | ||
21 | #include <asm/irq.h> | ||
22 | #include <asm/hd64465/hd64465.h> | ||
23 | |||
24 | static void disable_hd64465_irq(unsigned int irq) | ||
25 | { | ||
26 | unsigned short nimr; | ||
27 | unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); | ||
28 | |||
29 | pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask); | ||
30 | nimr = inw(HD64465_REG_NIMR); | ||
31 | nimr |= mask; | ||
32 | outw(nimr, HD64465_REG_NIMR); | ||
33 | } | ||
34 | |||
35 | static void enable_hd64465_irq(unsigned int irq) | ||
36 | { | ||
37 | unsigned short nimr; | ||
38 | unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); | ||
39 | |||
40 | pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask); | ||
41 | nimr = inw(HD64465_REG_NIMR); | ||
42 | nimr &= ~mask; | ||
43 | outw(nimr, HD64465_REG_NIMR); | ||
44 | } | ||
45 | |||
46 | static void mask_and_ack_hd64465(unsigned int irq) | ||
47 | { | ||
48 | disable_hd64465_irq(irq); | ||
49 | } | ||
50 | |||
51 | static void end_hd64465_irq(unsigned int irq) | ||
52 | { | ||
53 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | ||
54 | enable_hd64465_irq(irq); | ||
55 | } | ||
56 | |||
57 | static unsigned int startup_hd64465_irq(unsigned int irq) | ||
58 | { | ||
59 | enable_hd64465_irq(irq); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static void shutdown_hd64465_irq(unsigned int irq) | ||
64 | { | ||
65 | disable_hd64465_irq(irq); | ||
66 | } | ||
67 | |||
68 | static struct hw_interrupt_type hd64465_irq_type = { | ||
69 | .typename = "HD64465-IRQ", | ||
70 | .startup = startup_hd64465_irq, | ||
71 | .shutdown = shutdown_hd64465_irq, | ||
72 | .enable = enable_hd64465_irq, | ||
73 | .disable = disable_hd64465_irq, | ||
74 | .ack = mask_and_ack_hd64465, | ||
75 | .end = end_hd64465_irq, | ||
76 | }; | ||
77 | |||
78 | static irqreturn_t hd64465_interrupt(int irq, void *dev_id) | ||
79 | { | ||
80 | printk(KERN_INFO | ||
81 | "HD64465: spurious interrupt, nirr: 0x%x nimr: 0x%x\n", | ||
82 | inw(HD64465_REG_NIRR), inw(HD64465_REG_NIMR)); | ||
83 | |||
84 | return IRQ_NONE; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Support for a secondary IRQ demux step. This is necessary | ||
89 | * because the HD64465 presents a very thin interface to the | ||
90 | * PCMCIA bus; a lot of features (such as remapping interrupts) | ||
91 | * normally done in hardware by other PCMCIA host bridges is | ||
92 | * instead done in software. | ||
93 | */ | ||
94 | static struct { | ||
95 | int (*func)(int, void *); | ||
96 | void *dev; | ||
97 | } hd64465_demux[HD64465_IRQ_NUM]; | ||
98 | |||
99 | void hd64465_register_irq_demux(int irq, | ||
100 | int (*demux)(int irq, void *dev), void *dev) | ||
101 | { | ||
102 | hd64465_demux[irq - HD64465_IRQ_BASE].func = demux; | ||
103 | hd64465_demux[irq - HD64465_IRQ_BASE].dev = dev; | ||
104 | } | ||
105 | EXPORT_SYMBOL(hd64465_register_irq_demux); | ||
106 | |||
107 | void hd64465_unregister_irq_demux(int irq) | ||
108 | { | ||
109 | hd64465_demux[irq - HD64465_IRQ_BASE].func = 0; | ||
110 | } | ||
111 | EXPORT_SYMBOL(hd64465_unregister_irq_demux); | ||
112 | |||
113 | int hd64465_irq_demux(int irq) | ||
114 | { | ||
115 | if (irq == CONFIG_HD64465_IRQ) { | ||
116 | unsigned short i, bit; | ||
117 | unsigned short nirr = inw(HD64465_REG_NIRR); | ||
118 | unsigned short nimr = inw(HD64465_REG_NIMR); | ||
119 | |||
120 | pr_debug("hd64465_irq_demux, nirr=%04x, nimr=%04x\n", nirr, nimr); | ||
121 | nirr &= ~nimr; | ||
122 | for (bit = 1, i = 0 ; i < HD64465_IRQ_NUM ; bit <<= 1, i++) | ||
123 | if (nirr & bit) | ||
124 | break; | ||
125 | |||
126 | if (i < HD64465_IRQ_NUM) { | ||
127 | irq = HD64465_IRQ_BASE + i; | ||
128 | if (hd64465_demux[i].func != 0) | ||
129 | irq = hd64465_demux[i].func(irq, hd64465_demux[i].dev); | ||
130 | } | ||
131 | } | ||
132 | return irq; | ||
133 | } | ||
134 | |||
135 | static struct irqaction irq0 = { | ||
136 | .handler = hd64465_interrupt, | ||
137 | .flags = IRQF_DISABLED, | ||
138 | .mask = CPU_MASK_NONE, | ||
139 | .name = "HD64465", | ||
140 | }; | ||
141 | |||
142 | static int __init setup_hd64465(void) | ||
143 | { | ||
144 | int i; | ||
145 | unsigned short rev; | ||
146 | unsigned short smscr; | ||
147 | |||
148 | if (!MACH_HD64465) | ||
149 | return 0; | ||
150 | |||
151 | printk(KERN_INFO "HD64465 configured at 0x%x on irq %d(mapped into %d to %d)\n", | ||
152 | CONFIG_HD64465_IOBASE, | ||
153 | CONFIG_HD64465_IRQ, | ||
154 | HD64465_IRQ_BASE, | ||
155 | HD64465_IRQ_BASE+HD64465_IRQ_NUM-1); | ||
156 | |||
157 | if (inw(HD64465_REG_SDID) != HD64465_SDID) { | ||
158 | printk(KERN_ERR "HD64465 device ID not found, check base address\n"); | ||
159 | } | ||
160 | |||
161 | rev = inw(HD64465_REG_SRR); | ||
162 | printk(KERN_INFO "HD64465 hardware revision %d.%d\n", (rev >> 8) & 0xff, rev & 0xff); | ||
163 | |||
164 | outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */ | ||
165 | |||
166 | for (i = 0; i < HD64465_IRQ_NUM ; i++) { | ||
167 | irq_desc[HD64465_IRQ_BASE + i].chip = &hd64465_irq_type; | ||
168 | } | ||
169 | |||
170 | setup_irq(CONFIG_HD64465_IRQ, &irq0); | ||
171 | |||
172 | /* wake up the UART from STANDBY at this point */ | ||
173 | smscr = inw(HD64465_REG_SMSCR); | ||
174 | outw(smscr & (~HD64465_SMSCR_UARTST), HD64465_REG_SMSCR); | ||
175 | |||
176 | /* remap IO ports for first ISA serial port to HD64465 UART */ | ||
177 | hd64465_port_map(0x3f8, 8, CONFIG_HD64465_IOBASE + 0x8000, 1); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | module_init(setup_hd64465); | ||
diff --git a/arch/sh/include/asm/hd64465/gpio.h b/arch/sh/include/asm/hd64465/gpio.h deleted file mode 100644 index a3cdca2713dd..000000000000 --- a/arch/sh/include/asm/hd64465/gpio.h +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | #ifndef _ASM_SH_HD64465_GPIO_ | ||
2 | #define _ASM_SH_HD64465_GPIO_ 1 | ||
3 | /* | ||
4 | * $Id: gpio.h,v 1.3 2003/05/04 19:30:14 lethal Exp $ | ||
5 | * | ||
6 | * Hitachi HD64465 companion chip: General Purpose IO pins support. | ||
7 | * This layer enables other device drivers to configure GPIO | ||
8 | * pins, get and set their values, and register an interrupt | ||
9 | * routine for when input pins change in hardware. | ||
10 | * | ||
11 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
12 | * (c) 2000 PocketPenguins Inc. | ||
13 | */ | ||
14 | #include <asm/hd64465.h> | ||
15 | |||
16 | /* Macro to construct a portpin number (used in all | ||
17 | * subsequent functions) from a port letter and a pin | ||
18 | * number, e.g. HD64465_GPIO_PORTPIN('A', 5). | ||
19 | */ | ||
20 | #define HD64465_GPIO_PORTPIN(port,pin) (((port)-'A')<<3|(pin)) | ||
21 | |||
22 | /* Pin configuration constants for _configure() */ | ||
23 | #define HD64465_GPIO_FUNCTION2 0 /* use the pin's *other* function */ | ||
24 | #define HD64465_GPIO_OUT 1 /* output */ | ||
25 | #define HD64465_GPIO_IN_PULLUP 2 /* input, pull-up MOS on */ | ||
26 | #define HD64465_GPIO_IN 3 /* input */ | ||
27 | |||
28 | /* Configure a pin's direction */ | ||
29 | extern void hd64465_gpio_configure(int portpin, int direction); | ||
30 | |||
31 | /* Get, set value */ | ||
32 | extern void hd64465_gpio_set_pin(int portpin, unsigned int value); | ||
33 | extern unsigned int hd64465_gpio_get_pin(int portpin); | ||
34 | extern void hd64465_gpio_set_port(int port, unsigned int value); | ||
35 | extern unsigned int hd64465_gpio_get_port(int port); | ||
36 | |||
37 | /* mode constants for _register_irq() */ | ||
38 | #define HD64465_GPIO_FALLING 0 | ||
39 | #define HD64465_GPIO_RISING 1 | ||
40 | |||
41 | /* Interrupt on external value change */ | ||
42 | extern void hd64465_gpio_register_irq(int portpin, int mode, | ||
43 | void (*handler)(int portpin, void *dev), void *dev); | ||
44 | extern void hd64465_gpio_unregister_irq(int portpin); | ||
45 | |||
46 | #endif /* _ASM_SH_HD64465_GPIO_ */ | ||
diff --git a/arch/sh/include/asm/hd64465/hd64465.h b/arch/sh/include/asm/hd64465/hd64465.h deleted file mode 100644 index cfd0e803d2a2..000000000000 --- a/arch/sh/include/asm/hd64465/hd64465.h +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | #ifndef _ASM_SH_HD64465_ | ||
2 | #define _ASM_SH_HD64465_ 1 | ||
3 | /* | ||
4 | * $Id: hd64465.h,v 1.3 2003/05/04 19:30:15 lethal Exp $ | ||
5 | * | ||
6 | * Hitachi HD64465 companion chip support | ||
7 | * | ||
8 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
9 | * (c) 2000 PocketPenguins Inc. | ||
10 | * | ||
11 | * Derived from <asm/hd64461.h> which bore the message: | ||
12 | * Copyright (C) 2000 YAEGASHI Takeshi | ||
13 | */ | ||
14 | #include <asm/io.h> | ||
15 | #include <asm/irq.h> | ||
16 | |||
17 | /* | ||
18 | * Note that registers are defined here as virtual port numbers, | ||
19 | * which have no meaning except to get translated by hd64465_isa_port2addr() | ||
20 | * to an address in the range 0xb0000000-0xb3ffffff. Note that | ||
21 | * this translation happens to consist of adding the lower 16 bits | ||
22 | * of the virtual port number to 0xb0000000. Note also that the manual | ||
23 | * shows addresses as absolute physical addresses starting at 0x10000000, | ||
24 | * so e.g. the NIRR register is listed as 0x15000 here, 0x10005000 in the | ||
25 | * manual, and accessed using address 0xb0005000 - Greg. | ||
26 | */ | ||
27 | |||
28 | /* System registers */ | ||
29 | #define HD64465_REG_SRR 0x1000c /* System Revision Register */ | ||
30 | #define HD64465_REG_SDID 0x10010 /* System Device ID Reg */ | ||
31 | #define HD64465_SDID 0x8122 /* 64465 device ID */ | ||
32 | |||
33 | /* Power Management registers */ | ||
34 | #define HD64465_REG_SMSCR 0x10000 /* System Module Standby Control Reg */ | ||
35 | #define HD64465_SMSCR_PS2ST 0x4000 /* PS/2 Standby */ | ||
36 | #define HD64465_SMSCR_ADCST 0x1000 /* ADC Standby */ | ||
37 | #define HD64465_SMSCR_UARTST 0x0800 /* UART Standby */ | ||
38 | #define HD64465_SMSCR_SCDIST 0x0200 /* Serial Codec Standby */ | ||
39 | #define HD64465_SMSCR_PPST 0x0100 /* Parallel Port Standby */ | ||
40 | #define HD64465_SMSCR_PC0ST 0x0040 /* PCMCIA0 Standby */ | ||
41 | #define HD64465_SMSCR_PC1ST 0x0020 /* PCMCIA1 Standby */ | ||
42 | #define HD64465_SMSCR_AFEST 0x0010 /* AFE Standby */ | ||
43 | #define HD64465_SMSCR_TM0ST 0x0008 /* Timer0 Standby */ | ||
44 | #define HD64465_SMSCR_TM1ST 0x0004 /* Timer1 Standby */ | ||
45 | #define HD64465_SMSCR_IRDAST 0x0002 /* IRDA Standby */ | ||
46 | #define HD64465_SMSCR_KBCST 0x0001 /* Keyboard Controller Standby */ | ||
47 | |||
48 | /* Interrupt Controller registers */ | ||
49 | #define HD64465_REG_NIRR 0x15000 /* Interrupt Request Register */ | ||
50 | #define HD64465_REG_NIMR 0x15002 /* Interrupt Mask Register */ | ||
51 | #define HD64465_REG_NITR 0x15004 /* Interrupt Trigger Mode Register */ | ||
52 | |||
53 | /* Timer registers */ | ||
54 | #define HD64465_REG_TCVR1 0x16000 /* Timer 1 constant value register */ | ||
55 | #define HD64465_REG_TCVR0 0x16002 /* Timer 0 constant value register */ | ||
56 | #define HD64465_REG_TRVR1 0x16004 /* Timer 1 read value register */ | ||
57 | #define HD64465_REG_TRVR0 0x16006 /* Timer 0 read value register */ | ||
58 | #define HD64465_REG_TCR1 0x16008 /* Timer 1 control register */ | ||
59 | #define HD64465_REG_TCR0 0x1600A /* Timer 0 control register */ | ||
60 | #define HD64465_TCR_EADT 0x10 /* Enable ADTRIG# signal */ | ||
61 | #define HD64465_TCR_ETMO 0x08 /* Enable TMO signal */ | ||
62 | #define HD64465_TCR_PST_MASK 0x06 /* Clock Prescale */ | ||
63 | #define HD64465_TCR_PST_1 0x06 /* 1:1 */ | ||
64 | #define HD64465_TCR_PST_4 0x04 /* 1:4 */ | ||
65 | #define HD64465_TCR_PST_8 0x02 /* 1:8 */ | ||
66 | #define HD64465_TCR_PST_16 0x00 /* 1:16 */ | ||
67 | #define HD64465_TCR_TSTP 0x01 /* Start/Stop timer */ | ||
68 | #define HD64465_REG_TIRR 0x1600C /* Timer interrupt request register */ | ||
69 | #define HD64465_REG_TIDR 0x1600E /* Timer interrupt disable register */ | ||
70 | #define HD64465_REG_PWM1CS 0x16010 /* PWM 1 clock scale register */ | ||
71 | #define HD64465_REG_PWM1LPC 0x16012 /* PWM 1 low pulse width counter register */ | ||
72 | #define HD64465_REG_PWM1HPC 0x16014 /* PWM 1 high pulse width counter register */ | ||
73 | #define HD64465_REG_PWM0CS 0x16018 /* PWM 0 clock scale register */ | ||
74 | #define HD64465_REG_PWM0LPC 0x1601A /* PWM 0 low pulse width counter register */ | ||
75 | #define HD64465_REG_PWM0HPC 0x1601C /* PWM 0 high pulse width counter register */ | ||
76 | |||
77 | /* Analog/Digital Converter registers */ | ||
78 | #define HD64465_REG_ADDRA 0x1E000 /* A/D data register A */ | ||
79 | #define HD64465_REG_ADDRB 0x1E002 /* A/D data register B */ | ||
80 | #define HD64465_REG_ADDRC 0x1E004 /* A/D data register C */ | ||
81 | #define HD64465_REG_ADDRD 0x1E006 /* A/D data register D */ | ||
82 | #define HD64465_REG_ADCSR 0x1E008 /* A/D control/status register */ | ||
83 | #define HD64465_ADCSR_ADF 0x80 /* A/D End Flag */ | ||
84 | #define HD64465_ADCSR_ADST 0x40 /* A/D Start Flag */ | ||
85 | #define HD64465_ADCSR_ADIS 0x20 /* A/D Interrupt Status */ | ||
86 | #define HD64465_ADCSR_TRGE 0x10 /* A/D Trigger Enable */ | ||
87 | #define HD64465_ADCSR_ADIE 0x08 /* A/D Interrupt Enable */ | ||
88 | #define HD64465_ADCSR_SCAN 0x04 /* A/D Scan Mode */ | ||
89 | #define HD64465_ADCSR_CH_MASK 0x03 /* A/D Channel */ | ||
90 | #define HD64465_REG_ADCALCR 0x1E00A /* A/D calibration sample control */ | ||
91 | #define HD64465_REG_ADCAL 0x1E00C /* A/D calibration data register */ | ||
92 | |||
93 | |||
94 | /* General Purpose I/O ports registers */ | ||
95 | #define HD64465_REG_GPACR 0x14000 /* Port A Control Register */ | ||
96 | #define HD64465_REG_GPBCR 0x14002 /* Port B Control Register */ | ||
97 | #define HD64465_REG_GPCCR 0x14004 /* Port C Control Register */ | ||
98 | #define HD64465_REG_GPDCR 0x14006 /* Port D Control Register */ | ||
99 | #define HD64465_REG_GPECR 0x14008 /* Port E Control Register */ | ||
100 | #define HD64465_REG_GPADR 0x14010 /* Port A Data Register */ | ||
101 | #define HD64465_REG_GPBDR 0x14012 /* Port B Data Register */ | ||
102 | #define HD64465_REG_GPCDR 0x14014 /* Port C Data Register */ | ||
103 | #define HD64465_REG_GPDDR 0x14016 /* Port D Data Register */ | ||
104 | #define HD64465_REG_GPEDR 0x14018 /* Port E Data Register */ | ||
105 | #define HD64465_REG_GPAICR 0x14020 /* Port A Interrupt Control Register */ | ||
106 | #define HD64465_REG_GPBICR 0x14022 /* Port B Interrupt Control Register */ | ||
107 | #define HD64465_REG_GPCICR 0x14024 /* Port C Interrupt Control Register */ | ||
108 | #define HD64465_REG_GPDICR 0x14026 /* Port D Interrupt Control Register */ | ||
109 | #define HD64465_REG_GPEICR 0x14028 /* Port E Interrupt Control Register */ | ||
110 | #define HD64465_REG_GPAISR 0x14040 /* Port A Interrupt Status Register */ | ||
111 | #define HD64465_REG_GPBISR 0x14042 /* Port B Interrupt Status Register */ | ||
112 | #define HD64465_REG_GPCISR 0x14044 /* Port C Interrupt Status Register */ | ||
113 | #define HD64465_REG_GPDISR 0x14046 /* Port D Interrupt Status Register */ | ||
114 | #define HD64465_REG_GPEISR 0x14048 /* Port E Interrupt Status Register */ | ||
115 | |||
116 | /* PCMCIA bridge interface */ | ||
117 | #define HD64465_REG_PCC0ISR 0x12000 /* socket 0 interface status */ | ||
118 | #define HD64465_PCCISR_PREADY 0x80 /* mem card ready / io card IREQ */ | ||
119 | #define HD64465_PCCISR_PIREQ 0x80 | ||
120 | #define HD64465_PCCISR_PMWP 0x40 /* mem card write-protected */ | ||
121 | #define HD64465_PCCISR_PVS2 0x20 /* voltage select pin 2 */ | ||
122 | #define HD64465_PCCISR_PVS1 0x10 /* voltage select pin 1 */ | ||
123 | #define HD64465_PCCISR_PCD_MASK 0x0c /* card detect */ | ||
124 | #define HD64465_PCCISR_PBVD_MASK 0x03 /* battery voltage */ | ||
125 | #define HD64465_PCCISR_PBVD_BATGOOD 0x03 /* battery good */ | ||
126 | #define HD64465_PCCISR_PBVD_BATWARN 0x01 /* battery low warning */ | ||
127 | #define HD64465_PCCISR_PBVD_BATDEAD1 0x02 /* battery dead */ | ||
128 | #define HD64465_PCCISR_PBVD_BATDEAD2 0x00 /* battery dead */ | ||
129 | #define HD64465_REG_PCC0GCR 0x12002 /* socket 0 general control */ | ||
130 | #define HD64465_PCCGCR_PDRV 0x80 /* output drive */ | ||
131 | #define HD64465_PCCGCR_PCCR 0x40 /* PC card reset */ | ||
132 | #define HD64465_PCCGCR_PCCT 0x20 /* PC card type, 1=IO&mem, 0=mem */ | ||
133 | #define HD64465_PCCGCR_PVCC0 0x10 /* voltage control pin VCC0SEL0 */ | ||
134 | #define HD64465_PCCGCR_PMMOD 0x08 /* memory mode */ | ||
135 | #define HD64465_PCCGCR_PPA25 0x04 /* pin A25 */ | ||
136 | #define HD64465_PCCGCR_PPA24 0x02 /* pin A24 */ | ||
137 | #define HD64465_PCCGCR_PREG 0x01 /* ping PCC0REG# */ | ||
138 | #define HD64465_REG_PCC0CSCR 0x12004 /* socket 0 card status change */ | ||
139 | #define HD64465_PCCCSCR_PSCDI 0x80 /* sw card detect intr */ | ||
140 | #define HD64465_PCCCSCR_PSWSEL 0x40 /* power select */ | ||
141 | #define HD64465_PCCCSCR_PIREQ 0x20 /* IREQ intr req */ | ||
142 | #define HD64465_PCCCSCR_PSC 0x10 /* STSCHG (status change) pin */ | ||
143 | #define HD64465_PCCCSCR_PCDC 0x08 /* CD (card detect) change */ | ||
144 | #define HD64465_PCCCSCR_PRC 0x04 /* ready change */ | ||
145 | #define HD64465_PCCCSCR_PBW 0x02 /* battery warning change */ | ||
146 | #define HD64465_PCCCSCR_PBD 0x01 /* battery dead change */ | ||
147 | #define HD64465_REG_PCC0CSCIER 0x12006 /* socket 0 card status change interrupt enable */ | ||
148 | #define HD64465_PCCCSCIER_PCRE 0x80 /* change reset enable */ | ||
149 | #define HD64465_PCCCSCIER_PIREQE_MASK 0x60 /* IREQ enable */ | ||
150 | #define HD64465_PCCCSCIER_PIREQE_DISABLED 0x00 /* IREQ disabled */ | ||
151 | #define HD64465_PCCCSCIER_PIREQE_LEVEL 0x20 /* IREQ level-triggered */ | ||
152 | #define HD64465_PCCCSCIER_PIREQE_FALLING 0x40 /* IREQ falling-edge-trig */ | ||
153 | #define HD64465_PCCCSCIER_PIREQE_RISING 0x60 /* IREQ rising-edge-trig */ | ||
154 | #define HD64465_PCCCSCIER_PSCE 0x10 /* status change enable */ | ||
155 | #define HD64465_PCCCSCIER_PCDE 0x08 /* card detect change enable */ | ||
156 | #define HD64465_PCCCSCIER_PRE 0x04 /* ready change enable */ | ||
157 | #define HD64465_PCCCSCIER_PBWE 0x02 /* battery warn change enable */ | ||
158 | #define HD64465_PCCCSCIER_PBDE 0x01 /* battery dead change enable*/ | ||
159 | #define HD64465_REG_PCC0SCR 0x12008 /* socket 0 software control */ | ||
160 | #define HD64465_PCCSCR_SHDN 0x10 /* TPS2206 SHutDowN pin */ | ||
161 | #define HD64465_PCCSCR_SWP 0x01 /* write protect */ | ||
162 | #define HD64465_REG_PCCPSR 0x1200A /* serial power switch control */ | ||
163 | #define HD64465_REG_PCC1ISR 0x12010 /* socket 1 interface status */ | ||
164 | #define HD64465_REG_PCC1GCR 0x12012 /* socket 1 general control */ | ||
165 | #define HD64465_REG_PCC1CSCR 0x12014 /* socket 1 card status change */ | ||
166 | #define HD64465_REG_PCC1CSCIER 0x12016 /* socket 1 card status change interrupt enable */ | ||
167 | #define HD64465_REG_PCC1SCR 0x12018 /* socket 1 software control */ | ||
168 | |||
169 | |||
170 | /* PS/2 Keyboard and mouse controller -- *not* register compatible */ | ||
171 | #define HD64465_REG_KBCSR 0x1dc00 /* Keyboard Control/Status reg */ | ||
172 | #define HD64465_KBCSR_KBCIE 0x8000 /* KBCK Input Enable */ | ||
173 | #define HD64465_KBCSR_KBCOE 0x4000 /* KBCK Output Enable */ | ||
174 | #define HD64465_KBCSR_KBDOE 0x2000 /* KB DATA Output Enable */ | ||
175 | #define HD64465_KBCSR_KBCD 0x1000 /* KBCK Driven */ | ||
176 | #define HD64465_KBCSR_KBDD 0x0800 /* KB DATA Driven */ | ||
177 | #define HD64465_KBCSR_KBCS 0x0400 /* KBCK pin Status */ | ||
178 | #define HD64465_KBCSR_KBDS 0x0200 /* KB DATA pin Status */ | ||
179 | #define HD64465_KBCSR_KBDP 0x0100 /* KB DATA Parity bit */ | ||
180 | #define HD64465_KBCSR_KBD_MASK 0x00ff /* KD DATA shift reg */ | ||
181 | #define HD64465_REG_KBISR 0x1dc04 /* Keyboard Interrupt Status reg */ | ||
182 | #define HD64465_KBISR_KBRDF 0x0001 /* KB Received Data Full */ | ||
183 | #define HD64465_REG_MSCSR 0x1dc10 /* Mouse Control/Status reg */ | ||
184 | #define HD64465_REG_MSISR 0x1dc14 /* Mouse Interrupt Status reg */ | ||
185 | |||
186 | |||
187 | /* | ||
188 | * Logical address at which the HD64465 is mapped. Note that this | ||
189 | * should always be in the P2 segment (uncached and untranslated). | ||
190 | */ | ||
191 | #ifndef CONFIG_HD64465_IOBASE | ||
192 | #define CONFIG_HD64465_IOBASE 0xb0000000 | ||
193 | #endif | ||
194 | /* | ||
195 | * The HD64465 multiplexes all its modules' interrupts onto | ||
196 | * this single interrupt. | ||
197 | */ | ||
198 | #ifndef CONFIG_HD64465_IRQ | ||
199 | #define CONFIG_HD64465_IRQ 5 | ||
200 | #endif | ||
201 | |||
202 | |||
203 | #define _HD64465_IO_MASK 0xf8000000 | ||
204 | #define is_hd64465_addr(addr) \ | ||
205 | ((addr & _HD64465_IO_MASK) == (CONFIG_HD64465_IOBASE & _HD64465_IO_MASK)) | ||
206 | |||
207 | /* | ||
208 | * A range of 16 virtual interrupts generated by | ||
209 | * demuxing the HD64465 muxed interrupt. | ||
210 | */ | ||
211 | #define HD64465_IRQ_BASE OFFCHIP_IRQ_BASE | ||
212 | #define HD64465_IRQ_NUM 16 | ||
213 | #define HD64465_IRQ_ADC (HD64465_IRQ_BASE+0) | ||
214 | #define HD64465_IRQ_USB (HD64465_IRQ_BASE+1) | ||
215 | #define HD64465_IRQ_SCDI (HD64465_IRQ_BASE+2) | ||
216 | #define HD64465_IRQ_PARALLEL (HD64465_IRQ_BASE+3) | ||
217 | /* bit 4 is reserved */ | ||
218 | #define HD64465_IRQ_UART (HD64465_IRQ_BASE+5) | ||
219 | #define HD64465_IRQ_IRDA (HD64465_IRQ_BASE+6) | ||
220 | #define HD64465_IRQ_PS2MOUSE (HD64465_IRQ_BASE+7) | ||
221 | #define HD64465_IRQ_KBC (HD64465_IRQ_BASE+8) | ||
222 | #define HD64465_IRQ_TIMER1 (HD64465_IRQ_BASE+9) | ||
223 | #define HD64465_IRQ_TIMER0 (HD64465_IRQ_BASE+10) | ||
224 | #define HD64465_IRQ_GPIO (HD64465_IRQ_BASE+11) | ||
225 | #define HD64465_IRQ_AFE (HD64465_IRQ_BASE+12) | ||
226 | #define HD64465_IRQ_PCMCIA1 (HD64465_IRQ_BASE+13) | ||
227 | #define HD64465_IRQ_PCMCIA0 (HD64465_IRQ_BASE+14) | ||
228 | #define HD64465_IRQ_PS2KBD (HD64465_IRQ_BASE+15) | ||
229 | |||
230 | /* Constants for PCMCIA mappings */ | ||
231 | #define HD64465_PCC_WINDOW 0x01000000 | ||
232 | |||
233 | #define HD64465_PCC0_BASE 0xb8000000 /* area 6 */ | ||
234 | #define HD64465_PCC0_ATTR (HD64465_PCC0_BASE) | ||
235 | #define HD64465_PCC0_COMM (HD64465_PCC0_BASE+HD64465_PCC_WINDOW) | ||
236 | #define HD64465_PCC0_IO (HD64465_PCC0_BASE+2*HD64465_PCC_WINDOW) | ||
237 | |||
238 | #define HD64465_PCC1_BASE 0xb4000000 /* area 5 */ | ||
239 | #define HD64465_PCC1_ATTR (HD64465_PCC1_BASE) | ||
240 | #define HD64465_PCC1_COMM (HD64465_PCC1_BASE+HD64465_PCC_WINDOW) | ||
241 | #define HD64465_PCC1_IO (HD64465_PCC1_BASE+2*HD64465_PCC_WINDOW) | ||
242 | |||
243 | /* | ||
244 | * Base of USB controller interface (as memory) | ||
245 | */ | ||
246 | #define HD64465_USB_BASE (CONFIG_HD64465_IOBASE+0xb000) | ||
247 | #define HD64465_USB_LEN 0x1000 | ||
248 | /* | ||
249 | * Base of embedded SRAM, used for USB controller. | ||
250 | */ | ||
251 | #define HD64465_SRAM_BASE (CONFIG_HD64465_IOBASE+0x9000) | ||
252 | #define HD64465_SRAM_LEN 0x1000 | ||
253 | |||
254 | |||
255 | |||
256 | #endif /* _ASM_SH_HD64465_ */ | ||
diff --git a/arch/sh/include/asm/hd64465/io.h b/arch/sh/include/asm/hd64465/io.h deleted file mode 100644 index 139f1472e5bb..000000000000 --- a/arch/sh/include/asm/hd64465/io.h +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* | ||
2 | * include/asm-sh/hd64465/io.h | ||
3 | * | ||
4 | * By Greg Banks <gbanks@pocketpenguins.com> | ||
5 | * (c) 2000 PocketPenguins Inc. | ||
6 | * | ||
7 | * Derived from io_hd64461.h, which bore the message: | ||
8 | * Copyright 2000 Stuart Menefy (stuart.menefy@st.com) | ||
9 | * | ||
10 | * May be copied or modified under the terms of the GNU General Public | ||
11 | * License. See linux/COPYING for more information. | ||
12 | * | ||
13 | * IO functions for an HD64465 "Windows CE Intelligent Peripheral Controller". | ||
14 | */ | ||
15 | |||
16 | #ifndef _ASM_SH_IO_HD64465_H | ||
17 | #define _ASM_SH_IO_HD64465_H | ||
18 | |||
19 | extern unsigned char hd64465_inb(unsigned long port); | ||
20 | extern unsigned short hd64465_inw(unsigned long port); | ||
21 | extern unsigned int hd64465_inl(unsigned long port); | ||
22 | |||
23 | extern void hd64465_outb(unsigned char value, unsigned long port); | ||
24 | extern void hd64465_outw(unsigned short value, unsigned long port); | ||
25 | extern void hd64465_outl(unsigned int value, unsigned long port); | ||
26 | |||
27 | extern unsigned char hd64465_inb_p(unsigned long port); | ||
28 | extern void hd64465_outb_p(unsigned char value, unsigned long port); | ||
29 | |||
30 | extern unsigned long hd64465_isa_port2addr(unsigned long offset); | ||
31 | extern int hd64465_irq_demux(int irq); | ||
32 | /* Provision for generic secondary demux step -- used by PCMCIA code */ | ||
33 | extern void hd64465_register_irq_demux(int irq, | ||
34 | int (*demux)(int irq, void *dev), void *dev); | ||
35 | extern void hd64465_unregister_irq_demux(int irq); | ||
36 | /* Set this variable to 1 to see port traffic */ | ||
37 | extern int hd64465_io_debug; | ||
38 | /* Map a range of ports to a range of kernel virtual memory. | ||
39 | */ | ||
40 | extern void hd64465_port_map(unsigned short baseport, unsigned int nports, | ||
41 | unsigned long addr, unsigned char shift); | ||
42 | extern void hd64465_port_unmap(unsigned short baseport, unsigned int nports); | ||
43 | |||
44 | #endif /* _ASM_SH_IO_HD64465_H */ | ||
diff --git a/arch/sh/include/asm/serial.h b/arch/sh/include/asm/serial.h index e13cc948ee60..11f854dd1363 100644 --- a/arch/sh/include/asm/serial.h +++ b/arch/sh/include/asm/serial.h | |||
@@ -7,8 +7,6 @@ | |||
7 | #ifndef _ASM_SERIAL_H | 7 | #ifndef _ASM_SERIAL_H |
8 | #define _ASM_SERIAL_H | 8 | #define _ASM_SERIAL_H |
9 | 9 | ||
10 | #include <linux/kernel.h> | ||
11 | |||
12 | /* | 10 | /* |
13 | * This assumes you have a 1.8432 MHz clock for your UART. | 11 | * This assumes you have a 1.8432 MHz clock for your UART. |
14 | * | 12 | * |
@@ -18,19 +16,4 @@ | |||
18 | */ | 16 | */ |
19 | #define BASE_BAUD ( 1843200 / 16 ) | 17 | #define BASE_BAUD ( 1843200 / 16 ) |
20 | 18 | ||
21 | #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) | ||
22 | |||
23 | #ifdef CONFIG_HD64465 | ||
24 | #include <asm/hd64465/hd64465.h> | ||
25 | |||
26 | #define SERIAL_PORT_DFNS \ | ||
27 | /* UART CLK PORT IRQ FLAGS */ \ | ||
28 | { 0, BASE_BAUD, 0x3F8, HD64465_IRQ_UART, STD_COM_FLAGS } /* ttyS0 */ | ||
29 | |||
30 | #else | ||
31 | |||
32 | #define SERIAL_PORT_DFNS | ||
33 | |||
34 | #endif | ||
35 | |||
36 | #endif /* _ASM_SERIAL_H */ | 19 | #endif /* _ASM_SERIAL_H */ |
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types index d4fb11f7e2ee..d0c2928d1066 100644 --- a/arch/sh/tools/mach-types +++ b/arch/sh/tools/mach-types | |||
@@ -13,7 +13,6 @@ RTS7751R2D SH_RTS7751R2D | |||
13 | # List of companion chips / MFDs. | 13 | # List of companion chips / MFDs. |
14 | # | 14 | # |
15 | HD64461 HD64461 | 15 | HD64461 HD64461 |
16 | HD64465 HD64465 | ||
17 | 16 | ||
18 | # | 17 | # |
19 | # List of boards. | 18 | # List of boards. |
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index f57eeae3830a..222904411a13 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -188,10 +188,6 @@ config PCMCIA_M8XX | |||
188 | 188 | ||
189 | This driver is also available as a module called m8xx_pcmcia. | 189 | This driver is also available as a module called m8xx_pcmcia. |
190 | 190 | ||
191 | config HD64465_PCMCIA | ||
192 | tristate "HD64465 host bridge support" | ||
193 | depends on HD64465 && PCMCIA | ||
194 | |||
195 | config PCMCIA_AU1X00 | 191 | config PCMCIA_AU1X00 |
196 | tristate "Au1x00 pcmcia support" | 192 | tristate "Au1x00 pcmcia support" |
197 | depends on SOC_AU1X00 && PCMCIA | 193 | depends on SOC_AU1X00 && PCMCIA |
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 23e492bf75cf..238629ad7f7c 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -22,7 +22,6 @@ obj-$(CONFIG_I82365) += i82365.o | |||
22 | obj-$(CONFIG_I82092) += i82092.o | 22 | obj-$(CONFIG_I82092) += i82092.o |
23 | obj-$(CONFIG_TCIC) += tcic.o | 23 | obj-$(CONFIG_TCIC) += tcic.o |
24 | obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o | 24 | obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o |
25 | obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o | ||
26 | obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o | 25 | obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o |
27 | obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o | 26 | obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o |
28 | obj-$(CONFIG_M32R_PCC) += m32r_pcc.o | 27 | obj-$(CONFIG_M32R_PCC) += m32r_pcc.o |
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c deleted file mode 100644 index 9ef69cdb3183..000000000000 --- a/drivers/pcmcia/hd64465_ss.c +++ /dev/null | |||
@@ -1,939 +0,0 @@ | |||
1 | /* | ||
2 | * Device driver for the PCMCIA controller module of the | ||
3 | * Hitachi HD64465 handheld companion chip. | ||
4 | * | ||
5 | * Note that the HD64465 provides a very thin PCMCIA host bridge | ||
6 | * layer, requiring a lot of the work of supporting cards to be | ||
7 | * performed by the processor. For example: mapping of card | ||
8 | * interrupts to processor IRQs is done by IRQ demuxing software; | ||
9 | * IO and memory mappings are fixed; setting voltages according | ||
10 | * to card Voltage Select pins etc is done in software. | ||
11 | * | ||
12 | * Note also that this driver uses only the simple, fixed, | ||
13 | * 16MB, 16-bit wide mappings to PCMCIA spaces defined by the | ||
14 | * HD64465. Larger mappings, smaller mappings, or mappings of | ||
15 | * different width to the same socket, are all possible only by | ||
16 | * involving the SH7750's MMU, which is considered unnecessary here. | ||
17 | * The downside is that it may be possible for some drivers to | ||
18 | * break because they need or expect 8-bit mappings. | ||
19 | * | ||
20 | * This driver currently supports only the following configuration: | ||
21 | * SH7750 CPU, HD64465, TPS2206 voltage control chip. | ||
22 | * | ||
23 | * by Greg Banks <gbanks@pocketpenguins.com> | ||
24 | * (c) 2000 PocketPenguins Inc | ||
25 | */ | ||
26 | |||
27 | #include <linux/types.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/string.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/ioport.h> | ||
33 | #include <linux/mm.h> | ||
34 | #include <linux/vmalloc.h> | ||
35 | #include <asm/errno.h> | ||
36 | #include <linux/irq.h> | ||
37 | #include <linux/interrupt.h> | ||
38 | #include <linux/platform_device.h> | ||
39 | |||
40 | #include <asm/io.h> | ||
41 | #include <asm/hd64465/hd64465.h> | ||
42 | #include <asm/hd64465/io.h> | ||
43 | |||
44 | #include <pcmcia/cs_types.h> | ||
45 | #include <pcmcia/cs.h> | ||
46 | #include <pcmcia/cistpl.h> | ||
47 | #include <pcmcia/ds.h> | ||
48 | #include <pcmcia/ss.h> | ||
49 | |||
50 | #define MODNAME "hd64465_ss" | ||
51 | |||
52 | /* #define HD64465_DEBUG 1 */ | ||
53 | |||
54 | #if HD64465_DEBUG | ||
55 | #define DPRINTK(args...) printk(MODNAME ": " args) | ||
56 | #else | ||
57 | #define DPRINTK(args...) | ||
58 | #endif | ||
59 | |||
60 | extern int hd64465_io_debug; | ||
61 | extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags); | ||
62 | extern void p3_iounmap(void *addr); | ||
63 | |||
64 | /*============================================================*/ | ||
65 | |||
66 | #define HS_IO_MAP_SIZE (64*1024) | ||
67 | |||
68 | typedef struct hs_socket_t | ||
69 | { | ||
70 | unsigned int number; | ||
71 | u_int irq; | ||
72 | u_long mem_base; | ||
73 | void *io_base; | ||
74 | u_long mem_length; | ||
75 | u_int ctrl_base; | ||
76 | socket_state_t state; | ||
77 | pccard_io_map io_maps[MAX_IO_WIN]; | ||
78 | pccard_mem_map mem_maps[MAX_WIN]; | ||
79 | struct pcmcia_socket socket; | ||
80 | } hs_socket_t; | ||
81 | |||
82 | |||
83 | |||
84 | #define HS_MAX_SOCKETS 2 | ||
85 | static hs_socket_t hs_sockets[HS_MAX_SOCKETS]; | ||
86 | |||
87 | #define hs_in(sp, r) inb((sp)->ctrl_base + (r)) | ||
88 | #define hs_out(sp, v, r) outb(v, (sp)->ctrl_base + (r)) | ||
89 | |||
90 | |||
91 | /* translate a boolean value to a bit in a register */ | ||
92 | #define bool_to_regbit(sp, r, bi, bo) \ | ||
93 | do { \ | ||
94 | unsigned short v = hs_in(sp, r); \ | ||
95 | if (bo) \ | ||
96 | v |= (bi); \ | ||
97 | else \ | ||
98 | v &= ~(bi); \ | ||
99 | hs_out(sp, v, r); \ | ||
100 | } while(0) | ||
101 | |||
102 | /* register offsets from HD64465_REG_PCC[01]ISR */ | ||
103 | #define ISR 0x0 | ||
104 | #define GCR 0x2 | ||
105 | #define CSCR 0x4 | ||
106 | #define CSCIER 0x6 | ||
107 | #define SCR 0x8 | ||
108 | |||
109 | |||
110 | /* Mask and values for CSCIER register */ | ||
111 | #define IER_MASK 0x80 | ||
112 | #define IER_ON 0x3f /* interrupts on */ | ||
113 | #define IER_OFF 0x00 /* interrupts off */ | ||
114 | |||
115 | /*============================================================*/ | ||
116 | |||
117 | #if HD64465_DEBUG > 10 | ||
118 | |||
119 | static void cis_hex_dump(const unsigned char *x, int len) | ||
120 | { | ||
121 | int i; | ||
122 | |||
123 | for (i=0 ; i<len ; i++) | ||
124 | { | ||
125 | if (!(i & 0xf)) | ||
126 | printk("\n%08x", (unsigned)(x + i)); | ||
127 | printk(" %02x", *(volatile unsigned short*)x); | ||
128 | x += 2; | ||
129 | } | ||
130 | printk("\n"); | ||
131 | } | ||
132 | |||
133 | #endif | ||
134 | /*============================================================*/ | ||
135 | |||
136 | /* | ||
137 | * This code helps create the illusion that the IREQ line from | ||
138 | * the PC card is mapped to one of the CPU's IRQ lines by the | ||
139 | * host bridge hardware (which is how every host bridge *except* | ||
140 | * the HD64465 works). In particular, it supports enabling | ||
141 | * and disabling the IREQ line by code which knows nothing | ||
142 | * about the host bridge (e.g. device drivers, IDE code) using | ||
143 | * the request_irq(), free_irq(), probe_irq_on() and probe_irq_off() | ||
144 | * functions. Also, it supports sharing the mapped IRQ with | ||
145 | * real hardware IRQs from the -IRL0-3 lines. | ||
146 | */ | ||
147 | |||
148 | #define HS_NUM_MAPPED_IRQS 16 /* Limitation of the PCMCIA code */ | ||
149 | static struct | ||
150 | { | ||
151 | /* index is mapped irq number */ | ||
152 | hs_socket_t *sock; | ||
153 | hw_irq_controller *old_handler; | ||
154 | } hs_mapped_irq[HS_NUM_MAPPED_IRQS]; | ||
155 | |||
156 | static void hs_socket_enable_ireq(hs_socket_t *sp) | ||
157 | { | ||
158 | unsigned short cscier; | ||
159 | |||
160 | DPRINTK("hs_socket_enable_ireq(sock=%d)\n", sp->number); | ||
161 | |||
162 | cscier = hs_in(sp, CSCIER); | ||
163 | cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK; | ||
164 | cscier |= HD64465_PCCCSCIER_PIREQE_LEVEL; | ||
165 | hs_out(sp, cscier, CSCIER); | ||
166 | } | ||
167 | |||
168 | static void hs_socket_disable_ireq(hs_socket_t *sp) | ||
169 | { | ||
170 | unsigned short cscier; | ||
171 | |||
172 | DPRINTK("hs_socket_disable_ireq(sock=%d)\n", sp->number); | ||
173 | |||
174 | cscier = hs_in(sp, CSCIER); | ||
175 | cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK; | ||
176 | hs_out(sp, cscier, CSCIER); | ||
177 | } | ||
178 | |||
179 | static unsigned int hs_startup_irq(unsigned int irq) | ||
180 | { | ||
181 | hs_socket_enable_ireq(hs_mapped_irq[irq].sock); | ||
182 | hs_mapped_irq[irq].old_handler->startup(irq); | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static void hs_shutdown_irq(unsigned int irq) | ||
187 | { | ||
188 | hs_socket_disable_ireq(hs_mapped_irq[irq].sock); | ||
189 | hs_mapped_irq[irq].old_handler->shutdown(irq); | ||
190 | } | ||
191 | |||
192 | static void hs_enable_irq(unsigned int irq) | ||
193 | { | ||
194 | hs_socket_enable_ireq(hs_mapped_irq[irq].sock); | ||
195 | hs_mapped_irq[irq].old_handler->enable(irq); | ||
196 | } | ||
197 | |||
198 | static void hs_disable_irq(unsigned int irq) | ||
199 | { | ||
200 | hs_socket_disable_ireq(hs_mapped_irq[irq].sock); | ||
201 | hs_mapped_irq[irq].old_handler->disable(irq); | ||
202 | } | ||
203 | |||
204 | extern struct hw_interrupt_type no_irq_type; | ||
205 | |||
206 | static void hs_mask_and_ack_irq(unsigned int irq) | ||
207 | { | ||
208 | hs_socket_disable_ireq(hs_mapped_irq[irq].sock); | ||
209 | /* ack_none() spuriously complains about an unexpected IRQ */ | ||
210 | if (hs_mapped_irq[irq].old_handler != &no_irq_type) | ||
211 | hs_mapped_irq[irq].old_handler->ack(irq); | ||
212 | } | ||
213 | |||
214 | static void hs_end_irq(unsigned int irq) | ||
215 | { | ||
216 | hs_socket_enable_ireq(hs_mapped_irq[irq].sock); | ||
217 | hs_mapped_irq[irq].old_handler->end(irq); | ||
218 | } | ||
219 | |||
220 | |||
221 | static struct hw_interrupt_type hd64465_ss_irq_type = { | ||
222 | .typename = "PCMCIA-IRQ", | ||
223 | .startup = hs_startup_irq, | ||
224 | .shutdown = hs_shutdown_irq, | ||
225 | .enable = hs_enable_irq, | ||
226 | .disable = hs_disable_irq, | ||
227 | .ack = hs_mask_and_ack_irq, | ||
228 | .end = hs_end_irq | ||
229 | }; | ||
230 | |||
231 | /* | ||
232 | * This function should only ever be called with interrupts disabled. | ||
233 | */ | ||
234 | static void hs_map_irq(hs_socket_t *sp, unsigned int irq) | ||
235 | { | ||
236 | struct irq_desc *desc; | ||
237 | |||
238 | DPRINTK("hs_map_irq(sock=%d irq=%d)\n", sp->number, irq); | ||
239 | |||
240 | if (irq >= HS_NUM_MAPPED_IRQS) | ||
241 | return; | ||
242 | |||
243 | desc = irq_to_desc(irq); | ||
244 | hs_mapped_irq[irq].sock = sp; | ||
245 | /* insert ourselves as the irq controller */ | ||
246 | hs_mapped_irq[irq].old_handler = desc->chip; | ||
247 | desc->chip = &hd64465_ss_irq_type; | ||
248 | } | ||
249 | |||
250 | |||
251 | /* | ||
252 | * This function should only ever be called with interrupts disabled. | ||
253 | */ | ||
254 | static void hs_unmap_irq(hs_socket_t *sp, unsigned int irq) | ||
255 | { | ||
256 | struct irq_desc *desc; | ||
257 | |||
258 | DPRINTK("hs_unmap_irq(sock=%d irq=%d)\n", sp->number, irq); | ||
259 | |||
260 | if (irq >= HS_NUM_MAPPED_IRQS) | ||
261 | return; | ||
262 | |||
263 | desc = irq_to_desc(irq); | ||
264 | /* restore the original irq controller */ | ||
265 | desc->chip = hs_mapped_irq[irq].old_handler; | ||
266 | } | ||
267 | |||
268 | /*============================================================*/ | ||
269 | |||
270 | |||
271 | /* | ||
272 | * Set Vpp and Vcc (in tenths of a Volt). Does not | ||
273 | * support the hi-Z state. | ||
274 | * | ||
275 | * Note, this assumes the board uses a TPS2206 chip to control | ||
276 | * the Vcc and Vpp voltages to the hs_sockets. If your board | ||
277 | * uses the MIC2563 (also supported by the HD64465) then you | ||
278 | * will have to modify this function. | ||
279 | */ | ||
280 | /* 0V 3.3V 5.5V */ | ||
281 | static const u_char hs_tps2206_avcc[3] = { 0x00, 0x04, 0x08 }; | ||
282 | static const u_char hs_tps2206_bvcc[3] = { 0x00, 0x80, 0x40 }; | ||
283 | |||
284 | static int hs_set_voltages(hs_socket_t *sp, int Vcc, int Vpp) | ||
285 | { | ||
286 | u_int psr; | ||
287 | u_int vcci = 0; | ||
288 | u_int sock = sp->number; | ||
289 | |||
290 | DPRINTK("hs_set_voltage(%d, %d, %d)\n", sock, Vcc, Vpp); | ||
291 | |||
292 | switch (Vcc) | ||
293 | { | ||
294 | case 0: vcci = 0; break; | ||
295 | case 33: vcci = 1; break; | ||
296 | case 50: vcci = 2; break; | ||
297 | default: return 0; | ||
298 | } | ||
299 | |||
300 | /* Note: Vpp = 120 not supported -- Greg Banks */ | ||
301 | if (Vpp != 0 && Vpp != Vcc) | ||
302 | return 0; | ||
303 | |||
304 | /* The PSR register holds 8 of the 9 bits which control | ||
305 | * the TPS2206 via its serial interface. | ||
306 | */ | ||
307 | psr = inw(HD64465_REG_PCCPSR); | ||
308 | switch (sock) | ||
309 | { | ||
310 | case 0: | ||
311 | psr &= 0x0f; | ||
312 | psr |= hs_tps2206_avcc[vcci]; | ||
313 | psr |= (Vpp == 0 ? 0x00 : 0x02); | ||
314 | break; | ||
315 | case 1: | ||
316 | psr &= 0xf0; | ||
317 | psr |= hs_tps2206_bvcc[vcci]; | ||
318 | psr |= (Vpp == 0 ? 0x00 : 0x20); | ||
319 | break; | ||
320 | }; | ||
321 | outw(psr, HD64465_REG_PCCPSR); | ||
322 | |||
323 | return 1; | ||
324 | } | ||
325 | |||
326 | |||
327 | /*============================================================*/ | ||
328 | |||
329 | /* | ||
330 | * Drive the RESET line to the card. | ||
331 | */ | ||
332 | static void hs_reset_socket(hs_socket_t *sp, int on) | ||
333 | { | ||
334 | unsigned short v; | ||
335 | |||
336 | v = hs_in(sp, GCR); | ||
337 | if (on) | ||
338 | v |= HD64465_PCCGCR_PCCR; | ||
339 | else | ||
340 | v &= ~HD64465_PCCGCR_PCCR; | ||
341 | hs_out(sp, v, GCR); | ||
342 | } | ||
343 | |||
344 | /*============================================================*/ | ||
345 | |||
346 | static int hs_init(struct pcmcia_socket *s) | ||
347 | { | ||
348 | hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); | ||
349 | |||
350 | DPRINTK("hs_init(%d)\n", sp->number); | ||
351 | |||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | /*============================================================*/ | ||
356 | |||
357 | |||
358 | static int hs_get_status(struct pcmcia_socket *s, u_int *value) | ||
359 | { | ||
360 | hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); | ||
361 | unsigned int isr; | ||
362 | u_int status = 0; | ||
363 | |||
364 | |||
365 | isr = hs_in(sp, ISR); | ||
366 | |||
367 | /* Card is seated and powered when *both* CD pins are low */ | ||
368 | if ((isr & HD64465_PCCISR_PCD_MASK) == 0) | ||
369 | { | ||
370 | status |= SS_DETECT; /* card present */ | ||
371 | |||
372 | switch (isr & HD64465_PCCISR_PBVD_MASK) | ||
373 | { | ||
374 | case HD64465_PCCISR_PBVD_BATGOOD: | ||
375 | break; | ||
376 | case HD64465_PCCISR_PBVD_BATWARN: | ||
377 | status |= SS_BATWARN; | ||
378 | break; | ||
379 | default: | ||
380 | status |= SS_BATDEAD; | ||
381 | break; | ||
382 | } | ||
383 | |||
384 | if (isr & HD64465_PCCISR_PREADY) | ||
385 | status |= SS_READY; | ||
386 | |||
387 | if (isr & HD64465_PCCISR_PMWP) | ||
388 | status |= SS_WRPROT; | ||
389 | |||
390 | /* Voltage Select pins interpreted as per Table 4-5 of the std. | ||
391 | * Assuming we have the TPS2206, the socket is a "Low Voltage | ||
392 | * key, 3.3V and 5V available, no X.XV available". | ||
393 | */ | ||
394 | switch (isr & (HD64465_PCCISR_PVS2|HD64465_PCCISR_PVS1)) | ||
395 | { | ||
396 | case HD64465_PCCISR_PVS1: | ||
397 | printk(KERN_NOTICE MODNAME ": cannot handle X.XV card, ignored\n"); | ||
398 | status = 0; | ||
399 | break; | ||
400 | case 0: | ||
401 | case HD64465_PCCISR_PVS2: | ||
402 | /* 3.3V */ | ||
403 | status |= SS_3VCARD; | ||
404 | break; | ||
405 | case HD64465_PCCISR_PVS2|HD64465_PCCISR_PVS1: | ||
406 | /* 5V */ | ||
407 | break; | ||
408 | } | ||
409 | |||
410 | /* TODO: SS_POWERON */ | ||
411 | /* TODO: SS_STSCHG */ | ||
412 | } | ||
413 | |||
414 | DPRINTK("hs_get_status(%d) = %x\n", sock, status); | ||
415 | |||
416 | *value = status; | ||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | /*============================================================*/ | ||
421 | |||
422 | static int hs_set_socket(struct pcmcia_socket *s, socket_state_t *state) | ||
423 | { | ||
424 | hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); | ||
425 | u_long flags; | ||
426 | u_int changed; | ||
427 | unsigned short cscier; | ||
428 | |||
429 | DPRINTK("hs_set_socket(sock=%d, flags=%x, csc_mask=%x, Vcc=%d, Vpp=%d, io_irq=%d)\n", | ||
430 | sock, state->flags, state->csc_mask, state->Vcc, state->Vpp, state->io_irq); | ||
431 | |||
432 | local_irq_save(flags); /* Don't want interrupts happening here */ | ||
433 | |||
434 | if (state->Vpp != sp->state.Vpp || | ||
435 | state->Vcc != sp->state.Vcc) { | ||
436 | if (!hs_set_voltages(sp, state->Vcc, state->Vpp)) { | ||
437 | local_irq_restore(flags); | ||
438 | return -EINVAL; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | /* hd64465_io_debug = 1; */ | ||
443 | /* | ||
444 | * Handle changes in the Card Status Change mask, | ||
445 | * by propagating to the CSCR register | ||
446 | */ | ||
447 | changed = sp->state.csc_mask ^ state->csc_mask; | ||
448 | cscier = hs_in(sp, CSCIER); | ||
449 | |||
450 | if (changed & SS_DETECT) { | ||
451 | if (state->csc_mask & SS_DETECT) | ||
452 | cscier |= HD64465_PCCCSCIER_PCDE; | ||
453 | else | ||
454 | cscier &= ~HD64465_PCCCSCIER_PCDE; | ||
455 | } | ||
456 | |||
457 | if (changed & SS_READY) { | ||
458 | if (state->csc_mask & SS_READY) | ||
459 | cscier |= HD64465_PCCCSCIER_PRE; | ||
460 | else | ||
461 | cscier &= ~HD64465_PCCCSCIER_PRE; | ||
462 | } | ||
463 | |||
464 | if (changed & SS_BATDEAD) { | ||
465 | if (state->csc_mask & SS_BATDEAD) | ||
466 | cscier |= HD64465_PCCCSCIER_PBDE; | ||
467 | else | ||
468 | cscier &= ~HD64465_PCCCSCIER_PBDE; | ||
469 | } | ||
470 | |||
471 | if (changed & SS_BATWARN) { | ||
472 | if (state->csc_mask & SS_BATWARN) | ||
473 | cscier |= HD64465_PCCCSCIER_PBWE; | ||
474 | else | ||
475 | cscier &= ~HD64465_PCCCSCIER_PBWE; | ||
476 | } | ||
477 | |||
478 | if (changed & SS_STSCHG) { | ||
479 | if (state->csc_mask & SS_STSCHG) | ||
480 | cscier |= HD64465_PCCCSCIER_PSCE; | ||
481 | else | ||
482 | cscier &= ~HD64465_PCCCSCIER_PSCE; | ||
483 | } | ||
484 | |||
485 | hs_out(sp, cscier, CSCIER); | ||
486 | |||
487 | if (sp->state.io_irq && !state->io_irq) | ||
488 | hs_unmap_irq(sp, sp->state.io_irq); | ||
489 | else if (!sp->state.io_irq && state->io_irq) | ||
490 | hs_map_irq(sp, state->io_irq); | ||
491 | |||
492 | |||
493 | /* | ||
494 | * Handle changes in the flags field, | ||
495 | * by propagating to config registers. | ||
496 | */ | ||
497 | changed = sp->state.flags ^ state->flags; | ||
498 | |||
499 | if (changed & SS_IOCARD) { | ||
500 | DPRINTK("card type: %s\n", | ||
501 | (state->flags & SS_IOCARD ? "i/o" : "memory" )); | ||
502 | bool_to_regbit(sp, GCR, HD64465_PCCGCR_PCCT, | ||
503 | state->flags & SS_IOCARD); | ||
504 | } | ||
505 | |||
506 | if (changed & SS_RESET) { | ||
507 | DPRINTK("%s reset card\n", | ||
508 | (state->flags & SS_RESET ? "start" : "stop")); | ||
509 | bool_to_regbit(sp, GCR, HD64465_PCCGCR_PCCR, | ||
510 | state->flags & SS_RESET); | ||
511 | } | ||
512 | |||
513 | if (changed & SS_OUTPUT_ENA) { | ||
514 | DPRINTK("%sabling card output\n", | ||
515 | (state->flags & SS_OUTPUT_ENA ? "en" : "dis")); | ||
516 | bool_to_regbit(sp, GCR, HD64465_PCCGCR_PDRV, | ||
517 | state->flags & SS_OUTPUT_ENA); | ||
518 | } | ||
519 | |||
520 | /* TODO: SS_SPKR_ENA */ | ||
521 | |||
522 | /* hd64465_io_debug = 0; */ | ||
523 | sp->state = *state; | ||
524 | |||
525 | local_irq_restore(flags); | ||
526 | |||
527 | #if HD64465_DEBUG > 10 | ||
528 | if (state->flags & SS_OUTPUT_ENA) | ||
529 | cis_hex_dump((const unsigned char*)sp->mem_base, 0x100); | ||
530 | #endif | ||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | /*============================================================*/ | ||
535 | |||
536 | static int hs_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) | ||
537 | { | ||
538 | hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); | ||
539 | int map = io->map; | ||
540 | int sock = sp->number; | ||
541 | struct pccard_io_map *sio; | ||
542 | pgprot_t prot; | ||
543 | |||
544 | DPRINTK("hs_set_io_map(sock=%d, map=%d, flags=0x%x, speed=%dns, start=%#lx, stop=%#lx)\n", | ||
545 | sock, map, io->flags, io->speed, io->start, io->stop); | ||
546 | if (map >= MAX_IO_WIN) | ||
547 | return -EINVAL; | ||
548 | sio = &sp->io_maps[map]; | ||
549 | |||
550 | /* check for null changes */ | ||
551 | if (io->flags == sio->flags && | ||
552 | io->start == sio->start && | ||
553 | io->stop == sio->stop) | ||
554 | return 0; | ||
555 | |||
556 | if (io->flags & MAP_AUTOSZ) | ||
557 | prot = PAGE_KERNEL_PCC(sock, _PAGE_PCC_IODYN); | ||
558 | else if (io->flags & MAP_16BIT) | ||
559 | prot = PAGE_KERNEL_PCC(sock, _PAGE_PCC_IO16); | ||
560 | else | ||
561 | prot = PAGE_KERNEL_PCC(sock, _PAGE_PCC_IO8); | ||
562 | |||
563 | /* TODO: handle MAP_USE_WAIT */ | ||
564 | if (io->flags & MAP_USE_WAIT) | ||
565 | printk(KERN_INFO MODNAME ": MAP_USE_WAIT unimplemented\n"); | ||
566 | /* TODO: handle MAP_PREFETCH */ | ||
567 | if (io->flags & MAP_PREFETCH) | ||
568 | printk(KERN_INFO MODNAME ": MAP_PREFETCH unimplemented\n"); | ||
569 | /* TODO: handle MAP_WRPROT */ | ||
570 | if (io->flags & MAP_WRPROT) | ||
571 | printk(KERN_INFO MODNAME ": MAP_WRPROT unimplemented\n"); | ||
572 | /* TODO: handle MAP_0WS */ | ||
573 | if (io->flags & MAP_0WS) | ||
574 | printk(KERN_INFO MODNAME ": MAP_0WS unimplemented\n"); | ||
575 | |||
576 | if (io->flags & MAP_ACTIVE) { | ||
577 | unsigned long pstart, psize, paddrbase; | ||
578 | |||
579 | paddrbase = virt_to_phys((void*)(sp->mem_base + 2 * HD64465_PCC_WINDOW)); | ||
580 | pstart = io->start & PAGE_MASK; | ||
581 | psize = ((io->stop + PAGE_SIZE) & PAGE_MASK) - pstart; | ||
582 | |||
583 | /* | ||
584 | * Change PTEs in only that portion of the mapping requested | ||
585 | * by the caller. This means that most of the time, most of | ||
586 | * the PTEs in the io_vma will be unmapped and only the bottom | ||
587 | * page will be mapped. But the code allows for weird cards | ||
588 | * that might want IO ports > 4K. | ||
589 | */ | ||
590 | sp->io_base = p3_ioremap(paddrbase + pstart, psize, pgprot_val(prot)); | ||
591 | |||
592 | /* | ||
593 | * Change the mapping used by inb() outb() etc | ||
594 | */ | ||
595 | hd64465_port_map(io->start, | ||
596 | io->stop - io->start + 1, | ||
597 | (unsigned long)sp->io_base + io->start, 0); | ||
598 | } else { | ||
599 | hd64465_port_unmap(sio->start, sio->stop - sio->start + 1); | ||
600 | p3_iounmap(sp->io_base); | ||
601 | } | ||
602 | |||
603 | *sio = *io; | ||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | /*============================================================*/ | ||
608 | |||
609 | static int hs_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem) | ||
610 | { | ||
611 | hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); | ||
612 | struct pccard_mem_map *smem; | ||
613 | int map = mem->map; | ||
614 | unsigned long paddr; | ||
615 | |||
616 | #if 0 | ||
617 | DPRINTK("hs_set_mem_map(sock=%d, map=%d, flags=0x%x, card_start=0x%08x)\n", | ||
618 | sock, map, mem->flags, mem->card_start); | ||
619 | #endif | ||
620 | |||
621 | if (map >= MAX_WIN) | ||
622 | return -EINVAL; | ||
623 | smem = &sp->mem_maps[map]; | ||
624 | |||
625 | paddr = sp->mem_base; /* base of Attribute mapping */ | ||
626 | if (!(mem->flags & MAP_ATTRIB)) | ||
627 | paddr += HD64465_PCC_WINDOW; /* base of Common mapping */ | ||
628 | paddr += mem->card_start; | ||
629 | |||
630 | /* Because we specified SS_CAP_STATIC_MAP, we are obliged | ||
631 | * at this time to report the system address corresponding | ||
632 | * to the card address requested. This is how Socket Services | ||
633 | * queries our fixed mapping. I wish this fact had been | ||
634 | * documented - Greg Banks. | ||
635 | */ | ||
636 | mem->static_start = paddr; | ||
637 | |||
638 | *smem = *mem; | ||
639 | |||
640 | return 0; | ||
641 | } | ||
642 | |||
643 | /* TODO: do we need to use the MMU to access Common memory ??? */ | ||
644 | |||
645 | /*============================================================*/ | ||
646 | |||
647 | /* | ||
648 | * This function is registered with the HD64465 glue code to do a | ||
649 | * secondary demux step on the PCMCIA interrupts. It handles | ||
650 | * mapping the IREQ request from the card to a standard Linux | ||
651 | * IRQ, as requested by SocketServices. | ||
652 | */ | ||
653 | static int hs_irq_demux(int irq, void *dev) | ||
654 | { | ||
655 | hs_socket_t *sp = dev; | ||
656 | u_int cscr; | ||
657 | |||
658 | DPRINTK("hs_irq_demux(irq=%d)\n", irq); | ||
659 | |||
660 | if (sp->state.io_irq && | ||
661 | (cscr = hs_in(sp, CSCR)) & HD64465_PCCCSCR_PIREQ) { | ||
662 | cscr &= ~HD64465_PCCCSCR_PIREQ; | ||
663 | hs_out(sp, cscr, CSCR); | ||
664 | return sp->state.io_irq; | ||
665 | } | ||
666 | |||
667 | return irq; | ||
668 | } | ||
669 | |||
670 | /*============================================================*/ | ||
671 | |||
672 | /* | ||
673 | * Interrupt handling routine. | ||
674 | */ | ||
675 | |||
676 | static irqreturn_t hs_interrupt(int irq, void *dev) | ||
677 | { | ||
678 | hs_socket_t *sp = dev; | ||
679 | u_int events = 0; | ||
680 | u_int cscr; | ||
681 | |||
682 | cscr = hs_in(sp, CSCR); | ||
683 | |||
684 | DPRINTK("hs_interrupt, cscr=%04x\n", cscr); | ||
685 | |||
686 | /* check for bus-related changes to be reported to Socket Services */ | ||
687 | if (cscr & HD64465_PCCCSCR_PCDC) { | ||
688 | /* double-check for a 16-bit card, as we don't support CardBus */ | ||
689 | if ((hs_in(sp, ISR) & HD64465_PCCISR_PCD_MASK) != 0) { | ||
690 | printk(KERN_NOTICE MODNAME | ||
691 | ": socket %d, card not a supported card type or not inserted correctly\n", | ||
692 | sp->number); | ||
693 | /* Don't do the rest unless a card is present */ | ||
694 | cscr &= ~(HD64465_PCCCSCR_PCDC| | ||
695 | HD64465_PCCCSCR_PRC| | ||
696 | HD64465_PCCCSCR_PBW| | ||
697 | HD64465_PCCCSCR_PBD| | ||
698 | HD64465_PCCCSCR_PSC); | ||
699 | } else { | ||
700 | cscr &= ~HD64465_PCCCSCR_PCDC; | ||
701 | events |= SS_DETECT; /* card insertion or removal */ | ||
702 | } | ||
703 | } | ||
704 | if (cscr & HD64465_PCCCSCR_PRC) { | ||
705 | cscr &= ~HD64465_PCCCSCR_PRC; | ||
706 | events |= SS_READY; /* ready signal changed */ | ||
707 | } | ||
708 | if (cscr & HD64465_PCCCSCR_PBW) { | ||
709 | cscr &= ~HD64465_PCCCSCR_PSC; | ||
710 | events |= SS_BATWARN; /* battery warning */ | ||
711 | } | ||
712 | if (cscr & HD64465_PCCCSCR_PBD) { | ||
713 | cscr &= ~HD64465_PCCCSCR_PSC; | ||
714 | events |= SS_BATDEAD; /* battery dead */ | ||
715 | } | ||
716 | if (cscr & HD64465_PCCCSCR_PSC) { | ||
717 | cscr &= ~HD64465_PCCCSCR_PSC; | ||
718 | events |= SS_STSCHG; /* STSCHG (status changed) signal */ | ||
719 | } | ||
720 | |||
721 | if (cscr & HD64465_PCCCSCR_PIREQ) { | ||
722 | cscr &= ~HD64465_PCCCSCR_PIREQ; | ||
723 | |||
724 | /* This should have been dealt with during irq demux */ | ||
725 | printk(KERN_NOTICE MODNAME ": unexpected IREQ from card\n"); | ||
726 | } | ||
727 | |||
728 | hs_out(sp, cscr, CSCR); | ||
729 | |||
730 | if (events) | ||
731 | pcmcia_parse_events(&sp->socket, events); | ||
732 | |||
733 | return IRQ_HANDLED; | ||
734 | } | ||
735 | |||
736 | /*============================================================*/ | ||
737 | |||
738 | static struct pccard_operations hs_operations = { | ||
739 | .init = hs_init, | ||
740 | .get_status = hs_get_status, | ||
741 | .set_socket = hs_set_socket, | ||
742 | .set_io_map = hs_set_io_map, | ||
743 | .set_mem_map = hs_set_mem_map, | ||
744 | }; | ||
745 | |||
746 | static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base, | ||
747 | unsigned int ctrl_base) | ||
748 | { | ||
749 | unsigned short v; | ||
750 | int i, err; | ||
751 | |||
752 | memset(sp, 0, sizeof(*sp)); | ||
753 | sp->irq = irq; | ||
754 | sp->mem_base = mem_base; | ||
755 | sp->mem_length = 4*HD64465_PCC_WINDOW; /* 16MB */ | ||
756 | sp->ctrl_base = ctrl_base; | ||
757 | |||
758 | for (i=0 ; i<MAX_IO_WIN ; i++) | ||
759 | sp->io_maps[i].map = i; | ||
760 | for (i=0 ; i<MAX_WIN ; i++) | ||
761 | sp->mem_maps[i].map = i; | ||
762 | |||
763 | hd64465_register_irq_demux(sp->irq, hs_irq_demux, sp); | ||
764 | |||
765 | if ((err = request_irq(sp->irq, hs_interrupt, IRQF_DISABLED, MODNAME, sp)) < 0) | ||
766 | return err; | ||
767 | if (request_mem_region(sp->mem_base, sp->mem_length, MODNAME) == 0) { | ||
768 | sp->mem_base = 0; | ||
769 | return -ENOMEM; | ||
770 | } | ||
771 | |||
772 | |||
773 | /* According to section 3.2 of the PCMCIA standard, low-voltage | ||
774 | * capable cards must implement cold insertion, i.e. Vpp and | ||
775 | * Vcc set to 0 before card is inserted. | ||
776 | */ | ||
777 | /*hs_set_voltages(sp, 0, 0);*/ | ||
778 | |||
779 | /* hi-Z the outputs to the card and set 16MB map mode */ | ||
780 | v = hs_in(sp, GCR); | ||
781 | v &= ~HD64465_PCCGCR_PCCT; /* memory-only card */ | ||
782 | hs_out(sp, v, GCR); | ||
783 | |||
784 | v = hs_in(sp, GCR); | ||
785 | v |= HD64465_PCCGCR_PDRV; /* enable outputs to card */ | ||
786 | hs_out(sp, v, GCR); | ||
787 | |||
788 | v = hs_in(sp, GCR); | ||
789 | v |= HD64465_PCCGCR_PMMOD; /* 16MB mapping mode */ | ||
790 | hs_out(sp, v, GCR); | ||
791 | |||
792 | v = hs_in(sp, GCR); | ||
793 | /* lowest 16MB of Common */ | ||
794 | v &= ~(HD64465_PCCGCR_PPA25|HD64465_PCCGCR_PPA24); | ||
795 | hs_out(sp, v, GCR); | ||
796 | |||
797 | hs_reset_socket(sp, 1); | ||
798 | |||
799 | printk(KERN_INFO "HD64465 PCMCIA bridge socket %d at 0x%08lx irq %d\n", | ||
800 | i, sp->mem_base, sp->irq); | ||
801 | |||
802 | return 0; | ||
803 | } | ||
804 | |||
805 | static void hs_exit_socket(hs_socket_t *sp) | ||
806 | { | ||
807 | unsigned short cscier, gcr; | ||
808 | unsigned long flags; | ||
809 | |||
810 | local_irq_save(flags); | ||
811 | |||
812 | /* turn off interrupts in hardware */ | ||
813 | cscier = hs_in(sp, CSCIER); | ||
814 | cscier = (cscier & IER_MASK) | IER_OFF; | ||
815 | hs_out(sp, cscier, CSCIER); | ||
816 | |||
817 | /* hi-Z the outputs to the card */ | ||
818 | gcr = hs_in(sp, GCR); | ||
819 | gcr &= HD64465_PCCGCR_PDRV; | ||
820 | hs_out(sp, gcr, GCR); | ||
821 | |||
822 | /* power the card down */ | ||
823 | hs_set_voltages(sp, 0, 0); | ||
824 | |||
825 | if (sp->mem_base != 0) | ||
826 | release_mem_region(sp->mem_base, sp->mem_length); | ||
827 | if (sp->irq != 0) { | ||
828 | free_irq(sp->irq, hs_interrupt); | ||
829 | hd64465_unregister_irq_demux(sp->irq); | ||
830 | } | ||
831 | |||
832 | local_irq_restore(flags); | ||
833 | } | ||
834 | |||
835 | static struct device_driver hd64465_driver = { | ||
836 | .name = "hd64465-pcmcia", | ||
837 | .bus = &platform_bus_type, | ||
838 | .suspend = pcmcia_socket_dev_suspend, | ||
839 | .resume = pcmcia_socket_dev_resume, | ||
840 | }; | ||
841 | |||
842 | static struct platform_device hd64465_device = { | ||
843 | .name = "hd64465-pcmcia", | ||
844 | .id = 0, | ||
845 | }; | ||
846 | |||
847 | static int __init init_hs(void) | ||
848 | { | ||
849 | int i; | ||
850 | unsigned short v; | ||
851 | |||
852 | /* hd64465_io_debug = 1; */ | ||
853 | if (driver_register(&hd64465_driver)) | ||
854 | return -EINVAL; | ||
855 | |||
856 | /* Wake both sockets out of STANDBY mode */ | ||
857 | /* TODO: wait 15ms */ | ||
858 | v = inw(HD64465_REG_SMSCR); | ||
859 | v &= ~(HD64465_SMSCR_PC0ST|HD64465_SMSCR_PC1ST); | ||
860 | outw(v, HD64465_REG_SMSCR); | ||
861 | |||
862 | /* keep power controller out of shutdown mode */ | ||
863 | v = inb(HD64465_REG_PCC0SCR); | ||
864 | v |= HD64465_PCCSCR_SHDN; | ||
865 | outb(v, HD64465_REG_PCC0SCR); | ||
866 | |||
867 | /* use serial (TPS2206) power controller */ | ||
868 | v = inb(HD64465_REG_PCC0CSCR); | ||
869 | v |= HD64465_PCCCSCR_PSWSEL; | ||
870 | outb(v, HD64465_REG_PCC0CSCR); | ||
871 | |||
872 | /* | ||
873 | * Setup hs_sockets[] structures and request system resources. | ||
874 | * TODO: on memory allocation failure, power down the socket | ||
875 | * before quitting. | ||
876 | */ | ||
877 | for (i=0; i<HS_MAX_SOCKETS; i++) { | ||
878 | hs_set_voltages(&hs_sockets[i], 0, 0); | ||
879 | |||
880 | hs_sockets[i].socket.features |= SS_CAP_PCCARD | SS_CAP_STATIC_MAP; /* mappings are fixed in host memory */ | ||
881 | hs_sockets[i].socket.resource_ops = &pccard_static_ops; | ||
882 | hs_sockets[i].socket.irq_mask = 0xffde;/*0xffff*/ /* IRQs mapped in s/w so can do any, really */ | ||
883 | hs_sockets[i].socket.map_size = HD64465_PCC_WINDOW; /* 16MB fixed window size */ | ||
884 | |||
885 | hs_sockets[i].socket.owner = THIS_MODULE; | ||
886 | hs_sockets[i].socket.ss_entry = &hs_operations; | ||
887 | } | ||
888 | |||
889 | i = hs_init_socket(&hs_sockets[0], | ||
890 | HD64465_IRQ_PCMCIA0, | ||
891 | HD64465_PCC0_BASE, | ||
892 | HD64465_REG_PCC0ISR); | ||
893 | if (i < 0) { | ||
894 | unregister_driver(&hd64465_driver); | ||
895 | return i; | ||
896 | } | ||
897 | i = hs_init_socket(&hs_sockets[1], | ||
898 | HD64465_IRQ_PCMCIA1, | ||
899 | HD64465_PCC1_BASE, | ||
900 | HD64465_REG_PCC1ISR); | ||
901 | if (i < 0) { | ||
902 | unregister_driver(&hd64465_driver); | ||
903 | return i; | ||
904 | } | ||
905 | |||
906 | /* hd64465_io_debug = 0; */ | ||
907 | |||
908 | platform_device_register(&hd64465_device); | ||
909 | |||
910 | for (i=0; i<HS_MAX_SOCKETS; i++) { | ||
911 | unsigned int ret; | ||
912 | hs_sockets[i].socket.dev.parent = &hd64465_device.dev; | ||
913 | hs_sockets[i].number = i; | ||
914 | ret = pcmcia_register_socket(&hs_sockets[i].socket); | ||
915 | if (ret && i) | ||
916 | pcmcia_unregister_socket(&hs_sockets[0].socket); | ||
917 | } | ||
918 | |||
919 | return 0; | ||
920 | } | ||
921 | |||
922 | static void __exit exit_hs(void) | ||
923 | { | ||
924 | int i; | ||
925 | |||
926 | for (i=0 ; i<HS_MAX_SOCKETS ; i++) { | ||
927 | pcmcia_unregister_socket(&hs_sockets[i].socket); | ||
928 | hs_exit_socket(&hs_sockets[i]); | ||
929 | } | ||
930 | |||
931 | platform_device_unregister(&hd64465_device); | ||
932 | unregister_driver(&hd64465_driver); | ||
933 | } | ||
934 | |||
935 | module_init(init_hs); | ||
936 | module_exit(exit_hs); | ||
937 | |||
938 | /*============================================================*/ | ||
939 | /*END*/ | ||