patch-2.4.22 linux-2.4.22/drivers/pcmcia/au1000_generic.c

Next file: linux-2.4.22/drivers/pcmcia/au1000_pb1x00.c
Previous file: linux-2.4.22/drivers/pcmcia/au1000_db1x00.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.21/drivers/pcmcia/au1000_generic.c linux-2.4.22/drivers/pcmcia/au1000_generic.c
@@ -2,7 +2,7 @@
  *
  * Alchemy Semi Au1000 pcmcia driver
  *
- * Copyright 2001 MontaVista Software Inc.
+ * Copyright 2001-2003 MontaVista Software Inc.
  * Author: MontaVista Software, Inc.
  *         	ppopov@mvista.com or source@mvista.com
  *
@@ -132,13 +132,16 @@
 #endif
 };
 
+static spinlock_t pcmcia_lock = SPIN_LOCK_UNLOCKED;
+
+extern const unsigned long mips_io_port_base;
+
 static int __init au1000_pcmcia_driver_init(void)
 {
 	servinfo_t info;
 	struct pcmcia_init pcmcia_init;
 	struct pcmcia_state state;
 	unsigned int i;
-	unsigned long timing3;
 
 	printk("\nAu1x00 PCMCIA (CS release %s)\n", CS_RELEASE);
 
@@ -156,6 +159,10 @@
 
 #if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500)
 	pcmcia_low_level=&pb1x00_pcmcia_ops;
+#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500)
+	pcmcia_low_level=&db1x00_pcmcia_ops;
+#elif defined(CONFIG_MIPS_XXS1500)
+	pcmcia_low_level=&xxs1500_pcmcia_ops;
 #else
 #error Unsupported AU1000 board.
 #endif
@@ -192,18 +199,31 @@
 		pcmcia_socket[i].k_state=state;
 		pcmcia_socket[i].cs_state.csc_mask=SS_DETECT;
 		
+		/*
+		 * PCMCIA drivers use the inb/outb macros to access the
+		 * IO registers. Since mips_io_port_base is added to the
+		 * access address, we need to subtract it here.
+		 */
 		if (i == 0) {
 			pcmcia_socket[i].virt_io = 
-				(u32)ioremap((ioaddr_t)0xF00000000, 0x1000);
-			pcmcia_socket[i].phys_attr = (memaddr_t)0xF40000000;
-			pcmcia_socket[i].phys_mem = (memaddr_t)0xF80000000;
+				(u32)ioremap((ioaddr_t)AU1X_SOCK0_IO, 0x1000) -
+				mips_io_port_base;
+			pcmcia_socket[i].phys_attr = 
+				(ioaddr_t)AU1X_SOCK0_PHYS_ATTR;
+			pcmcia_socket[i].phys_mem = 
+				(ioaddr_t)AU1X_SOCK0_PHYS_MEM;
 		}
+#ifndef CONFIG_MIPS_XXS1500
 		else  {
 			pcmcia_socket[i].virt_io = 
-				(u32)ioremap((ioaddr_t)0xF08000000, 0x1000);
-			pcmcia_socket[i].phys_attr = (memaddr_t)0xF48000000;
-			pcmcia_socket[i].phys_mem = (memaddr_t)0xF88000000;
+				(u32)ioremap((ioaddr_t)AU1X_SOCK1_IO, 0x1000) -
+				mips_io_port_base;
+			pcmcia_socket[i].phys_attr = 
+				(ioaddr_t)AU1X_SOCK1_PHYS_ATTR;
+			pcmcia_socket[i].phys_mem = 
+				(ioaddr_t)AU1X_SOCK1_PHYS_MEM;
 		}
+#endif
 	}
 
 	/* Only advertise as many sockets as we can detect: */
@@ -234,7 +254,8 @@
 	flush_scheduled_tasks();
 	for(i=0; i < socket_count; i++) {
 		if (pcmcia_socket[i].virt_io) 
-			iounmap((void *)pcmcia_socket[i].virt_io);
+			iounmap((void *)pcmcia_socket[i].virt_io + 
+					mips_io_port_base);
 	}
 	DEBUG(1, "au1000: shutdown complete\n");
 }
@@ -585,8 +606,7 @@
 		}
 	}
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&pcmcia_lock, flags);
 	start=map->sys_start;
 
 	if(map->sys_stop==0)
@@ -603,7 +623,7 @@
 
 	map->sys_stop=map->sys_start+(map->sys_stop-start);
 	pcmcia_socket[sock].mem_map[map->map]=*map;
-	restore_flags(flags);
+	spin_unlock_irqrestore(&pcmcia_lock, flags);
 	DEBUG(3, "set_mem_map %d start %x stop %x card_start %x\n", 
 			map->map, map->sys_start, map->sys_stop, 
 			map->card_start);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)