spi: au1550: Convert to let spi core handle checking transfer speed
By setting master->max_speed_hz and master->min_speed_hz, spi core will handle checking transfer speed. So we can remove the same checking in this driver. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Родитель
38dbfb59d1
Коммит
0dd26e53b5
|
@ -55,8 +55,6 @@ struct au1550_spi {
|
||||||
|
|
||||||
volatile psc_spi_t __iomem *regs;
|
volatile psc_spi_t __iomem *regs;
|
||||||
int irq;
|
int irq;
|
||||||
unsigned freq_max;
|
|
||||||
unsigned freq_min;
|
|
||||||
|
|
||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned tx_count;
|
unsigned tx_count;
|
||||||
|
@ -248,11 +246,8 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
|
||||||
hz = t->speed_hz;
|
hz = t->speed_hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hz > spi->max_speed_hz || hz > hw->freq_max || hz < hw->freq_min) {
|
if (!hz)
|
||||||
dev_err(&spi->dev, "setupxfer: clock rate=%d out of range\n",
|
|
||||||
hz);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
au1550_spi_bits_handlers_set(hw, spi->bits_per_word);
|
au1550_spi_bits_handlers_set(hw, spi->bits_per_word);
|
||||||
|
|
||||||
|
@ -287,23 +282,6 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int au1550_spi_setup(struct spi_device *spi)
|
|
||||||
{
|
|
||||||
struct au1550_spi *hw = spi_master_get_devdata(spi->master);
|
|
||||||
|
|
||||||
if (spi->max_speed_hz == 0)
|
|
||||||
spi->max_speed_hz = hw->freq_max;
|
|
||||||
if (spi->max_speed_hz > hw->freq_max
|
|
||||||
|| spi->max_speed_hz < hw->freq_min)
|
|
||||||
return -EINVAL;
|
|
||||||
/*
|
|
||||||
* NOTE: cannot change speed and other hw settings immediately,
|
|
||||||
* otherwise sharing of spi bus is not possible,
|
|
||||||
* so do not call setupxfer(spi, NULL) here
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for dma spi transfers, we have to setup rx channel, otherwise there is
|
* for dma spi transfers, we have to setup rx channel, otherwise there is
|
||||||
* no reliable way how to recognize that spi transfer is done
|
* no reliable way how to recognize that spi transfer is done
|
||||||
|
@ -838,7 +816,6 @@ static int au1550_spi_probe(struct platform_device *pdev)
|
||||||
hw->bitbang.master = hw->master;
|
hw->bitbang.master = hw->master;
|
||||||
hw->bitbang.setup_transfer = au1550_spi_setupxfer;
|
hw->bitbang.setup_transfer = au1550_spi_setupxfer;
|
||||||
hw->bitbang.chipselect = au1550_spi_chipsel;
|
hw->bitbang.chipselect = au1550_spi_chipsel;
|
||||||
hw->bitbang.master->setup = au1550_spi_setup;
|
|
||||||
hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs;
|
hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs;
|
||||||
|
|
||||||
if (hw->usedma) {
|
if (hw->usedma) {
|
||||||
|
@ -909,8 +886,9 @@ static int au1550_spi_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int min_div = (2 << 0) * (2 * (4 + 1));
|
int min_div = (2 << 0) * (2 * (4 + 1));
|
||||||
int max_div = (2 << 3) * (2 * (63 + 1));
|
int max_div = (2 << 3) * (2 * (63 + 1));
|
||||||
hw->freq_max = hw->pdata->mainclk_hz / min_div;
|
master->max_speed_hz = hw->pdata->mainclk_hz / min_div;
|
||||||
hw->freq_min = hw->pdata->mainclk_hz / (max_div + 1) + 1;
|
master->min_speed_hz =
|
||||||
|
hw->pdata->mainclk_hz / (max_div + 1) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
au1550_spi_setup_psc_as_spi(hw);
|
au1550_spi_setup_psc_as_spi(hw);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче