From: Greg Kroah-Hartman Date: Wed, 17 May 2023 08:28:42 +0000 (+0200) Subject: drop spi imx patches from 5.4 X-Git-Tag: v4.14.315~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cc7d45f08dd7143fca41739d6c4cad32d6b50429;p=thirdparty%2Fkernel%2Fstable-queue.git drop spi imx patches from 5.4 --- diff --git a/queue-5.4/series b/queue-5.4/series index 5facb6678f9..3be6c1506a9 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -117,10 +117,6 @@ pstore-revert-pmsg_lock-back-to-a-normal-mutex.patch usb-host-xhci-rcar-remove-leftover-quirk-handling.patch fpga-bridge-fix-kernel-doc-parameter-description.patch iio-light-max44009-add-missing-of-device-matching.patch -spi-imx-fsl-lpspi-convert-to-gpio-descriptors.patch -spi-imx-enable-runtime-pm-support.patch -spi-spi-imx-using-pm_runtime_resume_and_get-instead-.patch -spi-imx-don-t-skip-cleanup-in-remove-s-error-path.patch usb-gadget-udc-renesas_usb3-fix-use-after-free-bug-i.patch pci-imx6-install-the-fault-handler-only-on-compatibl.patch genirq-add-irqf_no_autoen-for-request_irq-nmi.patch @@ -270,8 +266,6 @@ pci-pciehp-use-down_read-write_nested-reset_lock-to-fix-lockdep-errors.patch pci-pciehp-fix-ab-ba-deadlock-between-reset_lock-and-device_lock.patch printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch pm-domains-restore-comment-indentation-for-generic_pm_domain.child_links.patch -spi-imx-fix-runtime-pm-support-for-config_pm.patch -spi-imx-fix-reference-leak-in-two-imx-operations.patch drm-msm-fix-double-pm_runtime_disable-call.patch firmware-raspberrypi-fix-possible-memory-leak-in-rpi_firmware_probe.patch drm-msm-adreno-fix-null-ptr-access-in-adreno_gpu_cleanup.patch diff --git a/queue-5.4/spi-imx-don-t-skip-cleanup-in-remove-s-error-path.patch b/queue-5.4/spi-imx-don-t-skip-cleanup-in-remove-s-error-path.patch deleted file mode 100644 index fe4436ffde8..00000000000 --- a/queue-5.4/spi-imx-don-t-skip-cleanup-in-remove-s-error-path.patch +++ /dev/null @@ -1,52 +0,0 @@ -From ca27eb15976c4e9cc19355dcc1b41b4f39d4479e Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 6 Mar 2023 07:57:32 +0100 -Subject: spi: imx: Don't skip cleanup in remove's error path -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -From: Uwe Kleine-König - -[ Upstream commit 11951c9e3f364d7ae3b568a0e52c8335d43066b5 ] - -Returning early in a platform driver's remove callback is wrong. In this -case the dma resources are not released in the error path. this is never -retried later and so this is a permanent leak. To fix this, only skip -hardware disabling if waking the device fails. - -Fixes: d593574aff0a ("spi: imx: do not access registers while clocks disabled") -Signed-off-by: Uwe Kleine-König -Link: https://lore.kernel.org/r/20230306065733.2170662-2-u.kleine-koenig@pengutronix.de -Signed-off-by: Mark Brown -Signed-off-by: Sasha Levin ---- - drivers/spi/spi-imx.c | 12 +++++------- - 1 file changed, 5 insertions(+), 7 deletions(-) - -diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c -index 780c234257ca8..ffd370abdab35 100644 ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -1737,13 +1737,11 @@ static int spi_imx_remove(struct platform_device *pdev) - - spi_bitbang_stop(&spi_imx->bitbang); - -- ret = pm_runtime_resume_and_get(spi_imx->dev); -- if (ret < 0) { -- dev_err(spi_imx->dev, "failed to enable clock\n"); -- return ret; -- } -- -- writel(0, spi_imx->base + MXC_CSPICTRL); -+ ret = pm_runtime_get_sync(spi_imx->dev); -+ if (ret >= 0) -+ writel(0, spi_imx->base + MXC_CSPICTRL); -+ else -+ dev_warn(spi_imx->dev, "failed to enable clock, skip hw disable\n"); - - pm_runtime_dont_use_autosuspend(spi_imx->dev); - pm_runtime_put_sync(spi_imx->dev); --- -2.39.2 - diff --git a/queue-5.4/spi-imx-enable-runtime-pm-support.patch b/queue-5.4/spi-imx-enable-runtime-pm-support.patch deleted file mode 100644 index c8e3d4fb193..00000000000 --- a/queue-5.4/spi-imx-enable-runtime-pm-support.patch +++ /dev/null @@ -1,233 +0,0 @@ -From 7516b7ec64e1fc1ae822d99e2b36c9ca74bc2dda Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Mon, 27 Jul 2020 14:33:54 +0800 -Subject: spi: imx: enable runtime pm support - -From: Clark Wang - -[ Upstream commit 525c9e5a32bd7951eae3f06d9d077fea51718a6c ] - -Enable runtime pm support for spi-imx driver. - -Signed-off-by: Clark Wang -Link: https://lore.kernel.org/r/20200727063354.17031-1-xiaoning.wang@nxp.com -Signed-off-by: Mark Brown -Stable-dep-of: 11951c9e3f36 ("spi: imx: Don't skip cleanup in remove's error path") -Signed-off-by: Sasha Levin ---- - drivers/spi/spi-imx.c | 121 ++++++++++++++++++++++++++++++------------ - 1 file changed, 88 insertions(+), 33 deletions(-) - -diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c -index 90793fc321358..95f1746a85d9d 100644 ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -13,7 +13,9 @@ - #include - #include - #include -+#include - #include -+#include - #include - #include - #include -@@ -30,6 +32,8 @@ static bool use_dma = true; - module_param(use_dma, bool, 0644); - MODULE_PARM_DESC(use_dma, "Enable usage of DMA when available (default)"); - -+#define MXC_RPM_TIMEOUT 2000 /* 2000ms */ -+ - #define MXC_CSPIRXDATA 0x00 - #define MXC_CSPITXDATA 0x04 - #define MXC_CSPICTRL 0x08 -@@ -1532,20 +1536,16 @@ spi_imx_prepare_message(struct spi_master *master, struct spi_message *msg) - struct spi_imx_data *spi_imx = spi_master_get_devdata(master); - int ret; - -- ret = clk_enable(spi_imx->clk_per); -- if (ret) -- return ret; -- -- ret = clk_enable(spi_imx->clk_ipg); -- if (ret) { -- clk_disable(spi_imx->clk_per); -+ ret = pm_runtime_get_sync(spi_imx->dev); -+ if (ret < 0) { -+ dev_err(spi_imx->dev, "failed to enable clock\n"); - return ret; - } - - ret = spi_imx->devtype_data->prepare_message(spi_imx, msg); - if (ret) { -- clk_disable(spi_imx->clk_ipg); -- clk_disable(spi_imx->clk_per); -+ pm_runtime_mark_last_busy(spi_imx->dev); -+ pm_runtime_put_autosuspend(spi_imx->dev); - } - - return ret; -@@ -1556,8 +1556,8 @@ spi_imx_unprepare_message(struct spi_master *master, struct spi_message *msg) - { - struct spi_imx_data *spi_imx = spi_master_get_devdata(master); - -- clk_disable(spi_imx->clk_ipg); -- clk_disable(spi_imx->clk_per); -+ pm_runtime_mark_last_busy(spi_imx->dev); -+ pm_runtime_put_autosuspend(spi_imx->dev); - return 0; - } - -@@ -1676,13 +1676,15 @@ static int spi_imx_probe(struct platform_device *pdev) - goto out_master_put; - } - -- ret = clk_prepare_enable(spi_imx->clk_per); -- if (ret) -- goto out_master_put; -+ pm_runtime_enable(spi_imx->dev); -+ pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT); -+ pm_runtime_use_autosuspend(spi_imx->dev); - -- ret = clk_prepare_enable(spi_imx->clk_ipg); -- if (ret) -- goto out_put_per; -+ ret = pm_runtime_get_sync(spi_imx->dev); -+ if (ret < 0) { -+ dev_err(spi_imx->dev, "failed to enable clock\n"); -+ goto out_runtime_pm_put; -+ } - - spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per); - /* -@@ -1692,7 +1694,7 @@ static int spi_imx_probe(struct platform_device *pdev) - if (spi_imx->devtype_data->has_dmamode) { - ret = spi_imx_sdma_init(&pdev->dev, spi_imx, master); - if (ret == -EPROBE_DEFER) -- goto out_clk_put; -+ goto out_runtime_pm_put; - - if (ret < 0) - dev_err(&pdev->dev, "dma setup error %d, use pio\n", -@@ -1707,19 +1709,20 @@ static int spi_imx_probe(struct platform_device *pdev) - ret = spi_bitbang_start(&spi_imx->bitbang); - if (ret) { - dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); -- goto out_clk_put; -+ goto out_runtime_pm_put; - } - - dev_info(&pdev->dev, "probed\n"); - -- clk_disable(spi_imx->clk_ipg); -- clk_disable(spi_imx->clk_per); -+ pm_runtime_mark_last_busy(spi_imx->dev); -+ pm_runtime_put_autosuspend(spi_imx->dev); -+ - return ret; - --out_clk_put: -- clk_disable_unprepare(spi_imx->clk_ipg); --out_put_per: -- clk_disable_unprepare(spi_imx->clk_per); -+out_runtime_pm_put: -+ pm_runtime_dont_use_autosuspend(spi_imx->dev); -+ pm_runtime_put_sync(spi_imx->dev); -+ pm_runtime_disable(spi_imx->dev); - out_master_put: - spi_master_put(master); - -@@ -1734,30 +1737,82 @@ static int spi_imx_remove(struct platform_device *pdev) - - spi_bitbang_stop(&spi_imx->bitbang); - -- ret = clk_enable(spi_imx->clk_per); -+ ret = pm_runtime_get_sync(spi_imx->dev); -+ if (ret < 0) { -+ dev_err(spi_imx->dev, "failed to enable clock\n"); -+ return ret; -+ } -+ -+ writel(0, spi_imx->base + MXC_CSPICTRL); -+ -+ pm_runtime_dont_use_autosuspend(spi_imx->dev); -+ pm_runtime_put_sync(spi_imx->dev); -+ pm_runtime_disable(spi_imx->dev); -+ -+ spi_imx_sdma_exit(spi_imx); -+ spi_master_put(master); -+ -+ return 0; -+} -+ -+static int __maybe_unused spi_imx_runtime_resume(struct device *dev) -+{ -+ struct spi_master *master = dev_get_drvdata(dev); -+ struct spi_imx_data *spi_imx; -+ int ret; -+ -+ spi_imx = spi_master_get_devdata(master); -+ -+ ret = clk_prepare_enable(spi_imx->clk_per); - if (ret) - return ret; - -- ret = clk_enable(spi_imx->clk_ipg); -+ ret = clk_prepare_enable(spi_imx->clk_ipg); - if (ret) { -- clk_disable(spi_imx->clk_per); -+ clk_disable_unprepare(spi_imx->clk_per); - return ret; - } - -- writel(0, spi_imx->base + MXC_CSPICTRL); -- clk_disable_unprepare(spi_imx->clk_ipg); -+ return 0; -+} -+ -+static int __maybe_unused spi_imx_runtime_suspend(struct device *dev) -+{ -+ struct spi_master *master = dev_get_drvdata(dev); -+ struct spi_imx_data *spi_imx; -+ -+ spi_imx = spi_master_get_devdata(master); -+ - clk_disable_unprepare(spi_imx->clk_per); -- spi_imx_sdma_exit(spi_imx); -- spi_master_put(master); -+ clk_disable_unprepare(spi_imx->clk_ipg); -+ -+ return 0; -+} - -+static int __maybe_unused spi_imx_suspend(struct device *dev) -+{ -+ pinctrl_pm_select_sleep_state(dev); - return 0; - } - -+static int __maybe_unused spi_imx_resume(struct device *dev) -+{ -+ pinctrl_pm_select_default_state(dev); -+ return 0; -+} -+ -+static const struct dev_pm_ops imx_spi_pm = { -+ SET_RUNTIME_PM_OPS(spi_imx_runtime_suspend, -+ spi_imx_runtime_resume, NULL) -+ SET_SYSTEM_SLEEP_PM_OPS(spi_imx_suspend, spi_imx_resume) -+}; -+ - static struct platform_driver spi_imx_driver = { - .driver = { - .name = DRIVER_NAME, - .of_match_table = spi_imx_dt_ids, -- }, -+ .pm = &imx_spi_pm, -+ }, - .id_table = spi_imx_devtype, - .probe = spi_imx_probe, - .remove = spi_imx_remove, --- -2.39.2 - diff --git a/queue-5.4/spi-imx-fix-reference-leak-in-two-imx-operations.patch b/queue-5.4/spi-imx-fix-reference-leak-in-two-imx-operations.patch deleted file mode 100644 index 6820ae9d7f0..00000000000 --- a/queue-5.4/spi-imx-fix-reference-leak-in-two-imx-operations.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 1dcbdd944824369d4569959f8130336fe6fe5f39 Mon Sep 17 00:00:00 2001 -From: Zhang Qilong -Date: Mon, 2 Nov 2020 22:58:35 +0800 -Subject: spi: imx: fix reference leak in two imx operations - -From: Zhang Qilong - -commit 1dcbdd944824369d4569959f8130336fe6fe5f39 upstream. - -pm_runtime_get_sync will increment pm usage counter even it -failed. Forgetting to pm_runtime_put_noidle will result in -reference leak in callers(spi_imx_prepare_message and -spi_imx_remove), so we should fix it. - -Fixes: 525c9e5a32bd7 ("spi: imx: enable runtime pm support") -Signed-off-by: Zhang Qilong -Link: https://lore.kernel.org/r/20201102145835.4765-1-zhangqilong3@huawei.com -Signed-off-by: Mark Brown -Signed-off-by: Greg Kroah-Hartman ---- - drivers/spi/spi-imx.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -1538,6 +1538,7 @@ spi_imx_prepare_message(struct spi_maste - - ret = pm_runtime_resume_and_get(spi_imx->dev); - if (ret < 0) { -+ pm_runtime_put_noidle(spi_imx->dev); - dev_err(spi_imx->dev, "failed to enable clock\n"); - return ret; - } diff --git a/queue-5.4/spi-imx-fix-runtime-pm-support-for-config_pm.patch b/queue-5.4/spi-imx-fix-runtime-pm-support-for-config_pm.patch deleted file mode 100644 index 1155fc6d82f..00000000000 --- a/queue-5.4/spi-imx-fix-runtime-pm-support-for-config_pm.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 43b6bf406cd0319e522638f97c9086b7beebaeaa Mon Sep 17 00:00:00 2001 -From: Sascha Hauer -Date: Wed, 21 Oct 2020 12:45:13 +0200 -Subject: spi: imx: fix runtime pm support for !CONFIG_PM - -From: Sascha Hauer - -commit 43b6bf406cd0319e522638f97c9086b7beebaeaa upstream. - -525c9e5a32bd introduced pm_runtime support for the i.MX SPI driver. With -this pm_runtime is used to bring up the clocks initially. When CONFIG_PM -is disabled the clocks are no longer enabled and the driver doesn't work -anymore. Fix this by enabling the clocks in the probe function and -telling pm_runtime that the device is active using -pm_runtime_set_active(). - -Fixes: 525c9e5a32bd spi: imx: enable runtime pm support -Tested-by: Christian Eggers [tested for !CONFIG_PM only] -Signed-off-by: Sascha Hauer -Link: https://lore.kernel.org/r/20201021104513.21560-1-s.hauer@pengutronix.de -Signed-off-by: Mark Brown -Signed-off-by: Greg Kroah-Hartman ---- - drivers/spi/spi-imx.c | 23 +++++++++++++++-------- - 1 file changed, 15 insertions(+), 8 deletions(-) - ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -1676,15 +1676,18 @@ static int spi_imx_probe(struct platform - goto out_master_put; - } - -- pm_runtime_enable(spi_imx->dev); -+ ret = clk_prepare_enable(spi_imx->clk_per); -+ if (ret) -+ goto out_master_put; -+ -+ ret = clk_prepare_enable(spi_imx->clk_ipg); -+ if (ret) -+ goto out_put_per; -+ - pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT); - pm_runtime_use_autosuspend(spi_imx->dev); -- -- ret = pm_runtime_get_sync(spi_imx->dev); -- if (ret < 0) { -- dev_err(spi_imx->dev, "failed to enable clock\n"); -- goto out_runtime_pm_put; -- } -+ pm_runtime_set_active(spi_imx->dev); -+ pm_runtime_enable(spi_imx->dev); - - spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per); - /* -@@ -1721,8 +1724,12 @@ static int spi_imx_probe(struct platform - - out_runtime_pm_put: - pm_runtime_dont_use_autosuspend(spi_imx->dev); -- pm_runtime_put_sync(spi_imx->dev); -+ pm_runtime_set_suspended(&pdev->dev); - pm_runtime_disable(spi_imx->dev); -+ -+ clk_disable_unprepare(spi_imx->clk_ipg); -+out_put_per: -+ clk_disable_unprepare(spi_imx->clk_per); - out_master_put: - spi_master_put(master); - diff --git a/queue-5.4/spi-imx-fsl-lpspi-convert-to-gpio-descriptors.patch b/queue-5.4/spi-imx-fsl-lpspi-convert-to-gpio-descriptors.patch deleted file mode 100644 index 11ef9d5a1a1..00000000000 --- a/queue-5.4/spi-imx-fsl-lpspi-convert-to-gpio-descriptors.patch +++ /dev/null @@ -1,811 +0,0 @@ -From 7704957f62ff7625f79205362f543662d486f93e Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 25 Jun 2020 22:02:52 +0200 -Subject: spi: imx/fsl-lpspi: Convert to GPIO descriptors -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -From: Linus Walleij - -[ Upstream commit 8cdcd8aeee2819199ec7f68114b77b04c10611d3 ] - -This converts the two Freescale i.MX SPI drivers -Freescale i.MX (CONFIG_SPI_IMX) and Freescale i.MX LPSPI -(CONFIG_SPI_FSL_LPSPI) to use GPIO descriptors handled in -the SPI core for GPIO chip selects whether defined in -the device tree or a board file. - -The reason why both are converted at the same time is -that they were both using the same platform data and -platform device population helpers when using -board files intertwining the code so this gives a cleaner -cut. - -The platform device creation was passing a platform data -container from each boardfile down to the driver using -struct spi_imx_master from , -but this was only conveying the number of chipselects and -an int * array of the chipselect GPIO numbers. - -The imx27 and imx31 platforms had code passing the -now-unused platform data when creating the platform devices, -this has been repurposed to pass around GPIO descriptor -tables. The platform data struct that was just passing an -array of integers and number of chip selects for the GPIO -lines has been removed. - -The number of chipselects used to be passed from the board -file, because this number also limits the number of native -chipselects that the platform can use. To deal with this we -just augment the i.MX (CONFIG_SPI_IMX) driver to support 3 -chipselects if the platform does not define "num-cs" as a -device property (such as from the device tree). This covers -all the legacy boards as these use <= 3 native chip selects -(or GPIO lines, and in that case the number of chip selects -is determined by the core from the number of available -GPIO lines). Any new boards should use device tree, so -this is a reasonable simplification to cover all old -boards. - -The LPSPI driver never assigned the number of chipselects -and thus always fall back to the core default of 1 chip -select if no GPIOs are defined in the device tree. - -The Freescale i.MX driver was already partly utilizing -the SPI core to obtain the GPIO numbers from the device tree, -so this completes the transtion to let the core handle all -of it. - -All board files and the core i.MX boardfile registration -code is augmented to account for these changes. - -This has been compile-tested with the imx_v4_v5_defconfig -and the imx_v6_v7_defconfig. - -Signed-off-by: Linus Walleij -Acked-by: Shawn Guo -Cc: Uwe Kleine-König -Cc: Robin Gong -Cc: Trent Piepho -Cc: Clark Wang -Cc: Shawn Guo -Cc: Sascha Hauer -Cc: Pengutronix Kernel Team -Cc: Fabio Estevam -Cc: NXP Linux Team -Link: https://lore.kernel.org/r/20200625200252.207614-1-linus.walleij@linaro.org -Signed-off-by: Mark Brown -Stable-dep-of: 11951c9e3f36 ("spi: imx: Don't skip cleanup in remove's error path") -Signed-off-by: Sasha Levin ---- - arch/arm/mach-imx/devices-imx27.h | 10 +-- - arch/arm/mach-imx/devices-imx31.h | 10 +-- - arch/arm/mach-imx/devices/devices-common.h | 5 +- - arch/arm/mach-imx/devices/platform-spi_imx.c | 9 +- - arch/arm/mach-imx/mach-mx27_3ds.c | 40 ++++++--- - arch/arm/mach-imx/mach-mx31_3ds.c | 13 +-- - arch/arm/mach-imx/mach-mx31lilly.c | 14 +-- - arch/arm/mach-imx/mach-mx31lite.c | 19 +--- - arch/arm/mach-imx/mach-mx31moboard.c | 12 +-- - arch/arm/mach-imx/mach-pca100.c | 21 +++-- - arch/arm/mach-imx/mach-pcm037_eet.c | 7 +- - drivers/spi/spi-fsl-lpspi.c | 47 +--------- - drivers/spi/spi-imx.c | 92 ++++---------------- - include/linux/platform_data/spi-imx.h | 33 ------- - 14 files changed, 88 insertions(+), 244 deletions(-) - delete mode 100644 include/linux/platform_data/spi-imx.h - -diff --git a/arch/arm/mach-imx/devices-imx27.h b/arch/arm/mach-imx/devices-imx27.h -index f89f4ae0e1ca6..583a1d773d682 100644 ---- a/arch/arm/mach-imx/devices-imx27.h -+++ b/arch/arm/mach-imx/devices-imx27.h -@@ -75,11 +75,11 @@ extern const struct imx_mxc_w1_data imx27_mxc_w1_data; - imx_add_mxc_w1(&imx27_mxc_w1_data) - - extern const struct imx_spi_imx_data imx27_cspi_data[]; --#define imx27_add_cspi(id, pdata) \ -- imx_add_spi_imx(&imx27_cspi_data[id], pdata) --#define imx27_add_spi_imx0(pdata) imx27_add_cspi(0, pdata) --#define imx27_add_spi_imx1(pdata) imx27_add_cspi(1, pdata) --#define imx27_add_spi_imx2(pdata) imx27_add_cspi(2, pdata) -+#define imx27_add_cspi(id, gtable) \ -+ imx_add_spi_imx(&imx27_cspi_data[id], gtable) -+#define imx27_add_spi_imx0(gtable) imx27_add_cspi(0, gtable) -+#define imx27_add_spi_imx1(gtable) imx27_add_cspi(1, gtable) -+#define imx27_add_spi_imx2(gtable) imx27_add_cspi(2, gtable) - - extern const struct imx_pata_imx_data imx27_pata_imx_data; - #define imx27_add_pata_imx() \ -diff --git a/arch/arm/mach-imx/devices-imx31.h b/arch/arm/mach-imx/devices-imx31.h -index 5a4ba35a47ed0..f7cc623725322 100644 ---- a/arch/arm/mach-imx/devices-imx31.h -+++ b/arch/arm/mach-imx/devices-imx31.h -@@ -69,11 +69,11 @@ extern const struct imx_mxc_w1_data imx31_mxc_w1_data; - imx_add_mxc_w1(&imx31_mxc_w1_data) - - extern const struct imx_spi_imx_data imx31_cspi_data[]; --#define imx31_add_cspi(id, pdata) \ -- imx_add_spi_imx(&imx31_cspi_data[id], pdata) --#define imx31_add_spi_imx0(pdata) imx31_add_cspi(0, pdata) --#define imx31_add_spi_imx1(pdata) imx31_add_cspi(1, pdata) --#define imx31_add_spi_imx2(pdata) imx31_add_cspi(2, pdata) -+#define imx31_add_cspi(id, gtable) \ -+ imx_add_spi_imx(&imx31_cspi_data[id], gtable) -+#define imx31_add_spi_imx0(gtable) imx31_add_cspi(0, gtable) -+#define imx31_add_spi_imx1(gtable) imx31_add_cspi(1, gtable) -+#define imx31_add_spi_imx2(gtable) imx31_add_cspi(2, gtable) - - extern const struct imx_pata_imx_data imx31_pata_imx_data; - #define imx31_add_pata_imx() \ -diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h -index 2a685adec1df7..f8f3e4967c31f 100644 ---- a/arch/arm/mach-imx/devices/devices-common.h -+++ b/arch/arm/mach-imx/devices/devices-common.h -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include - - extern struct device mxc_aips_bus; -@@ -276,7 +277,6 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx( - const struct imx_sdhci_esdhc_imx_data *data, - const struct esdhc_platform_data *pdata); - --#include - struct imx_spi_imx_data { - const char *devid; - int id; -@@ -285,8 +285,7 @@ struct imx_spi_imx_data { - int irq; - }; - struct platform_device *__init imx_add_spi_imx( -- const struct imx_spi_imx_data *data, -- const struct spi_imx_master *pdata); -+ const struct imx_spi_imx_data *data, struct gpiod_lookup_table *gtable); - - struct platform_device *imx_add_imx_dma(char *name, resource_size_t iobase, - int irq, int irq_err); -diff --git a/arch/arm/mach-imx/devices/platform-spi_imx.c b/arch/arm/mach-imx/devices/platform-spi_imx.c -index f2cafa52c1872..27747bf628a31 100644 ---- a/arch/arm/mach-imx/devices/platform-spi_imx.c -+++ b/arch/arm/mach-imx/devices/platform-spi_imx.c -@@ -3,6 +3,7 @@ - * Copyright (C) 2009-2010 Pengutronix - * Uwe Kleine-Koenig - */ -+#include - #include "../hardware.h" - #include "devices-common.h" - -@@ -57,8 +58,7 @@ const struct imx_spi_imx_data imx35_cspi_data[] __initconst = { - #endif /* ifdef CONFIG_SOC_IMX35 */ - - struct platform_device *__init imx_add_spi_imx( -- const struct imx_spi_imx_data *data, -- const struct spi_imx_master *pdata) -+ const struct imx_spi_imx_data *data, struct gpiod_lookup_table *gtable) - { - struct resource res[] = { - { -@@ -71,7 +71,8 @@ struct platform_device *__init imx_add_spi_imx( - .flags = IORESOURCE_IRQ, - }, - }; -- -+ if (gtable) -+ gpiod_add_lookup_table(gtable); - return imx_add_platform_device(data->devid, data->id, -- res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); -+ res, ARRAY_SIZE(res), NULL, 0); - } -diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c -index 7b8325fb5b413..51204521b903b 100644 ---- a/arch/arm/mach-imx/mach-mx27_3ds.c -+++ b/arch/arm/mach-imx/mach-mx27_3ds.c -@@ -304,18 +304,34 @@ static struct imx_ssi_platform_data mx27_3ds_ssi_pdata = { - }; - - /* SPI */ --static int spi1_chipselect[] = {SPI1_SS0}; -- --static const struct spi_imx_master spi1_pdata __initconst = { -- .chipselect = spi1_chipselect, -- .num_chipselect = ARRAY_SIZE(spi1_chipselect), -+static struct gpiod_lookup_table mx27_spi1_gpiod_table = { -+ .dev_id = "imx27-cspi.0", /* Actual device name for spi1 */ -+ .table = { -+ /* -+ * The i.MX27 has the i.MX21 GPIO controller, the SPI1 CS GPIO -+ * SPI1_SS0 is numbered IMX_GPIO_NR(4, 28). -+ * -+ * This is in "bank 4" which is subtracted by one in the macro -+ * so this is actually bank 3 on "imx21-gpio.3". -+ */ -+ GPIO_LOOKUP_IDX("imx21-gpio.3", 28, "cs", 0, GPIO_ACTIVE_LOW), -+ { }, -+ }, - }; - --static int spi2_chipselect[] = {SPI2_SS0}; -- --static const struct spi_imx_master spi2_pdata __initconst = { -- .chipselect = spi2_chipselect, -- .num_chipselect = ARRAY_SIZE(spi2_chipselect), -+static struct gpiod_lookup_table mx27_spi2_gpiod_table = { -+ .dev_id = "imx27-cspi.1", /* Actual device name for spi2 */ -+ .table = { -+ /* -+ * The i.MX27 has the i.MX21 GPIO controller, the SPI2 CS GPIO -+ * SPI2_SS0 is numbered IMX_GPIO_NR(4, 21). -+ * -+ * This is in "bank 4" which is subtracted by one in the macro -+ * so this is actually bank 3 on "imx21-gpio.3". -+ */ -+ GPIO_LOOKUP_IDX("imx21-gpio.3", 21, "cs", 0, GPIO_ACTIVE_LOW), -+ { }, -+ }, - }; - - static struct imx_fb_videomode mx27_3ds_modes[] = { -@@ -389,8 +405,8 @@ static void __init mx27pdk_init(void) - imx27_add_imx_keypad(&mx27_3ds_keymap_data); - imx27_add_imx2_wdt(); - -- imx27_add_spi_imx1(&spi2_pdata); -- imx27_add_spi_imx0(&spi1_pdata); -+ imx27_add_spi_imx1(&mx27_spi2_gpiod_table); -+ imx27_add_spi_imx0(&mx27_spi1_gpiod_table); - - imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data); - imx27_add_imx_fb(&mx27_3ds_fb_data); -diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c -index 716d2ad511035..99295ce8d0549 100644 ---- a/arch/arm/mach-imx/mach-mx31_3ds.c -+++ b/arch/arm/mach-imx/mach-mx31_3ds.c -@@ -364,15 +364,6 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = { - .flags = IMX_SSI_DMA | IMX_SSI_NET, - }; - --/* SPI */ --static const struct spi_imx_master spi0_pdata __initconst = { -- .num_chipselect = 3, --}; -- --static const struct spi_imx_master spi1_pdata __initconst = { -- .num_chipselect = 3, --}; -- - static struct spi_board_info mx31_3ds_spi_devs[] __initdata = { - { - .modalias = "mc13783", -@@ -548,14 +539,14 @@ static void __init mx31_3ds_init(void) - imx31_add_imx_uart0(&uart_pdata); - imx31_add_mxc_nand(&mx31_3ds_nand_board_info); - -- imx31_add_spi_imx1(&spi1_pdata); -+ imx31_add_spi_imx1(NULL); - - imx31_add_imx_keypad(&mx31_3ds_keymap_data); - - imx31_add_imx2_wdt(); - imx31_add_imx_i2c0(&mx31_3ds_i2c0_data); - -- imx31_add_spi_imx0(&spi0_pdata); -+ imx31_add_spi_imx0(NULL); - imx31_add_ipu_core(); - imx31_add_mx3_sdc_fb(&mx3fb_pdata); - -diff --git a/arch/arm/mach-imx/mach-mx31lilly.c b/arch/arm/mach-imx/mach-mx31lilly.c -index 8f725248299e1..4b955ccc92cdc 100644 ---- a/arch/arm/mach-imx/mach-mx31lilly.c -+++ b/arch/arm/mach-imx/mach-mx31lilly.c -@@ -215,16 +215,6 @@ static void __init lilly1131_usb_init(void) - imx31_add_mxc_ehci_hs(2, &usbh2_pdata); - } - --/* SPI */ -- --static const struct spi_imx_master spi0_pdata __initconst = { -- .num_chipselect = 3, --}; -- --static const struct spi_imx_master spi1_pdata __initconst = { -- .num_chipselect = 3, --}; -- - static struct mc13xxx_platform_data mc13783_pdata __initdata = { - .flags = MC13XXX_USE_RTC | MC13XXX_USE_TOUCHSCREEN, - }; -@@ -281,8 +271,8 @@ static void __init mx31lilly_board_init(void) - mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS1__SS1, "SPI2_SS1"); - mxc_iomux_alloc_pin(MX31_PIN_CSPI2_SS2__SS2, "SPI2_SS2"); - -- imx31_add_spi_imx0(&spi0_pdata); -- imx31_add_spi_imx1(&spi1_pdata); -+ imx31_add_spi_imx0(NULL); -+ imx31_add_spi_imx1(NULL); - - regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); - } -diff --git a/arch/arm/mach-imx/mach-mx31lite.c b/arch/arm/mach-imx/mach-mx31lite.c -index c0055f57c02dd..aaccf52f7ac16 100644 ---- a/arch/arm/mach-imx/mach-mx31lite.c -+++ b/arch/arm/mach-imx/mach-mx31lite.c -@@ -73,11 +73,6 @@ static const struct imxuart_platform_data uart_pdata __initconst = { - .flags = IMXUART_HAVE_RTSCTS, - }; - --/* SPI */ --static const struct spi_imx_master spi0_pdata __initconst = { -- .num_chipselect = 3, --}; -- - static const struct mxc_nand_platform_data - mx31lite_nand_board_info __initconst = { - .width = 1, -@@ -111,16 +106,6 @@ static struct platform_device smsc911x_device = { - }, - }; - --/* -- * SPI -- * -- * The MC13783 is the only hard-wired SPI device on the module. -- */ -- --static const struct spi_imx_master spi1_pdata __initconst = { -- .num_chipselect = 1, --}; -- - static struct mc13xxx_platform_data mc13783_pdata __initdata = { - .flags = MC13XXX_USE_RTC, - }; -@@ -246,13 +231,13 @@ static void __init mx31lite_init(void) - "mx31lite"); - - imx31_add_imx_uart0(&uart_pdata); -- imx31_add_spi_imx0(&spi0_pdata); -+ imx31_add_spi_imx0(NULL); - - /* NOR and NAND flash */ - platform_device_register(&physmap_flash_device); - imx31_add_mxc_nand(&mx31lite_nand_board_info); - -- imx31_add_spi_imx1(&spi1_pdata); -+ imx31_add_spi_imx1(NULL); - - regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); - } -diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c -index 36f08f45b0cad..96845a4eaf57e 100644 ---- a/arch/arm/mach-imx/mach-mx31moboard.c -+++ b/arch/arm/mach-imx/mach-mx31moboard.c -@@ -143,10 +143,6 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = { - .bitrate = 100000, - }; - --static const struct spi_imx_master moboard_spi1_pdata __initconst = { -- .num_chipselect = 3, --}; -- - static struct regulator_consumer_supply sdhc_consumers[] = { - { - .dev_name = "imx31-mmc.0", -@@ -287,10 +283,6 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = { - }, - }; - --static const struct spi_imx_master moboard_spi2_pdata __initconst = { -- .num_chipselect = 2, --}; -- - #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0) - #define SDHC1_WP IOMUX_TO_GPIO(MX31_PIN_ATA_CS1) - -@@ -514,8 +506,8 @@ static void __init mx31moboard_init(void) - imx31_add_imx_i2c0(&moboard_i2c0_data); - imx31_add_imx_i2c1(&moboard_i2c1_data); - -- imx31_add_spi_imx1(&moboard_spi1_pdata); -- imx31_add_spi_imx2(&moboard_spi2_pdata); -+ imx31_add_spi_imx1(NULL); -+ imx31_add_spi_imx2(NULL); - - mx31moboard_init_cam(); - -diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c -index 2e28e1b5cddfd..27a3678e0658a 100644 ---- a/arch/arm/mach-imx/mach-pca100.c -+++ b/arch/arm/mach-imx/mach-pca100.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -188,11 +189,19 @@ static struct spi_board_info pca100_spi_board_info[] __initdata = { - }, - }; - --static int pca100_spi_cs[] = {SPI1_SS0, SPI1_SS1}; -- --static const struct spi_imx_master pca100_spi0_data __initconst = { -- .chipselect = pca100_spi_cs, -- .num_chipselect = ARRAY_SIZE(pca100_spi_cs), -+static struct gpiod_lookup_table pca100_spi0_gpiod_table = { -+ .dev_id = "imx27-cspi.0", /* Actual device name for spi0 */ -+ .table = { -+ /* -+ * The i.MX27 has the i.MX21 GPIO controller, port D is -+ * bank 3 and thus named "imx21-gpio.3". -+ * SPI1_SS0 is GPIO_PORTD + 28 -+ * SPI1_SS1 is GPIO_PORTD + 27 -+ */ -+ GPIO_LOOKUP_IDX("imx21-gpio.3", 28, "cs", 0, GPIO_ACTIVE_LOW), -+ GPIO_LOOKUP_IDX("imx21-gpio.3", 27, "cs", 1, GPIO_ACTIVE_LOW), -+ { }, -+ }, - }; - - static void pca100_ac97_warm_reset(struct snd_ac97 *ac97) -@@ -362,7 +371,7 @@ static void __init pca100_init(void) - mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN); - spi_register_board_info(pca100_spi_board_info, - ARRAY_SIZE(pca100_spi_board_info)); -- imx27_add_spi_imx0(&pca100_spi0_data); -+ imx27_add_spi_imx0(&pca100_spi0_gpiod_table); - - imx27_add_imx_fb(&pca100_fb_data); - -diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c -index 51f5142920cf5..8b0e03a595c19 100644 ---- a/arch/arm/mach-imx/mach-pcm037_eet.c -+++ b/arch/arm/mach-imx/mach-pcm037_eet.c -@@ -52,11 +52,6 @@ static struct spi_board_info pcm037_spi_dev[] = { - }, - }; - --/* Platform Data for MXC CSPI */ --static const struct spi_imx_master pcm037_spi1_pdata __initconst = { -- .num_chipselect = 2, --}; -- - /* GPIO-keys input device */ - static struct gpio_keys_button pcm037_gpio_keys[] = { - { -@@ -163,7 +158,7 @@ int __init pcm037_eet_init_devices(void) - - /* SPI */ - spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev)); -- imx31_add_spi_imx0(&pcm037_spi1_pdata); -+ imx31_add_spi_imx0(NULL); - - imx_add_gpio_keys(&pcm037_gpio_keys_platform_data); - -diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c -index 58b2da91be1c0..a813c192a018d 100644 ---- a/drivers/spi/spi-fsl-lpspi.c -+++ b/drivers/spi/spi-fsl-lpspi.c -@@ -11,7 +11,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -19,11 +18,9 @@ - #include - #include - #include --#include - #include - #include - #include --#include - #include - #include - #include -@@ -227,20 +224,6 @@ static int lpspi_unprepare_xfer_hardware(struct spi_controller *controller) - return 0; - } - --static int fsl_lpspi_prepare_message(struct spi_controller *controller, -- struct spi_message *msg) --{ -- struct fsl_lpspi_data *fsl_lpspi = -- spi_controller_get_devdata(controller); -- struct spi_device *spi = msg->spi; -- int gpio = fsl_lpspi->chipselect[spi->chip_select]; -- -- if (gpio_is_valid(gpio)) -- gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); -- -- return 0; --} -- - static void fsl_lpspi_write_tx_fifo(struct fsl_lpspi_data *fsl_lpspi) - { - u8 txfifo_cnt; -@@ -835,13 +818,10 @@ static int fsl_lpspi_init_rpm(struct fsl_lpspi_data *fsl_lpspi) - - static int fsl_lpspi_probe(struct platform_device *pdev) - { -- struct device_node *np = pdev->dev.of_node; - struct fsl_lpspi_data *fsl_lpspi; - struct spi_controller *controller; -- struct spi_imx_master *lpspi_platform_info = -- dev_get_platdata(&pdev->dev); - struct resource *res; -- int i, ret, irq; -+ int ret, irq; - u32 temp; - bool is_slave; - -@@ -871,6 +851,8 @@ static int fsl_lpspi_probe(struct platform_device *pdev) - controller->dev.of_node = pdev->dev.of_node; - controller->bus_num = pdev->id; - controller->slave_abort = fsl_lpspi_slave_abort; -+ if (!fsl_lpspi->is_slave) -+ controller->use_gpio_descriptors = true; - - ret = devm_spi_register_controller(&pdev->dev, controller); - if (ret < 0) { -@@ -878,29 +860,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev) - goto out_controller_put; - } - -- if (!fsl_lpspi->is_slave) { -- for (i = 0; i < controller->num_chipselect; i++) { -- int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); -- -- if (!gpio_is_valid(cs_gpio) && lpspi_platform_info) -- cs_gpio = lpspi_platform_info->chipselect[i]; -- -- fsl_lpspi->chipselect[i] = cs_gpio; -- if (!gpio_is_valid(cs_gpio)) -- continue; -- -- ret = devm_gpio_request(&pdev->dev, -- fsl_lpspi->chipselect[i], -- DRIVER_NAME); -- if (ret) { -- dev_err(&pdev->dev, "can't get cs gpios\n"); -- goto out_controller_put; -- } -- } -- controller->cs_gpios = fsl_lpspi->chipselect; -- controller->prepare_message = fsl_lpspi_prepare_message; -- } -- - init_completion(&fsl_lpspi->xfer_done); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c -index 9d593675257e0..90793fc321358 100644 ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -8,7 +8,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -21,10 +20,9 @@ - #include - #include - #include --#include -+#include - - #include --#include - - #define DRIVER_NAME "spi_imx" - -@@ -727,7 +725,7 @@ static int mx31_prepare_transfer(struct spi_imx_data *spi_imx, - reg |= MX31_CSPICTRL_POL; - if (spi->mode & SPI_CS_HIGH) - reg |= MX31_CSPICTRL_SSPOL; -- if (!gpio_is_valid(spi->cs_gpio)) -+ if (!spi->cs_gpiod) - reg |= (spi->chip_select) << - (is_imx35_cspi(spi_imx) ? MX35_CSPICTRL_CS_SHIFT : - MX31_CSPICTRL_CS_SHIFT); -@@ -827,7 +825,7 @@ static int mx21_prepare_transfer(struct spi_imx_data *spi_imx, - reg |= MX21_CSPICTRL_POL; - if (spi->mode & SPI_CS_HIGH) - reg |= MX21_CSPICTRL_SSPOL; -- if (!gpio_is_valid(spi->cs_gpio)) -+ if (!spi->cs_gpiod) - reg |= spi->chip_select << MX21_CSPICTRL_CS_SHIFT; - - writel(reg, spi_imx->base + MXC_CSPICTRL); -@@ -1056,20 +1054,6 @@ static const struct of_device_id spi_imx_dt_ids[] = { - }; - MODULE_DEVICE_TABLE(of, spi_imx_dt_ids); - --static void spi_imx_chipselect(struct spi_device *spi, int is_active) --{ -- int active = is_active != BITBANG_CS_INACTIVE; -- int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH); -- -- if (spi->mode & SPI_NO_CS) -- return; -- -- if (!gpio_is_valid(spi->cs_gpio)) -- return; -- -- gpio_set_value(spi->cs_gpio, dev_is_lowactive ^ active); --} -- - static void spi_imx_set_burst_len(struct spi_imx_data *spi_imx, int n_bits) - { - u32 ctrl; -@@ -1535,15 +1519,6 @@ static int spi_imx_setup(struct spi_device *spi) - dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__, - spi->mode, spi->bits_per_word, spi->max_speed_hz); - -- if (spi->mode & SPI_NO_CS) -- return 0; -- -- if (gpio_is_valid(spi->cs_gpio)) -- gpio_direction_output(spi->cs_gpio, -- spi->mode & SPI_CS_HIGH ? 0 : 1); -- -- spi_imx_chipselect(spi, BITBANG_CS_INACTIVE); -- - return 0; - } - -@@ -1601,20 +1576,14 @@ static int spi_imx_probe(struct platform_device *pdev) - struct device_node *np = pdev->dev.of_node; - const struct of_device_id *of_id = - of_match_device(spi_imx_dt_ids, &pdev->dev); -- struct spi_imx_master *mxc_platform_info = -- dev_get_platdata(&pdev->dev); - struct spi_master *master; - struct spi_imx_data *spi_imx; - struct resource *res; -- int i, ret, irq, spi_drctl; -+ int ret, irq, spi_drctl; - const struct spi_imx_devtype_data *devtype_data = of_id ? of_id->data : - (struct spi_imx_devtype_data *)pdev->id_entry->driver_data; - bool slave_mode; -- -- if (!np && !mxc_platform_info) { -- dev_err(&pdev->dev, "can't get the platform data\n"); -- return -EINVAL; -- } -+ u32 val; - - slave_mode = devtype_data->has_slavemode && - of_property_read_bool(np, "spi-slave"); -@@ -1637,6 +1606,7 @@ static int spi_imx_probe(struct platform_device *pdev) - - master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); - master->bus_num = np ? -1 : pdev->id; -+ master->use_gpio_descriptors = true; - - spi_imx = spi_master_get_devdata(master); - spi_imx->bitbang.master = master; -@@ -1645,28 +1615,17 @@ static int spi_imx_probe(struct platform_device *pdev) - - spi_imx->devtype_data = devtype_data; - -- /* Get number of chip selects, either platform data or OF */ -- if (mxc_platform_info) { -- master->num_chipselect = mxc_platform_info->num_chipselect; -- if (mxc_platform_info->chipselect) { -- master->cs_gpios = devm_kcalloc(&master->dev, -- master->num_chipselect, sizeof(int), -- GFP_KERNEL); -- if (!master->cs_gpios) -- return -ENOMEM; -- -- for (i = 0; i < master->num_chipselect; i++) -- master->cs_gpios[i] = mxc_platform_info->chipselect[i]; -- } -- } else { -- u32 num_cs; -- -- if (!of_property_read_u32(np, "num-cs", &num_cs)) -- master->num_chipselect = num_cs; -- /* If not preset, default value of 1 is used */ -- } -+ /* -+ * Get number of chip selects from device properties. This can be -+ * coming from device tree or boardfiles, if it is not defined, -+ * a default value of 3 chip selects will be used, as all the legacy -+ * board files have <= 3 chip selects. -+ */ -+ if (!device_property_read_u32(&pdev->dev, "num-cs", &val)) -+ master->num_chipselect = val; -+ else -+ master->num_chipselect = 3; - -- spi_imx->bitbang.chipselect = spi_imx_chipselect; - spi_imx->bitbang.setup_transfer = spi_imx_setupxfer; - spi_imx->bitbang.txrx_bufs = spi_imx_transfer; - spi_imx->bitbang.master->setup = spi_imx_setup; -@@ -1751,31 +1710,12 @@ static int spi_imx_probe(struct platform_device *pdev) - goto out_clk_put; - } - -- /* Request GPIO CS lines, if any */ -- if (!spi_imx->slave_mode && master->cs_gpios) { -- for (i = 0; i < master->num_chipselect; i++) { -- if (!gpio_is_valid(master->cs_gpios[i])) -- continue; -- -- ret = devm_gpio_request(&pdev->dev, -- master->cs_gpios[i], -- DRIVER_NAME); -- if (ret) { -- dev_err(&pdev->dev, "Can't get CS GPIO %i\n", -- master->cs_gpios[i]); -- goto out_spi_bitbang; -- } -- } -- } -- - dev_info(&pdev->dev, "probed\n"); - - clk_disable(spi_imx->clk_ipg); - clk_disable(spi_imx->clk_per); - return ret; - --out_spi_bitbang: -- spi_bitbang_stop(&spi_imx->bitbang); - out_clk_put: - clk_disable_unprepare(spi_imx->clk_ipg); - out_put_per: -diff --git a/include/linux/platform_data/spi-imx.h b/include/linux/platform_data/spi-imx.h -deleted file mode 100644 -index 328f670d10bd7..0000000000000 ---- a/include/linux/platform_data/spi-imx.h -+++ /dev/null -@@ -1,33 +0,0 @@ --/* SPDX-License-Identifier: GPL-2.0 */ -- --#ifndef __MACH_SPI_H_ --#define __MACH_SPI_H_ -- --/* -- * struct spi_imx_master - device.platform_data for SPI controller devices. -- * @chipselect: Array of chipselects for this master or NULL. Numbers >= 0 -- * mean GPIO pins, -ENOENT means internal CSPI chipselect -- * matching the position in the array. E.g., if chipselect[1] = -- * -ENOENT then a SPI slave using chip select 1 will use the -- * native SS1 line of the CSPI. Omitting the array will use -- * all native chip selects. -- -- * Normally you want to use gpio based chip selects as the CSPI -- * module tries to be intelligent about when to assert the -- * chipselect: The CSPI module deasserts the chipselect once it -- * runs out of input data. The other problem is that it is not -- * possible to mix between high active and low active chipselects -- * on one single bus using the internal chipselects. -- * Unfortunately, on some SoCs, Freescale decided to put some -- * chipselects on dedicated pins which are not usable as gpios, -- * so we have to support the internal chipselects. -- * -- * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect), -- * otherwise the number of native chip selects. -- */ --struct spi_imx_master { -- int *chipselect; -- int num_chipselect; --}; -- --#endif /* __MACH_SPI_H_*/ --- -2.39.2 - diff --git a/queue-5.4/spi-spi-imx-using-pm_runtime_resume_and_get-instead-.patch b/queue-5.4/spi-spi-imx-using-pm_runtime_resume_and_get-instead-.patch deleted file mode 100644 index deb91937f86..00000000000 --- a/queue-5.4/spi-spi-imx-using-pm_runtime_resume_and_get-instead-.patch +++ /dev/null @@ -1,49 +0,0 @@ -From af1684e36a6be041fe0556a931486ad55ad2b692 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 14 Apr 2022 08:53:42 +0000 -Subject: spi: spi-imx: using pm_runtime_resume_and_get instead of - pm_runtime_get_sync - -From: Minghao Chi - -[ Upstream commit 7d34ff58f35c82207698f43af79817a05e1342e5 ] - -Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and -pm_runtime_put_noidle. This change is just to simplify the code, no -actual functional changes. - -Reported-by: Zeal Robot -Signed-off-by: Minghao Chi -Link: https://lore.kernel.org/r/20220414085343.2541608-1-chi.minghao@zte.com.cn -Signed-off-by: Mark Brown -Stable-dep-of: 11951c9e3f36 ("spi: imx: Don't skip cleanup in remove's error path") -Signed-off-by: Sasha Levin ---- - drivers/spi/spi-imx.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c -index 95f1746a85d9d..780c234257ca8 100644 ---- a/drivers/spi/spi-imx.c -+++ b/drivers/spi/spi-imx.c -@@ -1536,7 +1536,7 @@ spi_imx_prepare_message(struct spi_master *master, struct spi_message *msg) - struct spi_imx_data *spi_imx = spi_master_get_devdata(master); - int ret; - -- ret = pm_runtime_get_sync(spi_imx->dev); -+ ret = pm_runtime_resume_and_get(spi_imx->dev); - if (ret < 0) { - dev_err(spi_imx->dev, "failed to enable clock\n"); - return ret; -@@ -1737,7 +1737,7 @@ static int spi_imx_remove(struct platform_device *pdev) - - spi_bitbang_stop(&spi_imx->bitbang); - -- ret = pm_runtime_get_sync(spi_imx->dev); -+ ret = pm_runtime_resume_and_get(spi_imx->dev); - if (ret < 0) { - dev_err(spi_imx->dev, "failed to enable clock\n"); - return ret; --- -2.39.2 -