spi: fspi: enable fspi on imx8qxp and imx8mm
Subsystems (4)
PATCH 1/5 spi: fspi: enable fspi on imx8qxp and imx8mm
From: Han Xu <[email protected]>
Pull in this patch from NXP's upstream repo to
enable fspi on imx8qxp and imx8mm
drivers/spi/spi-nxp-fspi.c +18 -0
@@ -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);
Signature · 1 line
2.24.0
PATCH 2/5 spi: fspi: dynamically alloc AHB memory
From: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
dynamically allocate AHB memory as needed.
drivers/spi/spi-nxp-fspi.c +34 -6
@@ -307,6 +307,7 @@#define POLL_TOUT 5000#define NXP_FSPI_MAX_CHIPSELECT 4 +#define NXP_FSPI_MIN_IOMAP SZ_4Mstruct 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 ; }
Signature · 1 line
2.24.0
PATCH 3/5 spi: spi-nxp-fspi: Enable the Octal Mode in MCR0
In reply to Adam FordFrom: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
Enable the octal combination mode in MCR0
drivers/spi/spi-nxp-fspi.c +3 -2
@@ -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
Signature · 1 line
2.24.0
PATCH 4/5 dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
In reply to Adam FordAdd support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings document.
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +3 -0
@@ -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:
Signature · 1 line
2.24.0
PATCH 5/5 arm64: dts: enable fspi in imx8mm dts
In reply to Adam FordPull in upstream patch from NXP repo to:
enable fspi in imx8mm DT file
arch/arm64/boot/dts/freescale/imx8mm.dtsi +15 -1
@@ -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";
Signature · 1 line
2.24.0
Mark Brown
maintainerQuoted 7 lines · Adam Ford
From: Han Xu <[email protected]>
Pull in this patch from NXP's upstream repo to
enable fspi on imx8qxp and imx8mmSigned-off-by Adam Ford <[email protected]>Signed-off-by Han Xu <[email protected]>
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.