1 /*
2 * vrc4171.c, NEC VRC4171 base driver.
3 *
4 * Copyright (C) 2003 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 #include <linux/init.h>
21 #include <linux/ioport.h>
22 #include <linux/module.h>
23 #include <linux/types.h>
24
25 #include <asm/io.h>
26 #include <asm/vr41xx/vrc4171.h>
27
28 MODULE_DESCRIPTION("NEC VRC4171 base driver");
29 MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>");
30 MODULE_LICENSE("GPL");
31
32 EXPORT_SYMBOL_GPL(vrc4171_get_irq_status);
33 EXPORT_SYMBOL_GPL(vrc4171_set_multifunction_pin);
34
35 #define CONFIGURATION1 0x05fe
36 #define SLOTB_CONFIG 0xc000
37 #define SLOTB_NONE 0x0000
38 #define SLOTB_PCCARD 0x4000
39 #define SLOTB_CF 0x8000
40 #define SLOTB_FLASHROM 0xc000
41
42 #define CONFIGURATION2 0x05fc
43 #define INTERRUPT_STATUS 0x05fa
44 #define PCS_CONTROL 0x05ee
45 #define GPIO_DATA PCS_CONTROL
46 #define PCS0_UPPER_START 0x05ec
47 #define PCS0_LOWER_START 0x05ea
48 #define PCS0_UPPER_STOP 0x05e8
49 #define PCS0_LOWER_STOP 0x05e6
50 #define PCS1_UPPER_START 0x05e4
51 #define PCS1_LOWER_START 0x05e2
52 #define PCS1_UPPER_STOP 0x05de
53 #define PCS1_LOWER_STOP 0x05dc
54
55 #define VRC4171_REGS_BASE PCS1_LOWER_STOP
56 #define VRC4171_REGS_SIZE 0x24
57
vrc4171_get_irq_status(void)58 uint16_t vrc4171_get_irq_status(void)
59 {
60 return inw(INTERRUPT_STATUS);
61 }
62
vrc4171_set_multifunction_pin(int config)63 void vrc4171_set_multifunction_pin(int config)
64 {
65 uint16_t config1;
66
67 config1 = inw(CONFIGURATION1);
68 config1 &= ~SLOTB_CONFIG;
69
70 switch (config) {
71 case SLOTB_IS_NONE:
72 config1 |= SLOTB_NONE;
73 break;
74 case SLOTB_IS_PCCARD:
75 config1 |= SLOTB_PCCARD;
76 break;
77 case SLOTB_IS_CF:
78 config1 |= SLOTB_CF;
79 break;
80 case SLOTB_IS_FLASHROM:
81 config1 |= SLOTB_FLASHROM;
82 break;
83 default:
84 break;
85 }
86
87 outw(config1, CONFIGURATION1);
88 }
89
vrc4171_init(void)90 static int __devinit vrc4171_init(void)
91 {
92 if (request_region(VRC4171_REGS_BASE, VRC4171_REGS_SIZE, "NEC VRC4171") == NULL)
93 return -EBUSY;
94
95 printk(KERN_INFO "NEC VRC4171 base driver\n");
96
97 return 0;
98 }
99
vrc4171_exit(void)100 static void __devexit vrc4171_exit(void)
101 {
102 release_region(VRC4171_REGS_BASE, VRC4171_REGS_SIZE);
103 }
104
105 module_init(vrc4171_init);
106 module_exit(vrc4171_exit);
107