23 #include <linux/module.h>
25 #include <linux/types.h>
38 #define CARD_MAX_SLOTS 2
41 #define CARD_SLOTB_OFFSET 0x40
43 #define CARD_MEM_START 0x10000000
44 #define CARD_MEM_END 0x13ffffff
45 #define CARD_MAX_MEM_OFFSET 0x3ffffff
46 #define CARD_MAX_MEM_SPEED 1000
48 #define CARD_CONTROLLER_INDEX 0x03e0
49 #define CARD_CONTROLLER_DATA 0x03e1
51 #define VPP_GET_VCC 0x01
52 #define POWER_ENABLE 0x10
53 #define CARD_VOLTAGE_SENSE 0x1f
54 #define VCC_3VORXV_CAPABLE 0x00
55 #define VCC_XV_ONLY 0x01
56 #define VCC_3V_CAPABLE 0x02
57 #define VCC_5V_ONLY 0x03
58 #define CARD_VOLTAGE_SELECT 0x2f
62 #define VCC_STATUS_3V 0x02
63 #define VCC_STATUS_5V 0x01
64 #define VCC_STATUS_XV 0x03
65 #define GLOBAL_CONTROL 0x1e
70 #define INTERRUPT_STATUS 0x05fa
74 #define CONFIGURATION1 0x05fe
75 #define SLOTB_CONFIG 0xc000
76 #define SLOTB_NONE 0x0000
77 #define SLOTB_PCCARD 0x4000
78 #define SLOTB_CF 0x8000
79 #define SLOTB_FLASHROM 0xc000
81 #define CARD_CONTROLLER_START CARD_CONTROLLER_INDEX
82 #define CARD_CONTROLLER_END CARD_CONTROLLER_DATA
85 #define MEM_MAX_MAPS 5
113 static char vrc4171_card_name[] =
"NEC VRC4171 Card Controller";
114 static unsigned int vrc4171_irq;
115 static uint16_t vrc4171_irq_mask = 0xdeb8;
117 static struct resource vrc4171_card_resource[3] = {
118 { .name = vrc4171_card_name,
122 { .name = vrc4171_card_name,
126 { .name = vrc4171_card_name,
133 .name = vrc4171_card_name,
136 .resource = vrc4171_card_resource,
139 static inline uint16_t vrc4171_get_irq_status(
void)
221 static inline int search_nonuse_irq(
void)
225 for (i = 0; i < 16; i++) {
226 if (vrc4171_irq_mask & (1 << i)) {
227 vrc4171_irq_mask &= ~(1 <<
i);
246 socket = &vrc4171_sockets[
slot];
247 socket->
csc_irq = search_nonuse_irq();
248 socket->
io_irq = search_nonuse_irq();
271 else if ((status & (I365_CS_BVD1 |
I365_CS_BVD2)) == I365_CS_BVD1)
324 (state->
Vpp != state->
Vcc && state->
Vpp != 0) ||
325 (state->
Vcc != 50 && state->
Vcc != 33 && state->
Vcc != 0))
329 socket = &vrc4171_sockets[
slot];
331 spin_lock_irq(&socket->
lock);
333 voltage = set_Vcc_value(state->
Vcc);
337 if (state->
Vpp == state->
Vcc)
345 control |= socket->
io_irq;
358 cscint |= socket->
csc_irq << 8;
374 spin_unlock_irq(&socket->
lock);
432 mem->
res->start > mem->
res->end ||
446 start = (mem->
res->start >> 12) & 0x3fff;
451 stop = (mem->
res->end >> 12) & 0x3fff;
452 switch (mem->
speed) {
484 .get_status = pccard_get_status,
485 .set_socket = pccard_set_socket,
486 .set_io_map = pccard_set_io_map,
487 .set_mem_map = pccard_set_mem_map,
490 static inline unsigned int get_events(
int slot)
496 csc = exca_read_byte(slot,
I365_CSC);
498 if (exca_read_byte(slot,
I365_INTCTL) & I365_PC_IOCARD) {
503 if (!(status & I365_CS_BVD1))
505 else if ((status & (I365_CS_BVD1 |
I365_CS_BVD2)) == I365_CS_BVD1)
511 if ((csc &
I365_CSC_DETECT) && ((status & I365_CS_DETECT) == I365_CS_DETECT))
524 status = vrc4171_get_irq_status();
525 if (status &
IRQ_A) {
528 if (status & (1 << socket->
csc_irq)) {
538 if (status &
IRQ_B) {
541 if (status & (1 << socket->
csc_irq)) {
554 static inline void reserve_using_irq(
int slot)
560 vrc4171_irq_mask &= ~(1 << irq);
563 irq = (irq & 0xf0) >> 4;
564 vrc4171_irq_mask &= ~(1 << irq);
567 static int __devinit vrc4171_add_sockets(
void)
576 socket = &vrc4171_sockets[
slot];
580 switch (socket->
slot) {
595 reserve_using_irq(slot);
599 sprintf(socket->
name,
"NEC VRC4171 Card Slot %1c",
'A' + slot);
617 static void vrc4171_remove_sockets(
void)
626 socket = &vrc4171_sockets[
slot];
636 if (options ==
NULL || *options ==
'\0')
639 if (
strncmp(options,
"irq:", 4) == 0) {
651 if (
strncmp(options,
"slota:", 6) == 0) {
653 if (*options !=
'\0') {
654 if (
strncmp(options,
"memnoprobe", 10) == 0) {
657 }
else if (
strncmp(options,
"ionoprobe", 9) == 0) {
660 }
else if (
strncmp(options,
"noprobe", 7) == 0) {
673 if (
strncmp(options,
"slotb:", 6) == 0) {
675 if (*options !=
'\0') {
676 if (
strncmp(options,
"pccard", 6) == 0) {
679 }
else if (
strncmp(options,
"cf", 2) == 0) {
682 }
else if (
strncmp(options,
"flashrom", 8) == 0) {
685 }
else if (
strncmp(options,
"none", 4) == 0) {
694 if (
strncmp(options,
"memnoprobe", 10) == 0)
696 if (
strncmp(options,
"ionoprobe", 9) == 0)
698 if (
strncmp(options,
"noprobe", 7) == 0)
706 __setup(
"vrc4171_card=", vrc4171_card_setup);
710 .name = vrc4171_card_name,
715 static int __devinit vrc4171_card_init(
void)
729 vrc4171_set_multifunction_pin(vrc4171_slotb);
731 retval = vrc4171_add_sockets();
734 vrc4171_card_name, vrc4171_sockets);
737 vrc4171_remove_sockets();
744 vrc4171_card_driver.
driver.name, vrc4171_irq);
749 static void __devexit vrc4171_card_exit(
void)
751 free_irq(vrc4171_irq, vrc4171_sockets);
752 vrc4171_remove_sockets();