platform/kernel/linux-starfive.git
2 years agospi: cadence: fix platform_get_irq.cocci warning
Yihao Han [Thu, 3 Mar 2022 12:50:54 +0000 (04:50 -0800)]
spi: cadence: fix platform_get_irq.cocci warning

Remove dev_err() messages after platform_get_irq*() failures.
platform_get_irq() already prints an error.

Generated by: scripts/coccinelle/api/platform_get_irq.cocci

Signed-off-by: Yihao Han <hanyihao@vivo.com>
Link: https://lore.kernel.org/r/20220303125054.3574-1-hanyihao@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Update NXP Flexspi maintainer details
Kuldeep Singh [Wed, 2 Mar 2022 19:29:15 +0000 (00:59 +0530)]
spi: Update NXP Flexspi maintainer details

Add Han Xu as flexspi maintainer.
Also, update my email address as previous one is not working anymore.

Signed-off-by: Kuldeep Singh <singh.kuldeep87k@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220302192915.6193-1-singh.kuldeep87k@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Use of_device_get_match_data()
Minghao Chi (CGEL ZTE) [Thu, 3 Mar 2022 09:21:31 +0000 (09:21 +0000)]
spi: Use of_device_get_match_data()

Use of_device_get_match_data() to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/r/20220303092131.2060044-1-chi.minghao@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: spi-zynqmp-gqspi: Handle error for dma_set_mask
Jiasheng Jiang [Wed, 2 Mar 2022 09:20:51 +0000 (17:20 +0800)]
spi: spi-zynqmp-gqspi: Handle error for dma_set_mask

As the potential failure of the dma_set_mask(),
it should be better to check it and return error
if fails.

Fixes: 126bdb606fd2 ("spi: spi-zynqmp-gqspi: return -ENOMEM if dma_map_single fails")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220302092051.121343-1-jiasheng@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: mediatek: Set min size for 'mediatek,pad-select'
Rob Herring [Tue, 1 Mar 2022 21:23:57 +0000 (15:23 -0600)]
spi: dt-bindings: mediatek: Set min size for 'mediatek,pad-select'

The minimum array length defaults to the same size as the maximum. For
'mediatek,pad-select', the example has a length of 2 and in-tree .dts
files have a length of 1, but the schema says the length must be 4.

There's currently no warning in the example because the schema fixups
are not handling this case correctly.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220301212358.1887668-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: renesas,rspi: Drop comment for generic compatible string
Lad Prabhakar [Tue, 1 Mar 2022 13:42:43 +0000 (13:42 +0000)]
spi: dt-bindings: renesas,rspi: Drop comment for generic compatible string

Drop comment "# RZ/A and RZ/G2{L,LC}" for generic compatible string
"renesas,rspi-rz" as this will avoid changing the line for every new SoC
addition.

Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20220301134244.20174-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: renesas,rspi: Document RZ/V2L SoC
Lad Prabhakar [Sun, 27 Feb 2022 22:59:56 +0000 (22:59 +0000)]
spi: dt-bindings: renesas,rspi: Document RZ/V2L SoC

Add RSPI binding documentation for Renesas RZ/V2L SoC.

RSPI block is identical to one found on RZ/A, so no driver changes are
required. The fallback compatible string "renesas,rspi-rz" will be used
on RZ/V2L.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20220227225956.29570-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: use specific last_cs instead of last_cs_enable
Yun Zhou [Thu, 17 Feb 2022 14:12:34 +0000 (22:12 +0800)]
spi: use specific last_cs instead of last_cs_enable

Commit d40f0b6f2e21 instroduced last_cs_enable to avoid setting
chipselect if it's not necessary, but it also introduces a bug. The
chipselect may not be set correctly on multi-device SPI busses. The
reason is that we can't judge the chipselect by bool last_cs_enable,
since chipselect may be modified after other devices were accessed.

