Failure to detect card ins/rem with pd6729

Komuro komurojun at mbn.nifty.com
Sat Sep 18 20:23:20 EDT 2004


>>> and no "interrupts dropped" message in your system log?
>>
>> Sure Komuro, there they are in kernel log:
>>
>
>Your pd6729 interrupt is _not_ connected to the PCI bus...
>We need to add ISA-interrupt support to the pd6729 driver.

Here is a test patch for ISA-interrupt support(kernel 2.6.8.1).
You need "irq_mode=0" parameter for ISA-interrupt.

Best Regards
Komuro


diff -ruN linux/drivers/pcmcia.orig/pd6729.c linux/drivers/pcmcia/pd6729.c
--- linux/drivers/pcmcia.orig/pd6729.c	2004-08-14 19:56:01.000000000 +0900
+++ linux/drivers/pcmcia/pd6729.c	2004-09-19 09:02:18.031763880 +0900
@@ -39,8 +39,11 @@
  */
 #define to_cycles(ns)	((ns)/120)
 
+static int irq_mode = 1; /* 1 = PCI interrupt, 0 = ISA interrupt */
 static spinlock_t port_lock = SPIN_LOCK_UNLOCKED;
 
+module_param(irq_mode, int, 0444);
+
 /* basic value read/write functions */
 
 static unsigned char indirect_read(struct pd6729_socket *socket, unsigned sho
rt reg)
@@ -204,14 +207,13 @@
 	return IRQ_RETVAL(handled);
 }
 
-/* socket functions */
-
-static void set_bridge_state(struct pd6729_socket *socket)
+static void pd6729_interrupt_wrapper(unsigned long data)
 {
-	indirect_write(socket, I365_GBLCTL, 0x00);
-	indirect_write(socket, I365_GENCTL, 0x00);
+	struct pd6729_socket *socket = (struct pd6729_socket *) data;
 
-	indirect_setbit(socket, I365_INTCTL, 0x08);
+	pd6729_interrupt(0, (void *)socket, NULL);
+	socket->poll_timer.expires = jiffies + HZ;
+	add_timer(&socket->poll_timer);
 }
 
 static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
@@ -314,12 +316,9 @@
 		state->flags |= SS_IOCARD; /* This is an IO card */
 
 	/* Set the IRQ number */
-	state->io_irq = socket->socket.pci_irq;
+	state->io_irq = socket->card_irq;
 
-	/*
-	 * Card status change
-	 * CSCICR, Card Status Change Interrupt Configuration
-	 */
+	/* Card status change */
 	reg = indirect_read(socket, I365_CSCINT);
 
 	if (reg & I365_CSC_DETECT)
@@ -346,10 +345,10 @@
 	unsigned char reg;
 
 	/* First, set the global controller options */
+	indirect_write(socket, I365_GBLCTL, 0x00);
+	indirect_write(socket, I365_GENCTL, 0x00);
 
-	set_bridge_state(socket);
-
-	/* Values for the IGENC register */
+	socket->card_irq = state->io_irq;
 
 	reg = 0;
  	/* The reset bit has "inverse" logic */
@@ -418,9 +417,14 @@
 	if (reg != indirect_read(socket, I365_POWER))
 		indirect_write(socket, I365_POWER, reg);
 
-	/* Now, specifiy that all interrupts are to be done as PCI interrupts */
-	indirect_write(socket, PD67_EXT_INDEX, PD67_EXT_CTL_1);
-	indirect_write(socket, PD67_EXT_DATA, PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_C
ARD_IRQ);
+	if (irq_mode == 1) {
+		/*
+		 * Now, specifiy that all interrupts are to be done
+		 * as PCI interrupts
+		 */
+		indirect_write(socket, PD67_EXT_INDEX, PD67_EXT_CTL_1);
+		indirect_write(socket, PD67_EXT_DATA, PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_
CARD_IRQ);
+	}
 
 	/* Enable specific interrupt events */
 
@@ -439,11 +443,16 @@
 		if (state->csc_mask & SS_READY)
 			reg |= I365_CSC_READY;
 	}
