mci_spi: add clock frequency change support
setup the spi master correctly provide f_min and f_max Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0738b3c6fe
commit
6d0d1392f4
|
@ -318,7 +318,15 @@ static void mmc_spi_set_ios(struct mci_host *mci, struct mci_ios *ios)
|
|||
{
|
||||
struct mmc_spi_host *host = to_spi_host(mci);
|
||||
|
||||
spi_setup(host->spi);
|
||||
if (host->spi->max_speed_hz != ios->clock && ios->clock != 0) {
|
||||
int status;
|
||||
|
||||
host->spi->max_speed_hz = ios->clock;
|
||||
status = spi_setup(host->spi);
|
||||
dev_dbg(&host->spi->dev,
|
||||
"mmc_spi: clock to %d Hz, %d\n",
|
||||
host->spi->max_speed_hz, status);
|
||||
}
|
||||
}
|
||||
|
||||
static int mmc_spi_init(struct mci_host *mci, struct device_d *mci_dev)
|
||||
|
@ -384,6 +392,25 @@ static int spi_mci_probe(struct device_d *dev)
|
|||
spi->mode = SPI_MODE_0;
|
||||
spi->bits_per_word = 8;
|
||||
|
||||
status = spi_setup(spi);
|
||||
if (status < 0) {
|
||||
dev_dbg(&spi->dev, "needs SPI mode %02x, %d KHz; %d\n",
|
||||
spi->mode, spi->max_speed_hz / 1000,
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* SPI doesn't need the lowspeed device identification thing for
|
||||
* MMC or SD cards, since it never comes up in open drain mode.
|
||||
* That's good; some SPI masters can't handle very low speeds!
|
||||
*
|
||||
* However, low speed SDIO cards need not handle over 400 KHz;
|
||||
* that's the only reason not to use a few MHz for f_min (until
|
||||
* the upper layer reads the target frequency from the CSD).
|
||||
*/
|
||||
host->mci.f_min = 400000;
|
||||
host->mci.f_max = spi->max_speed_hz;
|
||||
|
||||
host->dev = dev;
|
||||
host->spi = spi;
|
||||
dev->priv = host;
|
||||
|
|
Loading…
Reference in New Issue