mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
spi: convert drivers to use bits_per_word_mask
Fill in the recently added spi_master.bits_per_word_mask field in as many drivers as possible. Make related cleanups, such as removing any redundant error-checking, or empty setup callbacks. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
committed by
Mark Brown
parent
2922a8de99
commit
24778be20f
@@ -103,16 +103,6 @@ static void altera_spi_chipsel(struct spi_device *spi, int value)
|
||||
}
|
||||
}
|
||||
|
||||
static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int altera_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
|
||||
{
|
||||
if (hw->tx) {
|
||||
@@ -231,7 +221,6 @@ static int altera_spi_probe(struct platform_device *pdev)
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = 16;
|
||||
master->mode_bits = SPI_CS_HIGH;
|
||||
master->setup = altera_spi_setup;
|
||||
|
||||
hw = spi_master_get_devdata(master);
|
||||
platform_set_drvdata(pdev, hw);
|
||||
@@ -240,7 +229,6 @@ static int altera_spi_probe(struct platform_device *pdev)
|
||||
hw->bitbang.master = spi_master_get(master);
|
||||
if (!hw->bitbang.master)
|
||||
return err;
|
||||
hw->bitbang.setup_transfer = altera_spi_setupxfer;
|
||||
hw->bitbang.chipselect = altera_spi_chipsel;
|
||||
hw->bitbang.txrx_bufs = altera_spi_txrx;
|
||||
|
||||
|
||||
@@ -155,9 +155,6 @@ static int ath79_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
if (spi->bits_per_word > 32)
|
||||
return -EINVAL;
|
||||
|
||||
if (!spi->controller_state) {
|
||||
status = ath79_spi_setup_cs(spi);
|
||||
if (status)
|
||||
@@ -226,6 +223,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
|
||||
|
||||
pdata = pdev->dev.platform_data;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||
master->setup = ath79_spi_setup;
|
||||
master->cleanup = ath79_spi_cleanup;
|
||||
if (pdata) {
|
||||
|
||||
@@ -1268,13 +1268,6 @@ static int atmel_spi_setup(struct spi_device *spi)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bits < 8 || bits > 16) {
|
||||
dev_dbg(&spi->dev,
|
||||
"setup: invalid bits_per_word %u (8 to 16)\n",
|
||||
bits);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* see notes above re chipselect */
|
||||
if (!atmel_spi_is_v2(as)
|
||||
&& spi->chip_select == 0
|
||||
@@ -1515,7 +1508,7 @@ static int atmel_spi_probe(struct platform_device *pdev)
|
||||
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16);
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = master->dev.of_node ? 0 : 4;
|
||||
|
||||
@@ -248,11 +248,6 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
|
||||
hz = t->speed_hz;
|
||||
}
|
||||
|
||||
if (bpw < 4 || bpw > 24) {
|
||||
dev_err(&spi->dev, "setupxfer: invalid bits_per_word=%d\n",
|
||||
bpw);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (hz > spi->max_speed_hz || hz > hw->freq_max || hz < hw->freq_min) {
|
||||
dev_err(&spi->dev, "setupxfer: clock rate=%d out of range\n",
|
||||
hz);
|
||||
@@ -296,12 +291,6 @@ static int au1550_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
struct au1550_spi *hw = spi_master_get_devdata(spi->master);
|
||||
|
||||
if (spi->bits_per_word < 4 || spi->bits_per_word > 24) {
|
||||
dev_err(&spi->dev, "setup: invalid bits_per_word=%d\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (spi->max_speed_hz == 0)
|
||||
spi->max_speed_hz = hw->freq_max;
|
||||
if (spi->max_speed_hz > hw->freq_max
|
||||
@@ -782,6 +771,7 @@ static int au1550_spi_probe(struct platform_device *pdev)
|
||||
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 24);
|
||||
|
||||
hw = spi_master_get_devdata(master);
|
||||
|
||||
|
||||
@@ -124,17 +124,6 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
#define MODEBITS (SPI_CPOL | SPI_CPHA)
|
||||
|
||||
static int bcm63xx_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
if (spi->bits_per_word != 8) {
|
||||
dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
|
||||
__func__, spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
|
||||
unsigned int num_transfers)
|
||||
{
|
||||
@@ -277,13 +266,6 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master,
|
||||
* full-duplex transfers.
|
||||
*/
|
||||
list_for_each_entry(t, &m->transfers, transfer_list) {
|
||||
if (t->bits_per_word != 8) {
|
||||
dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
|
||||
__func__, t->bits_per_word);
|
||||
status = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!first)
|
||||
first = t;
|
||||
|
||||
@@ -430,11 +412,11 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
|
||||
|
||||
master->bus_num = pdata->bus_num;
|
||||
master->num_chipselect = pdata->num_chipselect;
|
||||
master->setup = bcm63xx_spi_setup;
|
||||
master->prepare_transfer_hardware = bcm63xx_spi_prepare_transfer;
|
||||
master->unprepare_transfer_hardware = bcm63xx_spi_unprepare_transfer;
|
||||
master->transfer_one_message = bcm63xx_spi_transfer_one;
|
||||
master->mode_bits = MODEBITS;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
bs->msg_type_shift = pdata->msg_type_shift;
|
||||
bs->msg_ctl_width = pdata->msg_ctl_width;
|
||||
bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA));
|
||||
|
||||
@@ -417,7 +417,7 @@ bfin_sport_spi_pump_transfers(unsigned long data)
|
||||
|
||||
/* Bits per word setup */
|
||||
bits_per_word = transfer->bits_per_word;
|
||||
if (bits_per_word % 16 == 0)
|
||||
if (bits_per_word == 16)
|
||||
drv_data->ops = &bfin_sport_transfer_ops_u16;
|
||||
else
|
||||
drv_data->ops = &bfin_sport_transfer_ops_u8;
|
||||
@@ -600,13 +600,6 @@ bfin_sport_spi_setup(struct spi_device *spi)
|
||||
}
|
||||
}
|
||||
|
||||
if (spi->bits_per_word % 8) {
|
||||
dev_err(&spi->dev, "%d bits_per_word is not supported\n",
|
||||
spi->bits_per_word);
|
||||
ret = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* translate common spi framework into our register
|
||||
* following configure contents are same for tx and rx.
|
||||
*/
|
||||
@@ -778,6 +771,7 @@ static int bfin_sport_spi_probe(struct platform_device *pdev)
|
||||
drv_data->pin_req = platform_info->pin_req;
|
||||
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = platform_info->num_chipselect;
|
||||
master->cleanup = bfin_sport_spi_cleanup;
|
||||
|
||||
@@ -643,21 +643,16 @@ static void bfin_spi_pump_transfers(unsigned long data)
|
||||
|
||||
/* Bits per word setup */
|
||||
bits_per_word = transfer->bits_per_word;
|
||||
if (bits_per_word % 16 == 0) {
|
||||
if (bits_per_word == 16) {
|
||||
drv_data->n_bytes = bits_per_word/8;
|
||||
drv_data->len = (transfer->len) >> 1;
|
||||
cr_width = BIT_CTL_WORDSIZE;
|
||||
drv_data->ops = &bfin_bfin_spi_transfer_ops_u16;
|
||||
} else if (bits_per_word % 8 == 0) {
|
||||
} else if (bits_per_word == 8) {
|
||||
drv_data->n_bytes = bits_per_word/8;
|
||||
drv_data->len = transfer->len;
|
||||
cr_width = 0;
|
||||
drv_data->ops = &bfin_bfin_spi_transfer_ops_u8;
|
||||
} else {
|
||||
dev_err(&drv_data->pdev->dev, "transfer: unsupported bits_per_word\n");
|
||||
message->status = -EINVAL;
|
||||
bfin_spi_giveback(drv_data);
|
||||
return;
|
||||
}
|
||||
cr = bfin_read(&drv_data->regs->ctl) & ~(BIT_CTL_TIMOD | BIT_CTL_WORDSIZE);
|
||||
cr |= cr_width;
|
||||
@@ -808,13 +803,13 @@ static void bfin_spi_pump_transfers(unsigned long data)
|
||||
bfin_write(&drv_data->regs->tdbr, chip->idle_tx_val);
|
||||
else {
|
||||
int loop;
|
||||
if (bits_per_word % 16 == 0) {
|
||||
if (bits_per_word == 16) {
|
||||
u16 *buf = (u16 *)drv_data->tx;
|
||||
for (loop = 0; loop < bits_per_word / 16;
|
||||
loop++) {
|
||||
bfin_write(&drv_data->regs->tdbr, *buf++);
|
||||
}
|
||||
} else if (bits_per_word % 8 == 0) {
|
||||
} else if (bits_per_word == 8) {
|
||||
u8 *buf = (u8 *)drv_data->tx;
|
||||
for (loop = 0; loop < bits_per_word / 8; loop++)
|
||||
bfin_write(&drv_data->regs->tdbr, *buf++);
|
||||
@@ -1033,12 +1028,6 @@ static int bfin_spi_setup(struct spi_device *spi)
|
||||
chip->ctl_reg &= bfin_ctl_reg;
|
||||
}
|
||||
|
||||
if (spi->bits_per_word % 8) {
|
||||
dev_err(&spi->dev, "%d bits_per_word is not supported\n",
|
||||
spi->bits_per_word);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* translate common spi framework into our register */
|
||||
if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST)) {
|
||||
dev_err(&spi->dev, "unsupported spi modes detected\n");
|
||||
@@ -1299,7 +1288,7 @@ static int bfin_spi_probe(struct platform_device *pdev)
|
||||
|
||||
/* the spi->mode bits supported by this driver: */
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = platform_info->num_chipselect;
|
||||
master->cleanup = bfin_spi_cleanup;
|
||||
|
||||
@@ -42,12 +42,6 @@ static int spi_clps711x_setup(struct spi_device *spi)
|
||||
{
|
||||
struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master);
|
||||
|
||||
if (spi->bits_per_word != 8) {
|
||||
dev_err(&spi->dev, "Unsupported master bus width %i\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* We are expect that SPI-device is not selected */
|
||||
gpio_direction_output(hw->chipselect[spi->chip_select],
|
||||
!(spi->mode & SPI_CS_HIGH));
|
||||
@@ -190,6 +184,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
|
||||
|
||||
master->bus_num = pdev->id;
|
||||
master->mode_bits = SPI_CPHA | SPI_CS_HIGH;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
master->num_chipselect = pdata->num_chipselect;
|
||||
master->setup = spi_clps711x_setup;
|
||||
master->transfer_one_message = spi_clps711x_transfer_one_message;
|
||||
|
||||
@@ -312,10 +312,7 @@ static int mcfqspi_transfer_one_message(struct spi_master *master,
|
||||
bool cs_high = spi->mode & SPI_CS_HIGH;
|
||||
u16 qmr = MCFQSPI_QMR_MSTR;
|
||||
|
||||
if (t->bits_per_word)
|
||||
qmr |= t->bits_per_word << 10;
|
||||
else
|
||||
qmr |= spi->bits_per_word << 10;
|
||||
qmr |= t->bits_per_word << 10;
|
||||
if (spi->mode & SPI_CPHA)
|
||||
qmr |= MCFQSPI_QMR_CPHA;
|
||||
if (spi->mode & SPI_CPOL)
|
||||
@@ -377,11 +374,6 @@ static int mcfqspi_unprepare_transfer_hw(struct spi_master *master)
|
||||
|
||||
static int mcfqspi_setup(struct spi_device *spi)
|
||||
{
|
||||
if ((spi->bits_per_word < 8) || (spi->bits_per_word > 16)) {
|
||||
dev_dbg(&spi->dev, "%d bits per word is not supported\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (spi->chip_select >= spi->master->num_chipselect) {
|
||||
dev_dbg(&spi->dev, "%d chip select is out of range\n",
|
||||
spi->chip_select);
|
||||
@@ -477,6 +469,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
|
||||
mcfqspi->dev = &pdev->dev;
|
||||
|
||||
master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16);
|
||||
master->setup = mcfqspi_setup;
|
||||
master->transfer_one_message = mcfqspi_transfer_one_message;
|
||||
master->prepare_transfer_hardware = mcfqspi_prepare_transfer_hw;
|
||||
|
||||
@@ -299,16 +299,15 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
|
||||
* Assign function pointer to appropriate transfer method
|
||||
* 8bit, 16bit or 32bit transfer
|
||||
*/
|
||||
if (bits_per_word <= 8 && bits_per_word >= 2) {
|
||||
if (bits_per_word <= 8) {
|
||||
dspi->get_rx = davinci_spi_rx_buf_u8;
|
||||
dspi->get_tx = davinci_spi_tx_buf_u8;
|
||||
dspi->bytes_per_word[spi->chip_select] = 1;
|
||||
} else if (bits_per_word <= 16 && bits_per_word >= 2) {
|
||||
} else {
|
||||
dspi->get_rx = davinci_spi_rx_buf_u16;
|
||||
dspi->get_tx = davinci_spi_tx_buf_u16;
|
||||
dspi->bytes_per_word[spi->chip_select] = 2;
|
||||
} else
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!hz)
|
||||
hz = spi->max_speed_hz;
|
||||
@@ -933,6 +932,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = pdata->num_chipselect;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16);
|
||||
master->setup = davinci_spi_setup;
|
||||
|
||||
dspi->bitbang.chipselect = davinci_spi_chipselect;
|
||||
|
||||
@@ -457,19 +457,7 @@ static void pump_transfers(unsigned long data)
|
||||
}
|
||||
if (transfer->bits_per_word) {
|
||||
bits = transfer->bits_per_word;
|
||||
|
||||
switch (bits) {
|
||||
case 8:
|
||||
case 16:
|
||||
dws->n_bytes = dws->dma_width = bits >> 3;
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "MRST SPI0: unsupported bits:"
|
||||
"%db\n", bits);
|
||||
message->status = -EIO;
|
||||
goto early_exit;
|
||||
}
|
||||
|
||||
dws->n_bytes = dws->dma_width = bits >> 3;
|
||||
cr0 = (bits - 1)
|
||||
| (chip->type << SPI_FRF_OFFSET)
|
||||
| (spi->mode << SPI_MODE_OFFSET)
|
||||
@@ -629,9 +617,6 @@ static int dw_spi_setup(struct spi_device *spi)
|
||||
struct dw_spi_chip *chip_info = NULL;
|
||||
struct chip_data *chip;
|
||||
|
||||
if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
|
||||
return -EINVAL;
|
||||
|
||||
/* Only alloc on first setup */
|
||||
chip = spi_get_ctldata(spi);
|
||||
if (!chip) {
|
||||
@@ -660,16 +645,12 @@ static int dw_spi_setup(struct spi_device *spi)
|
||||
chip->enable_dma = chip_info->enable_dma;
|
||||
}
|
||||
|
||||
if (spi->bits_per_word <= 8) {
|
||||
if (spi->bits_per_word == 8) {
|
||||
chip->n_bytes = 1;
|
||||
chip->dma_width = 1;
|
||||
} else if (spi->bits_per_word <= 16) {
|
||||
} else if (spi->bits_per_word == 16) {
|
||||
chip->n_bytes = 2;
|
||||
chip->dma_width = 2;
|
||||
} else {
|
||||
/* Never take >16b case for MRST SPIC */
|
||||
dev_err(&spi->dev, "invalid wordsize\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
chip->bits_per_word = spi->bits_per_word;
|
||||
|
||||
@@ -824,6 +805,7 @@ int dw_spi_add_host(struct dw_spi *dws)
|
||||
}
|
||||
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
|
||||
master->bus_num = dws->bus_num;
|
||||
master->num_chipselect = dws->num_cs;
|
||||
master->cleanup = dw_spi_cleanup;
|
||||
|
||||
@@ -296,12 +296,6 @@ static int ep93xx_spi_setup(struct spi_device *spi)
|
||||
struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
|
||||
struct ep93xx_spi_chip *chip;
|
||||
|
||||
if (spi->bits_per_word < 4 || spi->bits_per_word > 16) {
|
||||
dev_err(&espi->pdev->dev, "invalid bits per word %d\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
chip = spi_get_ctldata(spi);
|
||||
if (!chip) {
|
||||
dev_dbg(&espi->pdev->dev, "initial setup for %s\n",
|
||||
@@ -365,10 +359,6 @@ static int ep93xx_spi_transfer(struct spi_device *spi, struct spi_message *msg)
|
||||
|
||||
/* first validate each transfer */
|
||||
list_for_each_entry(t, &msg->transfers, transfer_list) {
|
||||
if (t->bits_per_word) {
|
||||
if (t->bits_per_word < 4 || t->bits_per_word > 16)
|
||||
return -EINVAL;
|
||||
}
|
||||
if (t->speed_hz && t->speed_hz < espi->min_rate)
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1046,6 +1036,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = info->num_chipselect;
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
|
||||
|
||||
platform_set_drvdata(pdev, master);
|
||||
|
||||
|
||||
@@ -144,10 +144,6 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
|
||||
if (!bits_per_word)
|
||||
bits_per_word = spi->bits_per_word;
|
||||
|
||||
/* Make sure its a bit width we support [4..16] */
|
||||
if ((bits_per_word < 4) || (bits_per_word > 16))
|
||||
return -EINVAL;
|
||||
|
||||
if (!hz)
|
||||
hz = spi->max_speed_hz;
|
||||
|
||||
@@ -157,12 +153,10 @@ static int fsl_espi_setup_transfer(struct spi_device *spi,
|
||||
cs->get_tx = mpc8xxx_spi_tx_buf_u32;
|
||||
if (bits_per_word <= 8) {
|
||||
cs->rx_shift = 8 - bits_per_word;
|
||||
} else if (bits_per_word <= 16) {
|
||||
} else
|
||||
cs->rx_shift = 16 - bits_per_word;
|
||||
if (spi->mode & SPI_LSB_FIRST)
|
||||
cs->get_tx = fsl_espi_tx_buf_lsb;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mpc8xxx_spi->rx_shift = cs->rx_shift;
|
||||
@@ -609,6 +603,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
|
||||
if (ret)
|
||||
goto err_probe;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
|
||||
master->setup = fsl_espi_setup;
|
||||
|
||||
mpc8xxx_spi = spi_master_get_devdata(master);
|
||||
|
||||
@@ -239,9 +239,6 @@ static int spi_gpio_setup(struct spi_device *spi)
|
||||
struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);
|
||||
struct device_node *np = spi->master->dev.of_node;
|
||||
|
||||
if (spi->bits_per_word > 32)
|
||||
return -EINVAL;
|
||||
|
||||
if (np) {
|
||||
/*
|
||||
* In DT environments, the CS GPIOs have already been
|
||||
@@ -446,6 +443,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
|
||||
if (pdata)
|
||||
spi_gpio->pdata = *pdata;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||
master->flags = master_flags;
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = SPI_N_CHIPSEL;
|
||||
|
||||
@@ -698,11 +698,10 @@ static int spi_imx_setupxfer(struct spi_device *spi,
|
||||
} else if (config.bpw <= 16) {
|
||||
spi_imx->rx = spi_imx_buf_rx_u16;
|
||||
spi_imx->tx = spi_imx_buf_tx_u16;
|
||||
} else if (config.bpw <= 32) {
|
||||
}
|
||||
spi_imx->rx = spi_imx_buf_rx_u32;
|
||||
spi_imx->tx = spi_imx_buf_tx_u32;
|
||||
} else
|
||||
BUG();
|
||||
}
|
||||
|
||||
spi_imx->devtype_data->config(spi_imx, &config);
|
||||
|
||||
@@ -783,6 +782,7 @@ static int spi_imx_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, master);
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||
master->bus_num = pdev->id;
|
||||
master->num_chipselect = num_cs;
|
||||
|
||||
|
||||
@@ -75,12 +75,6 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
|
||||
if (t && t->bits_per_word)
|
||||
bits_per_word = t->bits_per_word;
|
||||
|
||||
if (bits_per_word != 8) {
|
||||
dev_err(&dev->dev, "%s, unsupported bits_per_word=%d\n",
|
||||
__func__, bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hz = dev->max_speed_hz;
|
||||
if (t && t->speed_hz)
|
||||
hz = min(hz, t->speed_hz);
|
||||
@@ -548,6 +542,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
|
||||
|
||||
master->transfer_one_message = mxs_spi_transfer_one;
|
||||
master->setup = mxs_spi_setup;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA;
|
||||
master->num_chipselect = 3;
|
||||
master->dev.of_node = np;
|
||||
|
||||
@@ -174,17 +174,6 @@ static void nuc900_spi_gobusy(struct nuc900_spi *hw)
|
||||
spin_unlock_irqrestore(&hw->lock, flags);
|
||||
}
|
||||
|
||||
static int nuc900_spi_setupxfer(struct spi_device *spi,
|
||||
struct spi_transfer *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nuc900_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
|
||||
{
|
||||
return hw->tx ? hw->tx[count] : 0;
|
||||
@@ -377,10 +366,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
|
||||
master->num_chipselect = hw->pdata->num_cs;
|
||||
master->bus_num = hw->pdata->bus_num;
|
||||
hw->bitbang.master = hw->master;
|
||||
hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
|
||||
hw->bitbang.chipselect = nuc900_spi_chipsel;
|
||||
hw->bitbang.txrx_bufs = nuc900_spi_txrx;
|
||||
hw->bitbang.master->setup = nuc900_spi_setup;
|
||||
|
||||
hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (hw->res == NULL) {
|
||||
|
||||
@@ -298,12 +298,6 @@ static int omap1_spi100k_setup(struct spi_device *spi)
|
||||
struct omap1_spi100k *spi100k;
|
||||
struct omap1_spi100k_cs *cs = spi->controller_state;
|
||||
|
||||
if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
|
||||
dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spi100k = spi_master_get_devdata(spi->master);
|
||||
|
||||
if (!cs) {
|
||||
@@ -451,10 +445,7 @@ static int omap1_spi100k_transfer(struct spi_device *spi, struct spi_message *m)
|
||||
unsigned len = t->len;
|
||||
|
||||
if (t->speed_hz > OMAP1_SPI100K_MAX_FREQ
|
||||
|| (len && !(rx_buf || tx_buf))
|
||||
|| (t->bits_per_word &&
|
||||
( t->bits_per_word < 4
|
||||
|| t->bits_per_word > 32))) {
|
||||
|| (len && !(rx_buf || tx_buf))) {
|
||||
dev_dbg(&spi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
|
||||
t->speed_hz,
|
||||
len,
|
||||
@@ -509,6 +500,7 @@ static int omap1_spi100k_probe(struct platform_device *pdev)
|
||||
master->cleanup = NULL;
|
||||
master->num_chipselect = 2;
|
||||
master->mode_bits = MODEBITS;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
|
||||
|
||||
dev_set_drvdata(&pdev->dev, master);
|
||||
|
||||
|
||||
@@ -857,12 +857,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
|
||||
struct omap2_mcspi_dma *mcspi_dma;
|
||||
struct omap2_mcspi_cs *cs = spi->controller_state;
|
||||
|
||||
if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
|
||||
dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
|
||||
|
||||
if (!cs) {
|
||||
@@ -1072,10 +1066,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
|
||||
unsigned len = t->len;
|
||||
|
||||
if (t->speed_hz > OMAP2_MCSPI_MAX_FREQ
|
||||
|| (len && !(rx_buf || tx_buf))
|
||||
|| (t->bits_per_word &&
|
||||
( t->bits_per_word < 4
|
||||
|| t->bits_per_word > 32))) {
|
||||
|| (len && !(rx_buf || tx_buf))) {
|
||||
dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
|
||||
t->speed_hz,
|
||||
len,
|
||||
@@ -1196,7 +1187,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
|
||||
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
|
||||
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
|
||||
master->setup = omap2_mcspi_setup;
|
||||
master->prepare_transfer_hardware = omap2_prepare_transfer;
|
||||
master->unprepare_transfer_hardware = omap2_unprepare_transfer;
|
||||
|
||||
@@ -190,12 +190,6 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
|
||||
speed = min(t->speed_hz, spi->max_speed_hz);
|
||||
}
|
||||
|
||||
if (bits_per_word != 8) {
|
||||
dev_err(&spi->dev, "invalid bits-per-word (%d)\n",
|
||||
bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!speed || (speed > spi->max_speed_hz)) {
|
||||
dev_err(&spi->dev, "invalid speed_hz (%d)\n", speed);
|
||||
return -EINVAL;
|
||||
@@ -229,12 +223,6 @@ static int spi_ppc4xx_setup(struct spi_device *spi)
|
||||
{
|
||||
struct spi_ppc4xx_cs *cs = spi->controller_state;
|
||||
|
||||
if (spi->bits_per_word != 8) {
|
||||
dev_err(&spi->dev, "invalid bits-per-word (%d)\n",
|
||||
spi->bits_per_word);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!spi->max_speed_hz) {
|
||||
dev_err(&spi->dev, "invalid max_speed_hz (must be non-zero)\n");
|
||||
return -EINVAL;
|
||||
@@ -465,6 +453,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
|
||||
bbp->use_dma = 0;
|
||||
bbp->master->setup = spi_ppc4xx_setup;
|
||||
bbp->master->cleanup = spi_ppc4xx_cleanup;
|
||||
bbp->master->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
|
||||
/* the spi->mode bits understood by this driver: */
|
||||
bbp->master->mode_bits =
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user