-	reg |= 0x30;	/* management IRQ: PCI INTA# = "irq 3" */
+	if (irq_mode == 1)
+		reg |= 0x30;	/* management IRQ: PCI INTA# = "irq 3" */
 	indirect_write(socket, I365_CSCINT, reg);
 
 	reg = indirect_read(socket, I365_INTCTL);
-	reg |= 0x03;	/* card IRQ: PCI INTA# = "irq 3" */
+	if (irq_mode == 1)
+		reg |= 0x03;	/* card IRQ: PCI INTA# = "irq 3" */
+	else
+		reg |= socket->card_irq;
+
 	indirect_write(socket, I365_INTCTL, reg);
 
 	/* now clear the (probably bogus) pending stuff by doing a dummy read */
@@ -610,6 +619,8 @@
 	char configbyte;
 	struct pd6729_socket *socket;
 
+	printk(KERN_INFO "pd6729-debug: irq_mode = %x \n", irq_mode);
+
 	socket = kmalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, GFP_KERNEL);
 	if (!socket)
 		return -ENOMEM;
@@ -644,7 +655,10 @@
 		socket[i].io_base = pci_resource_start(dev, 0);
 		socket[i].socket.features |= SS_CAP_PCCARD;
 		socket[i].socket.map_size = 0x1000;
-		socket[i].socket.irq_mask = 0;
+		if (irq_mode == 1)
+			socket[i].socket.irq_mask = 0;
+		else 
+			socket[i].socket.irq_mask = 0x0c00;
 		socket[i].socket.pci_irq  = dev->irq;
 		socket[i].socket.owner = THIS_MODULE;
 
@@ -657,10 +671,18 @@
 
 	pci_set_drvdata(dev, socket);
 
-	/* Register the interrupt handler */
-	if ((ret = request_irq(dev->irq, pd6729_interrupt, SA_SHIRQ, "pd6729", socke
t))) {
-		printk(KERN_ERR "pd6729: Failed to register irq %d, aborting\n", dev->irq);
-		goto err_out_free_res;
+	if (irq_mode == 1) { 
+		/* Register the interrupt handler */
+		if ((ret = request_irq(dev->irq, pd6729_interrupt, SA_SHIRQ, "pd6729", sock
et))) {
+			printk(KERN_ERR "pd6729: Failed to register irq %d, aborting\n", dev->irq)
;
+			goto err_out_free_res;
+		}
+	} else { 
+		init_timer(&socket->poll_timer);
+		socket->poll_timer.function = pd6729_interrupt_wrapper;
+		socket->poll_timer.data = (unsigned long)socket;
+		socket->poll_timer.expires = jiffies + HZ;
+		add_timer(&socket->poll_timer);
 	}
 
 	for (i = 0; i < MAX_SOCKETS; i++) {
@@ -676,7 +698,10 @@
 	return 0;
 
  err_out_free_res2:
-	free_irq(dev->irq, socket);
+	if (irq_mode == 1)
+		free_irq(dev->irq, socket);
+	else
+		del_timer_sync(&socket->poll_timer);
  err_out_free_res:
 	pci_release_regions(dev);
  err_out_disable:
@@ -695,7 +720,10 @@
 	for (i = 0; i < MAX_SOCKETS; i++)
 		pcmcia_unregister_socket(&socket[i].socket);
 
-	free_irq(dev->irq, socket);
+	if (irq_mode == 1)
+		free_irq(dev->irq, socket);
+	else
+		del_timer_sync(&socket->poll_timer);
 	pci_release_regions(dev);
 	pci_disable_device(dev);
 
diff -ruN linux/drivers/pcmcia.orig/pd6729.h linux/drivers/pcmcia/pd6729.h
--- linux/drivers/pcmcia.orig/pd6729.h	2004-08-14 19:54:47.000000000 +0900
+++ linux/drivers/pcmcia/pd6729.h	2004-09-19 09:02:21.122294048 +0900
@@ -21,8 +21,10 @@
 
 struct pd6729_socket {
 	int	number;
+	int	card_irq;
 	unsigned long io_base; 	/* base io address of the socket */
 	struct pcmcia_socket socket;
+	struct timer_list poll_timer;
 };
 
 #endif




More information about the linux-pcmcia mailing list