Work in progress. Makes spi_s3c24xx.c work for up to 12MHz. At speeds of 13MHz or higher, we have setup time issues. I.e., the SPI host sees the data coming from the device delayed by one bit, even though things look fine on the scope. This 12MHz/13MHz "barrier" exists with or without probes attached, suggesting capacitative loading plays only a minor role in this. Index: korig/drivers/spi/spi_s3c24xx.c =================================================================== --- korig.orig/drivers/spi/spi_s3c24xx.c 2008-09-27 21:32:30.000000000 -0300 +++ korig/drivers/spi/spi_s3c24xx.c 2008-09-27 22:27:20.000000000 -0300 @@ -198,6 +198,27 @@ 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. + * + * 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); + 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 +254,19 @@ 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 the byte preceding the first byte + * or the SPI engine gets upset. + */ + if (hw->rx) { + u8 b = readb(hw->regs + S3C2410_SPRDAT); + + if (count) + hw->rx[count-1] = b; + } count++; Index: korig/arch/arm/mach-s3c2440/mach-gta02.c =================================================================== --- korig.orig/arch/arm/mach-s3c2440/mach-gta02.c 2008-09-27 21:32:30.000000000 -0300 +++ korig/arch/arm/mach-s3c2440/mach-gta02.c 2008-09-27 21:32:30.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 = 12 * 1000 * 1000, /* SPI doesn't want to go faster */ .bus_num = 0, .chip_select = 0, .mode = SPI_MODE_0,