diff options
Diffstat (limited to 'arch/sh/boards/landisk')
-rw-r--r-- | arch/sh/boards/landisk/Makefile | 5 | ||||
-rw-r--r-- | arch/sh/boards/landisk/io.c | 250 | ||||
-rw-r--r-- | arch/sh/boards/landisk/irq.c | 99 | ||||
-rw-r--r-- | arch/sh/boards/landisk/landisk_pwb.c | 348 | ||||
-rw-r--r-- | arch/sh/boards/landisk/rtc.c | 93 | ||||
-rw-r--r-- | arch/sh/boards/landisk/setup.c | 177 |
6 files changed, 972 insertions, 0 deletions
diff --git a/arch/sh/boards/landisk/Makefile b/arch/sh/boards/landisk/Makefile new file mode 100644 index 000000000000..89e4beb2ad47 --- /dev/null +++ b/arch/sh/boards/landisk/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for I-O DATA DEVICE, INC. "LANDISK Series" | ||
3 | # | ||
4 | |||
5 | obj-y := setup.o io.o irq.o rtc.o landisk_pwb.o | ||
diff --git a/arch/sh/boards/landisk/io.c b/arch/sh/boards/landisk/io.c new file mode 100644 index 000000000000..92498b4947d5 --- /dev/null +++ b/arch/sh/boards/landisk/io.c | |||
@@ -0,0 +1,250 @@ | |||
1 | /* | ||
2 | * arch/sh/boards/landisk/io.c | ||
3 | * | ||
4 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel | ||
5 | * Based largely on io_se.c. | ||
6 | * | ||
7 | * I/O routine for I-O Data Device, Inc. LANDISK. | ||
8 | * | ||
9 | * Initial version only to support LAN access; some | ||
10 | * placeholder code from io_landisk.c left in with the | ||
11 | * expectation of later SuperIO and PCMCIA access. | ||
12 | */ | ||
13 | /* | ||
14 | * modifed by kogiidena | ||
15 | * 2005.03.03 | ||
16 | */ | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/pci.h> | ||
20 | #include <asm/landisk/iodata_landisk.h> | ||
21 | #include <asm/addrspace.h> | ||
22 | #include <asm/io.h> | ||
23 | |||
24 | extern void *area5_io_base; /* Area 5 I/O Base address */ | ||
25 | extern void *area6_io_base; /* Area 6 I/O Base address */ | ||
26 | |||
27 | static inline unsigned long port2adr(unsigned int port) | ||
28 | { | ||
29 | if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) | ||
30 | if (port == 0x3f6) | ||
31 | return ((unsigned long)area5_io_base + 0x2c); | ||
32 | else | ||
33 | return ((unsigned long)area5_io_base + PA_PIDE_OFFSET + | ||
34 | ((port - 0x1f0) << 1)); | ||
35 | else if ((0x170 <= port && port < 0x178) || port == 0x376) | ||
36 | if (port == 0x376) | ||
37 | return ((unsigned long)area6_io_base + 0x2c); | ||
38 | else | ||
39 | return ((unsigned long)area6_io_base + PA_SIDE_OFFSET + | ||
40 | ((port - 0x170) << 1)); | ||
41 | else | ||
42 | maybebadio((unsigned long)port); | ||
43 | |||
44 | return port; | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * General outline: remap really low stuff [eventually] to SuperIO, | ||
49 | * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) | ||
50 | * is mapped through the PCI IO window. Stuff with high bits (PXSEG) | ||
51 | * should be way beyond the window, and is used w/o translation for | ||
52 | * compatibility. | ||
53 | */ | ||
54 | u8 landisk_inb(unsigned long port) | ||
55 | { | ||
56 | if (PXSEG(port)) | ||
57 | return ctrl_inb(port); | ||
58 | else if (is_pci_ioaddr(port)) | ||
59 | return ctrl_inb(pci_ioaddr(port)); | ||
60 | |||
61 | return ctrl_inw(port2adr(port)) & 0xff; | ||
62 | } | ||
63 | |||
64 | u8 landisk_inb_p(unsigned long port) | ||
65 | { | ||
66 | u8 v; | ||
67 | |||
68 | if (PXSEG(port)) | ||
69 | v = ctrl_inb(port); | ||
70 | else if (is_pci_ioaddr(port)) | ||
71 | v = ctrl_inb(pci_ioaddr(port)); | ||
72 | else | ||
73 | v = ctrl_inw(port2adr(port)) & 0xff; | ||
74 | |||
75 | ctrl_delay(); | ||
76 | |||
77 | return v; | ||
78 | } | ||
79 | |||
80 | u16 landisk_inw(unsigned long port) | ||
81 | { | ||
82 | if (PXSEG(port)) | ||
83 | return ctrl_inw(port); | ||
84 | else if (is_pci_ioaddr(port)) | ||
85 | return ctrl_inw(pci_ioaddr(port)); | ||
86 | else | ||
87 | maybebadio(port); | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | u32 landisk_inl(unsigned long port) | ||
93 | { | ||
94 | if (PXSEG(port)) | ||
95 | return ctrl_inl(port); | ||
96 | else if (is_pci_ioaddr(port)) | ||
97 | return ctrl_inl(pci_ioaddr(port)); | ||
98 | else | ||
99 | maybebadio(port); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | void landisk_outb(u8 value, unsigned long port) | ||
105 | { | ||
106 | if (PXSEG(port)) | ||
107 | ctrl_outb(value, port); | ||
108 | else if (is_pci_ioaddr(port)) | ||
109 | ctrl_outb(value, pci_ioaddr(port)); | ||
110 | else | ||
111 | ctrl_outw(value, port2adr(port)); | ||
112 | } | ||
113 | |||
114 | void landisk_outb_p(u8 value, unsigned long port) | ||
115 | { | ||
116 | if (PXSEG(port)) | ||
117 | ctrl_outb(value, port); | ||
118 | else if (is_pci_ioaddr(port)) | ||
119 | ctrl_outb(value, pci_ioaddr(port)); | ||
120 | else | ||
121 | ctrl_outw(value, port2adr(port)); | ||
122 | ctrl_delay(); | ||
123 | } | ||
124 | |||
125 | void landisk_outw(u16 value, unsigned long port) | ||
126 | { | ||
127 | if (PXSEG(port)) | ||
128 | ctrl_outw(value, port); | ||
129 | else if (is_pci_ioaddr(port)) | ||
130 | ctrl_outw(value, pci_ioaddr(port)); | ||
131 | else | ||
132 | maybebadio(port); | ||
133 | } | ||
134 | |||
135 | void landisk_outl(u32 value, unsigned long port) | ||
136 | { | ||
137 | if (PXSEG(port)) | ||
138 | ctrl_outl(value, port); | ||
139 | else if (is_pci_ioaddr(port)) | ||
140 | ctrl_outl(value, pci_ioaddr(port)); | ||
141 | else | ||
142 | maybebadio(port); | ||
143 | } | ||
144 | |||
145 | void landisk_insb(unsigned long port, void *dst, unsigned long count) | ||
146 | { | ||
147 | volatile u16 *p; | ||
148 | u8 *buf = dst; | ||
149 | |||
150 | if (PXSEG(port)) { | ||
151 | while (count--) | ||
152 | *buf++ = *(volatile u8 *)port; | ||
153 | } else if (is_pci_ioaddr(port)) { | ||
154 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); | ||
155 | |||
156 | while (count--) | ||
157 | *buf++ = *bp; | ||
158 | } else { | ||
159 | p = (volatile u16 *)port2adr(port); | ||
160 | while (count--) | ||
161 | *buf++ = *p & 0xff; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | void landisk_insw(unsigned long port, void *dst, unsigned long count) | ||
166 | { | ||
167 | volatile u16 *p; | ||
168 | u16 *buf = dst; | ||
169 | |||
170 | if (PXSEG(port)) | ||
171 | p = (volatile u16 *)port; | ||
172 | else if (is_pci_ioaddr(port)) | ||
173 | p = (volatile u16 *)pci_ioaddr(port); | ||
174 | else | ||
175 | p = (volatile u16 *)port2adr(port); | ||
176 | while (count--) | ||
177 | *buf++ = *p; | ||
178 | } | ||
179 | |||
180 | void landisk_insl(unsigned long port, void *dst, unsigned long count) | ||
181 | { | ||
182 | u32 *buf = dst; | ||
183 | |||
184 | if (is_pci_ioaddr(port)) { | ||
185 | volatile u32 *p = (volatile u32 *)pci_ioaddr(port); | ||
186 | |||
187 | while (count--) | ||
188 | *buf++ = *p; | ||
189 | } else | ||
190 | maybebadio(port); | ||
191 | } | ||
192 | |||
193 | void landisk_outsb(unsigned long port, const void *src, unsigned long count) | ||
194 | { | ||
195 | volatile u16 *p; | ||
196 | const u8 *buf = src; | ||
197 | |||
198 | if (PXSEG(port)) | ||
199 | while (count--) | ||
200 | ctrl_outb(*buf++, port); | ||
201 | else if (is_pci_ioaddr(port)) { | ||
202 | volatile u8 *bp = (volatile u8 *)pci_ioaddr(port); | ||
203 | |||
204 | while (count--) | ||
205 | *bp = *buf++; | ||
206 | } else { | ||
207 | p = (volatile u16 *)port2adr(port); | ||
208 | while (count--) | ||
209 | *p = *buf++; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | void landisk_outsw(unsigned long port, const void *src, unsigned long count) | ||
214 | { | ||
215 | volatile u16 *p; | ||
216 | const u16 *buf = src; | ||
217 | |||
218 | if (PXSEG(port)) | ||
219 | p = (volatile u16 *)port; | ||
220 | else if (is_pci_ioaddr(port)) | ||
221 | p = (volatile u16 *)pci_ioaddr(port); | ||
222 | else | ||
223 | p = (volatile u16 *)port2adr(port); | ||
224 | |||
225 | while (count--) | ||
226 | *p = *buf++; | ||
227 | } | ||
228 | |||
229 | void landisk_outsl(unsigned long port, const void *src, unsigned long count) | ||
230 | { | ||
231 | const u32 *buf = src; | ||
232 | |||
233 | if (is_pci_ioaddr(port)) { | ||
234 | volatile u32 *p = (volatile u32 *)pci_ioaddr(port); | ||
235 | |||
236 | while (count--) | ||
237 | *p = *buf++; | ||
238 | } else | ||
239 | maybebadio(port); | ||
240 | } | ||
241 | |||
242 | void __iomem *landisk_ioport_map(unsigned long port, unsigned int size) | ||
243 | { | ||
244 | if (PXSEG(port)) | ||
245 | return (void __iomem *)port; | ||
246 | else if (is_pci_ioaddr(port)) | ||
247 | return (void __iomem *)pci_ioaddr(port); | ||
248 | |||
249 | return (void __iomem *)port2adr(port); | ||
250 | } | ||
diff --git a/arch/sh/boards/landisk/irq.c b/arch/sh/boards/landisk/irq.c new file mode 100644 index 000000000000..a006d6443225 --- /dev/null +++ b/arch/sh/boards/landisk/irq.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * arch/sh/boards/landisk/irq.c | ||
3 | * | ||
4 | * Copyright (C) 2001 Ian da Silva, Jeremy Siegel | ||
5 | * Based largely on io_se.c. | ||
6 | * | ||
7 | * I/O routine for I-O Data Device, Inc. LANDISK. | ||
8 | * | ||
9 | * Initial version only to support LAN access; some | ||
10 | * placeholder code from io_landisk.c left in with the | ||
11 | * expectation of later SuperIO and PCMCIA access. | ||
12 | */ | ||
13 | /* | ||
14 | * modified by kogiidena | ||
15 | * 2005.03.03 | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/irq.h> | ||
21 | #include <asm/io.h> | ||
22 | #include <asm/irq.h> | ||
23 | #include <asm/landisk/iodata_landisk.h> | ||
24 | |||
25 | static void enable_landisk_irq(unsigned int irq); | ||
26 | static void disable_landisk_irq(unsigned int irq); | ||
27 | |||
28 | /* shutdown is same as "disable" */ | ||
29 | #define shutdown_landisk_irq disable_landisk_irq | ||
30 | |||
31 | static void ack_landisk_irq(unsigned int irq); | ||
32 | static void end_landisk_irq(unsigned int irq); | ||
33 | |||
34 | static unsigned int startup_landisk_irq(unsigned int irq) | ||
35 | { | ||
36 | enable_landisk_irq(irq); | ||
37 | return 0; /* never anything pending */ | ||
38 | } | ||
39 | |||
40 | static void disable_landisk_irq(unsigned int irq) | ||
41 | { | ||
42 | unsigned char val; | ||
43 | unsigned char mask = 0xff ^ (0x01 << (irq - 5)); | ||
44 | |||
45 | /* Set the priority in IPR to 0 */ | ||
46 | val = ctrl_inb(PA_IMASK); | ||
47 | val &= mask; | ||
48 | ctrl_outb(val, PA_IMASK); | ||
49 | } | ||
50 | |||
51 | static void enable_landisk_irq(unsigned int irq) | ||
52 | { | ||
53 | unsigned char val; | ||
54 | unsigned char value = (0x01 << (irq - 5)); | ||
55 | |||
56 | /* Set priority in IPR back to original value */ | ||
57 | val = ctrl_inb(PA_IMASK); | ||
58 | val |= value; | ||
59 | ctrl_outb(val, PA_IMASK); | ||
60 | } | ||
61 | |||
62 | static void ack_landisk_irq(unsigned int irq) | ||
63 | { | ||
64 | disable_landisk_irq(irq); | ||
65 | } | ||
66 | |||
67 | static void end_landisk_irq(unsigned int irq) | ||
68 | { | ||
69 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) | ||
70 | enable_landisk_irq(irq); | ||
71 | } | ||
72 | |||
73 | static struct hw_interrupt_type landisk_irq_type = { | ||
74 | .typename = "LANDISK IRQ", | ||
75 | .startup = startup_landisk_irq, | ||
76 | .shutdown = shutdown_landisk_irq, | ||
77 | .enable = enable_landisk_irq, | ||
78 | .disable = disable_landisk_irq, | ||
79 | .ack = ack_landisk_irq, | ||
80 | .end = end_landisk_irq | ||
81 | }; | ||
82 | |||
83 | static void make_landisk_irq(unsigned int irq) | ||
84 | { | ||
85 | disable_irq_nosync(irq); | ||
86 | irq_desc[irq].handler = &landisk_irq_type; | ||
87 | disable_landisk_irq(irq); | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * Initialize IRQ setting | ||
92 | */ | ||
93 | void __init init_landisk_IRQ(void) | ||
94 | { | ||
95 | int i; | ||
96 | |||
97 | for (i = 5; i < 14; i++) | ||
98 | make_landisk_irq(i); | ||
99 | } | ||
diff --git a/arch/sh/boards/landisk/landisk_pwb.c b/arch/sh/boards/landisk/landisk_pwb.c new file mode 100644 index 000000000000..e75cb578a28b --- /dev/null +++ b/arch/sh/boards/landisk/landisk_pwb.c | |||
@@ -0,0 +1,348 @@ | |||
1 | /* | ||
2 | * arch/sh/boards/landisk/landisk_pwb.c -- driver for the Power control switch. | ||
3 | * | ||
4 | * This driver will also support the I-O DATA Device, Inc. LANDISK Board. | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | * | ||
10 | * Copylight (C) 2002 Atom Create Engineering Co., Ltd. | ||
11 | * | ||
12 | * LED control drive function added by kogiidena | ||
13 | */ | ||
14 | |||
15 | #include <linux/config.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/signal.h> | ||
19 | #include <linux/major.h> | ||
20 | #include <linux/poll.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/sched.h> | ||
24 | #include <linux/timer.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | |||
27 | #include <asm/system.h> | ||
28 | #include <asm/io.h> | ||
29 | #include <asm/irq.h> | ||
30 | #include <asm/uaccess.h> | ||
31 | #include <asm/landisk/iodata_landisk.h> | ||
32 | |||
33 | #define SHUTDOWN_BTN_MINOR 1 /* Shutdown button device minor no. */ | ||
34 | #define LED_MINOR 21 /* LED minor no. */ | ||
35 | #define BTN_MINOR 22 /* BUTTON minor no. */ | ||
36 | #define GIO_MINOR 40 /* GIO minor no. */ | ||
37 | |||
38 | static int openCnt; | ||
39 | static int openCntLED; | ||
40 | static int openCntGio; | ||
41 | static int openCntBtn; | ||
42 | static int landisk_btn; | ||
43 | static int landisk_btnctrlpid; | ||
44 | /* | ||
45 | * Functions prototypes | ||
46 | */ | ||
47 | |||
48 | static int gio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | ||
49 | unsigned long arg); | ||
50 | |||
51 | static int swdrv_open(struct inode *inode, struct file *filp) | ||
52 | { | ||
53 | int minor; | ||
54 | |||
55 | minor = MINOR(inode->i_rdev); | ||
56 | filp->private_data = (void *)minor; | ||
57 | |||
58 | if (minor == SHUTDOWN_BTN_MINOR) { | ||
59 | if (openCnt > 0) { | ||
60 | return -EALREADY; | ||
61 | } else { | ||
62 | openCnt++; | ||
63 | return 0; | ||
64 | } | ||
65 | } else if (minor == LED_MINOR) { | ||
66 | if (openCntLED > 0) { | ||
67 | return -EALREADY; | ||
68 | } else { | ||
69 | openCntLED++; | ||
70 | return 0; | ||
71 | } | ||
72 | } else if (minor == BTN_MINOR) { | ||
73 | if (openCntBtn > 0) { | ||
74 | return -EALREADY; | ||
75 | } else { | ||
76 | openCntBtn++; | ||
77 | return 0; | ||
78 | } | ||
79 | } else if (minor == GIO_MINOR) { | ||
80 | if (openCntGio > 0) { | ||
81 | return -EALREADY; | ||
82 | } else { | ||
83 | openCntGio++; | ||
84 | return 0; | ||
85 | } | ||
86 | } | ||
87 | return -ENOENT; | ||
88 | |||
89 | } | ||
90 | |||
91 | static int swdrv_close(struct inode *inode, struct file *filp) | ||
92 | { | ||
93 | int minor; | ||
94 | |||
95 | minor = MINOR(inode->i_rdev); | ||
96 | if (minor == SHUTDOWN_BTN_MINOR) { | ||
97 | openCnt--; | ||
98 | } else if (minor == LED_MINOR) { | ||
99 | openCntLED--; | ||
100 | } else if (minor == BTN_MINOR) { | ||
101 | openCntBtn--; | ||
102 | } else if (minor == GIO_MINOR) { | ||
103 | openCntGio--; | ||
104 | } | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static int swdrv_read(struct file *filp, char *buff, size_t count, | ||
109 | loff_t * ppos) | ||
110 | { | ||
111 | int minor; | ||
112 | minor = (int)(filp->private_data); | ||
113 | |||
114 | if (!access_ok(VERIFY_WRITE, (void *)buff, count)) | ||
115 | return -EFAULT; | ||
116 | |||
117 | if (minor == SHUTDOWN_BTN_MINOR) { | ||
118 | if (landisk_btn & 0x10) { | ||
119 | put_user(1, buff); | ||
120 | return 1; | ||
121 | } else { | ||
122 | return 0; | ||
123 | } | ||
124 | } | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int swdrv_write(struct file *filp, const char *buff, size_t count, | ||
129 | loff_t * ppos) | ||
130 | { | ||
131 | int minor; | ||
132 | minor = (int)(filp->private_data); | ||
133 | |||
134 | if (minor == SHUTDOWN_BTN_MINOR) { | ||
135 | return count; | ||
136 | } | ||
137 | return count; | ||
138 | } | ||
139 | |||
140 | static irqreturn_t sw_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
141 | { | ||
142 | landisk_btn = (0x0ff & (~ctrl_inb(PA_STATUS))); | ||
143 | disable_irq(IRQ_BUTTON); | ||
144 | disable_irq(IRQ_POWER); | ||
145 | ctrl_outb(0x00, PA_PWRINT_CLR); | ||
146 | |||
147 | if (landisk_btnctrlpid != 0) { | ||
148 | kill_proc(landisk_btnctrlpid, SIGUSR1, 1); | ||
149 | landisk_btnctrlpid = 0; | ||
150 | } | ||
151 | |||
152 | return IRQ_HANDLED; | ||
153 | } | ||
154 | |||
155 | static struct file_operations swdrv_fops = { | ||
156 | .read = swdrv_read, /* read */ | ||
157 | .write = swdrv_write, /* write */ | ||
158 | .open = swdrv_open, /* open */ | ||
159 | .release = swdrv_close, /* release */ | ||
160 | .ioctl = gio_ioctl, /* ioctl */ | ||
161 | |||
162 | }; | ||
163 | |||
164 | static char banner[] __initdata = | ||
165 | KERN_INFO "LANDISK and USL-5P Button, LED and GIO driver initialized\n"; | ||
166 | |||
167 | int __init swdrv_init(void) | ||
168 | { | ||
169 | int error; | ||
170 | |||
171 | printk("%s", banner); | ||
172 | |||
173 | openCnt = 0; | ||
174 | openCntLED = 0; | ||
175 | openCntBtn = 0; | ||
176 | openCntGio = 0; | ||
177 | landisk_btn = 0; | ||
178 | landisk_btnctrlpid = 0; | ||
179 | |||
180 | if ((error = register_chrdev(SHUTDOWN_BTN_MAJOR, "swdrv", &swdrv_fops))) { | ||
181 | printk(KERN_ERR | ||
182 | "Button, LED and GIO driver:Couldn't register driver, error=%d\n", | ||
183 | error); | ||
184 | return 1; | ||
185 | } | ||
186 | |||
187 | if (request_irq(IRQ_POWER, sw_interrupt, 0, "SHUTDOWNSWITCH", NULL)) { | ||
188 | printk(KERN_ERR "Unable to get IRQ 11.\n"); | ||
189 | return 1; | ||
190 | } | ||
191 | if (request_irq(IRQ_BUTTON, sw_interrupt, 0, "USL-5P BUTTON", NULL)) { | ||
192 | printk(KERN_ERR "Unable to get IRQ 12.\n"); | ||
193 | return 1; | ||
194 | } | ||
195 | ctrl_outb(0x00, PA_PWRINT_CLR); | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | module_init(swdrv_init); | ||
201 | |||
202 | /* | ||
203 | * gio driver | ||
204 | * | ||
205 | */ | ||
206 | |||
207 | #include <asm/landisk/gio.h> | ||
208 | |||
209 | static int gio_ioctl(struct inode *inode, struct file *filp, | ||
210 | unsigned int cmd, unsigned long arg) | ||
211 | { | ||
212 | int minor; | ||
213 | unsigned int data, mask; | ||
214 | static unsigned int addr = 0; | ||
215 | |||
216 | minor = (int)(filp->private_data); | ||
217 | |||
218 | /* access control */ | ||
219 | if (minor == GIO_MINOR) { | ||
220 | ; | ||
221 | } else if (minor == LED_MINOR) { | ||
222 | if (((cmd & 0x0ff) >= 9) && ((cmd & 0x0ff) < 20)) { | ||
223 | ; | ||
224 | } else { | ||
225 | return -EINVAL; | ||
226 | } | ||
227 | } else if (minor == BTN_MINOR) { | ||
228 | if (((cmd & 0x0ff) >= 20) && ((cmd & 0x0ff) < 30)) { | ||
229 | ; | ||
230 | } else { | ||
231 | return -EINVAL; | ||
232 | } | ||
233 | } else { | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | |||
237 | if (cmd & 0x01) { /* write */ | ||
238 | if (copy_from_user(&data, (int *)arg, sizeof(int))) { | ||
239 | return -EFAULT; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | switch (cmd) { | ||
244 | case GIODRV_IOCSGIOSETADDR: /* addres set */ | ||
245 | addr = data; | ||
246 | break; | ||
247 | |||
248 | case GIODRV_IOCSGIODATA1: /* write byte */ | ||
249 | ctrl_outb((unsigned char)(0x0ff & data), addr); | ||
250 | break; | ||
251 | |||
252 | case GIODRV_IOCSGIODATA2: /* write word */ | ||
253 | if (addr & 0x01) { | ||
254 | return -EFAULT; | ||
255 | } | ||
256 | ctrl_outw((unsigned short int)(0x0ffff & data), addr); | ||
257 | break; | ||
258 | |||
259 | case GIODRV_IOCSGIODATA4: /* write long */ | ||
260 | if (addr & 0x03) { | ||
261 | return -EFAULT; | ||
262 | } | ||
263 | ctrl_outl(data, addr); | ||
264 | break; | ||
265 | |||
266 | case GIODRV_IOCGGIODATA1: /* read byte */ | ||
267 | data = ctrl_inb(addr); | ||
268 | break; | ||
269 | |||
270 | case GIODRV_IOCGGIODATA2: /* read word */ | ||
271 | if (addr & 0x01) { | ||
272 | return -EFAULT; | ||
273 | } | ||
274 | data = ctrl_inw(addr); | ||
275 | break; | ||
276 | |||
277 | case GIODRV_IOCGGIODATA4: /* read long */ | ||
278 | if (addr & 0x03) { | ||
279 | return -EFAULT; | ||
280 | } | ||
281 | data = ctrl_inl(addr); | ||
282 | break; | ||
283 | case GIODRV_IOCSGIO_LED: /* write */ | ||
284 | mask = ((data & 0x00ffffff) << 8) | ||
285 | | ((data & 0x0000ffff) << 16) | ||
286 | | ((data & 0x000000ff) << 24); | ||
287 | landisk_ledparam = data & (~mask); | ||
288 | if (landisk_arch == 0) { /* arch == landisk */ | ||
289 | landisk_ledparam &= 0x03030303; | ||
290 | mask = (~(landisk_ledparam >> 22)) & 0x000c; | ||
291 | landisk_ledparam |= mask; | ||
292 | } else { /* arch == usl-5p */ | ||
293 | mask = (landisk_ledparam >> 24) & 0x0001; | ||
294 | landisk_ledparam |= mask; | ||
295 | landisk_ledparam &= 0x007f7f7f; | ||
296 | } | ||
297 | landisk_ledparam |= 0x80; | ||
298 | break; | ||
299 | case GIODRV_IOCGGIO_LED: /* read */ | ||
300 | data = landisk_ledparam; | ||
301 | if (landisk_arch == 0) { /* arch == landisk */ | ||
302 | data &= 0x03030303; | ||
303 | } else { /* arch == usl-5p */ | ||
304 | ; | ||
305 | } | ||
306 | data &= (~0x080); | ||
307 | break; | ||
308 | case GIODRV_IOCSGIO_BUZZER: /* write */ | ||
309 | landisk_buzzerparam = data; | ||
310 | landisk_ledparam |= 0x80; | ||
311 | break; | ||
312 | case GIODRV_IOCGGIO_LANDISK: /* read */ | ||
313 | data = landisk_arch & 0x01; | ||
314 | break; | ||
315 | case GIODRV_IOCGGIO_BTN: /* read */ | ||
316 | data = (0x0ff & ctrl_inb(PA_PWRINT_CLR)); | ||
317 | data <<= 8; | ||
318 | data |= (0x0ff & ctrl_inb(PA_IMASK)); | ||
319 | data <<= 8; | ||
320 | data |= (0x0ff & landisk_btn); | ||
321 | data <<= 8; | ||
322 | data |= (0x0ff & (~ctrl_inb(PA_STATUS))); | ||
323 | break; | ||
324 | case GIODRV_IOCSGIO_BTNPID: /* write */ | ||
325 | landisk_btnctrlpid = data; | ||
326 | landisk_btn = 0; | ||
327 | if (irq_desc[IRQ_BUTTON].depth) { | ||
328 | enable_irq(IRQ_BUTTON); | ||
329 | } | ||
330 | if (irq_desc[IRQ_POWER].depth) { | ||
331 | enable_irq(IRQ_POWER); | ||
332 | } | ||
333 | break; | ||
334 | case GIODRV_IOCGGIO_BTNPID: /* read */ | ||
335 | data = landisk_btnctrlpid; | ||
336 | break; | ||
337 | default: | ||
338 | return -EFAULT; | ||
339 | break; | ||
340 | } | ||
341 | |||
342 | if ((cmd & 0x01) == 0) { /* read */ | ||
343 | if (copy_to_user((int *)arg, &data, sizeof(int))) { | ||
344 | return -EFAULT; | ||
345 | } | ||
346 | } | ||
347 | return 0; | ||
348 | } | ||
diff --git a/arch/sh/boards/landisk/rtc.c b/arch/sh/boards/landisk/rtc.c new file mode 100644 index 000000000000..35ba726a0979 --- /dev/null +++ b/arch/sh/boards/landisk/rtc.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * arch/sh/boards/landisk/rtc.c -- RTC support | ||
3 | * | ||
4 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> | ||
5 | * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka | ||
6 | */ | ||
7 | /* | ||
8 | * modifed by kogiidena | ||
9 | * 2005.09.16 | ||
10 | */ | ||
11 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/sched.h> | ||
16 | #include <linux/time.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | #include <linux/bcd.h> | ||
20 | #include <asm/rtc.h> | ||
21 | |||
22 | extern spinlock_t rtc_lock; | ||
23 | |||
24 | extern void | ||
25 | rs5c313_set_cmos_time(unsigned int BCD_yr, unsigned int BCD_mon, | ||
26 | unsigned int BCD_day, unsigned int BCD_hr, | ||
27 | unsigned int BCD_min, unsigned int BCD_sec); | ||
28 | |||
29 | extern unsigned long | ||
30 | rs5c313_get_cmos_time(unsigned int *BCD_yr, unsigned int *BCD_mon, | ||
31 | unsigned int *BCD_day, unsigned int *BCD_hr, | ||
32 | unsigned int *BCD_min, unsigned int *BCD_sec); | ||
33 | |||
34 | void landisk_rtc_gettimeofday(struct timespec *tv) | ||
35 | { | ||
36 | unsigned int BCD_yr, BCD_mon, BCD_day, BCD_hr, BCD_min, BCD_sec; | ||
37 | unsigned long flags; | ||
38 | |||
39 | spin_lock_irqsave(&rtc_lock, flags); | ||
40 | tv->tv_sec = rs5c313_get_cmos_time | ||
41 | (&BCD_yr, &BCD_mon, &BCD_day, &BCD_hr, &BCD_min, &BCD_sec); | ||
42 | tv->tv_nsec = 0; | ||
43 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
44 | } | ||
45 | |||
46 | int landisk_rtc_settimeofday(const time_t secs) | ||
47 | { | ||
48 | int retval = 0; | ||
49 | int real_seconds, real_minutes, cmos_minutes; | ||
50 | unsigned long flags; | ||
51 | unsigned long nowtime = secs; | ||
52 | unsigned int BCD_yr, BCD_mon, BCD_day, BCD_hr, BCD_min, BCD_sec; | ||
53 | |||
54 | spin_lock_irqsave(&rtc_lock, flags); | ||
55 | |||
56 | rs5c313_get_cmos_time | ||
57 | (&BCD_yr, &BCD_mon, &BCD_day, &BCD_hr, &BCD_min, &BCD_sec); | ||
58 | cmos_minutes = BCD_min; | ||
59 | BCD_TO_BIN(cmos_minutes); | ||
60 | |||
61 | /* | ||
62 | * since we're only adjusting minutes and seconds, | ||
63 | * don't interfere with hour overflow. This avoids | ||
64 | * messing with unknown time zones but requires your | ||
65 | * RTC not to be off by more than 15 minutes | ||
66 | */ | ||
67 | real_seconds = nowtime % 60; | ||
68 | real_minutes = nowtime / 60; | ||
69 | if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1) | ||
70 | real_minutes += 30; /* correct for half hour time zone */ | ||
71 | real_minutes %= 60; | ||
72 | |||
73 | if (abs(real_minutes - cmos_minutes) < 30) { | ||
74 | BIN_TO_BCD(real_seconds); | ||
75 | BIN_TO_BCD(real_minutes); | ||
76 | rs5c313_set_cmos_time(BCD_yr, BCD_mon, BCD_day, BCD_hr, | ||
77 | real_minutes, real_seconds); | ||
78 | } else { | ||
79 | printk(KERN_WARNING | ||
80 | "set_rtc_time: can't update from %d to %d\n", | ||
81 | cmos_minutes, real_minutes); | ||
82 | retval = -1; | ||
83 | } | ||
84 | |||
85 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
86 | return retval; | ||
87 | } | ||
88 | |||
89 | void landisk_time_init(void) | ||
90 | { | ||
91 | rtc_sh_get_time = landisk_rtc_gettimeofday; | ||
92 | rtc_sh_set_time = landisk_rtc_settimeofday; | ||
93 | } | ||
diff --git a/arch/sh/boards/landisk/setup.c b/arch/sh/boards/landisk/setup.c new file mode 100644 index 000000000000..127b9e020e00 --- /dev/null +++ b/arch/sh/boards/landisk/setup.c | |||
@@ -0,0 +1,177 @@ | |||
1 | /* | ||
2 | * arch/sh/boards/landisk/setup.c | ||
3 | * | ||
4 | * Copyright (C) 2000 Kazumoto Kojima | ||
5 | * Copyright (C) 2002 Paul Mundt | ||
6 | * | ||
7 | * I-O DATA Device, Inc. LANDISK Support. | ||
8 | * | ||
9 | * Modified for LANDISK by | ||
10 | * Atom Create Engineering Co., Ltd. 2002. | ||
11 | * | ||
12 | * modifed by kogiidena | ||
13 | * 2005.09.16 | ||
14 | * | ||
15 | * This file is subject to the terms and conditions of the GNU General Public | ||
16 | * License. See the file "COPYING" in the main directory of this archive | ||
17 | * for more details. | ||
18 | */ | ||
19 | #include <linux/config.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/pm.h> | ||
22 | #include <linux/mm.h> | ||
23 | #include <asm/machvec.h> | ||
24 | #include <asm/rtc.h> | ||
25 | #include <asm/landisk/iodata_landisk.h> | ||
26 | #include <asm/io.h> | ||
27 | |||
28 | void landisk_time_init(void); | ||
29 | void init_landisk_IRQ(void); | ||
30 | |||
31 | int landisk_ledparam; | ||
32 | int landisk_buzzerparam; | ||
33 | int landisk_arch; | ||
34 | |||
35 | /* cycle the led's in the clasic knightrider/sun pattern */ | ||
36 | static void heartbeat_landisk(void) | ||
37 | { | ||
38 | static unsigned int cnt = 0, blink = 0x00, period = 25; | ||
39 | volatile u8 *p = (volatile u8 *)PA_LED; | ||
40 | char data; | ||
41 | |||
42 | if ((landisk_ledparam & 0x080) == 0) | ||
43 | return; | ||
44 | |||
45 | cnt += 1; | ||
46 | |||
47 | if (cnt < period) | ||
48 | return; | ||
49 | |||
50 | cnt = 0; | ||
51 | blink++; | ||
52 | |||
53 | data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0; | ||
54 | data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0; | ||
55 | data |= landisk_ledparam; | ||
56 | |||
57 | /* buzzer */ | ||
58 | if (landisk_buzzerparam & 0x1) { | ||
59 | data |= 0x80; | ||
60 | } else { | ||
61 | data &= 0x7f; | ||
62 | } | ||
63 | *p = data; | ||
64 | |||
65 | if (((landisk_ledparam & 0x007f7f00) == 0) && | ||
66 | (landisk_buzzerparam == 0)) | ||
67 | landisk_ledparam &= (~0x0080); | ||
68 | |||
69 | landisk_buzzerparam >>= 1; | ||
70 | } | ||
71 | |||
72 | static void landisk_power_off(void) | ||
73 | { | ||
74 | ctrl_outb(0x01, PA_SHUTDOWN); | ||
75 | } | ||
76 | |||
77 | static void check_usl5p(void) | ||
78 | { | ||
79 | volatile u8 *p = (volatile u8 *)PA_LED; | ||
80 | u8 tmp1, tmp2; | ||
81 | |||
82 | tmp1 = *p; | ||
83 | *p = 0x40; | ||
84 | tmp2 = *p; | ||
85 | *p = tmp1; | ||
86 | |||
87 | landisk_arch = (tmp2 == 0x40); | ||
88 | if (landisk_arch == 1) { | ||
89 | /* arch == usl-5p */ | ||
90 | landisk_ledparam = 0x00000380; | ||
91 | landisk_ledparam |= (tmp1 & 0x07c); | ||
92 | } else { | ||
93 | /* arch == landisk */ | ||
94 | landisk_ledparam = 0x02000180; | ||
95 | landisk_ledparam |= 0x04; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | void *area5_io_base; | ||
100 | void *area6_io_base; | ||
101 | |||
102 | static int __init landisk_cf_init(void) | ||
103 | { | ||
104 | pgprot_t prot; | ||
105 | unsigned long paddrbase, psize; | ||
106 | |||
107 | /* open I/O area window */ | ||
108 | paddrbase = virt_to_phys((void *)PA_AREA5_IO); | ||
109 | psize = PAGE_SIZE; | ||
110 | prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16); | ||
111 | area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot); | ||
112 | if (!area5_io_base) { | ||
113 | printk("allocate_cf_area : can't open CF I/O window!\n"); | ||
114 | return -ENOMEM; | ||
115 | } | ||
116 | |||
117 | paddrbase = virt_to_phys((void *)PA_AREA6_IO); | ||
118 | psize = PAGE_SIZE; | ||
119 | prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16); | ||
120 | area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot); | ||
121 | if (!area6_io_base) { | ||
122 | printk("allocate_cf_area : can't open HDD I/O window!\n"); | ||
123 | return -ENOMEM; | ||
124 | } | ||
125 | |||
126 | printk(KERN_INFO "Allocate Area5/6 success.\n"); | ||
127 | |||
128 | /* XXX : do we need attribute and common-memory area also? */ | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static void __init landisk_setup(char **cmdline_p) | ||
134 | { | ||
135 | device_initcall(landisk_cf_init); | ||
136 | |||
137 | landisk_buzzerparam = 0; | ||
138 | check_usl5p(); | ||
139 | |||
140 | printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n"); | ||
141 | |||
142 | board_time_init = landisk_time_init; | ||
143 | pm_power_off = landisk_power_off; | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * The Machine Vector | ||
148 | */ | ||
149 | struct sh_machine_vector mv_landisk __initmv = { | ||
150 | .mv_name = "LANDISK", | ||
151 | .mv_setup = landisk_setup, | ||
152 | .mv_nr_irqs = 72, | ||
153 | .mv_inb = landisk_inb, | ||
154 | .mv_inw = landisk_inw, | ||
155 | .mv_inl = landisk_inl, | ||
156 | .mv_outb = landisk_outb, | ||
157 | .mv_outw = landisk_outw, | ||
158 | .mv_outl = landisk_outl, | ||
159 | .mv_inb_p = landisk_inb_p, | ||
160 | .mv_inw_p = landisk_inw, | ||
161 | .mv_inl_p = landisk_inl, | ||
162 | .mv_outb_p = landisk_outb_p, | ||
163 | .mv_outw_p = landisk_outw, | ||
164 | .mv_outl_p = landisk_outl, | ||
165 | .mv_insb = landisk_insb, | ||
166 | .mv_insw = landisk_insw, | ||
167 | .mv_insl = landisk_insl, | ||
168 | .mv_outsb = landisk_outsb, | ||
169 | .mv_outsw = landisk_outsw, | ||
170 | .mv_outsl = landisk_outsl, | ||
171 | .mv_ioport_map = landisk_ioport_map, | ||
172 | .mv_init_irq = init_landisk_IRQ, | ||
173 | #ifdef CONFIG_HEARTBEAT | ||
174 | .mv_heartbeat = heartbeat_landisk, | ||
175 | #endif | ||
176 | }; | ||
177 | ALIAS_MV(landisk) | ||