Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> Linux 產業

修復 FL2440 2.6.28 核心的 SD 卡驅動問題

FL2440 的 2.6.28 核心,預設的 SD 卡驅動存在問題。修改 linux-2.6.28.7/drivers/mmc/host/s3cmci.c 中的 do_pio_write 函數即可:

static void do_pio_write(struct s3cmci_host *host)
{
	void __iomem *to_ptr;
	int res;
	u32 fifo;
	u32 *ptr;

	to_ptr = host->base + host->sdidata;

	//while ((fifo = fifo_free(host)))
	while ((fifo = fifo_free(host)) > 3) //lqm changed from feiling FAE.11-01-19
	{
		if (!host->pio_bytes)
		{
			res = get_data_buffer(host, &host->pio_bytes, &host->pio_ptr);
			if (res)
			{
				dbg(host, dbg_pio, "pio_write(): complete (no more data).\n");
				host->pio_active = XFER_NONE;
				return;
			}
			dbg(host, dbg_pio, "pio_write(): new source: [%i]@[%p]\n",
				host->pio_bytes, host->pio_ptr);
		}

		/* If we have reached the end of the block, we have to
		 * write exactly the remaining number of bytes. If we
		 * in the middle of the block, we have to write full
		 * words, so round down to an even multiple of 4. */
		if (fifo >= host->pio_bytes)
			fifo = host->pio_bytes;
		else
			fifo -= fifo & 3;

		host->pio_bytes -= fifo;
		host->pio_count += fifo;
		fifo = (fifo + 3) >> 2;
		ptr = host->pio_ptr;
		while (fifo--)
			writel(*ptr++, to_ptr);
		host->pio_ptr = ptr;
	}

	enable_imask(host, S3C2410_SDIIMSK_TXFIFOHALF);
}

關鍵在於把 FIFO 判斷從「大於0」改為「大於3」,避免在批次邊界寫入不足一個 word。實測1G與2G的 SD 卡都能穩定運行。

Copyright © Linux教程網 All Rights Reserved