Commit Graph

996262 Commits

Author SHA1 Message Date
Amit Kumar Mahapatra 2530b3df43
spi: spi-zynqmp-gqspi: Resolved slab-out-of-bounds bug
During a transfer the driver filled the fifo with 4bytes,
even if the data that needs to be transfer is less that 4bytes.
This resulted in slab-out-of-bounds bug in KernelAddressSanitizer.

This patch resolves slab-out-of-bounds bug by filling the fifo
with the number of bytes that needs to transferred.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Link: https://lore.kernel.org/r/20210416004652.2975446-4-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16 13:44:13 +01:00
Quanyang Wang 799f923f0a
spi: spi-zynqmp-gqspi: fix hang issue when suspend/resume
After calling platform_set_drvdata(pdev, xqspi) in probe, the return
value of dev_get_drvdata(dev) is a pointer to struct zynqmp_qspi but
not struct spi_controller. A wrong structure type passing to the
functions spi_controller_suspend/resume will hang the system.

And we should check the return value of spi_controller_suspend, if
an error is returned, return it to PM subsystem to stop suspend.

Also, GQSPI_EN_MASK should be written to GQSPI_EN_OFST to enable
the spi controller in zynqmp_qspi_resume since it was disabled in
zynqmp_qspi_suspend before.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Link: https://lore.kernel.org/r/20210416004652.2975446-3-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16 13:44:12 +01:00
Quanyang Wang c6bdae0801
spi: spi-zynqmp-gqspi: fix clk_enable/disable imbalance issue
The clks "pclk" and "ref_clk" are enabled twice during the probe. The
first time is in the function zynqmp_qspi_probe and the second time is
in zynqmp_qspi_setup_op which is called by devm_spi_register_controller.
Then calling zynqmp_qspi_remove (rmmod this module) to disable these clks
will trigger a warning as below:

[  309.124604] Unpreparing enabled qspi_ref
[  309.128641] WARNING: CPU: 1 PID: 537 at drivers/clk/clk.c:824 clk_core_unprepare+0x108/0x110

Since pm_runtime works now, clks can be enabled/disabled by calling
zynqmp_runtime_suspend/resume. So we don't need to enable these clks
explicitly in zynqmp_qspi_setup_op. Remove them to fix this issue.

And remove clk enabling/disabling in zynqmp_qspi_resume because there is
no spi transfer operation so enabling ref_clk is redundant meanwhile pclk
is not disabled for it is shared with other peripherals.

Furthermore replace clk_enable/disable with clk_prepare_enable and
clk_disable_unprepare in runtime_suspend/resume functions.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Link: https://lore.kernel.org/r/20210416004652.2975446-2-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16 13:44:12 +01:00
Mark Brown c7ed5fd5fb
Merge branch 'for-5.12' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-5.13 2021-04-15 19:29:40 +01:00
Dinghao Liu 58eaa7b2d0
spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe
There is a PM usage counter decrement after zynqmp_qspi_init_hw()
without any refcount increment, which leads to refcount leak.Add
a refcount increment to balance the refcount. Also set
auto_runtime_pm to resume suspended spi controller.

