mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-27 17:18:59 +00:00
cddd459140
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release which was tagged LSDK-20.04-V5.4. https://source.codeaurora.org/external/qoriq/qoriq-components/linux/ For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in LSDK, port the dts patches from 4.14. The patches are sorted into the following categories: 301-arch-xxxx 302-dts-xxxx 303-core-xxxx 701-net-xxxx 801-audio-xxxx 802-can-xxxx 803-clock-xxxx 804-crypto-xxxx 805-display-xxxx 806-dma-xxxx 807-gpio-xxxx 808-i2c-xxxx 809-jailhouse-xxxx 810-keys-xxxx 811-kvm-xxxx 812-pcie-xxxx 813-pm-xxxx 814-qe-xxxx 815-sata-xxxx 816-sdhc-xxxx 817-spi-xxxx 818-thermal-xxxx 819-uart-xxxx 820-usb-xxxx 821-vfio-xxxx Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
101 lines
2.8 KiB
Diff
101 lines
2.8 KiB
Diff
From 6e46fe6d9428a41543bd19644de3c9f2611b73bf Mon Sep 17 00:00:00 2001
|
|
From: Han Xu <han.xu@nxp.com>
|
|
Date: Wed, 5 Jun 2019 16:43:30 -0500
|
|
Subject: [PATCH] MLK-21960-2: spi: fspi: dynamically alloc AHB memory
|
|
|
|
dynamically allocate AHB memory as needed.
|
|
|
|
Signed-off-by: Han Xu <han.xu@nxp.com>
|
|
---
|
|
drivers/spi/spi-nxp-fspi.c | 40 ++++++++++++++++++++++++++++++++++------
|
|
1 file changed, 34 insertions(+), 6 deletions(-)
|
|
|
|
--- 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 n
|
|
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_m
|
|
*/
|
|
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 platfor
|
|
|
|
/* 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 platfo
|
|
|
|
mutex_destroy(&f->lock);
|
|
|
|
+ if (f->ahb_addr)
|
|
+ iounmap(f->ahb_addr);
|
|
+
|
|
return 0;
|
|
}
|
|
|