2024-05-02 11:08:43

by Ji Sheng Teoh

[permalink] [raw]
Subject: [PATCH v2 0/2] Add optional reset control for Cadence SPI

The first patch adds optional reset control to support assertion and
deassertion of reset signal to properly bring the SPI device into an
operating condition.
The second patch documents the optional reset control into dt-bindings.

Changes since v1:
- Dropped resets description and added reset-names property in dt-bindings.
- Specified "spi" as reset control name instead of using NULL in
devm_reset_control_get_optional_exclusive().
- Included reset.h in spi-cadence.c missing in v1.

Ji Sheng Teoh (2):
spi: spi-cadence: Add optional reset control support
dt-bindings: spi: spi-cadence: Add optional reset control

.../devicetree/bindings/spi/spi-cadence.yaml | 7 +++++++
drivers/spi/spi-cadence.c | 13 +++++++++++++
2 files changed, 20 insertions(+)

--
2.43.2



2024-05-02 13:21:55

by Ji Sheng Teoh

[permalink] [raw]
Subject: [PATCH v2 1/2] spi: spi-cadence: Add optional reset control support

Add optional reset control support for spi-cadence to properly bring
the SPI device into an operating condition.

Signed-off-by: Eng Lee Teh <[email protected]>
Signed-off-by: Ley Foon Tan <[email protected]>
Signed-off-by: Ji Sheng Teoh <[email protected]>
---
drivers/spi/spi-cadence.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index e5140532071d..11530a531673 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -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 */
@@ -111,6 +112,7 @@
* @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 = PTR_ERR(xspi->rstc);
+ dev_err(&pdev->dev, "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)) {
--
2.43.2


2024-05-02 14:17:50

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] spi: spi-cadence: Add optional reset control support

On 02/05/2024 12:47, Ji Sheng Teoh wrote:
>
> /* 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 = PTR_ERR(xspi->rstc);
> + dev_err(&pdev->dev, "Cannot get SPI reset.\n");

Please switch to:
ret = dev_err_probe()

Best regards,
Krzysztof


2024-05-03 01:22:41

by Ji Sheng Teoh

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] spi: spi-cadence: Add optional reset control support

> On 02/05/2024 12:47, Ji Sheng Teoh wrote:
> >
> > /* 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 = PTR_ERR(xspi->rstc);
> > + dev_err(&pdev->dev, "Cannot get SPI reset.\n");
>
> Please switch to:
> ret = dev_err_probe()

Ok, will switch to that. Thanks.