Fixes: 9e3a000362 ("spi: zynqmp: Add pm runtime support")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Tested-by: Quanyang Wang <quanyang.wang@windriver.com>
Link: https://lore.kernel.org/r/20210415074644.24646-1-dinghao.liu@zju.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:07:59 +01:00
Krzysztof Kozlowski d637141551
spi: s3c64xx: constify driver/match data
The match data (struct s3c64xx_spi_port_config) stored in of_device_id
and platform_device_id tables is not modified by the driver and can be
handled entirely in a const-way to increase the code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Sylwester Nawrocki <snawrocki@kernel.org>
Link: https://lore.kernel.org/r/20210414203343.203119-3-krzysztof.kozlowski@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:07:58 +01:00
Krzysztof Kozlowski 7d712f799a
spi: s3c64xx: correct kerneldoc of s3c64xx_spi_port_config
Correct the name of s3c64xx_spi_port_config structure in kerneldoc:

  drivers/spi/spi-s3c64xx.c:154: warning:
    expecting prototype for struct s3c64xx_spi_info. Prototype was for struct s3c64xx_spi_port_config instead

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Sylwester Nawrocki <snawrocki@kernel.org>
Link: https://lore.kernel.org/r/20210414203343.203119-2-krzysztof.kozlowski@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:07:57 +01:00
Krzysztof Kozlowski 609a2f9529
spi: s3c64xx: simplify getting of_device_id match data
Use of_device_get_match_data() to make the code slightly smaller and to
remove the of_device_id table forward declaration.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Sylwester Nawrocki <snawrocki@kernel.org>
Link: https://lore.kernel.org/r/20210414203343.203119-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:07:56 +01:00
Jarkko Nikula 8c4ffe4d02
spi: pxa2xx: Add support for Intel Alder Lake PCH-M
Add support for LPSS SPI on Intel Alder Lake PCH-M.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20210415135917.54144-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-15 16:06:55 +01:00
Mark Brown 089cde0797
Merge series "Minor updates for hisi-sfc-v3xx" from Yicong Yang <yangyicong@hisilicon.com>:
This series fix a potential interrupt race condition and
cleanup the ACPI protection for the driver.

Change since v1:
- reword the commit in patch #2
Link: https://lore.kernel.org/linux-spi/1617881505-51552-1-git-send-email-yangyicong@hisilicon.com/

Yicong Yang (2):
  spi: hisi-sfc-v3xx: fix potential irq race condition
  spi: hisi-sfc-v3xx: drop unnecessary ACPI_PTR and related ifendif
    protection

 drivers/spi/spi-hisi-sfc-v3xx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--
2.8.1
2021-04-12 19:56:27 +01:00
Wei Yongjun 6043357263
spi: spi-zynqmp-gqspi: Fix missing unlock on error in zynqmp_qspi_exec_op()
Add the missing unlock before return from function zynqmp_qspi_exec_op()
in the error handling case.

Fixes: a0f65be6e8 ("spi: spi-zynqmp-gqspi: add mutex locking for exec_op")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210412160025.194171-1-weiyongjun1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-12 17:07:39 +01:00
Yicong Yang 4a46f88681
spi: hisi-sfc-v3xx: drop unnecessary ACPI_PTR and related ifendif protection
We use ACPI_PTR() and related ifendif protection for the id table.
This is unnecessary as the struct acpi_device_id is defined in
mod_devicetable.h and doesn't rely on ACPI. The driver doesn't
use any ACPI apis, so it can be compiled in the ACPI=n case
with no warnings.

So remove the ACPI_PTR and related ifendif protection, also
replace the header acpi.h with mod_devicetable.h.

Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/1618228708-37949-3-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-12 17:07:38 +01:00
Yicong Yang 4c84e42d29
spi: hisi-sfc-v3xx: fix potential irq race condition
We mask the irq when the command completion is timeout. This won't
stop the already running irq handler. Use sychronize_irq() after
we mask the irq, to make sure there is no running handler.

Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/1618228708-37949-2-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-12 17:07:37 +01:00
Mark Brown 828b480977
Merge series "spi: spi-zynqmp-gpspi: fix some issues" from quanyang.wang@windriver.com
Quanyang Wang <quanyang.wang@windriver.com>:

From: Quanyang Wang <quanyang.wang@windriver.com>

Hello,

This series fix some issues that occurs when the gqspi driver switches to spi-mem framework.

Hi Amit,
I rewrite the "Subject" and "commit message" of these patches, so they
look different from the ones which you reviewed before. I still keep
your "Reviewed-by" and hope you will not mind.

Regards,
Quanyang Wang

Quanyang Wang (4):
  spi: spi-zynqmp-gqspi: use wait_for_completion_timeout to make
    zynqmp_qspi_exec_op not interruptible
  spi: spi-zynqmp-gqspi: add mutex locking for exec_op
  spi: spi-zynqmp-gqspi: transmit dummy circles by using the
    controller's internal functionality
  spi: spi-zynqmp-gqspi: fix incorrect operating mode in
    zynqmp_qspi_read_op

 drivers/spi/spi-zynqmp-gqspi.c | 53 +++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 26 deletions(-)

