r4672 - developers/werner/wlan-spi/patches

werner at docs.openmoko.org werner at docs.openmoko.org
Sat Sep 27 02:22:29 CEST 2008


Author: werner
Date: 2008-09-27 02:22:28 +0200 (Sat, 27 Sep 2008)
New Revision: 4672

Added:
   developers/werner/wlan-spi/patches/dont-poll-irq.patch
   developers/werner/wlan-spi/patches/tweak-spi.patch
Modified:
   developers/werner/wlan-spi/patches/gta02-no-glamo-mmc.patch
   developers/werner/wlan-spi/patches/hack-silence-battery.patch
   developers/werner/wlan-spi/patches/series
Log:
First steps towards getting S3C SPI to work. Still freaks out at higher
clock speeds and interrupt mode is actually the least efficient possible
mode.



Added: developers/werner/wlan-spi/patches/dont-poll-irq.patch
===================================================================
--- developers/werner/wlan-spi/patches/dont-poll-irq.patch	                        (rev 0)
+++ developers/werner/wlan-spi/patches/dont-poll-irq.patch	2008-09-27 00:22:28 UTC (rev 4672)
@@ -0,0 +1,33 @@
+The interrupt polling interferes with monitoring of the SDIO transactions.
+Disable it when debugging.
+
+Index: korig/drivers/mmc/core/sdio_irq.c
+===================================================================
+--- korig.orig/drivers/mmc/core/sdio_irq.c	2008-09-22 20:50:31.000000000 -0300
++++ korig/drivers/mmc/core/sdio_irq.c	2008-09-22 20:51:13.000000000 -0300
+@@ -70,7 +70,7 @@
+ 	unsigned long period, idle_period;
+ 	int ret;
+ 
+-	sched_setscheduler(current, SCHED_FIFO, &param);
++//	sched_setscheduler(current, SCHED_FIFO, &param);
+ 
+ 	/*
+ 	 * We want to allow for SDIO cards to work even on non SDIO
+@@ -102,7 +102,7 @@
+ 		ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort);
+ 		if (ret)
+ 			break;
+-		ret = process_sdio_pending_irqs(host->card);
++//		ret = process_sdio_pending_irqs(host->card);
+ 		mmc_release_host(host);
+ 
+ 		/*
+@@ -128,6 +128,7 @@
+ 			}
+ 		}
+ 
++yield();
+ 		set_task_state(current, TASK_INTERRUPTIBLE);
+ 		if (host->caps & MMC_CAP_SDIO_IRQ)
+ 			host->ops->enable_sdio_irq(host, 1);

Modified: developers/werner/wlan-spi/patches/gta02-no-glamo-mmc.patch
===================================================================
--- developers/werner/wlan-spi/patches/gta02-no-glamo-mmc.patch	2008-09-25 04:59:33 UTC (rev 4671)
+++ developers/werner/wlan-spi/patches/gta02-no-glamo-mmc.patch	2008-09-27 00:22:28 UTC (rev 4672)
@@ -7,8 +7,17 @@
 
 Index: korig/arch/arm/mach-s3c2440/mach-gta02.c
 ===================================================================
---- korig.orig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-09 21:18:55.000000000 -0300
-+++ korig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-09 21:20:25.000000000 -0300
+--- korig.orig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-17 19:37:50.000000000 -0300
++++ korig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-26 20:29:53.000000000 -0300
+@@ -1239,7 +1239,7 @@
+ static struct spi_board_info gta02_spi_mmc_bdinfo = {
+ 	.modalias	= "mmc_spi",
+ 	.irq		= IRQ_EINT3,	/* unused ? */
+-	.max_speed_hz	= 1 * 1000 * 1000,
++	.max_speed_hz	= 25 * 1000 * 1000,
+ 	.bus_num	= 0,
+ 	.chip_select	= 0,
+ 	.mode		= SPI_MODE_0,
 @@ -1476,12 +1476,14 @@
  
  static void gta02_glamo_mci_suspending(struct platform_device *dev)

Modified: developers/werner/wlan-spi/patches/hack-silence-battery.patch
===================================================================
--- developers/werner/wlan-spi/patches/hack-silence-battery.patch	2008-09-25 04:59:33 UTC (rev 4671)
+++ developers/werner/wlan-spi/patches/hack-silence-battery.patch	2008-09-27 00:22:28 UTC (rev 4672)
@@ -1,7 +1,7 @@
 Index: korig/drivers/power/power_supply_sysfs.c
 ===================================================================