So we should record the specific state of chipselect in case of
confusion.

Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
Link: https://lore.kernel.org/r/20220217141234.72737-1-yun.zhou@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Constify struct pxa_spi_info variables
Andy Shevchenko [Fri, 25 Feb 2022 17:23:50 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Constify struct pxa_spi_info variables

Now when there are no dynamical changes required, we may
constify struct pxa_spi_info variables.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-11-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Drop temporary storage use for a handful of members
Andy Shevchenko [Fri, 25 Feb 2022 17:23:49 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Drop temporary storage use for a handful of members

Instead of using temporary storage, assign the values directly
to the corresponding struct pxa2xx_spi_controller members.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-10-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:48 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register()

Extract pxa2xx_spi_pci_clk_register() from ->probe() in order to reuse it
later on for getting rid of max_clk_rate temporary storage.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-9-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:47 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup()

All of the LPSS devices are using DMA and set the parameters up,
hence no need to test for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-8-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Replace enum with direct use of PCI IDs
Andy Shevchenko [Fri, 25 Feb 2022 17:23:46 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Replace enum with direct use of PCI IDs

Instead of creating an abstraction on top of PCI IDs, just use them directly.
The corresponding enum can be dropped.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Move max_clk_rate assignment to ->setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:45 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Move max_clk_rate assignment to ->setup()

Move max_clk_rate to the corresponding ->setup() function to unify
with the rest.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Move dma_burst_size assignment to ->setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:44 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Move dma_burst_size assignment to ->setup()

Instead of using conditional, move dma_burst_size to the corresponding
->setup() function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Move port_id assignment to ->setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:43 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Move port_id assignment to ->setup()

Instead of using conditional, move port_id to the corresponding
->setup() functions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Drop redundant NULL check in ->probe()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:42 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Drop redundant NULL check in ->probe()

Since all platforms are using ->setup() function, drop unneeded check.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Refactor Quark X1000 to use ->setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:41 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Refactor Quark X1000 to use ->setup()

Refactor Quark X1000 handling code to use ->setup() instead of using
the configuration data structure directly.

It will allow to refactor further to avoid intermediate storage for
the used configuration parameters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Refactor CE4100 to use ->setup()
Andy Shevchenko [Fri, 25 Feb 2022 17:23:40 +0000 (19:23 +0200)]
spi: pxa2xx-pci: Refactor CE4100 to use ->setup()

Refactor CE4100 handling code to use ->setup() instead of spreading
potentially confusing conditional.

Besides that, it will allow to refactor further to avoid intermediate
storage for the used configuration parameters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220225172350.69797-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: remove unused required property
Li-hao Kuo [Fri, 25 Feb 2022 06:31:53 +0000 (14:31 +0800)]
spi: dt-bindings: remove unused required property

fix issue
/builds/robherring/linux-dt/Documentation/devicetree/bindings/spi/spi-sunplus-sp7021.example.dt.yaml:
spi@9C002D80: 'clocks-names' is a required property
From schema: /builds/robherring/linux-dt/Documentation/devicetree/bindings/spi/spi-sunplus-sp7021.yaml
delete unused required(clock-name)

Fixes: 3b8ab4da34 ("spi: Fix test error for sp7021")

Reported-by: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
Link: https://lore.kernel.org/r/097bbc8b703b17e8fb3e3f6f6d2f97fe668bd5c5.1645770648.git.lhjeff911@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoTegra QUAD SPI ACPI & device support
Mark Brown [Thu, 24 Feb 2022 22:55:45 +0000 (22:55 +0000)]
Tegra QUAD SPI ACPI & device support

Merge series from Krishna Yarlagadda <kyarlagadda@nvidia.com>:

Add ACPI support for Tegra210 QUAD SPI driver and a new compatilbe.

2 years agospi: tegra210-quad: add new chips to compatible
Krishna Yarlagadda [Tue, 22 Feb 2022 17:56:09 +0000 (23:26 +0530)]
spi: tegra210-quad: add new chips to compatible

Add support for Tegra234 and soc data to select capabilities.

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Link: https://lore.kernel.org/r/20220222175611.58051-4-kyarlagadda@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Add Tegra234 QUAD SPI compatible
Krishna Yarlagadda [Tue, 22 Feb 2022 17:56:08 +0000 (23:26 +0530)]
spi: Add Tegra234 QUAD SPI compatible

Add compatible string for Tegra234 for Tegra QUAD SPI

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Link: https://lore.kernel.org/r/20220222175611.58051-3-kyarlagadda@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: tegra210-quad: use device_reset method
Krishna Yarlagadda [Tue, 22 Feb 2022 17:56:07 +0000 (23:26 +0530)]
spi: tegra210-quad: use device_reset method

Use device_reset api to replace duplicate code in driver to call
reset_control_get api with reset handle.

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Link: https://lore.kernel.org/r/20220222175611.58051-2-kyarlagadda@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Balance reference count for PCI DMA device
Andy Shevchenko [Wed, 23 Feb 2022 19:16:37 +0000 (21:16 +0200)]
spi: pxa2xx-pci: Balance reference count for PCI DMA device

The pci_get_slot() increases its reference count, the caller
must decrement the reference count by calling pci_dev_put().

Fixes: 743485ea3bee ("spi: pxa2xx-pci: Do a specific setup in a separate function")
Fixes: 25014521603f ("spi: pxa2xx-pci: Enable DMA for Intel Merrifield")
Reported-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220223191637.31147-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx-pci: Do not dereference fwnode in struct device
Andy Shevchenko [Wed, 23 Feb 2022 19:19:48 +0000 (21:19 +0200)]
spi: pxa2xx-pci: Do not dereference fwnode in struct device

In order to make the underneath API easier to change in the future,
prevent users from dereferencing fwnode from struct device.
Instead, use the specific dev_fwnode() API for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220223191948.31325-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: add missing pci_dev_put() before return
Wang Qing [Tue, 15 Feb 2022 02:00:07 +0000 (18:00 -0800)]
spi: add missing pci_dev_put() before return

pci_get_slot() increases its reference count, the caller must
decrement the reference count by calling pci_dev_put()

Signed-off-by: Wang Qing <wangqing@vivo.com>
Link: https://lore.kernel.org/r/1644890407-65167-1-git-send-email-wangqing@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: gpio: Implement LSB First bitbang support
Andreas Färber [Sat, 19 Feb 2022 13:15:48 +0000 (14:15 +0100)]
spi: gpio: Implement LSB First bitbang support

Add support for slave DT property spi-lsb-first, i.e., SPI_LSB_FIRST mode.
Duplicate the inline helpers bitbang_txrx_be_cpha{0,1} as LE versions.
Conditionally call them from all the spi-gpio txrx_word callbacks.

Some alternatives to this implementation approach were discussed back
then [0], but eventually it was considered reasonable.

[0] https://lore.kernel.org/linux-arm-kernel/20191212033952.5967-8-afaerber@suse.de/

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Christian Hewitt <christianshewitt@gmail.com>
Link: https://lore.kernel.org/r/feac3377-4ad1-77d8-9a18-3588d80fb909@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: stm32: ignore Rx queue not empty in stm32f4 Tx only mode
Ahmad Fatoum [Tue, 1 Feb 2022 11:51:41 +0000 (12:51 +0100)]
spi: stm32: ignore Rx queue not empty in stm32f4 Tx only mode

STM32F4_SPI_SR_RXNE and STM32F4_SPI_SR_OVR are distinct bits in the same
status register.  ~STM32F4_SPI_SR_OVR | STM32F4_SPI_SR_RXNE is thus
equal to ~STM32F4_SPI_SR_OVR.

The original intention was likely for transmission-only transfers to
ignore interrupts both for when the Rx queue has bytes (RXNE) as well
as when these bytes haven't been read in time (OVR).

Fix the typo by adding the missing parenthesis.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20220201115142.3999860-1-a.fatoum@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Stacked/parallel memories bindings
Mark Brown [Mon, 21 Feb 2022 15:22:33 +0000 (15:22 +0000)]
spi: Stacked/parallel memories bindings

Merge series from Miquel Raynal <miquel.raynal@bootlin.com>:

DT bindings for stacked and parallel flash/memory devices.

base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07

2 years agospi: Use of_device_get_match_data()
Minghao Chi (CGEL ZTE) [Mon, 21 Feb 2022 02:02:33 +0000 (02:02 +0000)]
spi: Use of_device_get_match_data()

Use of_device_get_match_data() to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
Link: https://lore.kernel.org/r/20220221020233.1925154-1-chi.minghao@zte.com.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: Add an example with two stacked flashes
Miquel Raynal [Wed, 26 Jan 2022 11:26:07 +0000 (12:26 +0100)]
spi: dt-bindings: Add an example with two stacked flashes

Provide an example of how to describe two flashes in eg. stacked mode.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220126112608.955728-4-miquel.raynal@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: Describe stacked/parallel memories modes
Miquel Raynal [Wed, 26 Jan 2022 11:26:06 +0000 (12:26 +0100)]
spi: dt-bindings: Describe stacked/parallel memories modes

Describe two new memories modes:
- A stacked mode when the bus is common but the address space extended
  with an additinals wires.
- A parallel mode with parallel busses accessing parallel flashes where
  the data is spread.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220126112608.955728-3-miquel.raynal@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agodt-bindings: mtd: spi-nor: Allow two CS per device
Miquel Raynal [Wed, 26 Jan 2022 11:26:05 +0000 (12:26 +0100)]
dt-bindings: mtd: spi-nor: Allow two CS per device

The Xilinx QSPI controller has two advanced modes which allow the
controller to behave differently and consider two flashes as one single
storage.

One of these two modes is quite complex to support from a binding point
of view and is the dual parallel memories. In this mode, each byte of
data is stored in both devices: the even bits in one, the odd bits in
the other. The split is automatically handled by the QSPI controller and
is transparent for the user.

The other mode is simpler to support, it is called dual stacked
memories. The controller shares the same SPI bus but each of the devices
contain half of the data. Once in this mode, the controller does not
follow CS requests but instead internally wires the two CS levels with
the value of the most significant address bit.

Supporting these two modes will involve core changes which include the
possibility of providing two CS for a single SPI device

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20220126112608.955728-2-miquel.raynal@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: use sysfs_emit() for printing statistics and add trailing newline
Heiner Kallweit [Fri, 18 Feb 2022 13:58:35 +0000 (14:58 +0100)]
spi: use sysfs_emit() for printing statistics and add trailing newline

Use dedicated function sysfs_emit() that does some extra checking,
e.g. to ensure that no more than PAGESIZE bytes are written.
In addition add a trailing newline to the output, that makes it
better readable from the console.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/56e1588d-d53b-73e9-fdc8-7fe30bf91f11@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: clean up some inconsistent indenting
Yang Li [Thu, 17 Feb 2022 01:00:24 +0000 (09:00 +0800)]
spi: clean up some inconsistent indenting

Eliminate the follow smatch warning:
drivers/spi/spi-sunplus-sp7021.c:379 sp7021_spi_slave_transfer_one()
warn: inconsistent indenting

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220217010024.111904-1-yang.lee@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: New support and problem adjustment of SPI rockchip
Mark Brown [Thu, 17 Feb 2022 18:30:55 +0000 (18:30 +0000)]
spi: New support and problem adjustment of SPI rockchip

Merge series from Jon Lin <jon.lin@rock-chips.com>:

A collection of fixes and support for new features in the Rockchip
driver.

base-commit: 80808768e41324d2e23de89972b5406c1020e6e4

2 years agospi: rockchip: clear interrupt status in error handler
Jon Lin [Wed, 16 Feb 2022 01:40:28 +0000 (09:40 +0800)]
spi: rockchip: clear interrupt status in error handler

The interrupt status bit of the previous error data transmition will
affect the next operation and cause continuous SPI transmission failure.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-7-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: rockchip: Suspend and resume the bus during NOIRQ_SYSTEM_SLEEP_PM ops
shengfei Xu [Wed, 16 Feb 2022 01:40:27 +0000 (09:40 +0800)]
spi: rockchip: Suspend and resume the bus during NOIRQ_SYSTEM_SLEEP_PM ops

the wakeup interrupt handler which is guaranteed not to run while
@resume noirq() is being executed. the patch can help to avoid the
wakeup source try to access spi when the spi is in suspend mode.

Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-6-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: rockchip: Preset cs-high and clk polarity in setup progress
Jon Lin [Wed, 16 Feb 2022 01:40:26 +0000 (09:40 +0800)]
spi: rockchip: Preset cs-high and clk polarity in setup progress

After power up, the cs and clock is in default status, and the cs-high
and clock polarity dts property configuration will take no effect until
the calling of rockchip_spi_config in the first transmission.
So preset them to make sure a correct voltage before the first
transmission coming.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-5-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: rockchip: Stop spi slave dma receiver when cs inactive
Jon Lin [Wed, 16 Feb 2022 01:40:25 +0000 (09:40 +0800)]
spi: rockchip: Stop spi slave dma receiver when cs inactive

The spi which's version is higher than ver 2 will automatically
enable this feature.

If the length of master transmission is uncertain, the RK spi slave
is better to automatically stop after cs inactive instead of waiting
for xfer_completion forever.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-4-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: rockchip: terminate dma transmission when slave abort
Jon Lin [Wed, 16 Feb 2022 01:40:24 +0000 (09:40 +0800)]
spi: rockchip: terminate dma transmission when slave abort

After slave abort, all DMA should be stopped, or it will affect the
next transmission and maybe abort again.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-3-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: rockchip: Fix error in getting num-cs property
Jon Lin [Wed, 16 Feb 2022 01:40:23 +0000 (09:40 +0800)]
spi: rockchip: Fix error in getting num-cs property

Get num-cs u32 from dts of_node property rather than u16.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://lore.kernel.org/r/20220216014028.8123-2-jon.lin@rock-chips.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx: Add support for Intel Raptor Lake PCH-S
Jarkko Nikula [Wed, 16 Feb 2022 09:13:17 +0000 (11:13 +0200)]
spi: pxa2xx: Add support for Intel Raptor Lake PCH-S

Add support for LPSS SPI on Intel Raptor Lake PCH-S. It has four
controllers each having two chip selects.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20220216091317.1302254-1-jarkko.nikula@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: amd: Fix building without ACPI enabled
André Almeida [Wed, 16 Feb 2022 16:27:19 +0000 (13:27 -0300)]
spi: amd: Fix building without ACPI enabled

Commit 209043554915 ("spi: amd: Add support for version AMDI0062")
removed the cast ACPI_PTR() for no good reason. This wrapper is
important to make sure that the driver can be compiled with or without
CONFIG_ACPI enabled, useful for compiling test. Give back the cast so
compilation works again.

Fixes: 209043554915 ("spi: amd: Add support for version AMDI0062")
Signed-off-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20220216162719.116062-1-andrealmeid@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: intel-pci: Add support for Intel Ice Lake-N SPI serial flash
Andy Shevchenko [Tue, 15 Feb 2022 13:51:39 +0000 (15:51 +0200)]
spi: intel-pci: Add support for Intel Ice Lake-N SPI serial flash

Intel Ice Lake-N has the same SPI serial flash controller as Ice Lake-LP.
Add Ice Lake-N PCI ID to the driver list of supported devices.

The device can be found on MacBookPro16,2 [1].

[1]: https://linux-hardware.org/?probe=f1c5cf0c43

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20220215135139.4328-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: amd: Add support for new controller version
Mark Brown [Tue, 15 Feb 2022 12:53:32 +0000 (12:53 +0000)]
spi: amd: Add support for new controller version

Merge series from André Almeida <andrealmeid@collabora.com>:

This series do some cleanup and add support for new controller version,
AMDI0062.

2 years agomtd: spi-nor / spi / MFD: Convert intel-spi to SPI MEM
Mark Brown [Tue, 15 Feb 2022 12:53:31 +0000 (12:53 +0000)]
mtd: spi-nor / spi / MFD: Convert intel-spi to SPI MEM

Merge series from Mika Westerberg <mika.westerberg@linux.intel.com>:

Based on discussion on the patch I sent some time ago here:

  http://lists.infradead.org/pipermail/linux-mtd/2021-June/086867.html

it turns out that the preferred way to deal with the SPI flash controller
drivers is through SPI MEM which is part of Linux SPI subsystem.

This series does that for the intel-spi driver. This also renames the
driver to follow the convention used in the SPI subsystem. The first patch
improves the write protection handling to be slightly more safer. The
following two patches do the conversion itself. Note the Intel SPI flash
controller only allows commands such as read, write and so on and it
internally uses whatever addressing etc. it figured from the SFDP on the
flash device.

base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07

2 years agospi: Retire legacy GPIO handling
Linus Walleij [Thu, 10 Feb 2022 23:19:54 +0000 (00:19 +0100)]
spi: Retire legacy GPIO handling

All drivers using GPIOs as chip select have been rewritten to use
GPIO descriptors passing the ->use_gpio_descriptors flag. Retire
the code and fields used by the legacy GPIO API.

Do not drop the ->use_gpio_descriptors flag: it now only indicates
that we want to use GPIOs in addition to native chip selects.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220210231954.807904-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Fix warning for Clang build and simplify code
Li-hao Kuo [Mon, 14 Feb 2022 02:20:11 +0000 (10:20 +0800)]
spi: Fix warning for Clang build and simplify code

Clang build fails with
spi-sunplus-sp7021.c:405:2: error: variable 'ret' is used
  uninitialized whenever switch default is taken
        default:

simplify code

Restore initializing ret. and add return error at default

Fixes: 47e8fe57a66f ("spi: Modify irq request position and modify parameters")
Reported-by: Tom Rix <trix@redhat.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reported-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
Link: https://lore.kernel.org/r/7d91e6ce29f9a8df2c53a47b4b977664020e237a.1644805060.git.lhjeff911@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoDocumentation / MTD: Rename the intel-spi driver
Mika Westerberg [Wed, 9 Feb 2022 12:27:06 +0000 (15:27 +0300)]
Documentation / MTD: Rename the intel-spi driver

Since the driver is renamed (and moved) update the BIOS upgrade guide
accordingly from intel-spi to spi-intel. Keep the guide under MTD
documentation because this is pretty much still about MTD and SPI-NOR.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mauro Lima <mauro.lima@eclypsium.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20220209122706.42439-4-mika.westerberg@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agomtd: spi-nor: intel-spi: Convert to SPI MEM
Mika Westerberg [Wed, 9 Feb 2022 12:27:05 +0000 (15:27 +0300)]
mtd: spi-nor: intel-spi: Convert to SPI MEM

The preferred way to implement SPI-NOR controller drivers is through SPI
subsubsystem utilizing the SPI MEM core functions. This converts the
Intel SPI flash controller driver over the SPI MEM by moving the driver
from SPI-NOR subsystem to SPI subsystem and in one go make it use the
SPI MEM functions. The driver name will be changed from intel-spi to
spi-intel to match the convention used in the SPI subsystem.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mauro Lima <mauro.lima@eclypsium.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20220209122706.42439-3-mika.westerberg@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agomtd: spi-nor: intel-spi: Disable write protection only if asked
Mika Westerberg [Wed, 9 Feb 2022 12:27:04 +0000 (15:27 +0300)]
mtd: spi-nor: intel-spi: Disable write protection only if asked

Currently the driver tries to disable the BIOS write protection
automatically even if this is not what the user wants. For this reason
modify the driver so that by default it does not touch the write
protection. Only if specifically asked by the user (setting writeable=1
command line parameter) the driver tries to disable the BIOS write
protection.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mauro Lima <mauro.lima@eclypsium.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220209122706.42439-2-mika.westerberg@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: amd: Add support for version AMDI0062
André Almeida [Fri, 11 Feb 2022 14:31:55 +0000 (11:31 -0300)]
spi: amd: Add support for version AMDI0062

Add support for the AMD SPI controller version AMDI0062. Do this in a
modular way where's easy to add new versions.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20220211143155.75513-4-andrealmeid@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: amd: Remove needless rom_addr variable
André Almeida [Fri, 11 Feb 2022 14:31:54 +0000 (11:31 -0300)]
spi: amd: Remove needless rom_addr variable

rom_addr is not used in the code, so we can just drop it from struct
amd_spi.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20220211143155.75513-3-andrealmeid@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: amd: Use iopoll for busy waiting
André Almeida [Fri, 11 Feb 2022 14:31:53 +0000 (11:31 -0300)]
spi: amd: Use iopoll for busy waiting

Instead of implementing a custom IO busy wait function, just use
readl_poll_timeout().

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Link: https://lore.kernel.org/r/20220211143155.75513-2-andrealmeid@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: make remove callback a void function
Mark Brown [Wed, 9 Feb 2022 14:32:59 +0000 (14:32 +0000)]
spi: make remove callback a void function

Merge series from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:

this series goal is to change the spi remove callback's return value to void.
After numerous patches nearly all drivers already return 0 unconditionally.
The four first patches in this series convert the remaining three drivers to
return 0, the final patch changes the remove prototype and converts all
implementers.

base-commit: 26291c54e111ff6ba87a164d85d4a4e134b7315c

2 years agospi: make remove callback a void function
Uwe Kleine-König [Sun, 23 Jan 2022 17:52:01 +0000 (18:52 +0100)]
spi: make remove callback a void function

The value returned by an spi driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Claudius Heine <ch@denx.de>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Acked-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Acked-by: Łukasz Stelmach <l.stelmach@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoplatform/chrome: cros_ec: Make cros_ec_unregister() return void
Uwe Kleine-König [Sun, 23 Jan 2022 17:52:00 +0000 (18:52 +0100)]
platform/chrome: cros_ec: Make cros_ec_unregister() return void

Up to now cros_ec_unregister() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c, platform and spi remove callbacks is
ignored anyway.

Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20211020071753.wltjslmimb6wtlp5@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agotpm: st33zp24: Make st33zp24_remove() a void function
Uwe Kleine-König [Sun, 23 Jan 2022 17:51:59 +0000 (18:51 +0100)]
tpm: st33zp24: Make st33zp24_remove() a void function

Up to now st33zp24_remove() returns zero unconditionally. Make it return
no value instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Link: https://lore.kernel.org/r/20220104231103.227924-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agostaging: fbtft: Deduplicate driver registration macros
Uwe Kleine-König [Sun, 23 Jan 2022 17:51:58 +0000 (18:51 +0100)]
staging: fbtft: Deduplicate driver registration macros

The two macros FBTFT_REGISTER_DRIVER and FBTFT_REGISTER_SPI_DRIVER
contain quite some duplication: Both define an spi driver and an of device
table and the differences are quite subtle.

So create two new macros and use both twice.

Link: https://lore.kernel.org/r/20220118181338.207943-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agostaging: fbtft: Fix error path in fbtft_driver_module_init()
Uwe Kleine-König [Sun, 23 Jan 2022 17:51:57 +0000 (18:51 +0100)]
staging: fbtft: Fix error path in fbtft_driver_module_init()

If registering the platform driver fails, the function must not return
without undoing the spi driver registration first.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Link: https://lore.kernel.org/r/20220118181338.207943-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Add compatible for Mediatek MT8186
Mark Brown [Tue, 8 Feb 2022 18:58:12 +0000 (18:58 +0000)]
spi: Add compatible for Mediatek MT8186

Merge series from Leilk Liu <leilk.liu@mediatek.com>:

This is more YAML conversion than new compatible.

2 years agospi: tegra210-quad: Fix missin IRQ check in tegra_qspi_probe
Miaoqian Lin [Fri, 28 Jan 2022 16:59:56 +0000 (16:59 +0000)]
spi: tegra210-quad: Fix missin IRQ check in tegra_qspi_probe

This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_threaded_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.
Stop calling request_threaded_irq() with invalid IRQ #s.

Fixes: 921fc1838fb0 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220128165956.27821-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Fix test error for sp7021.
Li-hao Kuo [Mon, 7 Feb 2022 01:46:34 +0000 (09:46 +0800)]
spi: Fix test error for sp7021.

Remove the include path and modify parameters for fix error for bt binding test

Fixes: a708078eeb99  ("spi: Add Sunplus SP7021 schema")
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
Link: https://lore.kernel.org/r/b8a94fbfcab68b1279b09b6297099310c209927b.1644198244.git.lhjeff911@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: tegra114: Add missing IRQ check in tegra_spi_probe
Miaoqian Lin [Fri, 28 Jan 2022 16:52:38 +0000 (16:52 +0000)]
spi: tegra114: Add missing IRQ check in tegra_spi_probe

This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_threaded_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.
Stop calling request_threaded_irq() with invalid IRQ #s.

Fixes: f333a331adfa ("spi/tegra114: add spi driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220128165238.25615-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: ath79: add mem_ops for fast-read
Luiz Angelo Daros de Luca [Sat, 29 Jan 2022 04:04:53 +0000 (01:04 -0300)]
spi: ath79: add mem_ops for fast-read

Reading from memory is 3x faster than bit-bang read operation. Also,
for tl-wr2543nd, the bit-bang read was sporadically returning random
data, possibly a HW defect, while fast-read works as expected.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://lore.kernel.org/r/20220129040453.8476-1-luizluca@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Modify irq request position and modify parameters
Li-hao Kuo [Mon, 7 Feb 2022 01:57:22 +0000 (09:57 +0800)]
spi: Modify irq request position and modify parameters

- Change irq request position to the back.
- Add temporary varilable and setting (as suggested by Mr. Andy Shevchenko)

Fixes: f62ca4e2a863 ("spi: Add spi driver for Sunplus SP7021")
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
Link: https://lore.kernel.org/r/a94e3b123773fe303221d2bd2e4ce36ffa905a1c.1644198957.git.lhjeff911@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: spidev: prevent spidev->speed_hz from being zero
Dan Carpenter [Tue, 25 Jan 2022 06:52:02 +0000 (09:52 +0300)]
spi: spidev: prevent spidev->speed_hz from being zero

A zero value for spi->max_speed_hz or spidev->speed_hz does not make
sense and trying to set that can lead to divide by zero crashes in
a some of the drivers.

drivers/spi/spi-s3c64xx.c:874 s3c64xx_spi_setup() error: potential divide by zero bug '/ spi->max_speed_hz'.
drivers/spi/spi-fsl-dspi.c:613 hz_to_spi_baud() error: potential divide by zero bug '/ speed_hz'.
drivers/spi/spi-xlp.c:146 xlp_spi_setup() error: potential divide by zero bug '/ (spi->max_speed_hz)'.
drivers/spi/spi-orion.c:162 orion_spi_baudrate_set() error: potential divide by zero bug '/ speed'.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220125065202.GA8807@kili
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Add compatible for Mediatek MT8186
Leilk Liu [Tue, 25 Jan 2022 01:23:30 +0000 (09:23 +0800)]
spi: Add compatible for Mediatek MT8186

This commit adds dt-binding documentation of spi bus for Mediatek MT8186 SoC
Platform.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220125012330.13449-4-leilk.liu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Convert spi-mt65xx to json-schema
Leilk Liu [Tue, 25 Jan 2022 01:23:29 +0000 (09:23 +0800)]
spi: Convert spi-mt65xx to json-schema

Convert Mediatek ARM SOC's SPI Master controller binding
to json-schema format.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220125012330.13449-3-leilk.liu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Convert spi-slave-mt27xx to json-schema
Leilk Liu [Tue, 25 Jan 2022 01:23:28 +0000 (09:23 +0800)]
spi: Convert spi-slave-mt27xx to json-schema

Convert Mediatek ARM SOC's SPI Slave controller binding
to json-schema format.

Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20220125012330.13449-2-leilk.liu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: spi-zynq-qspi: Fix a NULL pointer dereference in zynq_qspi_exec_mem_op()
Zhou Qingyang [Tue, 30 Nov 2021 17:22:53 +0000 (01:22 +0800)]
spi: spi-zynq-qspi: Fix a NULL pointer dereference in zynq_qspi_exec_mem_op()

In zynq_qspi_exec_mem_op(), kzalloc() is directly used in memset(),
which could lead to a NULL pointer dereference on failure of
kzalloc().

Fix this bug by adding a check of tmpbuf.

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_SPI_ZYNQ_QSPI=m show no new warnings,
and our static analyzer no longer warns about this code.

Fixes: 67dca5e580f1 ("spi: spi-mem: Add support for Zynq QSPI controller")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Link: https://lore.kernel.org/r/20211130172253.203700-1-zhou1615@umn.edu
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: dt-bindings: add mising description type to reg property
David Heidelberg [Wed, 2 Feb 2022 10:47:15 +0000 (11:47 +0100)]
spi: dt-bindings: add mising description type to reg property

Added missing description type.

Fixes warning:
Documentation/devicetree/bindings/spi/spi-sunplus-sp7021.yaml: properties:reg:items: 'anyOf' conditional failed

Fixes: a708078eeb99 ("spi: Add Sunplus SP7021 schema")

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://lore.kernel.org/r/20220202104715.27839-1-david@ixit.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: mpc512x-psc: Fix compile errors
Linus Walleij [Tue, 1 Feb 2022 23:45:35 +0000 (00:45 +0100)]
spi: mpc512x-psc: Fix compile errors

My patch created compilation bugs in the MPC512x-PSC driver.
Fix them up.

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: linuxppc-dev@lists.ozlabs.org
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 2818824ced4b (" spi: mpc512x-psc: Convert to use GPIO descriptors")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220201234535.569973-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Replace acpi_bus_get_device()
Rafael J. Wysocki [Tue, 1 Feb 2022 20:05:59 +0000 (21:05 +0100)]
spi: Replace acpi_bus_get_device()

Replace acpi_bus_get_device() that is going to be dropped with
acpi_fetch_acpi_dev().

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/2231987.ElGaqSPkdT@kreacher
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoMerge remote-tracking branch 'spi/for-5.18' into spi-5.18
Mark Brown [Wed, 2 Feb 2022 12:01:39 +0000 (12:01 +0000)]
Merge remote-tracking branch 'spi/for-5.18' into spi-5.18

2 years agospi: Enhance and export helpers for ACPI resources
Mark Brown [Tue, 1 Feb 2022 17:39:36 +0000 (17:39 +0000)]
spi: Enhance and export helpers for ACPI resources

Merge series from Stefan Binding <sbinding@opensource.cirrus.com>:

This series enhances the helpers for ACPI resources to cope with
multiple resources and exports them for use in the x86 platform code's
multi-instantiate driver.

2 years agospi: Add API to count spi acpi resources
Stefan Binding [Fri, 21 Jan 2022 17:24:26 +0000 (17:24 +0000)]
spi: Add API to count spi acpi resources

Some ACPI nodes may have more than one Spi Resource.
To be able to handle these case, its necessary to have
a way of counting these resources.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-5-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Support selection of the index of the ACPI Spi Resource before alloc
Stefan Binding [Fri, 21 Jan 2022 17:24:25 +0000 (17:24 +0000)]
spi: Support selection of the index of the ACPI Spi Resource before alloc

If a node contains more than one SPI resource it may be necessary to
use an index to select which one you want to allocate a spi device for.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-4-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Create helper API to lookup ACPI info for spi device
Stefan Binding [Fri, 21 Jan 2022 17:24:24 +0000 (17:24 +0000)]
spi: Create helper API to lookup ACPI info for spi device

This can then be used to find a spi resource inside an
ACPI node, and allocate a spi device.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-3-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Make spi_alloc_device and spi_add_device public again
Stefan Binding [Fri, 21 Jan 2022 17:24:23 +0000 (17:24 +0000)]
spi: Make spi_alloc_device and spi_add_device public again

This functions were previously made private since they
were not used. However, these functions will be needed
again.

Partial revert of commit da21fde0fdb3
("spi: Make several public functions private to spi.c")

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-2-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Enhance and export helpers for ACPI resources
Mark Brown [Tue, 1 Feb 2022 17:17:18 +0000 (17:17 +0000)]
spi: Enhance and export helpers for ACPI resources

Merge series from Stefan Binding <sbinding@opensource.cirrus.com>:

This series enhances the helpers for ACPI resources to cope with
multiple resources and exports them for use in the x86 platform code's
multi-instantiate driver.

2 years agospi: Add API to count spi acpi resources
Stefan Binding [Fri, 21 Jan 2022 17:24:26 +0000 (17:24 +0000)]
spi: Add API to count spi acpi resources

Some ACPI nodes may have more than one Spi Resource.
To be able to handle these case, its necessary to have
a way of counting these resources.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-5-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Support selection of the index of the ACPI Spi Resource before alloc
Stefan Binding [Fri, 21 Jan 2022 17:24:25 +0000 (17:24 +0000)]
spi: Support selection of the index of the ACPI Spi Resource before alloc

If a node contains more than one SPI resource it may be necessary to
use an index to select which one you want to allocate a spi device for.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-4-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Create helper API to lookup ACPI info for spi device
Stefan Binding [Fri, 21 Jan 2022 17:24:24 +0000 (17:24 +0000)]
spi: Create helper API to lookup ACPI info for spi device

This can then be used to find a spi resource inside an
ACPI node, and allocate a spi device.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-3-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: Make spi_alloc_device and spi_add_device public again
Stefan Binding [Fri, 21 Jan 2022 17:24:23 +0000 (17:24 +0000)]
spi: Make spi_alloc_device and spi_add_device public again

This functions were previously made private since they
were not used. However, these functions will be needed
again.

Partial revert of commit da21fde0fdb3
("spi: Make several public functions private to spi.c")

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220121172431.6876-2-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: bcm2835aux: Convert to use GPIO descriptors
Linus Walleij [Tue, 1 Feb 2022 01:29:56 +0000 (02:29 +0100)]
spi: bcm2835aux: Convert to use GPIO descriptors

This one is pretty straight forward to switch over, the driver
already relies on inspecting cs_gpio just check cs_gpiod instead
and stop the special handling of requesting the GPIO and stuff
the core will take care of.

Cc: Lukas Wunner <lukas@wunner.de>
Cc: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220201012956.563272-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: st-ssc4: Covert to use GPIO descriptors
Linus Walleij [Tue, 1 Feb 2022 01:26:54 +0000 (02:26 +0100)]
spi: st-ssc4: Covert to use GPIO descriptors

This switches the ST SSC SPI controller to use GPIO
descriptors from the core instead of GPIO numbers.
It is already using the core parsing of GPIO numbers
so the switch is pretty straight-forward.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220201012654.562578-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: mediatek: Avoid NULL pointer crash in interrupt
Benjamin Gaignard [Mon, 31 Jan 2022 14:17:08 +0000 (15:17 +0100)]
spi: mediatek: Avoid NULL pointer crash in interrupt

In some case, like after a transfer timeout, master->cur_msg pointer
is NULL which led to a kernel crash when trying to use master->cur_msg->spi.
mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter
avoid the problem by setting NULL as second parameter.

Fixes: a568231f46322 ("spi: mediatek: Add spi bus for Mediatek MT8173")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: sp7201: Fix compiler warnings
郭力豪 [Fri, 28 Jan 2022 14:47:41 +0000 (22:47 +0800)]
spi: sp7201: Fix compiler warnings

Fix compiler warming for kernel test

Fixes: f62ca4e2a863 ("spi: Add spi driver for Sunplus SP7021")
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
Link: https://lore.kernel.org/r/CAGcXWkzM6wbhNFLbYoijq7iS_76nYVod1ySFEDu-BRgnBokEQA@mail.gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pic32: Convert to use GPIO descriptors
Linus Walleij [Sat, 22 Jan 2022 00:48:46 +0000 (01:48 +0100)]
spi: pic32: Convert to use GPIO descriptors

The driver already relies on the core looking up GPIO lines
from the core, so this is trivial to switch over to using
GPIO descriptors.

Cc: Purna Chandra Mandal <purna.mandal@microchip.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220122004846.374930-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: mpc512x-psc: Convert to use GPIO descriptors
Linus Walleij [Thu, 20 Jan 2022 00:26:00 +0000 (01:26 +0100)]
spi: mpc512x-psc: Convert to use GPIO descriptors

This driver is already relying on the core to provide
valid GPIO numbers in spi->cs_gpio through
of_spi_get_gpio_numbers(), so we can switch to letting
the core use GPIO descriptors instead.

The driver was assigning a local function to the custom
chipselect callback, but I chose to just open code the
gpiod setting instead, this is easier to read.

The only platform that overrides the cs_control callback
is the mpc832x_rdb.

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220120002600.216667-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: mt65xx: Convert to GPIO descriptors
Linus Walleij [Sat, 22 Jan 2022 00:33:02 +0000 (01:33 +0100)]
spi: mt65xx: Convert to GPIO descriptors

The MT65xx driver was already relying on the core to get some
GPIO line numbers so it can be (hopefully) trivially converted
to use descriptors instead.

Cc: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Cc: Mason Zhang <Mason.Zhang@mediatek.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Peter Hess <peter.hess@ph-home.de>
Cc: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220122003302.374304-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agospi: pxa2xx_spi: Convert to use GPIO descriptors
Linus Walleij [Tue, 25 Jan 2022 00:58:36 +0000 (01:58 +0100)]
spi: pxa2xx_spi: Convert to use GPIO descriptors

This converts the PXA2xx SPI driver to use GPIO descriptors
exclusively to retrieve GPIO chip select lines.

The device tree and ACPI paths of the driver already use
descriptors, hence ->use_gpio_descriptors is already set and
this codepath is well tested.

Convert all the PXA boards providing chip select GPIOs as
platform data and drop the old GPIO chipselect handling in
favor of the core managing it exclusively.

Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220125005836.494807-1-linus.walleij@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2 years agoLinux 5.17-rc2
Linus Torvalds [Sun, 30 Jan 2022 13:37:07 +0000 (15:37 +0200)]
Linux 5.17-rc2

2 years agoMerge tag 'irq_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jan 2022 13:12:02 +0000 (15:12 +0200)]
Merge tag 'irq_urgent_for_v5.17_rc2_p2' of git://git./linux/kernel/git/tip/tip

Pull irq fixes from Borislav Petkov:

 - Drop an unused private data field in the AIC driver

 - Various fixes to the realtek-rtl driver

 - Make the GICv3 ITS driver compile again in !SMP configurations

 - Force reset of the GICv3 ITSs at probe time to avoid issues during kexec

 - Yet another kfree/bitmap_free conversion

 - Various DT updates (Renesas, SiFive)

* tag 'irq_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  dt-bindings: interrupt-controller: sifive,plic: Group interrupt tuples
  dt-bindings: interrupt-controller: sifive,plic: Fix number of interrupts
  dt-bindings: irqchip: renesas-irqc: Add R-Car V3U support
  irqchip/gic-v3-its: Reset each ITS's BASERn register before probe
  irqchip/gic-v3-its: Fix build for !SMP
  irqchip/loongson-pch-ms: Use bitmap_free() to free bitmap
  irqchip/realtek-rtl: Service all pending interrupts
  irqchip/realtek-rtl: Fix off-by-one in routing
  irqchip/realtek-rtl: Map control data to virq
  irqchip/apple-aic: Drop unused ipi_hwirq field

2 years agoMerge tag 'perf_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jan 2022 13:02:32 +0000 (15:02 +0200)]
Merge tag 'perf_urgent_for_v5.17_rc2_p2' of git://git./linux/kernel/git/tip/tip

Pull perf fixes from Borislav Petkov:

 - Prevent accesses to the per-CPU cgroup context list from another CPU
   except the one it belongs to, to avoid list corruption

 - Make sure parent events are always woken up to avoid indefinite hangs
   in the traced workload

* tag 'perf_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix cgroup event list management
  perf: Always wake the parent event

2 years agoMerge tag 'sched_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kerne...
Linus Torvalds [Sun, 30 Jan 2022 11:09:00 +0000 (13:09 +0200)]
Merge tag 'sched_urgent_for_v5.17_rc2_p2' of git://git./linux/kernel/git/tip/tip

Pull scheduler fix from Borislav Petkov:
 "Make sure the membarrier-rseq fence commands are part of the reported
  set when querying membarrier(2) commands through MEMBARRIER_CMD_QUERY"

* tag 'sched_urgent_for_v5.17_rc2_p2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/membarrier: Fix membarrier-rseq fence command missing from query bitmask

2 years agoMerge tag 'x86_urgent_for_v5.17_rc2' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 30 Jan 2022 10:55:06 +0000 (12:55 +0200)]
Merge tag 'x86_urgent_for_v5.17_rc2' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

 - Add another Intel CPU model to the list of CPUs supporting the
   processor inventory unique number

 - Allow writing to MCE thresholding sysfs files again - a previous
   change had accidentally disabled it and no one noticed. Goes to show
   how much is this stuff used

* tag 'x86_urgent_for_v5.17_rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/cpu: Add Xeon Icelake-D to list of CPUs that support PPIN
  x86/MCE/AMD: Allow thresholding interface updates after init