mtd: fsl-quadspi: Update slave device hwcap based on mode provided in dtsi file
Subsystems (4)
v3 cover mtd: fsl-quadspi: Update slave device hwcap based on mode provided in dtsi file
This patch-set added support to update hwcap of slave device connected to FSL QUADSPI controller by reading values from the device tree files.
Mode information is available via "spi-tx-bus-width" and "spi-rx-bus-width" nodes of device tree for the connected slave device.
Update read and write hwcap capability for slave device by reading "spi-rx-bus-width" and "spi-tx-bus-width" respectively.
Added usage example for spi-rx/tx-bus-width properties in spi-bus.txt
Depends on
https://patchwork.ozlabs.org/project/linux-mtd/list/?series=26084
Yogesh Gaur (2):
mtd: fsl-quadspi: Update slave device hwcap based on mode provided in
dtsi file
dt-bindings: spi: updated usage example for spi-rx/tx-bus-width
properties
Changes for v3:
- Incorporated changes as per Cyrille's review comments. Changes for v2:
- Drop patch 'dt-bindings: fsl-quadspi: spi-rx/tx-bus-width usage example'
- Added usage example for spi-rx/tx-bus-width properties in spi-bus.txt
Documentation/devicetree/bindings/spi/spi-bus.txt | 2 + drivers/mtd/spi-nor/fsl-quadspi.c | 72 +++++++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/2 mtd: fsl-quadspi: Update slave device hwcap based on mode provided in dtsi file
FSL QuadSPI controller supports Single, dual, quad modes of operation. Mode information is available via "spi-tx-bus-width" and "spi-rx-bus-width" nodes of device tree for the connected slave device.
Update read and write hwcap capability for slave device by reading "spi-rx-bus-width" and "spi-tx-bus-width" respectively. Assign hwcaps mask to minimal caps for the slave node i.e.
SNOR_HWCAPS_READ | SNOR_HWCAPS_READ_FAST | SNOR_HWCAPS_PP
If value not provided in device tree file, then fallback to default hwcaps for QSPI controller i.e. SNOR_HWCAPS_READ_1_1_4 and SNOR_HWCAPS_PP
---
Changes for v3:
- Incorporated changes as per Cyrille's review comments. Changes for v2:
- None.
drivers/mtd/spi-nor/fsl-quadspi.c | 72 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-)
drivers/mtd/spi-nor/fsl-quadspi.c +67 -5
@@ -29,6 +29,7 @@#include <linux/mutex.h> #include <linux/pm_qos.h> #include <linux/sizes.h> +#include <linux/spi/spi.h> /* Controller needs driver to swap endian */ #define QUADSPI_QUIRK_SWAP_ENDIAN (1 << 0)
@@ -994,17 +995,14 @@ static void fsl_qspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)static int fsl_qspi_probe (struct platform_device *pdev) { -const struct spi_nor_hwcaps hwcaps = { - .mask =SNOR_HWCAPS_READ_1_1_4 | -SNOR_HWCAPS_PP , - }; +struct spi_nor_hwcaps hwcaps;struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;struct fsl_qspi *q;struct resource *res;struct spi_nor *nor;struct mtd_info *mtd; -int ret, i =0 ; +int ret, i =0 , value, mode; q =devm_kzalloc (dev,sizeof (*q),GFP_KERNEL );if (!q)
@@ -1077,6 +1075,13 @@ static int fsl_qspi_probe(struct platform_device *pdev)/* iterate the subnodes. */ for_each_available_child_of_node (dev->of_node, np) { +/* Reset hwcaps mask to minimal caps for the slave node. */ + hwcaps.mask =SNOR_HWCAPS_READ | +SNOR_HWCAPS_READ_FAST | +SNOR_HWCAPS_PP ; + value =0 ; + mode =0 ; +/* skip the holes */ if (!q->has_second_chip) i *=2 ;
@@ -1106,6 +1111,63 @@ static int fsl_qspi_probe(struct platform_device *pdev)/* set the chip address for READID */ fsl_qspi_set_base_addr (q, nor); +/* +* If spi-rx-bus-width and spi-tx-bus-width not defined assign +* default hardware capabilities for READ as +* SNOR_HWCAPS_READ_1_1_4. +*/ +if (!of_property_read_u32 (np,"spi-rx-bus-width" , &value)) { +switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_RX_DUAL ; +break ; +case 4 : + mode |=SPI_RX_QUAD ; +break ; +default : +dev_err (dev, +"spi-rx-bus-width %d not supported\n" , + value); +break ; + } + }else { + hwcaps.mask |=SNOR_HWCAPS_READ_1_1_4 ; + } + +if (!of_property_read_u32 (np,"spi-tx-bus-width" , &value)) { +switch (value) { +case 1 : +break ; +case 2 : + mode |=SPI_TX_DUAL ; +break ; +case 4 : + mode |=SPI_TX_QUAD ; +break ; +default : +dev_err (dev, +"spi-tx-bus-width %d not supported\n" , + value); +break ; + } + } + +if (mode &SPI_RX_QUAD ) { + hwcaps.mask |=SNOR_HWCAPS_READ_1_1_4 ; + +if (mode &SPI_TX_QUAD ) + hwcaps.mask |= (SNOR_HWCAPS_READ_1_4_4 | +SNOR_HWCAPS_PP_1_1_4 | +SNOR_HWCAPS_PP_1_4_4 ); + }else if (mode &SPI_RX_DUAL ) { + hwcaps.mask |=SNOR_HWCAPS_READ_1_1_2 ; + +if (mode &SPI_TX_DUAL ) + hwcaps.mask |=SNOR_HWCAPS_READ_1_2_2 ; + } + ret =spi_nor_scan (nor,NULL , &hwcaps);if (ret) goto mutex_failed;
Signature · 1 line
1.9.1
PATCH v3 2/2 dt-bindings: spi: updated usage example for spi-rx/tx-bus-width properties
In reply to Yogesh GaurUpdated usage example by adding properties spi-rx-bus-width and spi-tx-bus-width for slave node binding.
---
Changes for v3:
- None
Changes for v2:
- None
Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/spi/spi-bus.txt +2 -0
@@ -101,6 +101,8 @@ SPI example for an MPC5200 SPI bus: compatible = "micrel,ks8995m"; spi-max-frequency = <1000000>; reg = <0>; + spi-rx-bus-width = 4; + spi-tx-bus-width = 4; }; codec at 1 {
Signature · 1 line
1.9.1
Rob Herring
maintainerPATCH v3 2/2 dt-bindings: spi: updated usage example for spi-rx/tx-bus-width properties
Quoted 4 lines · Yogesh Gaur
Updated usage example by adding properties spi-rx-bus-width and spi-tx-bus-width for slave node binding.
Signed-off-by Yogesh Gaur <[email protected]>
Quoted 8 lines
---
Changes for v3:
- None
Changes for v2:
- NoneDocumentation/devicetree/bindings/spi/spi-bus.txt | 2 ++ 1 file changed, 2 insertions(+)
Please add acked/reviewed bys when posting new versions.
Rob
PATCH v3 2/2 dt-bindings: spi: updated usage example for spi-rx/tx-bus-width properties
In reply to Yogesh GaurHi Yogesh,
Looks like you forgot to Cc Mark and the linux-spi ML.
Regards,
Boris
Quoted 26 lines · On Tue, 13 Feb 2018 12:21:15 +0530 Yogesh Gaur <[email protected]>…
Updated usage example by adding properties spi-rx-bus-width and spi-tx-bus-width for slave node binding.
Signed-off-by Yogesh Gaur <[email protected]>---
Changes for v3:
- None
Changes for v2:
- NoneDocumentation/devicetree/bindings/spi/spi-bus.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/spi/spi-bus.txt +2
-0@@ -101,6 +101,8 @@ SPI example for an MPC5200 SPI bus: compatible = "micrel,ks8995m"; spi-max-frequency = <1000000>; reg = <0>; + spi-rx-bus-width = 4; + spi-tx-bus-width = 4; }; codec at 1 {
Signature · 3 lines
Boris Brezillon, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com