patch-2.4.19 linux-2.4.19/drivers/pcmcia/sa1100_neponset.c

Next file: linux-2.4.19/drivers/pcmcia/sa1100_pangolin.c
Previous file: linux-2.4.19/drivers/pcmcia/sa1100_jornada720.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/drivers/pcmcia/sa1100_neponset.c linux-2.4.19/drivers/pcmcia/sa1100_neponset.c
@@ -1,249 +1,129 @@
 /*
- * drivers/pcmcia/sa1100_neponset.c
+ * linux/drivers/pcmcia/sa1100_neponset.c
  *
  * Neponset PCMCIA specific routines
- *
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
 
-#include <asm/delay.h>
 #include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/arch/pcmcia.h>
 #include <asm/arch/assabet.h>
+#include <asm/hardware/sa1111.h>
 
-static int neponset_pcmcia_init(struct pcmcia_init *init){
-  int return_val=0;
-
-  /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
-  PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-  
-  /* MAX1600 to standby mode: */
-  PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
-  NCR_0 &= ~(NCR_A0VPP | NCR_A1VPP);
-
-  INTPOL1 |= 
-    (1 << (S0_READY_NINT - SA1111_IRQ(32))) |
-    (1 << (S1_READY_NINT - SA1111_IRQ(32))) |
-    (1 << (S0_CD_VALID - SA1111_IRQ(32))) |
-    (1 << (S1_CD_VALID - SA1111_IRQ(32))) |
-    (1 << (S0_BVD1_STSCHG - SA1111_IRQ(32))) |
-    (1 << (S1_BVD1_STSCHG - SA1111_IRQ(32)));
-
-  return_val+=request_irq(S0_CD_VALID, init->handler, SA_INTERRUPT,
-			  "Neponset PCMCIA (0) CD", NULL);
-  return_val+=request_irq(S1_CD_VALID, init->handler, SA_INTERRUPT,
-			  "Neponset CF (1) CD", NULL);
-  return_val+=request_irq(S0_BVD1_STSCHG, init->handler, SA_INTERRUPT,
-			  "Neponset PCMCIA (0) BVD1", NULL);
-  return_val+=request_irq(S1_BVD1_STSCHG, init->handler, SA_INTERRUPT,
-			  "Neponset CF (1) BVD1", NULL);
-
-  return (return_val<0) ? -1 : 2;
-}
-
-static int neponset_pcmcia_shutdown(void){
-
-  free_irq(S0_CD_VALID, NULL);
-  free_irq(S1_CD_VALID, NULL);
-  free_irq(S0_BVD1_STSCHG, NULL);
-  free_irq(S1_BVD1_STSCHG, NULL);
-
-  INTPOL1 &= 
-    ~((1 << (S0_CD_VALID - SA1111_IRQ(32))) |
-      (1 << (S1_CD_VALID - SA1111_IRQ(32))) |
-      (1 << (S0_BVD1_STSCHG - SA1111_IRQ(32))) |
-      (1 << (S1_BVD1_STSCHG - SA1111_IRQ(32))));
-
-  return 0;
-}
-
-static int neponset_pcmcia_socket_state(struct pcmcia_state_array
-					*state_array){
-  unsigned long status;
-  int return_val=1;
-
-  if(state_array->size<2) return -1;
-
-  memset(state_array->state, 0, 
-	 (state_array->size)*sizeof(struct pcmcia_state));
-
-  status=PCSR;
-
-  state_array->state[0].detect=((status & PCSR_S0_DETECT)==0)?1:0;
-
-  state_array->state[0].ready=((status & PCSR_S0_READY)==0)?0:1;
+#include "sa1100_generic.h"
+#include "sa1111_generic.h"
 
-  state_array->state[0].bvd1=((status & PCSR_S0_BVD1)==0)?0:1;
+static int neponset_pcmcia_init(struct pcmcia_init *init)
+{
+	/* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
+	PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
 
-  state_array->state[0].bvd2=((status & PCSR_S0_BVD2)==0)?0:1;
+	/* MAX1600 to standby mode: */
+	PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
+	NCR_0 &= ~(NCR_A0VPP | NCR_A1VPP);
 
-  state_array->state[0].wrprot=((status & PCSR_S0_WP)==0)?0:1;
-
-  state_array->state[0].vs_3v=((status & PCSR_S0_VS1)==0)?1:0;
-
-  state_array->state[0].vs_Xv=((status & PCSR_S0_VS2)==0)?1:0;
-
-  state_array->state[1].detect=((status & PCSR_S1_DETECT)==0)?1:0;
-
-  state_array->state[1].ready=((status & PCSR_S1_READY)==0)?0:1;
-
-  state_array->state[1].bvd1=((status & PCSR_S1_BVD1)==0)?0:1;
-
-  state_array->state[1].bvd2=((status & PCSR_S1_BVD2)==0)?0:1;
-
-  state_array->state[1].wrprot=((status & PCSR_S1_WP)==0)?0:1;
-
-  state_array->state[1].vs_3v=((status & PCSR_S1_VS1)==0)?1:0;
-
-  state_array->state[1].vs_Xv=((status & PCSR_S1_VS2)==0)?1:0;
-
-  return return_val;
+	return sa1111_pcmcia_init(init);
 }
 
-static int neponset_pcmcia_get_irq_info(struct pcmcia_irq_info *info){
-
-  switch(info->sock){
-  case 0:
-    info->irq=S0_READY_NINT;
-    break;
-
-  case 1:
-    info->irq=S1_READY_NINT;
-    break;
-
-  default:
-    return -1;
-  }
+static int
+neponset_pcmcia_configure_socket(const struct pcmcia_configure *conf)
+{
+	unsigned int ncr_mask, pa_dwr_mask;
+	unsigned int ncr_set, pa_dwr_set;
+	int ret;
+
+	/* Neponset uses the Maxim MAX1600, with the following connections:
+
+	 *   MAX1600      Neponset
+	 *
+	 *    A0VCC        SA-1111 GPIO A<1>
+	 *    A1VCC        SA-1111 GPIO A<0>
+	 *    A0VPP        CPLD NCR A0VPP
+	 *    A1VPP        CPLD NCR A1VPP
+	 *    B0VCC        SA-1111 GPIO A<2>
+	 *    B1VCC        SA-1111 GPIO A<3>
+	 *    B0VPP        ground (slot B is CF)
+	 *    B1VPP        ground (slot B is CF)
+	 *
+	 *     VX          VCC (5V)
+	 *     VY          VCC3_3 (3.3V)
+	 *     12INA       12V
+	 *     12INB       ground (slot B is CF)
+	 *
+	 * The MAX1600 CODE pin is tied to ground, placing the device in 
+	 * "Standard Intel code" mode. Refer to the Maxim data sheet for
+	 * the corresponding truth table.
+	 */
+
+	switch (conf->sock) {
+	case 0:
+		pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
+		ncr_mask = NCR_A0VPP | NCR_A1VPP;
+
+		switch (conf->vcc) {
+		default:
+		case 0:		pa_dwr_set = 0;			break;
+		case 33:	pa_dwr_set = GPIO_GPIO1;	break;
+		case 50:	pa_dwr_set = GPIO_GPIO0;	break;
+		}
+
+		switch (conf->vpp) {
+		case 0:		ncr_set = 0;			break;
+		case 120:	ncr_set = NCR_A1VPP;		break;
+		default:
+			if (conf->vpp == conf->vcc)
+				ncr_set = NCR_A0VPP;
+			else {
+				printk(KERN_ERR "%s(): unrecognized VPP %u\n",
+				       __FUNCTION__, conf->vpp);
+				return -1;
+			}
+		}
+		break;
+
+	case 1:
+		pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
+		ncr_mask = 0;
+		ncr_set = 0;
+
+		switch (conf->vcc) {
+		default:
+		case 0:		pa_dwr_set = 0;			break;
+		case 33:	pa_dwr_set = GPIO_GPIO2;	break;
+		case 50:	pa_dwr_set = GPIO_GPIO3;	break;
+		}
+
+		if (conf->vpp != conf->vcc && conf->vpp != 0) {
+			printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
+			       __FUNCTION__, conf->vpp);
+			return -1;
+		}
+		break;
+
+	default:
+		return -1;
+	}
+
+	ret = sa1111_pcmcia_configure_socket(conf);
+	if (ret == 0) {
+		unsigned long flags;
+
+		local_irq_save(flags);
+		NCR_0 = (NCR_0 & ~ncr_mask) | ncr_set;
+		PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
+		local_irq_restore(flags);
+	}
 
-  return 0;
+	return 0;
 }
 
-static int neponset_pcmcia_configure_socket(const struct pcmcia_configure
-					    *configure){
-  unsigned long pccr=PCCR, ncr=NCR_0, gpio=PA_DWR;
-
-  /* Neponset uses the Maxim MAX1600, with the following connections:
-   *
-   *   MAX1600      Neponset
-   *
-   *    A0VCC        SA-1111 GPIO A<1>
-   *    A1VCC        SA-1111 GPIO A<0>
-   *    A0VPP        CPLD NCR A0VPP
-   *    A1VPP        CPLD NCR A1VPP
-   *    B0VCC        SA-1111 GPIO A<2>
-   *    B1VCC        SA-1111 GPIO A<3>
-   *    B0VPP        ground (slot B is CF)
-   *    B1VPP        ground (slot B is CF)
-   *
-   *     VX          VCC (5V)
-   *     VY          VCC3_3 (3.3V)
-   *     12INA       12V
-   *     12INB       ground (slot B is CF)
-   *
-   * The MAX1600 CODE pin is tied to ground, placing the device in 
-   * "Standard Intel code" mode. Refer to the Maxim data sheet for
-   * the corresponding truth table.
-   */
-
-  switch(configure->sock){
-  case 0:
-    
-    switch(configure->vcc){
-    case 0:
-      pccr=(pccr & ~PCCR_S0_FLT);
-      gpio&=~(GPIO_GPIO0 | GPIO_GPIO1);
-      break;
-
-    case 33:
-      pccr=(pccr & ~PCCR_S0_PSE) | PCCR_S0_FLT | PCCR_S0_PWAITEN;
-      gpio=(gpio & ~(GPIO_GPIO0 | GPIO_GPIO1)) | GPIO_GPIO1;
-      break;
-
-    case 50:
-      pccr=(pccr | PCCR_S0_PSE | PCCR_S0_FLT | PCCR_S0_PWAITEN);
-      gpio=(gpio & ~(GPIO_GPIO0 | GPIO_GPIO1)) | GPIO_GPIO0;
-      break;
-
-    default:
-      printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
-	     configure->vcc);
-      return -1;
-    }
-
-    switch(configure->vpp){
-    case 0:
-      ncr&=~(NCR_A0VPP | NCR_A1VPP);
-      break;
-
-    case 120:
-      ncr=(ncr & ~(NCR_A0VPP | NCR_A1VPP)) | NCR_A1VPP;
-      break;
-
-    default:
-      if(configure->vpp == configure->vcc)
-	ncr=(ncr & ~(NCR_A0VPP | NCR_A1VPP)) | NCR_A0VPP;
-      else {
-	printk(KERN_ERR "%s(): unrecognized Vpp %u\n", __FUNCTION__,
-	       configure->vpp);
-	return -1;
-      }
-    }
-
-    pccr=(configure->reset)?(pccr | PCCR_S0_RST):(pccr & ~PCCR_S0_RST);
-
-    break;
-
-  case 1:
-    switch(configure->vcc){
-    case 0:
-      pccr=(pccr & ~PCCR_S1_FLT);
-      gpio&=~(GPIO_GPIO2 | GPIO_GPIO3);
-      break;
-
-    case 33:
-      pccr=(pccr & ~PCCR_S1_PSE) | PCCR_S1_FLT | PCCR_S1_PWAITEN;
-      gpio=(gpio & ~(GPIO_GPIO2 | GPIO_GPIO3)) | GPIO_GPIO2;
-      break;
-
-    case 50:
-      pccr=(pccr | PCCR_S1_PSE | PCCR_S1_FLT | PCCR_S1_PWAITEN);
-      gpio=(gpio & ~(GPIO_GPIO2 | GPIO_GPIO3)) | GPIO_GPIO3;
-      break;
-
-    default:
-      printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
-	     configure->vcc);
-      return -1;
-    }
-
-    if(configure->vpp!=configure->vcc && configure->vpp!=0){
-      printk(KERN_ERR "%s(): CF slot cannot support Vpp %u\n", __FUNCTION__,
-	     configure->vpp);
-      return -1;
-    }
-
-    pccr=(configure->reset)?(pccr | PCCR_S1_RST):(pccr & ~PCCR_S1_RST);
-
-    break;
-
-  default:
-    return -1;
-  }
-
-  PCCR = pccr;
-  NCR_0 = ncr;
-  PA_DWR = gpio;
+struct pcmcia_low_level neponset_pcmcia_ops = {
+	init:			neponset_pcmcia_init,
+	shutdown:		sa1111_pcmcia_shutdown,
+	socket_state:		sa1111_pcmcia_socket_state,
+	get_irq_info:		sa1111_pcmcia_get_irq_info,
+	configure_socket:	neponset_pcmcia_configure_socket,
 
-  return 0;
-}
-
-struct pcmcia_low_level neponset_pcmcia_ops = { 
-  neponset_pcmcia_init,
-  neponset_pcmcia_shutdown,
-  neponset_pcmcia_socket_state,
-  neponset_pcmcia_get_irq_info,
-  neponset_pcmcia_configure_socket
+	socket_init:		sa1111_pcmcia_socket_init,
+	socket_suspend:		sa1111_pcmcia_socket_suspend,
 };
-

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