--
2.25.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
2021-04-09 16:28:09 +01:00
Tian Tao 30700a057c
spi: davinci: Use device_get_match_data() helper
Use the device_get_match_data() helper instead of open coding.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Suggested-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/1617152319-17701-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:44:04 +01:00
Wang Li cec77e0a24
spi: qup: fix PM reference leak in spi_qup_remove()
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Li <wangli74@huawei.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20210409095458.29921-1-wangli74@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:44:03 +01:00
Muhammad Usama Anjum e980048263
spi: orion: set devdata properly as it is being used later
If device_get_match_data returns NULL, devdata isn't being updated
properly. It is being used later in the function. Both devdata and
spi->devdata should be updated to avoid NULL pointer dereference.

Addresses-Coverity: ("NULL pointer dereference")
Fixes: 0e6521f13c ("spi: orion: Use device_get_match_data() helper")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Link: https://lore.kernel.org/r/20210408195718.GA3075166@LEGION
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:44:02 +01:00
Clark Wang 4df2f5e137
spi: imx: add a check for speed_hz before calculating the clock
When some drivers use spi to send data, spi_transfer->speed_hz is
not assigned. If spidev->max_speed_hz is not assigned as well, it
will cause an error in configuring the clock.
Add a check for these two values before configuring the clock. An
error will be returned when they are not assigned.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://lore.kernel.org/r/20210408103347.244313-2-xiaoning.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:44:01 +01:00
Wei Yongjun a23faea76d
spi: omap-100k: Fix reference leak to master
Call spi_master_get() holds the reference count to master device, thus
we need an additional spi_master_put() call to reduce the reference
count, otherwise we will leak a reference to master.

This commit fix it by removing the unnecessary spi_master_get().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210409082954.2906933-1-weiyongjun1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:44:00 +01:00
Wang Li a036754979
spi: fsl-lpspi: Fix PM reference leak in lpspi_prepare_xfer_hardware()
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Fixes: 944c01a889 ("spi: lpspi: enable runtime pm for lpspi")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Li <wangli74@huawei.com>
Link: https://lore.kernel.org/r/20210409095430.29868-1-wangli74@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:43:59 +01:00
Tian Tao 59ebbe40fb
spi: simplify devm_spi_register_controller
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/1617843307-53853-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:43:58 +01:00
Wei Yongjun 9b844b0871
spi: dln2: Fix reference leak to master
Call spi_master_get() holds the reference count to master device, thus
we need an additional spi_master_put() call to reduce the reference
count, otherwise we will leak a reference to master.

This commit fix it by removing the unnecessary spi_master_get().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210409082955.2907950-1-weiyongjun1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:43:57 +01:00
Quanyang Wang 41d3109300
spi: spi-zynqmp-gqspi: fix incorrect operating mode in zynqmp_qspi_read_op
When starting a read operation, we should call zynqmp_qspi_setuprxdma
first to set xqspi->mode according to xqspi->bytes_to_receive and
to calculate correct xqspi->dma_rx_bytes. Then in the function
zynqmp_qspi_fillgenfifo, generate the appropriate command with
operating mode and bytes to transfer, and fill the GENFIFO with
the command to perform the read operation.

Calling zynqmp_qspi_fillgenfifo before zynqmp_qspi_setuprxdma will
result in incorrect transfer length and operating mode. So change
the calling order to fix this issue.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Reviewed-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Link: https://lore.kernel.org/r/20210408040223.23134-5-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:40:50 +01:00
Quanyang Wang 8ad07d79bd
spi: spi-zynqmp-gqspi: transmit dummy circles by using the controller's internal functionality
There is a data corruption issue that occurs in the reading operation
(cmd:0x6c) when transmitting common data as dummy circles.

The gqspi controller has the functionality to send dummy clock circles.
When writing data with the fields [receive, transmit, data_xfer] = [0,0,1]
to the Generic FIFO, and configuring the correct SPI mode, the controller
will transmit dummy circles.

