lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/7] spi: realtek-rtl: set device capability flags
Read out the number of chip selects supported by the SoC and
whether the device supports Quad-IO and set the spi_controller
flags accordingly.

Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
drivers/spi/spi-realtek-rtl.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/spi/spi-realtek-rtl.c b/drivers/spi/spi-realtek-rtl.c
index 927bd44744a8..287ecc34e1cc 100644
--- a/drivers/spi/spi-realtek-rtl.c
+++ b/drivers/spi/spi-realtek-rtl.c
@@ -4,9 +4,11 @@
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>
+#include <linux/property.h>

struct rtspi {
void __iomem *base;
+ u32 dev_flags;
};

/* SPI Flash Configuration Register */
@@ -163,6 +165,7 @@ static int realtek_rtl_spi_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, ctrl);
rtspi = spi_controller_get_devdata(ctrl);
+ rtspi->dev_flags = (u32) device_get_match_data(&pdev->dev);

rtspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(rtspi->base)) {
@@ -174,8 +177,12 @@ static int realtek_rtl_spi_probe(struct platform_device *pdev)

ctrl->dev.of_node = pdev->dev.of_node;
ctrl->flags = SPI_CONTROLLER_HALF_DUPLEX;
+ ctrl->flags |= SPI_TX_DUAL | SPI_RX_DUAL;
+ if (rtspi->dev_flags & SPI_QUAD_SUPPORTED)
+ ctrl->flags |= SPI_TX_QUAD | SPI_RX_QUAD;
ctrl->set_cs = rt_set_cs;
ctrl->transfer_one = transfer_one;
+ ctrl->num_chipselect = rtspi->dev_flags & SPI_CSMAX_3?4:2;

err = devm_spi_register_controller(&pdev->dev, ctrl);
if (err) {
--
2.25.1
\
 
 \ /
  Last update: 2022-08-01 08:19    [W:1.973 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site