diff mbox series

[2/7] spi: realtek-rtl: set device capability flags

Message ID 4d10e375-7342-6c1b-9886-e49974b1620b@birger-koblitz.de
State New
Headers show
Series [1/7] spi: realteak-rtl: Add support for RTL93xx SoCs | expand

Commit Message

Birger Koblitz Aug. 1, 2022, 6:18 a.m. UTC
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 mbox series

Patch

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) {