So let's switch to hardware dummy cycles transfer to fix this issue.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Reviewed-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Link: https://lore.kernel.org/r/20210408040223.23134-4-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:40:49 +01:00
Quanyang Wang a0f65be6e8
spi: spi-zynqmp-gqspi: add mutex locking for exec_op
The spi-mem framework has no locking to prevent ctlr->mem_ops->exec_op
from concurrency. So add the locking to zynqmp_qspi_exec_op.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Reviewed-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Link: https://lore.kernel.org/r/20210408040223.23134-3-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:40:48 +01:00
Quanyang Wang a16bff68b7
spi: spi-zynqmp-gqspi: use wait_for_completion_timeout to make zynqmp_qspi_exec_op not interruptible
When Ctrl+C occurs during the process of zynqmp_qspi_exec_op, the function
wait_for_completion_interruptible_timeout will return a non-zero value
-ERESTARTSYS immediately. This will disrupt the SPI memory operation
because the data transmitting may begin before the command or address
transmitting completes. Use wait_for_completion_timeout to prevent
the process from being interruptible.

This patch fixes the error as below:
root@xilinx-zynqmp:~# flash_erase /dev/mtd3 0 0
Erasing 4 Kibyte @ 3d000 --  4 % complete
    (Press Ctrl+C)
[  169.581911] zynqmp-qspi ff0f0000.spi: Chip select timed out
[  170.585907] zynqmp-qspi ff0f0000.spi: Chip select timed out
[  171.589910] zynqmp-qspi ff0f0000.spi: Chip select timed out
[  172.593910] zynqmp-qspi ff0f0000.spi: Chip select timed out
[  173.597907] zynqmp-qspi ff0f0000.spi: Chip select timed out
[  173.603480] spi-nor spi0.0: Erase operation failed.
[  173.608368] spi-nor spi0.0: Attempted to modify a protected sector.

Fixes: 1c26372e5a ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework")
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Reviewed-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Link: https://lore.kernel.org/r/20210408040223.23134-2-quanyang.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-09 13:40:47 +01:00
Yang Yingliang 5fed9fe5b4
spi: fsl: add missing iounmap() on error in of_fsl_spi_probe()
Add the missing iounmap() before return from of_fsl_spi_probe()
in the error handling case.

Fixes: 0f0581b24b ("spi: fsl: Convert to use CS GPIO descriptors")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210401140350.1677925-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-08 15:21:58 +01:00
Linus Walleij d570838efb
ARM/spi: spear: Drop PL022 num_chipselect
A previous refactoring moved the chip select number handling
to the SPI core and we missed a leftover platform data user
in the ST spear platform. The spear is not using this
chipselect or PL022 for anything and should be using device
tree like the rest of the platform so just delete the
offending platform data.

Cc: Viresh Kumar <vireshk@kernel.org>
Cc: Shiraz Hashim <shiraz.linux.kernel@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20210408075045.3435046-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-08 15:21:58 +01:00
William A. Kennington III 794aaf0144
spi: Fix use-after-free with devm_spi_alloc_*
We can't rely on the contents of the devres list during
spi_unregister_controller(), as the list is already torn down at the
time we perform devres_find() for devm_spi_release_controller. This
causes devices registered with devm_spi_alloc_{master,slave}() to be
mistakenly identified as legacy, non-devm managed devices and have their
reference counters decremented below 0.

------------[ cut here ]------------
WARNING: CPU: 1 PID: 660 at lib/refcount.c:28 refcount_warn_saturate+0x108/0x174
[<b0396f04>] (refcount_warn_saturate) from [<b03c56a4>] (kobject_put+0x90/0x98)
[<b03c5614>] (kobject_put) from [<b0447b4c>] (put_device+0x20/0x24)
 r4:b6700140
[<b0447b2c>] (put_device) from [<b07515e8>] (devm_spi_release_controller+0x3c/0x40)
[<b07515ac>] (devm_spi_release_controller) from [<b045343c>] (release_nodes+0x84/0xc4)
 r5:b6700180 r4:b6700100
[<b04533b8>] (release_nodes) from [<b0454160>] (devres_release_all+0x5c/0x60)
 r8:b1638c54 r7:b117ad94 r6:b1638c10 r5:b117ad94 r4:b163dc10
