diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-atmel.c | 51 | ||||
-rw-r--r-- | drivers/spi/spi-davinci.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-tegra20-sflash.c | 5 | ||||
-rw-r--r-- | drivers/spi/spi.c | 9 |
4 files changed, 47 insertions, 20 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 787bd2c22bca..380387a47b1d 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c | |||
@@ -526,13 +526,17 @@ static void atmel_spi_next_xfer_pio(struct spi_master *master, | |||
526 | } | 526 | } |
527 | 527 | ||
528 | if (xfer->tx_buf) | 528 | if (xfer->tx_buf) |
529 | spi_writel(as, TDR, *(u8 *)(xfer->tx_buf)); | 529 | if (xfer->bits_per_word > 8) |
530 | spi_writel(as, TDR, *(u16 *)(xfer->tx_buf)); | ||
531 | else | ||
532 | spi_writel(as, TDR, *(u8 *)(xfer->tx_buf)); | ||
530 | else | 533 | else |
531 | spi_writel(as, TDR, 0); | 534 | spi_writel(as, TDR, 0); |
532 | 535 | ||
533 | dev_dbg(master->dev.parent, | 536 | dev_dbg(master->dev.parent, |
534 | " start pio xfer %p: len %u tx %p rx %p\n", | 537 | " start pio xfer %p: len %u tx %p rx %p bitpw %d\n", |
535 | xfer, xfer->len, xfer->tx_buf, xfer->rx_buf); | 538 | xfer, xfer->len, xfer->tx_buf, xfer->rx_buf, |
539 | xfer->bits_per_word); | ||
536 | 540 | ||
537 | /* Enable relevant interrupts */ | 541 | /* Enable relevant interrupts */ |
538 | spi_writel(as, IER, SPI_BIT(RDRF) | SPI_BIT(OVRES)); | 542 | spi_writel(as, IER, SPI_BIT(RDRF) | SPI_BIT(OVRES)); |
@@ -950,21 +954,39 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) | |||
950 | { | 954 | { |
951 | u8 *txp; | 955 | u8 *txp; |
952 | u8 *rxp; | 956 | u8 *rxp; |
957 | u16 *txp16; | ||
958 | u16 *rxp16; | ||
953 | unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; | 959 | unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; |
954 | 960 | ||
955 | if (xfer->rx_buf) { | 961 | if (xfer->rx_buf) { |
956 | rxp = ((u8 *)xfer->rx_buf) + xfer_pos; | 962 | if (xfer->bits_per_word > 8) { |
957 | *rxp = spi_readl(as, RDR); | 963 | rxp16 = (u16 *)(((u8 *)xfer->rx_buf) + xfer_pos); |
964 | *rxp16 = spi_readl(as, RDR); | ||
965 | } else { | ||
966 | rxp = ((u8 *)xfer->rx_buf) + xfer_pos; | ||
967 | *rxp = spi_readl(as, RDR); | ||
968 | } | ||
958 | } else { | 969 | } else { |
959 | spi_readl(as, RDR); | 970 | spi_readl(as, RDR); |
960 | } | 971 | } |
961 | 972 | if (xfer->bits_per_word > 8) { | |
962 | as->current_remaining_bytes--; | 973 | as->current_remaining_bytes -= 2; |
974 | if (as->current_remaining_bytes < 0) | ||
975 | as->current_remaining_bytes = 0; | ||
976 | } else { | ||
977 | as->current_remaining_bytes--; | ||
978 | } | ||
963 | 979 | ||
964 | if (as->current_remaining_bytes) { | 980 | if (as->current_remaining_bytes) { |
965 | if (xfer->tx_buf) { | 981 | if (xfer->tx_buf) { |
966 | txp = ((u8 *)xfer->tx_buf) + xfer_pos + 1; | 982 | if (xfer->bits_per_word > 8) { |
967 | spi_writel(as, TDR, *txp); | 983 | txp16 = (u16 *)(((u8 *)xfer->tx_buf) |
984 | + xfer_pos + 2); | ||
985 | spi_writel(as, TDR, *txp16); | ||
986 | } else { | ||
987 | txp = ((u8 *)xfer->tx_buf) + xfer_pos + 1; | ||
988 | spi_writel(as, TDR, *txp); | ||
989 | } | ||
968 | } else { | 990 | } else { |
969 | spi_writel(as, TDR, 0); | 991 | spi_writel(as, TDR, 0); |
970 | } | 992 | } |
@@ -1378,9 +1400,16 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg) | |||
1378 | } | 1400 | } |
1379 | } | 1401 | } |
1380 | 1402 | ||
1403 | if (xfer->bits_per_word > 8) { | ||
1404 | if (xfer->len % 2) { | ||
1405 | dev_dbg(&spi->dev, "buffer len should be 16 bits aligned\n"); | ||
1406 | return -EINVAL; | ||
1407 | } | ||
1408 | } | ||
1409 | |||
1381 | /* FIXME implement these protocol options!! */ | 1410 | /* FIXME implement these protocol options!! */ |
1382 | if (xfer->speed_hz) { | 1411 | if (xfer->speed_hz < spi->max_speed_hz) { |
1383 | dev_dbg(&spi->dev, "no protocol options yet\n"); | 1412 | dev_dbg(&spi->dev, "can't change speed in transfer\n"); |
1384 | return -ENOPROTOOPT; | 1413 | return -ENOPROTOOPT; |
1385 | } | 1414 | } |
1386 | 1415 | ||
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 2e8f24a1fb95..50b13c9b1ab6 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -784,7 +784,7 @@ static const struct of_device_id davinci_spi_of_match[] = { | |||
784 | }, | 784 | }, |
785 | { }, | 785 | { }, |
786 | }; | 786 | }; |
787 | MODULE_DEVICE_TABLE(of, davini_spi_of_match); | 787 | MODULE_DEVICE_TABLE(of, davinci_spi_of_match); |
788 | 788 | ||
789 | /** | 789 | /** |
790 | * spi_davinci_get_pdata - Get platform data from DTS binding | 790 | * spi_davinci_get_pdata - Get platform data from DTS binding |
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c index d65c000efe35..09df8e22dba0 100644 --- a/drivers/spi/spi-tegra20-sflash.c +++ b/drivers/spi/spi-tegra20-sflash.c | |||
@@ -489,11 +489,6 @@ static int tegra_sflash_probe(struct platform_device *pdev) | |||
489 | tegra_sflash_parse_dt(tsd); | 489 | tegra_sflash_parse_dt(tsd); |
490 | 490 | ||
491 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 491 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
492 | if (!r) { | ||
493 | dev_err(&pdev->dev, "No IO memory resource\n"); | ||
494 | ret = -ENODEV; | ||
495 | goto exit_free_master; | ||
496 | } | ||
497 | tsd->base = devm_ioremap_resource(&pdev->dev, r); | 492 | tsd->base = devm_ioremap_resource(&pdev->dev, r); |
498 | if (IS_ERR(tsd->base)) { | 493 | if (IS_ERR(tsd->base)) { |
499 | ret = PTR_ERR(tsd->base); | 494 | ret = PTR_ERR(tsd->base); |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 163fd802b7ac..32b7bb111eb6 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -334,7 +334,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master) | |||
334 | spi->dev.parent = &master->dev; | 334 | spi->dev.parent = &master->dev; |
335 | spi->dev.bus = &spi_bus_type; | 335 | spi->dev.bus = &spi_bus_type; |
336 | spi->dev.release = spidev_release; | 336 | spi->dev.release = spidev_release; |
337 | spi->cs_gpio = -EINVAL; | 337 | spi->cs_gpio = -ENOENT; |
338 | device_initialize(&spi->dev); | 338 | device_initialize(&spi->dev); |
339 | return spi; | 339 | return spi; |
340 | } | 340 | } |
@@ -1067,8 +1067,11 @@ static int of_spi_register_master(struct spi_master *master) | |||
1067 | nb = of_gpio_named_count(np, "cs-gpios"); | 1067 | nb = of_gpio_named_count(np, "cs-gpios"); |
1068 | master->num_chipselect = max(nb, (int)master->num_chipselect); | 1068 | master->num_chipselect = max(nb, (int)master->num_chipselect); |
1069 | 1069 | ||
1070 | if (nb < 1) | 1070 | /* Return error only for an incorrectly formed cs-gpios property */ |
1071 | if (nb == 0 || nb == -ENOENT) | ||
1071 | return 0; | 1072 | return 0; |
1073 | else if (nb < 0) | ||
1074 | return nb; | ||
1072 | 1075 | ||
1073 | cs = devm_kzalloc(&master->dev, | 1076 | cs = devm_kzalloc(&master->dev, |
1074 | sizeof(int) * master->num_chipselect, | 1077 | sizeof(int) * master->num_chipselect, |
@@ -1079,7 +1082,7 @@ static int of_spi_register_master(struct spi_master *master) | |||
1079 | return -ENOMEM; | 1082 | return -ENOMEM; |
1080 | 1083 | ||
1081 | for (i = 0; i < master->num_chipselect; i++) | 1084 | for (i = 0; i < master->num_chipselect; i++) |
1082 | cs[i] = -EINVAL; | 1085 | cs[i] = -ENOENT; |
1083 | 1086 | ||
1084 | for (i = 0; i < nb; i++) | 1087 | for (i = 0; i < nb; i++) |
1085 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); | 1088 | cs[i] = of_get_named_gpio(np, "cs-gpios", i); |