linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm
@ 2020-01-26 14:09 Adam Ford
  2020-01-26 14:09 ` [PATCH 2/5] spi: fspi: dynamically alloc AHB memory Adam Ford
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Adam Ford @ 2020-01-26 14:09 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Rutland, devicetree, Fabio Estevam, Shawn Guo, Sascha Hauer,
	Ashish Kumar, Rob Herring, linux-kernel, Yogesh Gaur, Mark Brown,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Adam Ford,
	linux-arm-kernel

From: Han Xu <han.xu@nxp.com>

Pull in this patch from NXP's upstream repo to
enable fspi on imx8qxp and imx8mm

Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Han Xu <han.xu@nxp.com>

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 8c5084a3a617..00c7899428a1 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -324,6 +324,22 @@ static const struct nxp_fspi_devtype_data lx2160a_data = {
 	.little_endian = true,  /* little-endian    */
 };
 
+static const struct nxp_fspi_devtype_data imx8mm_data = {
+	.rxfifo = SZ_512,       /* (64  * 64 bits)  */
+	.txfifo = SZ_1K,        /* (128 * 64 bits)  */
+	.ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */
+	.quirks = 0,
+	.little_endian = true,  /* little-endian    */
+};
+
+static const struct nxp_fspi_devtype_data imx8qxp_data = {
+	.rxfifo = SZ_512,       /* (64  * 64 bits)  */
+	.txfifo = SZ_1K,        /* (128 * 64 bits)  */
+	.ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */
+	.quirks = 0,
+	.little_endian = true,  /* little-endian    */
+};
+
 struct nxp_fspi {
 	void __iomem *iobase;
 	void __iomem *ahb_addr;
@@ -1076,6 +1092,8 @@ static int nxp_fspi_resume(struct device *dev)
 
 static const struct of_device_id nxp_fspi_dt_ids[] = {
 	{ .compatible = "nxp,lx2160a-fspi", .data = (void *)&lx2160a_data, },
+	{ .compatible = "nxp,imx8mm-fspi", .data = (void *)&imx8mm_data, },
+	{ .compatible = "nxp,imx8qxp-fspi", .data = (void *)&imx8qxp_data, },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, nxp_fspi_dt_ids);
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] spi: fspi: dynamically alloc AHB memory
  2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
@ 2020-01-26 14:09 ` Adam Ford
  2020-01-26 14:09 ` [PATCH 3/5] spi: spi-nxp-fspi: Enable the Octal Mode in MCR0 Adam Ford
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Ford @ 2020-01-26 14:09 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Rutland, devicetree, Fabio Estevam, Shawn Guo, Sascha Hauer,
	Ashish Kumar, Rob Herring, linux-kernel, Yogesh Gaur, Mark Brown,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Adam Ford,
	linux-arm-kernel

From: Han Xu <han.xu@nxp.com>

Apply patch from NXP upstream repo to
dynamically allocate AHB memory as needed.

Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Han Xu <han.xu@nxp.com>

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 00c7899428a1..23abf5ae318e 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -307,6 +307,7 @@
 
 #define POLL_TOUT		5000
 #define NXP_FSPI_MAX_CHIPSELECT		4
+#define NXP_FSPI_MIN_IOMAP	SZ_4M
 
 struct nxp_fspi_devtype_data {
 	unsigned int rxfifo;
@@ -345,6 +346,8 @@ struct nxp_fspi {
 	void __iomem *ahb_addr;
 	u32 memmap_phy;
 	u32 memmap_phy_size;
+	u32 memmap_start;
+	u32 memmap_len;
 	struct clk *clk, *clk_en;
 	struct device *dev;
 	struct completion c;
@@ -657,12 +660,35 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
 	f->selected = spi->chip_select;
 }
 
-static void nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
+static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
 {
+	u32 start = op->addr.val;
 	u32 len = op->data.nbytes;
 
+	/* if necessary, ioremap before AHB read */
+	if ((!f->ahb_addr) || start < f->memmap_start ||
+	     start + len > f->memmap_start + f->memmap_len) {
+		if (f->ahb_addr)
+			iounmap(f->ahb_addr);
+
+		f->memmap_start = start;
+		f->memmap_len = len > NXP_FSPI_MIN_IOMAP ?
+				len : NXP_FSPI_MIN_IOMAP;
+
+		f->ahb_addr = ioremap_wc(f->memmap_phy + f->memmap_start,
+					 f->memmap_len);
+
+		if (!f->ahb_addr) {
+			dev_err(f->dev, "failed to alloc memory\n");
+			return -ENOMEM;
+		}
+	}
+
 	/* Read out the data directly from the AHB buffer. */
-	memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), len);
+	memcpy_fromio(op->data.buf.in,
+		      f->ahb_addr + start - f->memmap_start, len);
+
+	return 0;
 }
 
 static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
@@ -822,7 +848,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	 */
 	if (op->data.nbytes > (f->devtype_data->rxfifo - 4) &&
 	    op->data.dir == SPI_MEM_DATA_IN) {
-		nxp_fspi_read_ahb(f, op);
+		err = nxp_fspi_read_ahb(f, op);
 	} else {
 		if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
 			nxp_fspi_fill_txfifo(f, op);
@@ -992,9 +1018,8 @@ static int nxp_fspi_probe(struct platform_device *pdev)
 
 	/* find the resources - controller memory mapped space */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fspi_mmap");
-	f->ahb_addr = devm_ioremap_resource(dev, res);
-	if (IS_ERR(f->ahb_addr)) {
-		ret = PTR_ERR(f->ahb_addr);
+	if (IS_ERR(res)) {
+		ret = PTR_ERR(res);
 		goto err_put_ctrl;
 	}
 
@@ -1073,6 +1098,9 @@ static int nxp_fspi_remove(struct platform_device *pdev)
 
 	mutex_destroy(&f->lock);
 
+	if (f->ahb_addr)
+		iounmap(f->ahb_addr);
+
 	return 0;
 }
 
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] spi: spi-nxp-fspi: Enable the Octal Mode in MCR0
  2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
  2020-01-26 14:09 ` [PATCH 2/5] spi: fspi: dynamically alloc AHB memory Adam Ford
