@@ -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) {
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(+)