[PATCH] MMC/SD SPI-mode driver
Ian Lepore
ian at FreeBSD.org
Wed Apr 10 18:51:00 UTC 2013
On Wed, 2013-04-10 at 10:21 -0700, Adrian Chadd wrote:
> On 10 April 2013 09:00, Ian Lepore <ian at freebsd.org> wrote:
>
> > I don't understand how reading is not a generic spi command
> > (presupposing the existance of the proposed changes that allow for a spi
> > read without a concurrent write and vice versa).
>
> No. Reading is an SPI method. But the SPI flash command for reading
> data is different than other SPI commands.
>
> The only thing we should be doing this for is SPI _flash reads_. Not
> SPI reads. Just data area reads from a directly attached flash chip.
>
> It's dirty or inefficient any way we do this. Either we special case
> spibus drivers, or we expose a SPI read / SPI write 'command' that
> knows it's not a generic SPI bus transaction but specifically a
> read-this-flash-data-from-this-offset-and-length transaction. Or some
> other kind of dirty hack.
>
Maybe something like this could work?
static int
ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
{
if (cmd->cs == sc->magic_mapped_flash_chipsel &&
cmd->tx_cmd == NULL && cmd->tx_data == NULL &&
*(uint8_t *)cmd->rx_cmd == SPIFLASH_READ_OPCODE &&
/* maybe some other constraints I don't know about */
/* maybe even check that child is the mx25l driver */)
return do_magic_mapped_read(...);
else
return do_mundane_nonmapped_transfer(...);
}
-- Ian
More information about the freebsd-mips
mailing list