[<b0454104>] (devres_release_all) from [<b044e41c>] (__device_release_driver+0x144/0x1ec)
 r5:b117ad94 r4:b163dc10
[<b044e2d8>] (__device_release_driver) from [<b044f70c>] (device_driver_detach+0x84/0xa0)
 r9:00000000 r8:00000000 r7:b117ad94 r6:b163dc54 r5:b1638c10 r4:b163dc10
[<b044f688>] (device_driver_detach) from [<b044d274>] (unbind_store+0xe4/0xf8)

Instead, determine the devm allocation state as a flag on the
controller which is guaranteed to be stable during cleanup.

Fixes: 5e844cc37a ("spi: Introduce device-managed SPI controller allocation")
Signed-off-by: William A. Kennington III <wak@google.com>
Link: https://lore.kernel.org/r/20210407095527.2771582-1-wak@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-08 15:08:53 +01:00
Dinghao Liu a21fbc4280
spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe
When platform_get_irq() fails, a pairing PM usage counter
increment is needed to keep the counter balanced. It's the
same for the following error paths.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20210408092559.3824-1-dinghao.liu@zju.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-08 15:08:52 +01:00
Tian Tao 0e6521f13c
spi: orion: Use device_get_match_data() helper
Use the device_get_match_data() helper instead of open coding.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1617258288-1490-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-07 16:58:35 +01:00
Jay Fang 9a446cf97a
spi: hisi-kunpeng: Fix Woverflow warning on conversion
Fix warning Woverflow on type conversion reported on x86_64:

  drivers/spi/spi-hisi-kunpeng.c:361:9: warning: conversion from 'long unsigned int' to 'u32'
  {aka 'unsigned int'} changes value from '18446744073709551600' to '4294967280' [-Woverflow]

The registers are 32 bit, so fix by casting to u32.

Fixes: c770d8631e ("spi: Add HiSilicon SPI Controller Driver for Kunpeng SoCs")
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1617762660-54681-1-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-07 16:58:34 +01:00
Wan Jiabing d6644a1c2e
spi: Remove repeated struct declaration
struct spi_transfer is declared twice. One is declared at 24th line.
The blew one is not needed though. Remove the duplicate.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20210401065904.994121-1-wanjiabing@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-01 12:19:45 +01:00
Mark Brown e667450802
Merge series "Convert Cadence QSPI bindings to yaml" from Pratyush Yadav <p.yadav@ti.com>:
Hi,

This series picks up Ramuthevar's effort on converting the Cadence QSPI
bindings to yaml [0]. During the conversion process, I discovered that
some TI device tree files were not using the compatible correctly. Those
are fixed in patches 1-3.

[0] https://patchwork.kernel.org/project/spi-devel-general/patch/20201116031003.19062-6-vadivel.muruganx.ramuthevar@linux.intel.com/

Pratyush Yadav (3):
  arm64: dts: ti: k3-j721e-mcu: Fix ospi compatible
  arm64: dts: ti: k3-j7200-mcu: Fix ospi compatible
  arm64: dts: ti: k3-am64-main: Fix ospi compatible

Ramuthevar Vadivel Murugan (1):
  dt-bindings: spi: Convert cadence-quadspi.txt to cadence-quadspi.yaml

 .../bindings/spi/cadence-quadspi.txt          |  68 ---------
 .../bindings/spi/cdns,qspi-nor.yaml           | 143 ++++++++++++++++++
 arch/arm64/boot/dts/ti/k3-am64-main.dtsi      |   2 +-
 .../boot/dts/ti/k3-j7200-mcu-wakeup.dtsi      |   2 +-
 .../boot/dts/ti/k3-j721e-mcu-wakeup.dtsi      |   4 +-
 5 files changed, 147 insertions(+), 72 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/spi/cadence-quadspi.txt
 create mode 100644 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml

--
2.30.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
2021-04-01 10:25:17 +01:00
Ramuthevar Vadivel Murugan e54338004c
spi: Convert cadence-quadspi.txt to cadence-quadspi.yaml
There is no way as of now to have a parent or bus defining properties
for child nodes. For now, avoid it in the example to silence warnings on
dt_schema_check. We can figure out how to deal with actual dts files
later.