@ 2020-01-26 14:09 ` Adam Ford
  2020-01-26 14:09 ` [PATCH 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp Adam Ford
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Ford @ 2020-01-26 14:09 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Rutland, devicetree, Fabio Estevam, Shawn Guo, Sascha Hauer,
	Ashish Kumar, Rob Herring, linux-kernel, Yogesh Gaur, Mark Brown,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Adam Ford,
	linux-arm-kernel

From: Han Xu <han.xu@nxp.com>

Apply patch from NXP upstream repo to
Enable the octal combination mode in MCR0

Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Han Xu <han.xu@nxp.com>

diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 23abf5ae318e..019f40e2917c 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -913,8 +913,9 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
 	fspi_writel(f, FSPI_DLLBCR_OVRDEN, base + FSPI_DLLBCR);
 
 	/* enable module */
-	fspi_writel(f, FSPI_MCR0_AHB_TIMEOUT(0xFF) | FSPI_MCR0_IP_TIMEOUT(0xFF),
-		 base + FSPI_MCR0);
+	fspi_writel(f, FSPI_MCR0_AHB_TIMEOUT(0xFF) |
+		    FSPI_MCR0_IP_TIMEOUT(0xFF) | (u32) FSPI_MCR0_OCTCOMB_EN,
+		    base + FSPI_MCR0);
 
 	/*
 	 * Disable same device enable bit and configure all slave devices
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
  2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
  2020-01-26 14:09 ` [PATCH 2/5] spi: fspi: dynamically alloc AHB memory Adam Ford
  2020-01-26 14:09 ` [PATCH 3/5] spi: spi-nxp-fspi: Enable the Octal Mode in MCR0 Adam Ford
@ 2020-01-26 14:09 ` Adam Ford
  2020-01-26 14:09 ` [PATCH 5/5] arm64: dts: enable fspi in imx8mm dts Adam Ford
  2020-01-27 17:47 ` [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Ford @ 2020-01-26 14:09 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Rutland, devicetree, Fabio Estevam, Shawn Guo, Sascha Hauer,
	Ashish Kumar, Rob Herring, linux-kernel, Yogesh Gaur, Mark Brown,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Adam Ford,
	linux-arm-kernel

Add support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings
document.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt b/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
index 2cd67eb727d4..7ac60d9fe357 100644
--- a/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
+++ b/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
@@ -2,6 +2,9 @@
 
 Required properties:
   - compatible : Should be "nxp,lx2160a-fspi"
+			    "nxp,imx8qxp-fspi"
+			    "nxp,imx8mm-fspi"
+
   - reg :        First contains the register location and length,
                  Second contains the memory mapping address and length
   - reg-names :  Should contain the resource reg names:
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] arm64: dts: enable fspi in imx8mm dts
  2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
                   ` (2 preceding siblings ...)
  2020-01-26 14:09 ` [PATCH 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp Adam Ford
@ 2020-01-26 14:09 ` Adam Ford
  2020-01-27 17:47 ` [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Ford @ 2020-01-26 14:09 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Rutland, devicetree, Fabio Estevam, Shawn Guo, Sascha Hauer,
	Ashish Kumar, Rob Herring, linux-kernel, Yogesh Gaur, Mark Brown,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Adam Ford,
	linux-arm-kernel

Pull in upstream patch from NXP repo to:
enable fspi in imx8mm DT file

Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Han Xu <han.xu@nxp.com>

diff --git a/arch/arm64/boot/dts/freescale/imx8mm.dtsi b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
index 1e5e11592f7b..679769fe6cab 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
@@ -558,7 +558,21 @@ aips3: bus@30800000 {
 			compatible = "simple-bus";
 			#address-cells = <1>;
 			#size-cells = <1>;
-			ranges = <0x30800000 0x30800000 0x400000>;
+			ranges = <0x30800000 0x30800000 0x400000>,
+				 <0x8000000 0x8000000 0x10000000>;
+
+			flexspi: spi@30bb0000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "nxp,imx8mm-fspi";
+				reg = <0x30bb0000 0x10000>, <0x8000000 0x10000000>;
+				reg-names = "fspi_base", "fspi_mmap";
+				interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_QSPI_ROOT>,
+					 <&clk IMX8MM_CLK_QSPI_ROOT>;
+				clock-names = "fspi", "fspi_en";
+				status = "disabled";
+			};
 
 			ecspi1: spi@30820000 {
 				compatible = "fsl,imx8mm-ecspi", "fsl,imx51-ecspi";
-- 
2.24.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm
  2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
                   ` (3 preceding siblings ...)
  2020-01-26 14:09 ` [PATCH 5/5] arm64: dts: enable fspi in imx8mm dts Adam Ford
@ 2020-01-27 17:47 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2020-01-27 17:47 UTC (permalink / raw)
  To: Adam Ford
  Cc: Mark Rutland, devicetree, Fabio Estevam, Sascha Hauer,
	Ashish Kumar, linux-spi, Yogesh Gaur, Rob Herring,
	NXP Linux Team, Pengutronix Kernel Team, han.xu, Shawn Guo,
	linux-kernel, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 424 bytes --]

On Sun, Jan 26, 2020 at 08:09:08AM -0600, Adam Ford wrote:
> From: Han Xu <han.xu@nxp.com>
> 
> Pull in this patch from NXP's upstream repo to
> enable fspi on imx8qxp and imx8mm
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> Signed-off-by: Han Xu <han.xu@nxp.com>

If you're sending a patch from someone else your signoff is supposed to
go after theirs to show the chain of people who forwarded the patch.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-27 17:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 14:09 [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Adam Ford
2020-01-26 14:09 ` [PATCH 2/5] spi: fspi: dynamically alloc AHB memory Adam Ford
2020-01-26 14:09 ` [PATCH 3/5] spi: spi-nxp-fspi: Enable the Octal Mode in MCR0 Adam Ford
2020-01-26 14:09 ` [PATCH 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp Adam Ford
2020-01-26 14:09 ` [PATCH 5/5] arm64: dts: enable fspi in imx8mm dts Adam Ford
2020-01-27 17:47 ` [PATCH 1/5] spi: fspi: enable fspi on imx8qxp and imx8mm Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).