2024-04-23 11:36:11

by Alvin Šipraga

[permalink] [raw]
Subject: [PATCH 0/3] spi: sc18is602: add support for SC18IS606

The SC18IS606 is basically already supported by the driver, but since it
has a larger data buffer and fewer chip selects, it deserves its own
compatible string together with some minor modifications to the driver
to support this.

While at it, convert the device tree bindings to YAML before adding an
additional compatible string.

Signed-off-by: Alvin Šipraga <[email protected]>
---
Alvin Šipraga (3):
spi: dt-bindings: nxp,sc18is602: convert binding to YAML
spi: dt-bindings: nxp,sc18is602: add compatible for SC18IS606
spi: sc18is602: add support for SC18IS606

.../devicetree/bindings/spi/nxp,sc18is602.yaml | 60 ++++++++++++++++++++++
.../devicetree/bindings/spi/spi-sc18is602.txt | 23 ---------
drivers/spi/spi-sc18is602.c | 29 ++++++++---
3 files changed, 83 insertions(+), 29 deletions(-)
---
base-commit: 5343a65e03e4ee9f81508032e70b547e3c9f99ed
change-id: 20240423-sc18is606-d375613ebd82



2024-04-23 11:36:12

by Alvin Šipraga

[permalink] [raw]
Subject: [PATCH 2/3] spi: dt-bindings: nxp,sc18is602: add compatible for SC18IS606

From: Alvin Šipraga <[email protected]>

The compatible string is nxp,sc18is606. It is a functional replacement
for the SC18IS602B with a larger data buffer, three (rather than four)
chip selects, and lacks support for quasi-directional GPIO.

Signed-off-by: Alvin Šipraga <[email protected]>
---
Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
index 5b34fdf6148a..8fbf74b95708 100644
--- a/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
+++ b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
@@ -4,7 +4,7 @@
$id: http://devicetree.org/schemas/spi/nxp,sc18is602.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

-title: NXP SC18IS602/602B/603 I2C to SPI bridge
+title: NXP SC18IS602/602B/603/606 I2C to SPI bridge

maintainers:
- Alvin Šipraga <[email protected]>
@@ -15,6 +15,7 @@ properties:
- nxp,sc18is602
- nxp,sc18is602b
- nxp,sc18is603
+ - nxp,sc18is606

reg:
maxItems: 1

--
2.44.0


2024-04-23 11:36:18

by Alvin Šipraga

[permalink] [raw]
Subject: [PATCH 3/3] spi: sc18is602: add support for SC18IS606

From: Alvin Šipraga <[email protected]>

Per its datasheet, the SC18IS606 is a functional replacement of the
currently supported SC18IS602B, with the only relevant exceptions to
this driver being an increased data buffer size (1024 vs 200 bytes) and
three (rather than four) chip selects. It also lacks support for
quasi-directional GPIO, but the driver does not use this feature anyway,
so this is not reflected in the changes.

To that end, update the driver to support variable data buffer sizes and
add populate the relevant driver private data fields for this new chip.

Signed-off-by: Alvin Šipraga <[email protected]>
---
drivers/spi/spi-sc18is602.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c
index eecf9ea95ae3..c4adfd4af804 100644
--- a/drivers/spi/spi-sc18is602.c
+++ b/drivers/spi/spi-sc18is602.c
@@ -16,9 +16,9 @@
#include <linux/platform_data/sc18is602.h>
#include <linux/gpio/consumer.h>

-enum chips { sc18is602, sc18is602b, sc18is603 };
+enum chips { sc18is602, sc18is602b, sc18is603, sc18is606 };

-#define SC18IS602_BUFSIZ 200
+#define SC18IS602_MAX_BUFSIZ 1024
#define SC18IS602_CLOCK 7372000

#define SC18IS602_MODE_CPHA BIT(2)
@@ -35,11 +35,12 @@ struct sc18is602 {
u8 ctrl;
u32 freq;
u32 speed;
+ size_t bufsiz; /* Data buffer size */

/* I2C data */
struct i2c_client *client;
enum chips id;
- u8 buffer[SC18IS602_BUFSIZ + 1];
+ u8 buffer[SC18IS602_MAX_BUFSIZ + 1];
int tlen; /* Data queued for tx in buffer */
int rindex; /* Receive data index in buffer */

@@ -99,7 +100,7 @@ static int sc18is602_txrx(struct sc18is602 *hw, struct spi_message *msg,
}

if (do_transfer && hw->tlen > 1) {
- ret = sc18is602_wait_ready(hw, SC18IS602_BUFSIZ);
+ ret = sc18is602_wait_ready(hw, hw->bufsiz);
if (ret < 0)
return ret;
ret = i2c_master_send(hw->client, hw->buffer, hw->tlen);
@@ -173,7 +174,9 @@ static int sc18is602_setup_transfer(struct sc18is602 *hw, u32 hz, u8 mode)
static int sc18is602_check_transfer(struct spi_device *spi,
struct spi_transfer *t, int tlen)
{
- if (t && t->len + tlen > SC18IS602_BUFSIZ + 1)
+ struct sc18is602 *hw = spi_controller_get_devdata(spi->controller);
+
+ if (t && t->len + tlen > hw->bufsiz + 1)
return -EINVAL;

return 0;
@@ -220,7 +223,9 @@ static int sc18is602_transfer_one(struct spi_controller *host,

static size_t sc18is602_max_transfer_size(struct spi_device *spi)
{
- return SC18IS602_BUFSIZ;
+ struct sc18is602 *hw = spi_controller_get_devdata(spi->controller);
+
+ return hw->bufsiz;
}

static int sc18is602_setup(struct spi_device *spi)
@@ -274,10 +279,12 @@ static int sc18is602_probe(struct i2c_client *client)
case sc18is602:
case sc18is602b:
host->num_chipselect = 4;
+ hw->bufsiz = 200;
hw->freq = SC18IS602_CLOCK;
break;
case sc18is603:
host->num_chipselect = 2;
+ hw->bufsiz = 200;
if (pdata) {
hw->freq = pdata->clock_frequency;
} else {
@@ -291,6 +298,11 @@ static int sc18is602_probe(struct i2c_client *client)
if (!hw->freq)
hw->freq = SC18IS602_CLOCK;
break;
+ case sc18is606:
+ host->num_chipselect = 3;
+ hw->bufsiz = 1024;
+ hw->freq = SC18IS602_CLOCK;
+ break;
}
host->bus_num = np ? -1 : client->adapter->nr;
host->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST;
@@ -310,6 +322,7 @@ static const struct i2c_device_id sc18is602_id[] = {
{ "sc18is602", sc18is602 },
{ "sc18is602b", sc18is602b },
{ "sc18is603", sc18is603 },
+ { "sc18is606", sc18is606 },
{ }
};
MODULE_DEVICE_TABLE(i2c, sc18is602_id);
@@ -327,6 +340,10 @@ static const struct of_device_id sc18is602_of_match[] __maybe_unused = {
.compatible = "nxp,sc18is603",
.data = (void *)sc18is603
},
+ {
+ .compatible = "nxp,sc18is606",
+ .data = (void *)sc18is606
+ },
{ },
};
MODULE_DEVICE_TABLE(of, sc18is602_of_match);

--
2.44.0


2024-04-23 11:36:26

by Alvin Šipraga

[permalink] [raw]
Subject: [PATCH 1/3] spi: dt-bindings: nxp,sc18is602: convert binding to YAML

From: Alvin Šipraga <[email protected]>

Convert the txt binding to YAML. In the example, the node name was
changed from sc18is603@28 to spi@28 to conform with the standard
$nodename property in the spi-controller.yaml schema.

Make myself maintainer of this binding, since nobody else has
volunteered themselves.

Signed-off-by: Alvin Šipraga <[email protected]>
---
.../devicetree/bindings/spi/nxp,sc18is602.yaml | 59 ++++++++++++++++++++++
.../devicetree/bindings/spi/spi-sc18is602.txt | 23 ---------
2 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
new file mode 100644
index 000000000000..5b34fdf6148a
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/nxp,sc18is602.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP SC18IS602/602B/603 I2C to SPI bridge
+
+maintainers:
+ - Alvin Šipraga <[email protected]>
+
+properties:
+ compatible:
+ enum:
+ - nxp,sc18is602
+ - nxp,sc18is602b
+ - nxp,sc18is603
+
+ reg:
+ maxItems: 1
+
+ clock-frequency:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description:
+ External oscillator clock frequency. Only relevant if the chip has an
+ external oscillator (SC18IS603).
+ default: 7372000
+
+required:
+ - compatible
+ - reg
+
+allOf:
+ - $ref: spi-controller.yaml#
+ - if:
+ not:
+ properties:
+ comptaible:
+ contains:
+ enum:
+ - nxp,sc18is603
+ then:
+ properties:
+ clock-frequency: false
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ spi@28 {
+ compatible = "nxp,sc18is603";
+ reg = <0x28>;
+ clock-frequency = <14744000>;
+ };
+ };
diff --git a/Documentation/devicetree/bindings/spi/spi-sc18is602.txt b/Documentation/devicetree/bindings/spi/spi-sc18is602.txt
deleted file mode 100644
index 02f9033270a2..000000000000
--- a/Documentation/devicetree/bindings/spi/spi-sc18is602.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-NXP SC18IS602/SCIS603
-
-Required properties:
- - compatible : Should be one of
- "nxp,sc18is602"
- "nxp,sc18is602b"
- "nxp,sc18is603"
- - reg: I2C bus address
-
-Optional properties:
- - clock-frequency : external oscillator clock frequency. If not
- specified, the SC18IS602 default frequency (7372000) will be used.
-
-The clock-frequency property is relevant and needed only if the chip has an
-external oscillator (SC18IS603).
-
-Example:
-
- sc18is603@28 {
- compatible = "nxp,sc18is603";
- reg = <0x28>;
- clock-frequency = <14744000>;
- }

--
2.44.0


2024-04-23 15:13:35

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 1/3] spi: dt-bindings: nxp,sc18is602: convert binding to YAML

On Tue, Apr 23, 2024 at 01:35:30PM +0200, Alvin Šipraga wrote:
> From: Alvin Šipraga <[email protected]>
>
> Convert the txt binding to YAML. In the example, the node name was
> changed from sc18is603@28 to spi@28 to conform with the standard
> $nodename property in the spi-controller.yaml schema.
>
> Make myself maintainer of this binding, since nobody else has
> volunteered themselves.
>
> Signed-off-by: Alvin Šipraga <[email protected]>
> ---
> .../devicetree/bindings/spi/nxp,sc18is602.yaml | 59 ++++++++++++++++++++++
> .../devicetree/bindings/spi/spi-sc18is602.txt | 23 ---------
> 2 files changed, 59 insertions(+), 23 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
> new file mode 100644
> index 000000000000..5b34fdf6148a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/spi/nxp,sc18is602.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP SC18IS602/602B/603 I2C to SPI bridge
> +
> +maintainers:
> + - Alvin Šipraga <[email protected]>
> +
> +properties:
> + compatible:
> + enum:
> + - nxp,sc18is602
> + - nxp,sc18is602b
> + - nxp,sc18is603
> +
> + reg:
> + maxItems: 1
> +
> + clock-frequency:
> + $ref: /schemas/types.yaml#/definitions/uint32

Drop. 'clock-frequency' already has a type. With that,

Reviewed-by: Rob Herring (Arm) <[email protected]>

2024-04-23 15:15:49

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 2/3] spi: dt-bindings: nxp,sc18is602: add compatible for SC18IS606


On Tue, 23 Apr 2024 13:35:31 +0200, Alvin Šipraga wrote:
> From: Alvin Šipraga <[email protected]>
>
> The compatible string is nxp,sc18is606. It is a functional replacement
> for the SC18IS602B with a larger data buffer, three (rather than four)
> chip selects, and lacks support for quasi-directional GPIO.
>
> Signed-off-by: Alvin Šipraga <[email protected]>
> ---
> Documentation/devicetree/bindings/spi/nxp,sc18is602.yaml | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>

Acked-by: Rob Herring (Arm) <[email protected]>