Commit Graph

249 Commits

Author SHA1 Message Date
Tudor Ambarus 7ad288208d spi: s3c64xx: switch exynos850 to new port config data
Exynos850 has the same version of USI SPI (v2.1) as GS101.
Drop the fifo_lvl_mask and rx_lvl_offset and switch to the new port
config data.

Backward compatibility with DT is not broken because when alises are
set:
- the SPI core will set the bus number according to the alias ID
- the FIFO depth is always the same size for exynos850 (64 bytes) no
  matter the alias ID number.

Advantages of the change:
- drop dependency on the OF alias ID.
- FIFO depth is inferred from the compatible. Exynos850 integrates 3 SPI
  IPs, all with 64 bytes FIFO depths.
- use full mask for SPI_STATUS.{RX, TX}_FIFO_LVL fields. Using partial
  masks is misleading and can hide problems of the driver logic.

Just compiled tested.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-13-tudor.ambarus@linaro.org
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:43:00 +00:00
Tudor Ambarus e8b16c7a42 spi: s3c64xx: switch gs101 to new port config data
Drop the fifo_lvl_mask and rx_lvl_offset and switch to the new port
config data.

Advantages of the change:
- drop dependency on the OF alias ID.
- FIFO depth is inferred from the compatible. GS101 integrates 16 SPI
  IPs, all with 64 bytes FIFO depths.
- use full mask for SPI_STATUS.{RX, TX}_FIFO_LVL fields. Using partial
  masks is misleading and can hide problems of the driver logic.

S3C64XX_SPI_ST_TX_FIFO_RDY_V2 was defined based on the USI's
SPI_VERSION.USI_IP_VERSION register field, which has value 2 at reset.

MAX_SPI_PORTS is updated to reflect the maximum number of ports for the
rest of the compatibles.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-12-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:59 +00:00
Tudor Ambarus ad0adac84d spi: s3c64xx: deprecate fifo_lvl_mask, rx_lvl_offset and port_id
Deprecate fifo_lvl_mask, rx_lvl_offset and port_id. One shall use
{rx, tx}_fifomask instead. Add messages to each port configuration.

Suggested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-11-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:58 +00:00
Tudor Ambarus ea3fba7c41 spi: s3c64xx: get rid of the OF alias ID dependency
Compatibles that set ``port_conf->{rx, tx}_fifomask`` are now safe to
get rid of the OF alias ID dependency. Let the driver probe even without
the alias for these.

With this we also protect the FIFO_LVL_MASK calls from
s3c64xx_spi_set_fifomask().

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-10-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:57 +00:00
Tudor Ambarus 2cda3623ff spi: s3c64xx: introduce s3c64xx_spi_set_port_id()
Prepare driver to get rid of the of alias ID dependency. Split the
port_id logic into a dedicated method.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-9-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:56 +00:00
Tudor Ambarus e08433e095 spi: s3c64xx: let the SPI core determine the bus number
Let the core determine the bus number, either by getting the alias ID
(as the driver forces now), or by allocating a dynamic bus number when
the alias is absent. Prepare the driver to allow dt aliases to be
absent.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-8-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:55 +00:00
Tudor Ambarus 82b98fb8cd spi: s3c64xx: allow FIFO depth to be determined from the compatible
There are SoCs that use the same FIFO depth for all the instances of the
SPI IP. See the fifo_lvl_mask defined for gs101 for example:
    .fifo_lvl_mask  = { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
                        0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f},

Instead of specifying the FIFO depth with the same value for all 16
nodes in this case, allow such SoCs to infer the FIFO depth from the
compatible. There are other SoCs than can benefit of this, see:
{gs101, fsd, exynos850, s3c641, s3c2443}_spi_port_config.

The FIFO depth inferred from the compatible has a higher precedence than
the one that might be specified via device tree, the driver shall know
better.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-7-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:54 +00:00
Tudor Ambarus 414d7b8c91 spi: s3c64xx: retrieve the FIFO depth from the device tree
There are SoCs that configure different FIFO depths for their instances
of the SPI IP. See the fifo_lvl_mask defined for exynos4_spi_port_config
for example:
        .fifo_lvl_mask  = { 0x1ff, 0x7F, 0x7F },
The first instance of the IP is configured with 256 bytes FIFOs, whereas
the last two are configured with 64 bytes FIFOs.

Instead of mangling with the .fifo_lvl_mask and its dependency of the DT
alias ID, allow such SoCs to determine the FIFO depth via the
``fifo-depth`` DT property.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-6-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:53 +00:00
Tudor Ambarus c6e776ab6a spi: s3c64xx: determine the fifo depth only once
Determine the FIFO depth only once, at probe time.
``sdd->fifo_depth`` can be set later on with the FIFO depth
specified in the device tree.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-5-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:52 +00:00
Tudor Ambarus d6911cf27e spi: s3c64xx: allow full FIFO masks
The driver is wrong because is using partial register field masks for the
SPI_STATUS.{RX, TX}_FIFO_LVL register fields.

We see s3c64xx_spi_port_config.fifo_lvl_mask with different values for
different instances of the same IP. Take s5pv210_spi_port_config for
example, it defines:
	.fifo_lvl_mask  = { 0x1ff, 0x7F },

fifo_lvl_mask is used to determine the FIFO depth of the instance of the
IP. In this case, the integrator uses a 256 bytes FIFO for the first SPI
instance of the IP, and a 64 bytes FIFO for the second instance. While
the first mask reflects the SPI_STATUS.{RX, TX}_FIFO_LVL register
fields, the second one is two bits short. Using partial field masks is
misleading and can hide problems of the driver's logic.

Allow platforms to specify the full FIFO mask, regardless of the FIFO
depth.

Introduce {rx, tx}_fifomask to represent the SPI_STATUS.{RX, TX}_FIFO_LVL
register fields. It's a shifted mask defining the field's length and
position. We'll be able to deprecate the use of @rx_lvl_offset, as the
shift value can be determined from the mask. The existing compatibles
shall start using {rx, tx}_fifomask so that they use the full field mask
and to avoid shifting the mask to position, and then shifting it back to
zero in the {TX, RX}_FIFO_LVL macros.

@rx_lvl_offset will be deprecated in a further patch, after we have the
infrastructure to deprecate @fifo_lvl_mask as well.

No functional change intended.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-4-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:51 +00:00
Tudor Ambarus ff8faa8a5c spi: s3c64xx: define a magic value
Define a magic value, it will be used in the next patch as well.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240216070555.2483977-3-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-03-05 20:42:50 +00:00
Mark Brown 4f4857730c
spi: s3c64xx: straightforward cleanup
Merge series from Tudor Ambarus <tudor.ambarus@linaro.org>:

Various simple cleanups for the s3c64xx driver.  Tested with gs101-spi.
2024-02-08 20:26:15 +00:00
Tudor Ambarus e010c04958
spi: s3c64xx: add support for google,gs101-spi
Add support for GS101 SPI. GS101 integrates 16 SPI nodes, all with 64
bytes FIFOs. GS101 allows just 32 bit register accesses, otherwise a
Serror Interrupt is raised. Do the write reg accesses in 32 bits.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207111516.2563218-5-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:47 +00:00
Tudor Ambarus b7bafb9f54
spi: s3c64xx: add s3c64xx_iowrite{8,16}_32_rep accessors
Allow SoCs that require 32 bits register accesses to write data in
chunks of 8 or 16 bits. One SoC that requires 32 bit register accesses
is the google gs101. The operation is rare, thus open code it in the
driver rather than making it generic (through asm-generic/io.h).

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207111516.2563218-4-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:46 +00:00
Tudor Ambarus 80d3204a3b
spi: s3c64xx: prepare for a different flavor of iowrite rep
There are SoCs (gs101) that allow only 32 bit register accesses. As the
requirement is rare enough, for those SoCs we'll open code in the driver
some s3c64xx_iowrite{8,16}_32_rep() accessors. Prepare for such addition.

Suggested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Link: https://lore.kernel.org/r/20240207111516.2563218-3-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:45 +00:00
Tudor Ambarus acd6c7b1d2
spi: s3c64xx: drop a superfluous bitwise NOT operation
val &= ~mask;
val |= mask;

is equivalent to:
val |= mask;

Drop the superfluous bitwise NOT operation.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-18-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:40 +00:00
Tudor Ambarus eb8096c30a
spi: s3c64xx: remove duplicated definition
S3C64XX_SPI_TRAILCNT brings no benefit in terms of name over
S3C64XX_SPI_MAX_TRAILCNT. Remove the duplicated definition.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-17-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:39 +00:00
Tudor Ambarus f186d34071
spi: s3c64xx: downgrade dev_warn to dev_dbg for optional dt props
"samsung,spi-src-clk" and "num-cs" are optional dt properties. Downgrade
the message from warning to debug message.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-16-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:38 +00:00
Tudor Ambarus 91a9b8e6b6
spi: s3c64xx: drop blank line between declarations
Drop the blank line and move the logical operation in the body of the
function rather than in initialization list.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-15-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:37 +00:00
Tudor Ambarus 1a234accc9
spi: s3c64xx: return ETIMEDOUT for wait_for_completion_timeout()
ETIMEDOUT is more specific than EIO, use it for
wait_for_completion_timeout().

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-14-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:36 +00:00
Tudor Ambarus 4c64520505
spi: s3c64xx: rename prepare_dma() to s3c64xx_prepare_dma()
Don't monopolize the name. Prepend the driver prefix to the function
name.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-13-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:36 +00:00
Tudor Ambarus 60dc8d342e
spi: s3c64xx: propagate the dma_submit_error() error code
DMA submit should just add the dma descriptor to a queue, without firing
it. EIO is misleading and hides what happens in DMA. Propagate the
dma_submit_error() error code, don't overwrite it.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-12-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:35 +00:00
Tudor Ambarus e9c49effde
spi: s3c64xx: check return code of dmaengine_slave_config()
Check the return code of dmaengine_slave_config().

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-11-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:34 +00:00
Tudor Ambarus 5d7f4f4367
spi: s3c64xx: move common code outside if else
Move common code outside if else to avoid code duplication.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-10-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:33 +00:00
Tudor Ambarus 9d47e411f4
spi: s3c64xx: remove else after return
Else case is not needed after a return, remove it.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-9-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:32 +00:00
Tudor Ambarus 271f18816b
spi: s3c64xx: remove unneeded (void *) casts in of_match_table
of_device_id::data is an opaque pointer. No explicit cast is needed.
Remove unneeded (void *) casts in of_match_table.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-8-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:31 +00:00
Tudor Ambarus 97b63f4707
spi: s3c64xx: fix typo, s/configuartion/configuration
Fix typo, s/configuartion/configuration.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-7-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:30 +00:00
Tudor Ambarus a336d41bbe
spi: s3c64xx: avoid possible negative array index
The platform id is used as an index into the fifo_lvl_mask array.
Platforms can come with a negative device ID, PLATFORM_DEVID_NONE (-1),
thus we risked a negative array index. Catch such cases and fail to
probe.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-6-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:29 +00:00
Tudor Ambarus 7256d6bdd4
spi: s3c64xx: explicitly include <linux/types.h>
The driver uses u32 and relies on an implicit inclusion of
<linux/types.h>.

It is good practice to directly include all headers used, it avoids
implicit dependencies and spurious breakage if someone rearranges
headers and causes the implicit include to vanish.

Include the missing header.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-5-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:28 +00:00
Tudor Ambarus 4568fa574f
spi: s3c64xx: explicitly include <linux/bits.h>
The driver uses GENMASK() but does not include <linux/bits.h>.

It is good practice to directly include all headers used, it avoids
implicit dependencies and spurious breakage if someone rearranges
headers and causes the implicit include to vanish.

Include the missing header.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-4-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:27 +00:00
Tudor Ambarus 42a9ac378d
spi: s3c64xx: explicitly include <linux/io.h>
The driver uses readl() but does not include <linux/io.h>.

It is good practice to directly include all headers used, it avoids
implicit dependencies and spurious breakage if someone rearranges
headers and causes the implicit include to vanish.

Include the missing header.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-3-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:27 +00:00
Tudor Ambarus a77ce80f63
spi: s3c64xx: sort headers alphabetically
Sorting headers alphabetically helps locating duplicates,
and makes it easier to figure out where to insert new headers.

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20240207120431.2766269-2-tudor.ambarus@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08 16:33:26 +00:00
Sam Protsenko 0229278bf3
spi: s3c64xx: Add Exynos850 support
Add SPI port configuration for Exynos850 SoC. It has 3 USI blocks which
can be configured in SPI mode:

  * spi_0: BLK_PERI_SPI_0 (0x13940000)
  * spi_1: BLK_ALIVE_USI_CMGP00 (0x11d00000)
  * spi_2: BLK_ALIVE_USI_CMGP01 (0x11d20000)

SPI FIFO depth is 64 bytes for all those SPI blocks, so the
.fifo_lvl_mask value is set to 0x7f. All blocks have DIV_4 as the
default internal clock divider, and an internal loopback mode to run
a loopback test.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://msgid.link/r/20240120012948.8836-6-semen.protsenko@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-24 15:11:43 +00:00
Sam Protsenko 460efee706
spi: s3c64xx: Extract FIFO depth calculation to a dedicated macro
Simplify the code by extracting all cases of FIFO depth calculation into
a dedicated macro. No functional change.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://msgid.link/r/20240120170001.3356-1-semen.protsenko@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-01-22 16:51:36 +00:00
Yang Yingliang f4bc49eda2
spi: s3c64xx: switch to use modern name
Change legacy name master/slave to modern name host/target or controller.

No functional changed.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20230818093154.1183529-17-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-21 14:29:32 +01:00
Chen Jiahao b2b5617570
spi: s3c64xx: Clean up redundant dev_err_probe()
Referring to platform_get_irq()'s definition, the return value has
already been checked if ret < 0, and printed via dev_err_probe().
Calling dev_err_probe() one more time outside platform_get_irq()
is obviously redundant.

Removing dev_err_probe() outside platform_get_irq() to clean up
above problem.

Signed-off-by: Chen Jiahao <chenjiahao16@huawei.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20230727131635.2898051-1-chenjiahao16@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-27 17:33:05 +01:00
Mark Brown 0b201982fe Linux 6.5-rc3
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAmS9qIoeHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiGH6EH/2EnB8lLGOl8QINL
 E8eTWj6e7hdXXEX42j5h+TeGZZgBbTwogzE08uHBOP7lO0h31GVa97D5xkjS8UIa
 CzjYcnAuvf36nexakdC/0T8WgGzWwzKo0MIVraPBbq/pPRyrJ0CXPzB0Sl4Z2XlL
 W3N12a1N655FRx/tjaXgUB+aMPGrdBA2t0k6eXwFWyBdQhmt7O8Y3xy0rTVA+qHZ
 F6D4fZI2Ej9WbxX+tBs+DLEk+ZUz+0fABUqvgJRNofjgm71CpGhbv4ZGUFQaJT+I
 5S7cu3R8pS2YLP8TA3kJSj5GUEwPEDEZpxMIJAqkr5uvkNysGi55lYRxxULUw/sO
 EYHRBJE=
 =c8SQ
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmS9qsoACgkQJNaLcl1U
 h9AgVQf/QABRhGbSHHC5Ghd5QXJlKTZqbems6QJFXX2yPvPtVwV7S1XmS/5IH49E
 RRQAeEfAK2MByqQ25999Kai0MF7ZXagOaNq/CanvuxgU72uD+iY8khNtuEf4ohSj
 w61uqWcwm/unNGkSI7dF7qaY5HANOoOWBVeEVAKnwFRDuuGIg6X/S79+J3aRZ3wy
 N634ApEQJzB/hQgXgiJeLKOWNkD+rf2xQdTNGGQV1bqaRndgdm9eRZ4rxoOucx9F
 W4/z1gxWBCuIKbZm86/XDxAH7emdzwuPl/H/bhlsrAZgj23RSnuGkLg1VR9F/O25
 eKPqTUVmd/WbzWs6m6ov26XSh+KDeQ==
 =u4QW
 -----END PGP SIGNATURE-----

spi: Merge up fixes from mainline

There's several things here that will really help my CI.
2023-07-23 23:33:41 +01:00
Rob Herring 749396cb29
spi: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230714174955.4064174-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-14 20:53:00 +01:00
Jaewon Kim 9ec3c5517e
spi: s3c64xx: clear loopback bit after loopback test
When SPI loopback transfer is performed, S3C64XX_SPI_MODE_SELF_LOOPBACK
bit still remained. It works as loopback even if the next transfer is
not spi loopback mode.
If not SPI_LOOP, needs to clear S3C64XX_SPI_MODE_SELF_LOOPBACK bit.

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
Fixes: ffb7bcd3b2 ("spi: s3c64xx: support loopback mode")
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Link: https://lore.kernel.org/r/20230711082020.138165-1-jaewon02.kim@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-12 13:11:06 +01:00
Yangtao Li 4f81b540cc
spi: s3c64xx: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230706032727.9180-7-frank.li@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:51:41 +01:00
Andi Shyti b4f273774c
spi: s3c64xx: Use dev_err_probe()
Simplify the code by using dev_err_probe() instead of dev_err()
and 'return'.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20230606012051.2139333-3-andi.shyti@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-06 13:53:39 +01:00
Andi Shyti 76fbad410c
spi: s3c64xx: Use the managed spi master allocation function
Use devm_spi_alloc_master() and get rid of one goto error path

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20230606012051.2139333-2-andi.shyti@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-06 13:53:38 +01:00
Andi Shyti 20c475d21e
spi: s3c64xx: Use devm_clk_get_enabled()
Replace the tuple devm_clk_get()/clk_prepare_enable() with the
single function devm_clk_get_enabled().

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20230531205550.568340-1-andi.shyti@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-01 17:15:53 +01:00
Jaewon Kim 26cd10a0b9
spi: s3c64xx: Disable IRQ mode when using DMA
Fixing the problem of enabling DMA mode and IRQ mode at the same time.
In this case, a value of more than 6bits is written to RDY_LVL, it can
cause an invasion of other registers, potentially leading to SPI
transfer failure.

Fixes: 1ee806718d ("spi: s3c64xx: support interrupt based pio mode")
Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org
Link: https://lore.kernel.org/r/20230510113942.89994-1-jaewon02.kim@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-11 10:30:43 +09:00
Jaewon Kim 1ee806718d
spi: s3c64xx: support interrupt based pio mode
Support interrupt based pio mode to optimize cpu usage.
When transmitting data size is larget than 32 bytes, operates with
interrupt based pio mode.

By using the FIFORDY INT, an interrupt can be triggered when
the desired size of data has been received. Using this, we can support
interrupt based pio mode.

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com
Link: https://lore.kernel.org/r/20230502062813.112434-4-jaewon02.kim@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-08 09:10:51 +09:00
Jaewon Kim 3456674f54
spi: s3c64xx: add sleep during transfer
In polling mode, the status register is continuously read to check data
transfer completion. It can cause excessive CPU usage.
To reduce this, we can calculate the transfer time and put the sleep during
transfer.

When test on ExynosAuto9 SADK board, throughput remained the same, but
100% CPU utilization decreased to 40%.

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org
Link: https://lore.kernel.org/r/20230502062813.112434-3-jaewon02.kim@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-08 09:10:51 +09:00
Jaewon Kim d1a7718ee8
spi: s3c64xx: change polling mode to optional
Previously, Polling mode was supported as quirk for SOC without DMA.
To provide more flexible support for polling mode, it changed to polling
mode when the 'dmas' property is not present in the devicetree, rather than
using a quirk.

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org
Link: https://lore.kernel.org/r/20230502062813.112434-2-jaewon02.kim@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-08 09:10:50 +09:00
Amit Kumar Mahapatra via Alsa-devel 9e264f3f85
spi: Replace all spi->chip_select and spi->cs_gpiod references with function call
Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod
members of struct spi_device to be an array. But changing the type of these
members to array would break the spi driver functionality. To make the
transition smoother introduced four new APIs to get/set the
spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and
spi->cs_gpiod references with get or set API calls.
While adding multi-cs support in further patches the chip_select & cs_gpiod
members of the spi_device structure would be converted to arrays & the
"idx" parameter of the APIs would be used as array index i.e.,
spi->chip_select[idx] & spi->cs_gpiod[idx] respectively.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Acked-by: Heiko Stuebner <heiko@sntech.de> # Rockchip drivers
Reviewed-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org> # Aspeed driver
Reviewed-by: Dhruva Gole <d-gole@ti.com> # SPI Cadence QSPI
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> # spi-stm32-qspi
Acked-by: William Zhang <william.zhang@broadcom.com> # bcm63xx-hsspi driver
Reviewed-by: Serge Semin <fancer.lancer@gmail.com> # DW SSI part
Link: https://lore.kernel.org/r/167847070432.26.15076794204368669839@mailman-core.alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-11 12:34:01 +00:00
Uwe Kleine-König 2b7981a655
spi: s3c64xx: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230303172041.2103336-63-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-06 21:18:05 +00:00
Vincent Whitchurch 1224e29572
spi: s3c64xx: Fix large transfers with DMA
The COUNT_VALUE in the PACKET_CNT register is 16-bit so the maximum
value is 65535.  Asking the driver to transfer a larger size currently
leads to the DMA transfer timing out.  Implement ->max_transfer_size()
and have the core split the transfer as needed.

Fixes: 230d42d422 ("spi: Add s3c64xx SPI Controller driver")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Link: https://lore.kernel.org/r/20220927112117.77599-5-vincent.whitchurch@axis.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-28 12:54:07 +01:00