Add optional reset control for Cadence SPI

Merge series from Ji Sheng Teoh <jisheng.teoh@starfivetech.com>:

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.
This commit is contained in:
Mark Brown 2024-05-29 11:07:55 +01:00
commit ab0b5a99d3
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 20 additions and 0 deletions

View File

@ -55,6 +55,13 @@ properties:
label:
description: Descriptive name of the SPI controller.
resets:
maxItems: 1
reset-names:
items:
- const: spi
required:
- compatible
- reg

View 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 */
@ -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 = 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)) {