---- korig.orig/drivers/power/power_supply_sysfs.c	2008-09-10 14:32:02.000000000 -0300
-+++ korig/drivers/power/power_supply_sysfs.c	2008-09-10 14:32:18.000000000 -0300
+--- korig.orig/drivers/power/power_supply_sysfs.c	2008-09-26 21:18:02.000000000 -0300
++++ korig/drivers/power/power_supply_sysfs.c	2008-09-26 21:18:44.000000000 -0300
 @@ -59,9 +59,11 @@
  	ret = psy->get_property(psy, off, &value);
  
@@ -14,3 +14,16 @@
  		return ret;
  	}
  
+Index: korig/arch/arm/mach-s3c2440/mach-gta02.c
+===================================================================
+--- korig.orig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-26 21:19:03.000000000 -0300
++++ korig/arch/arm/mach-s3c2440/mach-gta02.c	2008-09-26 21:19:07.000000000 -0300
+@@ -1239,7 +1239,7 @@
+ static struct spi_board_info gta02_spi_mmc_bdinfo = {
+ 	.modalias	= "mmc_spi",
+ 	.irq		= IRQ_EINT3,	/* unused ? */
+-	.max_speed_hz	= 25 * 1000 * 1000,
++	.max_speed_hz	= 10 * 1000 * 1000,
+ 	.bus_num	= 0,
+ 	.chip_select	= 0,
+ 	.mode		= SPI_MODE_0,

Modified: developers/werner/wlan-spi/patches/series
===================================================================
--- developers/werner/wlan-spi/patches/series	2008-09-25 04:59:33 UTC (rev 4671)
+++ developers/werner/wlan-spi/patches/series	2008-09-27 00:22:28 UTC (rev 4672)
@@ -25,4 +25,6 @@
 ar6k-essid-one-and-32.patch
 gta02-no-glamo-mmc.patch
 hack-silence-battery.patch
+tweak-spi.patch
+#dont-poll-irq.patch
 #try

Added: developers/werner/wlan-spi/patches/tweak-spi.patch
===================================================================
--- developers/werner/wlan-spi/patches/tweak-spi.patch	                        (rev 0)
+++ developers/werner/wlan-spi/patches/tweak-spi.patch	2008-09-27 00:22:28 UTC (rev 4672)
@@ -0,0 +1,63 @@
+Work in progress. Makes spi_s3c24xx.c work for 1 and 10MHz.
+Something breaks at 20 or 25MHz.
+
+Index: korig/drivers/spi/spi_s3c24xx.c
+===================================================================
+--- korig.orig/drivers/spi/spi_s3c24xx.c	2008-09-26 20:47:30.000000000 -0300
++++ korig/drivers/spi/spi_s3c24xx.c	2008-09-26 21:06:23.000000000 -0300
+@@ -198,6 +198,29 @@
+ 	writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);
+ 	wait_for_completion(&hw->done);
+ 
++	/*
++	 * Get the last byte. Since we don't have more data we can send in
++	 * order to clock the byte out of the SPI system, we need to wait and
++	 * to provide a clock by a dummy read.
++	 *
++	 * Duh, I'm just handwaving here about possible explanations of what's
++	 * going on in the hardware. This is the voodoo ritual that makes it
++	 * work while anything else fails.
++	 */
++	if (hw->rx && hw->count) {
++		udelay(1+10*1000000/spi->max_speed_hz);
++		//readb(hw->regs + S3C2410_SPRDAT);
++		hw->rx[hw->count-1] = readb(hw->regs + S3C2410_SPRDAT);
++	}
++
++	if (0&&t->rx_buf && t->len > 18) {
++		int i;
++
++		printk(KERN_INFO "RX (%p):", t->rx_buf);
++		for (i = 0; i != t->len; i++)
++			printk(" %02x", ((u8 *) t->rx_buf)[i]);
++		printk("\n");
++	}
+ 	return hw->count;
+ }
+ 
+@@ -233,8 +256,23 @@
+ 
+ 	hw->count++;
+ 
+-	if (hw->rx)
+-		hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT);
++	/*
++	 * Misfeature #1: the first byte received can only be read after
++	 * writing the second byte to send to the shifter.
++	 *
++	 * Misfeature #2: we need to consume all data received.
++	 *
++	 * Oddly enough,  it's not sufficient if we do a large number of SPRDAT
++	 * reads before or right after starting the transmission. We really
++	 * have to fetch a byte for each byte we send, or the SPI engine gets
++	 * upset.
++	 */
++	if (hw->rx) {
++		u8 b = readb(hw->regs + S3C2410_SPRDAT);
++
++		if (count)
++			hw->rx[count-1] = b;
++	}
+ 
+ 	count++;
+ 




More information about the commitlog mailing list