Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: tegra: use reset framework

Tegra's clock driver now provides an implementation of the common
reset API (include/linux/reset.h). Use this instead of the old Tegra-
specific API; that will soon be removed.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Mark Brown <broonie@linaro.org>
Reviewed-by: Thierry Reding <treding@nvidia.com>

+42 -15
+3
drivers/spi/Kconfig
··· 448 448 config SPI_TEGRA114 449 449 tristate "NVIDIA Tegra114 SPI Controller" 450 450 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST 451 + depends on RESET_CONTROLLER 451 452 help 452 453 SPI driver for NVIDIA Tegra114 SPI Controller interface. This controller 453 454 is different than the older SoCs SPI controller and also register interface ··· 457 456 config SPI_TEGRA20_SFLASH 458 457 tristate "Nvidia Tegra20 Serial flash Controller" 459 458 depends on ARCH_TEGRA || COMPILE_TEST 459 + depends on RESET_CONTROLLER 460 460 help 461 461 SPI driver for Nvidia Tegra20 Serial flash Controller interface. 462 462 The main usecase of this controller is to use spi flash as boot ··· 466 464 config SPI_TEGRA20_SLINK 467 465 tristate "Nvidia Tegra20/Tegra30 SLINK Controller" 468 466 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST 467 + depends on RESET_CONTROLLER 469 468 help 470 469 SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface. 471 470
+13 -5
drivers/spi/spi-tegra114.c
··· 17 17 */ 18 18 19 19 #include <linux/clk.h> 20 - #include <linux/clk/tegra.h> 21 20 #include <linux/completion.h> 22 21 #include <linux/delay.h> 23 22 #include <linux/dmaengine.h> ··· 33 34 #include <linux/pm_runtime.h> 34 35 #include <linux/of.h> 35 36 #include <linux/of_device.h> 37 + #include <linux/reset.h> 36 38 #include <linux/spi/spi.h> 37 39 38 40 #define SPI_COMMAND1 0x000 ··· 174 174 spinlock_t lock; 175 175 176 176 struct clk *clk; 177 + struct reset_control *rst; 177 178 void __iomem *base; 178 179 phys_addr_t phys; 179 180 unsigned irq; ··· 919 918 tspi->status_reg); 920 919 dev_err(tspi->dev, "CpuXfer 0x%08x:0x%08x\n", 921 920 tspi->command1_reg, tspi->dma_control_reg); 922 - tegra_periph_reset_assert(tspi->clk); 921 + reset_control_assert(tspi->rst); 923 922 udelay(2); 924 - tegra_periph_reset_deassert(tspi->clk); 923 + reset_control_deassert(tspi->rst); 925 924 complete(&tspi->xfer_completion); 926 925 goto exit; 927 926 } ··· 991 990 tspi->status_reg); 992 991 dev_err(tspi->dev, "DmaXfer 0x%08x:0x%08x\n", 993 992 tspi->command1_reg, tspi->dma_control_reg); 994 - tegra_periph_reset_assert(tspi->clk); 993 + reset_control_assert(tspi->rst); 995 994 udelay(2); 996 - tegra_periph_reset_deassert(tspi->clk); 995 + reset_control_deassert(tspi->rst); 997 996 complete(&tspi->xfer_completion); 998 997 spin_unlock_irqrestore(&tspi->lock, flags); 999 998 return IRQ_HANDLED; ··· 1125 1124 if (IS_ERR(tspi->clk)) { 1126 1125 dev_err(&pdev->dev, "can not get clock\n"); 1127 1126 ret = PTR_ERR(tspi->clk); 1127 + goto exit_free_irq; 1128 + } 1129 + 1130 + tspi->rst = devm_reset_control_get(&pdev->dev, "spi"); 1131 + if (IS_ERR(tspi->rst)) { 1132 + dev_err(&pdev->dev, "can not get reset\n"); 1133 + ret = PTR_ERR(tspi->rst); 1128 1134 goto exit_free_irq; 1129 1135 } 1130 1136
+13 -5
drivers/spi/spi-tegra20-sflash.c
··· 32 32 #include <linux/pm_runtime.h> 33 33 #include <linux/of.h> 34 34 #include <linux/of_device.h> 35 + #include <linux/reset.h> 35 36 #include <linux/spi/spi.h> 36 - #include <linux/clk/tegra.h> 37 37 38 38 #define SPI_COMMAND 0x000 39 39 #define SPI_GO BIT(30) ··· 118 118 spinlock_t lock; 119 119 120 120 struct clk *clk; 121 + struct reset_control *rst; 121 122 void __iomem *base; 122 123 unsigned irq; 123 124 u32 spi_max_frequency; ··· 390 389 dev_err(tsd->dev, 391 390 "CpuXfer 0x%08x:0x%08x\n", tsd->command_reg, 392 391 tsd->dma_control_reg); 393 - tegra_periph_reset_assert(tsd->clk); 392 + reset_control_assert(tsd->rst); 394 393 udelay(2); 395 - tegra_periph_reset_deassert(tsd->clk); 394 + reset_control_deassert(tsd->rst); 396 395 complete(&tsd->xfer_completion); 397 396 goto exit; 398 397 } ··· 506 505 goto exit_free_irq; 507 506 } 508 507 508 + tsd->rst = devm_reset_control_get(&pdev->dev, "spi"); 509 + if (IS_ERR(tsd->rst)) { 510 + dev_err(&pdev->dev, "can not get reset\n"); 511 + ret = PTR_ERR(tsd->rst); 512 + goto exit_free_irq; 513 + } 514 + 509 515 init_completion(&tsd->xfer_completion); 510 516 pm_runtime_enable(&pdev->dev); 511 517 if (!pm_runtime_enabled(&pdev->dev)) { ··· 528 520 } 529 521 530 522 /* Reset controller */ 531 - tegra_periph_reset_assert(tsd->clk); 523 + reset_control_assert(tsd->rst); 532 524 udelay(2); 533 - tegra_periph_reset_deassert(tsd->clk); 525 + reset_control_deassert(tsd->rst); 534 526 535 527 tsd->def_command_reg = SPI_M_S | SPI_CS_SW; 536 528 tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND);
+13 -5
drivers/spi/spi-tegra20-slink.c
··· 33 33 #include <linux/pm_runtime.h> 34 34 #include <linux/of.h> 35 35 #include <linux/of_device.h> 36 + #include <linux/reset.h> 36 37 #include <linux/spi/spi.h> 37 - #include <linux/clk/tegra.h> 38 38 39 39 #define SLINK_COMMAND 0x000 40 40 #define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0) ··· 167 167 spinlock_t lock; 168 168 169 169 struct clk *clk; 170 + struct reset_control *rst; 170 171 void __iomem *base; 171 172 phys_addr_t phys; 172 173 unsigned irq; ··· 885 884 dev_err(tspi->dev, 886 885 "CpuXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, 887 886 tspi->command2_reg, tspi->dma_control_reg); 888 - tegra_periph_reset_assert(tspi->clk); 887 + reset_control_assert(tspi->rst); 889 888 udelay(2); 890 - tegra_periph_reset_deassert(tspi->clk); 889 + reset_control_deassert(tspi->rst); 891 890 complete(&tspi->xfer_completion); 892 891 goto exit; 893 892 } ··· 958 957 dev_err(tspi->dev, 959 958 "DmaXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, 960 959 tspi->command2_reg, tspi->dma_control_reg); 961 - tegra_periph_reset_assert(tspi->clk); 960 + reset_control_assert(tspi->rst); 962 961 udelay(2); 963 - tegra_periph_reset_deassert(tspi->clk); 962 + reset_control_assert(tspi->rst); 964 963 complete(&tspi->xfer_completion); 965 964 spin_unlock_irqrestore(&tspi->lock, flags); 966 965 return IRQ_HANDLED; ··· 1116 1115 if (IS_ERR(tspi->clk)) { 1117 1116 dev_err(&pdev->dev, "can not get clock\n"); 1118 1117 ret = PTR_ERR(tspi->clk); 1118 + goto exit_free_irq; 1119 + } 1120 + 1121 + tspi->rst = devm_reset_control_get(&pdev->dev, "spi"); 1122 + if (IS_ERR(tspi->rst)) { 1123 + dev_err(&pdev->dev, "can not get reset\n"); 1124 + ret = PTR_ERR(tspi->rst); 1119 1125 goto exit_free_irq; 1120 1126 } 1121 1127