]> www.infradead.org Git - linux.git/commitdiff
spi: spi-cadence: Add optional reset control support
authorJi Sheng Teoh <jisheng.teoh@starfivetech.com>
Wed, 8 May 2024 05:47:27 +0000 (13:47 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 27 May 2024 00:32:57 +0000 (01:32 +0100)
Add optional reset control support for spi-cadence to properly bring
the SPI device into an operating condition.

Co-developed-by: Eng Lee Teh <englee.teh@starfivetech.com>
Signed-off-by: Eng Lee Teh <englee.teh@starfivetech.com>
Co-developed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>
Link: https://msgid.link/r/20240508054728.1751162-2-jisheng.teoh@starfivetech.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-cadence.c

index e5140532071d2b647ab77fa561f27630a334971a..4eacf3f6e031e8def140f34201dc0cc7285bc220 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/spi/spi.h>
 
 /* Name of this driver */
  * @dev_busy:          Device busy flag
  * @is_decoded_cs:     Flag for decoder property set or not
  * @tx_fifo_depth:     Depth of the TX FIFO
+ * @rstc:              Optional reset control for SPI controller
  */
 struct cdns_spi {
        void __iomem *regs;
@@ -125,6 +127,7 @@ struct cdns_spi {
        u8 dev_busy;
        u32 is_decoded_cs;
        unsigned int tx_fifo_depth;
+       struct reset_control *rstc;
 };
 
 /* Macros for the SPI controller read/write */
@@ -588,6 +591,16 @@ static int cdns_spi_probe(struct platform_device *pdev)
                goto remove_ctlr;
        }
 
+       xspi->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
+       if (IS_ERR(xspi->rstc)) {
+               ret = dev_err_probe(&pdev->dev, PTR_ERR(xspi->rstc),
+                                   "Cannot get SPI reset.\n");
+               goto remove_ctlr;
+       }
+
+       reset_control_assert(xspi->rstc);
+       reset_control_deassert(xspi->rstc);
+
        if (!spi_controller_is_target(ctlr)) {
                xspi->ref_clk = devm_clk_get_enabled(&pdev->dev, "ref_clk");
                if (IS_ERR(xspi->ref_clk)) {