patch-2.4.14 linux/drivers/pcmcia/sa1100_cerf.c

Next file: linux/drivers/pcmcia/sa1100_generic.c
Previous file: linux/drivers/pcmcia/sa1100_assabet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.13/linux/drivers/pcmcia/sa1100_cerf.c linux/drivers/pcmcia/sa1100_cerf.c
@@ -16,17 +16,12 @@
 static int cerf_pcmcia_init(struct pcmcia_init *init){
   int irq, res;
 
-  /* Enable CF bus: */
-//  BCR_clear(BCR_CF_BUS_OFF);
-
-  /* All those are inputs */
   GPDR &= ~(GPIO_CF_CD | GPIO_CF_BVD2 | GPIO_CF_BVD1 | GPIO_CF_IRQ);
+  GPDR |= (GPIO_CF_RESET);
 
-  /* Set transition detect */
   set_GPIO_IRQ_edge( GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1, GPIO_BOTH_EDGES );
   set_GPIO_IRQ_edge( GPIO_CF_IRQ, GPIO_FALLING_EDGE );
 
-  /* Register interrupts */
   irq = IRQ_GPIO_CF_CD;
   res = request_irq( irq, init->handler, SA_INTERRUPT, "CF_CD", NULL );
   if( res < 0 ) goto irq_err;
@@ -37,7 +32,6 @@
   res = request_irq( irq, init->handler, SA_INTERRUPT, "CF_BVD1", NULL );
   if( res < 0 ) goto irq_err;
 
-  /* There's only one slot, but it's "Slot 1": */
   return 2;
 
 irq_err:
@@ -47,13 +41,9 @@
 
 static int cerf_pcmcia_shutdown(void)
 {
-  /* disable IRQs */
   free_irq( IRQ_GPIO_CF_CD, NULL );
   free_irq( IRQ_GPIO_CF_BVD2, NULL );
   free_irq( IRQ_GPIO_CF_BVD1, NULL );
-  
-  /* Disable CF bus: */
-//  BCR_set(BCR_CF_BUS_OFF);
 
   return 0;
 }
@@ -61,6 +51,11 @@
 static int cerf_pcmcia_socket_state(struct pcmcia_state_array
 				       *state_array){
   unsigned long levels;
+#ifdef CONFIG_SA1100_CERF_CPLD
+  int i = 0;
+#else
+  int i = 1;
+#endif
 
   if(state_array->size<2) return -1;
 
@@ -69,19 +64,19 @@
 
   levels=GPLR;
 
-  state_array->state[1].detect=((levels & GPIO_CF_CD)==0)?1:0;
+  state_array->state[i].detect=((levels & GPIO_CF_CD)==0)?1:0;
 
-  state_array->state[1].ready=(levels & GPIO_CF_IRQ)?1:0;
+  state_array->state[i].ready=(levels & GPIO_CF_IRQ)?1:0;
 
-  state_array->state[1].bvd1=(levels & GPIO_CF_BVD1)?1:0;
+  state_array->state[i].bvd1=(levels & GPIO_CF_BVD1)?1:0;
 
-  state_array->state[1].bvd2=(levels & GPIO_CF_BVD2)?1:0;
+  state_array->state[i].bvd2=(levels & GPIO_CF_BVD2)?1:0;
 
-  state_array->state[1].wrprot=0; /* Not available on Assabet. */
+  state_array->state[i].wrprot=0;
 
-  state_array->state[1].vs_3v=1;  /* Can only apply 3.3V on Assabet. */
+  state_array->state[i].vs_3v=1;
 
-  state_array->state[1].vs_Xv=0;
+  state_array->state[i].vs_Xv=0;
 
   return 1;
 }
@@ -90,7 +85,11 @@
 
   if(info->sock>1) return -1;
 
+#ifdef CONFIG_SA1100_CERF_CPLD
+  if(info->sock==0)
+#else
   if(info->sock==1)
+#endif
     info->irq=IRQ_GPIO_CF_IRQ;
 
   return 0;
@@ -99,28 +98,31 @@
 static int cerf_pcmcia_configure_socket(const struct pcmcia_configure
 					   *configure)
 {
-  unsigned long value, flags;
+  unsigned long flags;
 
-  if(configure->sock>1) return -1;
+  if(configure->sock>1)
+    return -1;
 
-  if(configure->sock==0) return 0;
+#ifdef CONFIG_SA1100_CERF_CPLD
+  if(configure->sock==1)
+#else
+  if(configure->sock==0)
+#endif
+    return 0;
 
   save_flags_cli(flags);
 
-//  value = BCR_value;
-
   switch(configure->vcc){
   case 0:
-//    value &= ~BCR_CF_PWR;
     break;
 
   case 50:
-    printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
-	   __FUNCTION__);
-
-  case 33:  /* Can only apply 3.3V to the CF slot. */
-//    value |= BCR_CF_PWR;
-    break;
+  case 33:
+#ifdef CONFIG_SA1100_CERF_CPLD
+     GPDR |= GPIO_PWR_SHUTDOWN;
+     GPCR |= GPIO_PWR_SHUTDOWN;
+#endif
+     break;
 
   default:
     printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
@@ -129,11 +131,20 @@
     return -1;
   }
 
-//  value = (configure->reset) ? (value | BCR_CF_RST) : (value & ~BCR_CF_RST);
-
-  /* Silently ignore Vpp, output enable, speaker enable. */
-
-//  BCR = BCR_value = value;
+  if(configure->reset)
+  {
+#ifdef CONFIG_SA1100_CERF_CPLD
+    GPDR |= GPIO_CF_RESET;
+    GPSR |= GPIO_CF_RESET;
+#endif
+  }
+  else
+  {
+#ifdef CONFIG_SA1100_CERF_CPLD
+    GPDR |= GPIO_CF_RESET;
+    GPCR |= GPIO_CF_RESET;
+#endif
+  }
 
   restore_flags(flags);
 

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