[p.yadav@ti.com: Fix how compatible is defined, make reset optional, fix
minor typos, remove subnode properties in example, update commit
message.]

Signed-off-by: Ramuthevar Vadivel Murugan <vadivel.muruganx.ramuthevar@linux.intel.com>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210326130034.15231-5-p.yadav@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-01 08:31:53 +01:00
Jay Fang c770d8631e
spi: Add HiSilicon SPI Controller Driver for Kunpeng SoCs
This driver supports SPI Controller for HiSilicon Kunpeng SoCs. This
driver supports SPI operations using FIFO mode of transfer.

DMA is not supported, and we just use IRQ mode for operation completion
notification.

Only ACPI firmware is supported.

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616836200-45827-1-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31 18:04:19 +01:00
Linus Walleij 8bb2dbf1e1
spi: pl022: Convert to use GPIO descriptors
This converts the PL022 driver to use GPIO descriptors
instead of the old global GPIO numberspace. Since the
driver handles messages on its own it needs to manage
the GPIO descriptor directly.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210330164907.2346010-3-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31 13:54:29 +01:00
Linus Walleij 77f983a9df
spi: pl022: Use GPIOs looked up by the core
The SPI core looks up GPIO lines from the device tree,
so let's stop trying to do that on our own and rely
on the core to do this for us.

In addition to the GPIO line we also need to keep
track of the chip select index separately, as the native
chip select needs this index. The driver was reusing
the same GPIO array for native chip select indices,
so keep this in a separate state variable instead.

The facility to pass in custom GPIO lines from the
platform data can go, because even if we do have
out-of-tree code that want to use platform data, they
can soon pass in GPIOs using machine GPIO descriptor
tables which will be available after the next step
when we convert the driver to using GPIO descriptors.

The implicit inclusion of <linux/of.h> is made
explicit as we no longer need to include <linux/of_gpio.h>.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210330164907.2346010-2-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31 13:54:28 +01:00
Linus Walleij 4179e576b5
spi: pl022: Drop custom per-chip cs_control
Drop the custom cs_control() assigned through platform data,
we have no in-tree users and the only out-of-tree use I have
ever seen of this facility is to pull GPIO lines, which is
something the driver can already do for us.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210330164907.2346010-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31 13:54:27 +01:00
Linus Walleij 413c601e8f
spi: pl022: User more sensible defaults
When using the device tree, which must be considered normal
these days, in order to get some kind of normal functionality
out of the PL022 users have to actively go into the device
tree and edit the SPI clients like this:

spi {
  compatible = "arm,pl022";
  num-cs = <1>;
  cs-gpios = <&gpio 0 GPIO_ACTIVE_LOW>;

  foo@0 {
    compatible = "foo";
    reg = <0>;
    pl022,interface = <0>;
    pl022,com-mode = <0>;
  };
};

Otherwise the PL022 will come up as a client (slave) and
using polling mode. This is quite unintuitive and many users
will get their device trees wrong.

Alter the defaults such that we come up in host mode
(master) and use interrupt mode.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210328121530.1983081-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-29 17:29:07 +01:00
Mark Brown 85c0ed12f7
Merge series "enable flexspi support on imx8mp" from Heiko Schocher <hs@denx.de>:
add compatible entry in nxp_fspi driver for imx8mp

@Shawn: If this series is accepted, can you apply the DTS patches from
series v2?
http://lists.infradead.org/pipermail/linux-arm-kernel/2021-March/643292.html
http://lists.infradead.org/pipermail/linux-arm-kernel/2021-March/643293.html

Changes in v4:
rebased against:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
a43e89624baea ("Merge remote-tracking branch 'spi/for-5.13' into spi-next")

Changes in v3:
- seperate spi changes from series:
  http://lists.infradead.org/pipermail/linux-arm-kernel/2021-March/643289.html
  into own series as Kuldeep suggested and rebased against
  git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
  144c79ef33 ("Merge tag 'perf-tools-fixes-for-v5.12-2020-03-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux")
- no changes, rebased against
  git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
  144c79ef33 Merge tag 'perf-tools-fixes-for-v5.12-2020-03-07' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Changes in v2:
- work in comments from Marco
  add own compatible entry for imx8mp

Heiko Schocher (2):
  spi: fspi: enable fspi driver for on imx8mp
  dt-bindings: spi: add compatible entry for imx8mp in FlexSPI
    controller

 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt | 1 +
 drivers/spi/spi-nxp-fspi.c                             | 1 +
 2 files changed, 2 insertions(+)

--
2.29.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
2021-03-25 17:32:02 +00:00
Eddie James 3ed4c84cc7
spi: fsi: Remove multiple sequenced ops for restricted chips
Updated restricted chips have trouble processing multiple sequenced
operations. So remove the capability to sequence multiple operations and
reduce the maximum transfer size to 8 bytes.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/20210324220516.41192-1-eajames@linux.ibm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:59:44 +00:00
Heiko Schocher 2801a62dfa
dt-bindings: spi: add compatible entry for imx8mp in FlexSPI controller
add compatible entry "nxp,imx8mp-fspi" in NXP FlexSPI controller

Signed-off-by: Heiko Schocher <hs@denx.de>
Link: https://lore.kernel.org/r/20210316075928.1763460-3-hs@denx.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:59:43 +00:00
Heiko Schocher 0467a97367
spi: fspi: enable fspi driver for on imx8mp
add compatible entry in nxp_fspi driver for imx8mp.

Signed-off-by: Heiko Schocher <hs@denx.de>
Link: https://lore.kernel.org/r/20210316075928.1763460-2-hs@denx.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:59:42 +00:00
Jay Fang 9d53768721
spi: pl022: Fix trailing whitespace
Fix checkpatch error:

  ERROR: trailing whitespace
  #1198: FILE: spi-pl022.c:1198:

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-12-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:12 +00:00
Jay Fang 0262179996
spi: rockchip: Fix code indent should use tabs where possible
Fix checkpatch errors:

  ERROR: code indent should use tabs where possible
  #484: FILE: spi-rockchip.c:484:
  +^I        | CR0_BHT_8BIT << CR0_BHT_OFFSET$
  ERROR: code indent should use tabs where possible
  #485: FILE: spi-rockchip.c:485:
  +^I        | CR0_SSD_ONE  << CR0_SSD_OFFSET$
  ERROR: code indent should use tabs where possible
  #486: FILE: spi-rockchip.c:486:
  +^I        | CR0_EM_BIG   << CR0_EM_OFFSET;$

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-11-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:11 +00:00
Jay Fang 6ca6ad908e
spi: spi-mem: Fix code indent should use tabs where possible
Fix checkpatch errors:

  ERROR: code indent should use tabs where possible
  #624: FILE: spi-mem.c:624:
  ERROR: code indent should use tabs where possible
  #626: FILE: spi-mem.c:626:
  ERROR: code indent should use tabs where possible
  #627: FILE: spi-mem.c:627:

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-10-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:10 +00:00
Jay Fang 45793de7bf
spi: jcore: Fix trailing statements should be on next line
Fix checkpatch error:

  ERROR: trailing statements should be on next line
  #85: FILE: spi-jcore.c:85:
  +	if (speed == hw->speed_hz) return;

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-9-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:09 +00:00
Jay Fang f96c19fab3
spi: spi-bitbang: Fix open brace following function definitions go on the next line
Fix checkpatch errors:

  ERROR: open brace '{' following function definitions go on the next line
  #54: FILE: spi-bitbang.c:54:
  ERROR: open brace '{' following function definitions go on the next line
  #82: FILE: spi-bitbang.c:82:
  ERROR: open brace '{' following function definitions go on the next line
  #110: FILE: spi-bitbang.c:110:

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-8-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:08 +00:00
Jay Fang 211f8a0a39
spi: dln2: Fix open brace following function definitions go on the next line
Fix checkpatch error:

  ERROR: open brace '{' following function definitions go on the next line
  #545: FILE: spi-dln2.c:545:
  +static int dln2_spi_rdwr(struct dln2_spi *dln2, const u8 *tx_data,
  +			 u8 *rx_data, u16 data_len, u8 attr) {

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1616566602-13894-7-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:51:08 +00:00