diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-davinci.c | 39 | ||||
-rw-r--r-- | drivers/spi/spi-dw.c | 12 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-espi.c | 15 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-spi.c | 10 | ||||
-rw-r--r-- | drivers/spi/spi-pl022.c | 2 | ||||
-rw-r--r-- | drivers/spi/spi-rockchip.c | 5 | ||||
-rw-r--r-- | drivers/spi/spi-sirf.c | 5 |
7 files changed, 62 insertions, 26 deletions
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 48f1d26e6ad9..134fb6eb7b19 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
@@ -397,24 +397,21 @@ static int davinci_spi_setup(struct spi_device *spi) | |||
397 | struct spi_master *master = spi->master; | 397 | struct spi_master *master = spi->master; |
398 | struct device_node *np = spi->dev.of_node; | 398 | struct device_node *np = spi->dev.of_node; |
399 | bool internal_cs = true; | 399 | bool internal_cs = true; |
400 | unsigned long flags = GPIOF_DIR_OUT; | ||
401 | 400 | ||
402 | dspi = spi_master_get_devdata(spi->master); | 401 | dspi = spi_master_get_devdata(spi->master); |
403 | pdata = &dspi->pdata; | 402 | pdata = &dspi->pdata; |
404 | 403 | ||
405 | flags |= (spi->mode & SPI_CS_HIGH) ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH; | ||
406 | |||
407 | if (!(spi->mode & SPI_NO_CS)) { | 404 | if (!(spi->mode & SPI_NO_CS)) { |
408 | if (np && (master->cs_gpios != NULL) && (spi->cs_gpio >= 0)) { | 405 | if (np && (master->cs_gpios != NULL) && (spi->cs_gpio >= 0)) { |
409 | retval = gpio_request_one(spi->cs_gpio, | 406 | retval = gpio_direction_output( |
410 | flags, dev_name(&spi->dev)); | 407 | spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); |
411 | internal_cs = false; | 408 | internal_cs = false; |
412 | } else if (pdata->chip_sel && | 409 | } else if (pdata->chip_sel && |
413 | spi->chip_select < pdata->num_chipselect && | 410 | spi->chip_select < pdata->num_chipselect && |
414 | pdata->chip_sel[spi->chip_select] != SPI_INTERN_CS) { | 411 | pdata->chip_sel[spi->chip_select] != SPI_INTERN_CS) { |
415 | spi->cs_gpio = pdata->chip_sel[spi->chip_select]; | 412 | spi->cs_gpio = pdata->chip_sel[spi->chip_select]; |
416 | retval = gpio_request_one(spi->cs_gpio, | 413 | retval = gpio_direction_output( |
417 | flags, dev_name(&spi->dev)); | 414 | spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); |
418 | internal_cs = false; | 415 | internal_cs = false; |
419 | } | 416 | } |
420 | 417 | ||
@@ -439,12 +436,6 @@ static int davinci_spi_setup(struct spi_device *spi) | |||
439 | return retval; | 436 | return retval; |
440 | } | 437 | } |
441 | 438 | ||
442 | static void davinci_spi_cleanup(struct spi_device *spi) | ||
443 | { | ||
444 | if (spi->cs_gpio >= 0) | ||
445 | gpio_free(spi->cs_gpio); | ||
446 | } | ||
447 | |||
448 | static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) | 439 | static int davinci_spi_check_error(struct davinci_spi *dspi, int int_status) |
449 | { | 440 | { |
450 | struct device *sdev = dspi->bitbang.master->dev.parent; | 441 | struct device *sdev = dspi->bitbang.master->dev.parent; |
@@ -956,7 +947,6 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
956 | master->num_chipselect = pdata->num_chipselect; | 947 | master->num_chipselect = pdata->num_chipselect; |
957 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16); | 948 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16); |
958 | master->setup = davinci_spi_setup; | 949 | master->setup = davinci_spi_setup; |
959 | master->cleanup = davinci_spi_cleanup; | ||
960 | 950 | ||
961 | dspi->bitbang.chipselect = davinci_spi_chipselect; | 951 | dspi->bitbang.chipselect = davinci_spi_chipselect; |
962 | dspi->bitbang.setup_transfer = davinci_spi_setup_transfer; | 952 | dspi->bitbang.setup_transfer = davinci_spi_setup_transfer; |
@@ -967,6 +957,27 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
967 | if (dspi->version == SPI_VERSION_2) | 957 | if (dspi->version == SPI_VERSION_2) |
968 | dspi->bitbang.flags |= SPI_READY; | 958 | dspi->bitbang.flags |= SPI_READY; |
969 | 959 | ||
960 | if (pdev->dev.of_node) { | ||
961 | int i; | ||
962 | |||
963 | for (i = 0; i < pdata->num_chipselect; i++) { | ||
964 | int cs_gpio = of_get_named_gpio(pdev->dev.of_node, | ||
965 | "cs-gpios", i); | ||
966 | |||
967 | if (cs_gpio == -EPROBE_DEFER) { | ||
968 | ret = cs_gpio; | ||
969 | goto free_clk; | ||
970 | } | ||
971 | |||
972 | if (gpio_is_valid(cs_gpio)) { | ||
973 | ret = devm_gpio_request(&pdev->dev, cs_gpio, | ||
974 | dev_name(&pdev->dev)); | ||
975 | if (ret) | ||
976 | goto free_clk; | ||
977 | } | ||
978 | } | ||
979 | } | ||
980 | |||
970 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 981 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
971 | if (r) | 982 | if (r) |
972 | dma_rx_chan = r->start; | 983 | dma_rx_chan = r->start; |
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 670f0627f3bf..0dd0623319b0 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c | |||
@@ -547,8 +547,7 @@ static int dw_spi_setup(struct spi_device *spi) | |||
547 | /* Only alloc on first setup */ | 547 | /* Only alloc on first setup */ |
548 | chip = spi_get_ctldata(spi); | 548 | chip = spi_get_ctldata(spi); |
549 | if (!chip) { | 549 | if (!chip) { |
550 | chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data), | 550 | chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); |
551 | GFP_KERNEL); | ||
552 | if (!chip) | 551 | if (!chip) |
553 | return -ENOMEM; | 552 | return -ENOMEM; |
554 | spi_set_ctldata(spi, chip); | 553 | spi_set_ctldata(spi, chip); |
@@ -606,6 +605,14 @@ static int dw_spi_setup(struct spi_device *spi) | |||
606 | return 0; | 605 | return 0; |
607 | } | 606 | } |
608 | 607 | ||
608 | static void dw_spi_cleanup(struct spi_device *spi) | ||
609 | { | ||
610 | struct chip_data *chip = spi_get_ctldata(spi); | ||
611 | |||
612 | kfree(chip); | ||
613 | spi_set_ctldata(spi, NULL); | ||
614 | } | ||
615 | |||
609 | /* Restart the controller, disable all interrupts, clean rx fifo */ | 616 | /* Restart the controller, disable all interrupts, clean rx fifo */ |
610 | static void spi_hw_init(struct dw_spi *dws) | 617 | static void spi_hw_init(struct dw_spi *dws) |
611 | { | 618 | { |
@@ -661,6 +668,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) | |||
661 | master->bus_num = dws->bus_num; | 668 | master->bus_num = dws->bus_num; |
662 | master->num_chipselect = dws->num_cs; | 669 | master->num_chipselect = dws->num_cs; |
663 | master->setup = dw_spi_setup; | 670 | master->setup = dw_spi_setup; |
671 | master->cleanup = dw_spi_cleanup; | ||
664 | master->transfer_one_message = dw_spi_transfer_one_message; | 672 | master->transfer_one_message = dw_spi_transfer_one_message; |
665 | master->max_speed_hz = dws->max_freq; | 673 | master->max_speed_hz = dws->max_freq; |
666 | 674 | ||
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 8ebd724e4c59..429e11190265 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -452,16 +452,16 @@ static int fsl_espi_setup(struct spi_device *spi) | |||
452 | int retval; | 452 | int retval; |
453 | u32 hw_mode; | 453 | u32 hw_mode; |
454 | u32 loop_mode; | 454 | u32 loop_mode; |
455 | struct spi_mpc8xxx_cs *cs = spi->controller_state; | 455 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); |
456 | 456 | ||
457 | if (!spi->max_speed_hz) | 457 | if (!spi->max_speed_hz) |
458 | return -EINVAL; | 458 | return -EINVAL; |
459 | 459 | ||
460 | if (!cs) { | 460 | if (!cs) { |
461 | cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); | 461 | cs = kzalloc(sizeof(*cs), GFP_KERNEL); |
462 | if (!cs) | 462 | if (!cs) |
463 | return -ENOMEM; | 463 | return -ENOMEM; |
464 | spi->controller_state = cs; | 464 | spi_set_ctldata(spi, cs); |
465 | } | 465 | } |
466 | 466 | ||
467 | mpc8xxx_spi = spi_master_get_devdata(spi->master); | 467 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
@@ -496,6 +496,14 @@ static int fsl_espi_setup(struct spi_device *spi) | |||
496 | return 0; | 496 | return 0; |
497 | } | 497 | } |
498 | 498 | ||
499 | static void fsl_espi_cleanup(struct spi_device *spi) | ||
500 | { | ||
501 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); | ||
502 | |||
503 | kfree(cs); | ||
504 | spi_set_ctldata(spi, NULL); | ||
505 | } | ||
506 | |||
499 | void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) | 507 | void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) |
500 | { | 508 | { |
501 | struct fsl_espi_reg *reg_base = mspi->reg_base; | 509 | struct fsl_espi_reg *reg_base = mspi->reg_base; |
@@ -605,6 +613,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
605 | 613 | ||
606 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | 614 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); |
607 | master->setup = fsl_espi_setup; | 615 | master->setup = fsl_espi_setup; |
616 | master->cleanup = fsl_espi_cleanup; | ||
608 | 617 | ||
609 | mpc8xxx_spi = spi_master_get_devdata(master); | 618 | mpc8xxx_spi = spi_master_get_devdata(master); |
610 | mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; | 619 | mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; |
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 9452f6740997..590f31bc0aba 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c | |||
@@ -425,16 +425,16 @@ static int fsl_spi_setup(struct spi_device *spi) | |||
425 | struct fsl_spi_reg *reg_base; | 425 | struct fsl_spi_reg *reg_base; |
426 | int retval; | 426 | int retval; |
427 | u32 hw_mode; | 427 | u32 hw_mode; |
428 | struct spi_mpc8xxx_cs *cs = spi->controller_state; | 428 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); |
429 | 429 | ||
430 | if (!spi->max_speed_hz) | 430 | if (!spi->max_speed_hz) |
431 | return -EINVAL; | 431 | return -EINVAL; |
432 | 432 | ||
433 | if (!cs) { | 433 | if (!cs) { |
434 | cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); | 434 | cs = kzalloc(sizeof(*cs), GFP_KERNEL); |
435 | if (!cs) | 435 | if (!cs) |
436 | return -ENOMEM; | 436 | return -ENOMEM; |
437 | spi->controller_state = cs; | 437 | spi_set_ctldata(spi, cs); |
438 | } | 438 | } |
439 | mpc8xxx_spi = spi_master_get_devdata(spi->master); | 439 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
440 | 440 | ||
@@ -496,9 +496,13 @@ static int fsl_spi_setup(struct spi_device *spi) | |||
496 | static void fsl_spi_cleanup(struct spi_device *spi) | 496 | static void fsl_spi_cleanup(struct spi_device *spi) |
497 | { | 497 | { |
498 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); | 498 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); |
499 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); | ||
499 | 500 | ||
500 | if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio)) | 501 | if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio)) |
501 | gpio_free(spi->cs_gpio); | 502 | gpio_free(spi->cs_gpio); |
503 | |||
504 | kfree(cs); | ||
505 | spi_set_ctldata(spi, NULL); | ||
502 | } | 506 | } |
503 | 507 | ||
504 | static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) | 508 | static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 1189cfd96477..f1f0a587e4fc 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
@@ -2136,7 +2136,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
2136 | cs_gpio); | 2136 | cs_gpio); |
2137 | else if (gpio_direction_output(cs_gpio, 1)) | 2137 | else if (gpio_direction_output(cs_gpio, 1)) |
2138 | dev_err(&adev->dev, | 2138 | dev_err(&adev->dev, |
2139 | "could set gpio %d as output\n", | 2139 | "could not set gpio %d as output\n", |
2140 | cs_gpio); | 2140 | cs_gpio); |
2141 | } | 2141 | } |
2142 | } | 2142 | } |
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index cd0e08b0c9f6..3afc266b666d 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c | |||
@@ -220,7 +220,7 @@ static inline void wait_for_idle(struct rockchip_spi *rs) | |||
220 | do { | 220 | do { |
221 | if (!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)) | 221 | if (!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)) |
222 | return; | 222 | return; |
223 | } while (time_before(jiffies, timeout)); | 223 | } while (!time_after(jiffies, timeout)); |
224 | 224 | ||
225 | dev_warn(rs->dev, "spi controller is in busy state!\n"); | 225 | dev_warn(rs->dev, "spi controller is in busy state!\n"); |
226 | } | 226 | } |
@@ -529,7 +529,8 @@ static int rockchip_spi_transfer_one( | |||
529 | int ret = 0; | 529 | int ret = 0; |
530 | struct rockchip_spi *rs = spi_master_get_devdata(master); | 530 | struct rockchip_spi *rs = spi_master_get_devdata(master); |
531 | 531 | ||
532 | WARN_ON((readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)); | 532 | WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && |
533 | (readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY)); | ||
533 | 534 | ||
534 | if (!xfer->tx_buf && !xfer->rx_buf) { | 535 | if (!xfer->tx_buf && !xfer->rx_buf) { |
535 | dev_err(rs->dev, "No buffer for transfer\n"); | 536 | dev_err(rs->dev, "No buffer for transfer\n"); |
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 95ac276eaafe..6f0602fd7401 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c | |||
@@ -312,6 +312,8 @@ static int spi_sirfsoc_cmd_transfer(struct spi_device *spi, | |||
312 | u32 cmd; | 312 | u32 cmd; |
313 | 313 | ||
314 | sspi = spi_master_get_devdata(spi->master); | 314 | sspi = spi_master_get_devdata(spi->master); |
315 | writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_TXFIFO_OP); | ||
316 | writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_TXFIFO_OP); | ||
315 | memcpy(&cmd, sspi->tx, t->len); | 317 | memcpy(&cmd, sspi->tx, t->len); |
316 | if (sspi->word_width == 1 && !(spi->mode & SPI_LSB_FIRST)) | 318 | if (sspi->word_width == 1 && !(spi->mode & SPI_LSB_FIRST)) |
317 | cmd = cpu_to_be32(cmd) >> | 319 | cmd = cpu_to_be32(cmd) >> |
@@ -438,7 +440,8 @@ static void spi_sirfsoc_pio_transfer(struct spi_device *spi, | |||
438 | sspi->tx_word(sspi); | 440 | sspi->tx_word(sspi); |
439 | writel(SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN | | 441 | writel(SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN | |
440 | SIRFSOC_SPI_TX_UFLOW_INT_EN | | 442 | SIRFSOC_SPI_TX_UFLOW_INT_EN | |
441 | SIRFSOC_SPI_RX_OFLOW_INT_EN, | 443 | SIRFSOC_SPI_RX_OFLOW_INT_EN | |
444 | SIRFSOC_SPI_RX_IO_DMA_INT_EN, | ||
442 | sspi->base + SIRFSOC_SPI_INT_EN); | 445 | sspi->base + SIRFSOC_SPI_INT_EN); |
443 | writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, | 446 | writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, |
444 | sspi->base + SIRFSOC_SPI_TX_RX_EN); | 447 | sspi->base + SIRFSOC_SPI_TX_RX_EN); |