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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux