Skip to contentSkip to conversation

Adding support of ADI ARMv8 ADSP-SC598 SoC.

PATCH In review Arturs Artamonovs 10 participants 65 messages Sep 12, 2024 – Oct 2, 2024

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover Adding support of ADI ARMv8 ADSP-SC598 SoC.

This set of patches based on ADI fork of Linux Kerenl that support family of ADSP-SC5xx SoC's and used by customers for some time . Patch series contains minimal set of changes to add ADSP-SC598 support to upstream kernel. This series include UART,I2C,IRQCHIP,RCU drivers and device-tree to be able boot on EV-SC598-SOM board into serial shell and able to reset the board. Current SOM board requires I2C expander to enable UART output.

UART,I2C and PINCTRL drivers are based on old Blackfin drivers with ADSP-SC5xx related bug fixes and improvments.

---
Arturs Artamonovs (21):
arm64: Add ADI ADSP-SC598 SoC
reset: Add driver for ADI ADSP-SC5xx reset controller
dt-bindigs: arm64: adi,sc598 bindings
dt-bindings: arm64: adi,sc598: Add ADSP-SC598 SoC bindings clock:Add driver for ADI ADSP-SC5xx PLL
include: dt-binding: clock: add adi clock header file
clock: Add driver for ADI ADSP-SC5xx clock
dt-bindings: clock: adi,sc5xx-clocks: add bindings
gpio: add driver for ADI ADSP-SC5xx platform
dt-bindings: gpio: adi,adsp-port-gpio: add bindings
irqchip: Add irqchip for ADI ADSP-SC5xx platform
dt-bindings: irqchip: adi,adsp-pint: add binding
pinctrl: Add drivers for ADI ADSP-SC5xx platform
dt-bindings: pinctrl: adi,adsp-pinctrl: add bindings
i2c: Add driver for ADI ADSP-SC5xx platforms
dt-bindings: i2c: add i2c/twi driver documentation
serial: adi,uart: Add driver for ADI ADSP-SC5xx
dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation
arm64: dts: adi: sc598: add device tree
arm64: defconfig: sc598 add minimal changes
MAINTAINERS: add adi sc5xx maintainers

 .../devicetree/bindings/arm/analog/adi,sc5xx.yaml  |   24 +
 .../bindings/clock/adi,sc5xx-clocks.yaml           |   65 ++
 .../bindings/gpio/adi,adsp-port-gpio.yaml          |   69 ++
 Documentation/devicetree/bindings/i2c/adi,twi.yaml |   71 ++
 .../interrupt-controller/adi,adsp-pint.yaml        |   51 +
 .../bindings/pinctrl/adi,adsp-pinctrl.yaml         |   83 ++
 .../devicetree/bindings/serial/adi,uart.yaml       |   85 ++
 .../bindings/soc/adi/adi,reset-controller.yaml     |   38 +
 MAINTAINERS                                        |   22 +
 arch/arm64/Kconfig.platforms                       |   13 +
 arch/arm64/boot/dts/Makefile                       |    1 +
 arch/arm64/boot/dts/adi/Makefile                   |    2 +
 arch/arm64/boot/dts/adi/sc598-som-ezkit.dts        |   14 +
 arch/arm64/boot/dts/adi/sc598-som.dtsi             |   58 ++
 arch/arm64/boot/dts/adi/sc59x-64.dtsi              |  367 +++++++
 arch/arm64/configs/defconfig                       |    6 +
 drivers/clk/Kconfig                                |    9 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/adi/Makefile                           |    4 +
 drivers/clk/adi/clk-adi-pll.c                      |  151 +++
 drivers/clk/adi/clk-adi-sc598.c                    |  329 ++++++
 drivers/clk/adi/clk.h                              |   99 ++
 drivers/gpio/Kconfig                               |    8 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-adi-adsp-port.c                  |  145 +++
 drivers/i2c/busses/Kconfig                         |   17 +
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-adi-twi.c                   |  940 ++++++++++++++++++
 drivers/irqchip/Kconfig                            |    9 +
 drivers/irqchip/Makefile                           |    2 +
 drivers/irqchip/irq-adi-adsp.c                     |  310 ++++++
 drivers/pinctrl/Kconfig                            |   12 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-adsp.c                     |  919 +++++++++++++++++
 drivers/reset/Makefile                             |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/adi/Makefile                           |    5 +
 drivers/soc/adi/system.c                           |  257 +++++
 drivers/tty/serial/Kconfig                         |   19 +-
 drivers/tty/serial/Makefile                        |    1 +
 drivers/tty/serial/adi_uart.c                      | 1045 ++++++++++++++++++++
 include/dt-bindings/clock/adi-sc5xx-clock.h        |   93 ++
 include/dt-bindings/pinctrl/adi-adsp.h             |   19 +
 include/linux/soc/adi/adsp-gpio-port.h             |   85 ++
 include/linux/soc/adi/cpu.h                        |  107 ++
 include/linux/soc/adi/rcu.h                        |   55 ++
 include/linux/soc/adi/sc59x.h                      |  147 +++
 include/linux/soc/adi/system_config.h              |   65 ++
 include/uapi/linux/serial_core.h                   |    3 +
 49 files changed, 5829 insertions(+), 1 deletion(-)

---
base-commit: da3ea35007d0af457a0afc87e84fddaebc4e0b63
change-id: 20240909-test-8ec5f76fe6d2

Best regards,

Signature · 1 line
Arturs Artamonovs <[email protected]>
#1 lore raw

PATCH 1/21 arm64: Add ADI ADSP-SC598 SoC

Add ADSP-SC598 platform.

---
 arch/arm64/Kconfig.platforms           |  13 ++
 drivers/soc/Makefile                   |   1 +
 drivers/soc/adi/Makefile               |   5 +
 drivers/soc/adi/system.c               | 257 +++++++++++++++++++++++++++++++++
 include/linux/soc/adi/adsp-gpio-port.h |  85 +++++++++++
 include/linux/soc/adi/cpu.h            | 107 ++++++++++++++
 include/linux/soc/adi/rcu.h            |  55 +++++++
 include/linux/soc/adi/sc59x.h          | 147 +++++++++++++++++++
 include/linux/soc/adi/system_config.h  |  65 +++++++++
 9 files changed, 735 insertions(+)
arch/arm64/Kconfig.platforms +13 -0
index 6c6d11536b42ec6e878db8d355c17994c2500d7b..b9ea22ecddfcbff98486a314143e52934f26df44 100644
@@ -292,6 +292,19 @@ config ARCH_ROCKCHIP
 	  This enables support for the ARMv8 based Rockchip chipsets,
 	  like the RK3368.
 
+config ARCH_SC59X_64
+	bool "ADI 64-bit SC59X Platforms"
+	select TIMER_OF
+	select GPIOLIB
+	select PINCTRL
+	select COMMON_CLK_ADI_SC598
+	select PINCTRL_ADSP
+	select ADI_ADSP_IRQ
+	select COUNTER
+	help
+		This enables support for Analog Devices Incorporated's
+		Family of ARM64 DSP processors
+
 config ARCH_SEATTLE
 	bool "AMD Seattle SoC Family"
 	help
drivers/soc/Makefile +1 -0
index fb2bd31387d070387fcf8a579f618dc2b25bdc69..af518539185563a96e37a2d42ad5535e7366c5fa 100644
@@ -3,6 +3,7 @@
 # Makefile for the Linux Kernel SOC specific device drivers.
 #
 
+obj-$(CONFIG_ARCH_SC59X_64)	+= adi/
 obj-y				+= apple/
 obj-y				+= aspeed/
 obj-$(CONFIG_ARCH_AT91)		+= atmel/
drivers/soc/adi/Makefile new file +5 -0
new file mode 100644
index 0000000000000000000000000000000000000000..113720192d462e833da69214ce91a7b84aec141b
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# todo modularize; already depends on CONFIG_ARCH_SC59X_64 though
+
+obj-y += system.o
drivers/soc/adi/system.c new file +257 -0

258 lines not on this page · raw message

include/linux/soc/adi/adsp-gpio-port.h new file +85 -0

85 lines not on this page · raw message

include/linux/soc/adi/cpu.h new file +107 -0

107 lines not on this page · raw message

include/linux/soc/adi/rcu.h new file +55 -0

55 lines not on this page · raw message

include/linux/soc/adi/sc59x.h new file +147 -0

147 lines not on this page · raw message

include/linux/soc/adi/system_config.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

Quoted 10 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC598 platform.

arch/arm64/Kconfig.platforms +0 -0
@@ -292,6 +292,19 @@ config ARCH_ROCKCHIP
 	  This enables support for the ARMv8 based Rockchip chipsets,
 	  like the RK3368.

arch/arm64/Kconfig.platforms config ARCH_ROCKCHIP · line 303

Quoted 10 lines
arch/arm64/Kconfig.platforms +9 -0
 
+config ARCH_SC59X_64
+	bool "ADI 64-bit SC59X Platforms"
+	select TIMER_OF
+	select GPIOLIB
+	select PINCTRL
+	select COMMON_CLK_ADI_SC598
+	select PINCTRL_ADSP
+	select ADI_ADSP_IRQ
+	select COUNTER

You can remove the 'select' statements above and just make your drivers 'default ARCH_SC59X_64'.

It may also help to pick a more generic name for the platform in case someone wants to add support for SC57x/SC58x later, assuming these use some of the same drivers,.

The Kconfig change can normally go into the same patch as the MAINTAINERS file update, but should be separate from any of the drivers.

drivers/soc/adi/system.c

Quoted 9 lines
drivers/soc/adi/Makefile new file +5 -0
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# todo modularize; already depends on CONFIG_ARCH_SC59X_64 though
+
+obj-y += system.o
drivers/soc/adi/system.c +0 -0

I'm confused about the purpose of this driver. Please split this out into a separate patch and add a detailed description of how it is actually being used, since it does not interact with any of the normal subsystems.

include/linux/soc/adi/sc59x.h

Quoted 15 lines
include/linux/soc/adi/cpu.h new file +0 -0
include/linux/soc/adi/rcu.h new file +0 -0
@@ -0,0 +1,55 @@
include/linux/soc/adi/sc59x.h new file +0 -0

I don't see these files being included in the driver you add here, maybe they got added by accident here?

Arnd

#3 lore raw

RE: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

Quoted 50 lines

-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Friday, September 13, 2024 9:16 AM
To: Artamonovs, Arturs <[email protected]>; Catalin Marinas <[email protected]>; Will Deacon <[email protected]>; Greg Malysa <[email protected]>; Philipp Zabel <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Agarwal, Utsav <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; Linus Walleij <[email protected]>; Bartosz Golaszewski <[email protected]>; Thomas Gleixner <[email protected]>; Andi Shyti <[email protected]>; Greg Kroah-Hartman <[email protected]>; Jiri Slaby <[email protected]>; Olof Johansson <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; open list:GPIO SUBSYSTEM <[email protected]>; [email protected]; linux- [email protected]; Linux Factory <[email protected]>; Nathan Barrett- Morrison <[email protected]>
Subject: Re: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

[External]

Quoted 10 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC598 platform.

arch/arm64/Kconfig.platforms +0 -0
@@ -292,6 +292,19 @@ config ARCH_ROCKCHIP
 	  This enables support for the ARMv8 based Rockchip chipsets,
 	  like the RK3368.

arch/arm64/Kconfig.platforms config ARCH_ROCKCHIP · line 303

Quoted 10 lines
arch/arm64/Kconfig.platforms +9 -0
 
+config ARCH_SC59X_64
+	bool "ADI 64-bit SC59X Platforms"
+	select TIMER_OF
+	select GPIOLIB
+	select PINCTRL
+	select COMMON_CLK_ADI_SC598
+	select PINCTRL_ADSP
+	select ADI_ADSP_IRQ
+	select COUNTER

You can remove the 'select' statements above and just make your drivers 'default ARCH_SC59X_64'.

Quoted 8 lines

It may also help to pick a more generic name for the platform in case someone wants to add support for SC57x/SC58x later, assuming these use some of the same drivers,.

The Kconfig change can normally go into the same patch as the MAINTAINERS file update, but should be separate from any of the drivers.

Hi, yes future plan is too add other platforms like SC57x/SC58x and SC594. Drivers are compatible.

Quoted 6 lines
Quoted 6 lines
drivers/soc/adi/Makefile new file +3 -0
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# todo modularize; already depends on CONFIG_ARCH_SC59X_64 though
Quoted 9 lines

drivers/soc/adi/system.c

Quoted 3 lines
drivers/soc/adi/Makefile new file +2 -0
+
+obj-y += system.o
drivers/soc/adi/system.c +0 -0

I'm confused about the purpose of this driver. Please split this out into a separate patch and add a detailed description of how it is actually being used, since it does not interact with any of the normal subsystems.

Hi, yes we cleaned this driver as much as possible, will make effort to remove it.

Quoted 10 lines
Quoted 9 lines
include/linux/soc/adi/cpu.h new file +0 -0
include/linux/soc/adi/rcu.h new file +0 -0
@@ -0,0 +1,55 @@
Quoted 9 lines

include/linux/soc/adi/sc59x.h

Quoted 5 lines
include/linux/soc/adi/sc59x.h new file +0 -0

I don't see these files being included in the driver you add here, maybe they got added by accident here?

Should be used in reset driver its removed during rebase, will fix that In next series.

Quoted 1 line

Arnd

#4 lore raw

Re: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

In reply to Arturs Artamonovs

…

Quoted 2 lines

+++ b/drivers/soc/adi/system.c

(quoted diff) +0 -0
@@ -0,0 +1,257 @@

…

Quoted 1 line

+static void adi_system_config_remove(struct platform_device *pdev)

+{

drivers/soc/adi/system.c line 232

Quoted 7 lines
drivers/soc/adi/system.c new file +7 -0
+	struct adi_system_config *config = platform_get_drvdata(pdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&adi_system_config_lock, flags);
+	list_del(&config->list);
+	spin_unlock_irqrestore(&adi_system_config_lock, flags);
+}

…

Under which circumstances would you become interested to apply a statement like “guard(spinlock_irqsave)(&adi_system_config_lock);”?
https://elixir.bootlin.com/linux/v6.11-rc7/source/include/linux/spinlock.h#L572

Regards,
Markus

#5 lore raw

Re: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

Quoted 15 lines · Markus Elfring

…

Quoted 2 lines

+++ b/drivers/soc/adi/system.c

(quoted diff) +0 -0
@@ -0,0 +1,257 @@

…

Quoted 1 line

+static void adi_system_config_remove(struct platform_device *pdev)

+{

Quoted 7 lines
drivers/soc/adi/system.c new file +7 -0
+	struct adi_system_config *config = platform_get_drvdata(pdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&adi_system_config_lock, flags);
+	list_del(&config->list);
+	spin_unlock_irqrestore(&adi_system_config_lock, flags);
+}

…

Quoted 7 lines

Under which circumstances would you become interested to apply a statement like “guard(spinlock_irqsave)(&adi_system_config_lock);”?
https://elixir.bootlin.com/linux/v6.11-rc7/source/include/linux/spinlock.h#L572

Regards,
Markus

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them.

thanks,

greg k-h's patch email bot

#6 lore raw

Re: [PATCH 01/21] arm64: Add ADI ADSP-SC598 SoC

In reply to Arturs Artamonovs
Quoted 33 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC598 platform.

---
 arch/arm64/Kconfig.platforms           |  13 ++
 drivers/soc/Makefile                   |   1 +
 drivers/soc/adi/Makefile               |   5 +
 drivers/soc/adi/system.c               | 257 +++++++++++++++++++++++++++++++++
 include/linux/soc/adi/adsp-gpio-port.h |  85 +++++++++++
 include/linux/soc/adi/cpu.h            | 107 ++++++++++++++
 include/linux/soc/adi/rcu.h            |  55 +++++++
 include/linux/soc/adi/sc59x.h          | 147 +++++++++++++++++++
 include/linux/soc/adi/system_config.h  |  65 +++++++++
 9 files changed, 735 insertions(+)
arch/arm64/Kconfig.platforms +2 -0
index 6c6d11536b42ec6e878db8d355c17994c2500d7b..b9ea22ecddfcbff98486a314143e52934f26df44 100644
@@ -292,6 +292,19 @@ config ARCH_ROCKCHIP
 	  This enables support for the ARMv8 based Rockchip chipsets,
 	  like the RK3368.
 
+config ARCH_SC59X_64
+	bool "ADI 64-bit SC59X Platforms"

arch/arm64/Kconfig.platforms config ARCH_ROCKCHIP · line 306

Quoted 10 lines
arch/arm64/Kconfig.platforms +10 -0
+	select TIMER_OF
+	select GPIOLIB
+	select PINCTRL
+	select COMMON_CLK_ADI_SC598
+	select PINCTRL_ADSP
+	select ADI_ADSP_IRQ
+	select COUNTER
+	help
+		This enables support for Analog Devices Incorporated's
+		Family of ARM64 DSP processors

Messed indentation.

Quoted 14 lines
arch/arm64/Kconfig.platforms +12 -0
+
 
 
+
+static int regmap_system_write(void *context, unsigned int reg,
+		unsigned int val)
+{
+	struct adi_system_context *ctx = context;
+	struct adi_system_register *sreg = radix_tree_lookup(&ctx->tree, reg);
+
+	if (!sreg)
+		return -EIO;
+
+	if (sreg->is_bits) {

arch/arm64/Kconfig.platforms config ARCH_ROCKCHIP

Quoted 10 lines
arch/arm64/Kconfig.platforms +10 -0
+		return regmap_update_bits(ctx->regmap, sreg->offset,
+				sreg->mask,
+			(val << sreg->shift) & sreg->mask);
+	}
+
+	return regmap_write(ctx->regmap, sreg->offset, val);
+}
+
+static struct adi_system_context *create_context
+(struct adi_system_config *config)

That's wrong wrapping. Wrapping happens after return type in such cases.

Quoted 140 lines
arch/arm64/Kconfig.platforms +140 -0
+{
+	struct regmap *regmap = config->mmio_regmap;
+	struct adi_system_context *ctx;
+	size_t i;
+	int ret;
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return ERR_PTR(-ENOMEM);
+
+	ctx->regmap = regmap;
+	INIT_RADIX_TREE(&ctx->tree, GFP_KERNEL);
+
+	for (i = 0; i < config->len; ++i) {
+		struct adi_system_register *sreg = &config->registers[i];
+
+		ret = radix_tree_insert(&ctx->tree, sreg->id, sreg);
+		if (ret)
+			return ERR_PTR(ret);
+	}
+
+	config->config.max_register = config->max_register;
+	config->config.reg_bits = 8 * sizeof(uint32_t);
+	config->config.val_bits = 8 * sizeof(uint32_t);
+	config->config.reg_stride = 1;
+
+	return ctx;
+}
+
+static void regmap_system_free_context(void *context)
+{
+	struct adi_system_context *ctx = context;
+	unsigned int i;
+
+	for (i = 0; i < ctx->config->len; ++i)
+		radix_tree_delete(&ctx->tree,
+				ctx->config->registers[i].id);
+
+	kfree(ctx);
+}
+
+static const struct regmap_bus regmap_system_bus = {
+	.fast_io = true,
+	.reg_write = regmap_system_write,
+	.reg_read = regmap_system_read,
+	.free_context = regmap_system_free_context,
+	.val_format_endian_default = REGMAP_ENDIAN_LITTLE,
+};
+
+static struct regmap *__devm_regmap_init_adi_system_config(struct device *dev,
+	struct adi_system_config *config,
+	struct lock_class_key *lock_key, const char *lock_name)
+{
+	struct adi_system_context *ctx = create_context(config);
+
+	if (IS_ERR(ctx))
+		return ERR_PTR(PTR_ERR(ctx));
+
+	return __devm_regmap_init(dev, &regmap_system_bus, ctx,
+			&config->config,
+		lock_key, lock_name);
+}
+
+static DEFINE_SPINLOCK(adi_system_config_lock);
+static LIST_HEAD(adi_system_config_list);
+
+static int adi_system_config_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct adi_system_config *config = &adi_pads_config;
+	struct device_node *np = dev->of_node;
+	struct regmap *regmap_mmio;
+	struct regmap *regmap_system;
+	struct resource *res;
+	void __iomem *base;
+	unsigned long flags;
+
+	struct regmap_config mmio_config = {
+		.reg_bits = 8 * sizeof(uint32_t),
+		.val_bits = 8 * sizeof(uint32_t),
+		.reg_stride = sizeof(uint32_t),
+	};
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+	base = devm_ioremap(dev, res->start, resource_size(res));
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	mmio_config.name = dev_name(dev);
+	mmio_config.max_register = resource_size(res) - sizeof(uint32_t);
+
+	regmap_mmio = devm_regmap_init_mmio(dev, base, &mmio_config);
+	if (IS_ERR(regmap_mmio)) {
+		dev_err(dev, "mmio regmap initialization failed\n");
+		return PTR_ERR(regmap_mmio);
+	}
+
+	config->mmio_regmap = regmap_mmio;
+	regmap_system = devm_regmap_init_adi_system_config(dev, config);
+	if (IS_ERR(regmap_system)) {
+		dev_err(dev, "system config regmap initialization failed\n");
+		return PTR_ERR(regmap_system);
+	}
+
+	config->np = np;
+	config->system_regmap = regmap_system;
+	platform_set_drvdata(pdev, config);
+
+	spin_lock_irqsave(&adi_system_config_lock, flags);
+	list_add_tail(&config->list, &adi_system_config_list);
+	spin_unlock_irqrestore(&adi_system_config_lock, flags);
+	return 0;
+}
+
+static void adi_system_config_remove(struct platform_device *pdev)
+{
+	struct adi_system_config *config = platform_get_drvdata(pdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&adi_system_config_lock, flags);
+	list_del(&config->list);
+	spin_unlock_irqrestore(&adi_system_config_lock, flags);
+}
+
+/*
+ * PADs configuration registers are required to configure peripherals,
+ * and by extension the system. Hence the driver focuses on driving them while
+ * also setting up the remaining system.
+ */
+static const struct of_device_id pads_dt_ids[] = {
+	{ .compatible = "adi,pads-peripheral-config", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pads_dt_ids);
+
+static struct platform_driver pads_driver = {
+	.driver = {
+		.name = "adi-system-config",
+		.of_match_table = pads_dt_ids,

arch/arm64/Kconfig.platforms

Quoted 10 lines
arch/arm64/Kconfig.platforms +9 -0
+	},
+	.probe = adi_system_config_probe,
+	.remove = adi_system_config_remove,
+};
+module_platform_driver(pads_driver);
+
+MODULE_AUTHOR("Greg Malysa <[email protected]>");
+MODULE_DESCRIPTION("ADI ADSP PADS CFG-based System Configuration Driver");
+MODULE_LICENSE("GPL v2");
\ No newline at end of file

You need to fix such errors.

Quoted 8 lines
include/linux/soc/adi/adsp-gpio-port.h new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6466ded03ec6092149a2abfc56a305f9124ac695
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*

include/linux/soc/adi/adsp-gpio-port.h line 12

Quoted 10 lines
include/linux/soc/adi/adsp-gpio-port.h new file +10 -0
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#ifndef GPIO_ADI_ADSP_PORT_H
+#define GPIO_ADI_ADSP_PORT_H
+
+#include <linux/gpio/driver.h>
+
+/* Number of GPIOs per port instance */
+#define ADSP_PORT_NGPIO 16

Hm? No, you cannot have GPIO driver in linux/soc...

Quoted 34 lines
include/linux/soc/adi/adsp-gpio-port.h new file +34 -0
+
+/* PORT memory layout */
+#define ADSP_PORT_REG_FER		0x00
+#define ADSP_PORT_REG_FER_SET		0x04
+#define ADSP_PORT_REG_FER_CLEAR		0x08
+#define ADSP_PORT_REG_DATA		0x0c
+#define ADSP_PORT_REG_DATA_SET		0x10
+#define ADSP_PORT_REG_DATA_CLEAR	0x14
+#define ADSP_PORT_REG_DIR		0x18
+#define ADSP_PORT_REG_DIR_SET		0x1c
+#define ADSP_PORT_REG_DIR_CLEAR		0x20
+#define ADSP_PORT_REG_INEN		0x24
+#define ADSP_PORT_REG_INEN_SET		0x28
+#define ADSP_PORT_REG_INEN_CLEAR	0x2c
+#define ADSP_PORT_REG_PORT_MUX		0x30
+#define ADSP_PORT_REG_DATA_TGL		0x34
+#define ADSP_PORT_REG_POLAR		0x38
+#define ADSP_PORT_REG_POLAR_SET		0x3c
+#define ADSP_PORT_REG_POLAR_CLEAR	0x40
+#define ADSP_PORT_REG_LOCK		0x44
+#define ADSP_PORT_REG_TRIG_TGL		0x48
+
+/*
+ * One gpio instance per PORT instance in the hardware, provides the per-PORT
+ * interface to the hardware. Referenced in GPIO and PINCTRL drivers
+ */
+struct adsp_gpio_port {
+	struct device *dev;
+	void __iomem *regs;
+	struct gpio_chip gpio;
+	struct irq_domain *irq_domain;
+	uint32_t irq_offset;
+	uint32_t open_drain;
+	spinlock_t lock;

include/linux/soc/adi/adsp-gpio-port.h line 56

Quoted 10 lines
include/linux/soc/adi/adsp-gpio-port.h new file +10 -0
+};
+
+/* may need lock depending on register */
+static inline uint32_t __adsp_gpio_readl(struct adsp_gpio_port *port,
+				    size_t offset)
+{
+	return readl(port->regs + offset);
+}
+
+/* may need lock depending on register */

What does it mean?

include/linux/soc/adi/adsp-gpio-port.h line 60

Quoted 4 lines
include/linux/soc/adi/adsp-gpio-port.h new file +4 -0
+static inline void __adsp_gpio_writel(struct adsp_gpio_port *port, uint32_t val,
+				      size_t offset)
+{
+	writel(val, port->regs + offset);

Not useful wrapper. Makes code bigger.

Quoted 31 lines
include/linux/soc/adi/adsp-gpio-port.h new file +25 -0
+}
+
+/* may need lock depending on register */
+static inline u16 __adsp_gpio_readw(struct adsp_gpio_port *port,
+				    size_t offset)
+{
+	return readw(port->regs + offset);
+}
+
+/* may need lock depending on register */
+static inline void __adsp_gpio_writew(struct adsp_gpio_port *port, u16 val,
+				      size_t offset)
+{
+	writew(val, port->regs + offset);
+}
+
+static inline struct adsp_gpio_port *to_adsp_gpio_port(struct gpio_chip
+						       *chip)
+{
+	return container_of(chip, struct adsp_gpio_port, gpio);
+}
+
+int adsp_attach_pint_to_gpio(struct adsp_gpio_port *port);
+
+#endif
include/linux/soc/adi/cpu.h new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0ddb30619b423ce70e9b8018ed6404cfd4ef6039

include/linux/soc/adi/cpu.h line 7

Quoted 7 lines
include/linux/soc/adi/cpu.h new file +7 -0
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#ifndef __MACH_CPU_H
+#define __MACH_CPU_H

That's not an accurate header guard.

Quoted 88 lines
include/linux/soc/adi/cpu.h new file +88 -0
+
+#define SYS_L2_START		0x20080000
+#define SYS_SRAM_BASE		(0x20080000 + SZ_16K)
+
+#define SYS_SRAM_SIZE		(SZ_16K + SZ_32K * 3)
+#define SYS_SRAM_ICC_SIZE	SZ_4K
+#define SYS_MMR_BASE		0x31000000
+#define SYS_MMR_SIZE		SZ_1M
+#define SYS_SMC_BANK1		0x44000000
+
+#define SC59X_GIC_PORT0		0x310B2000
+#define SC59X_GIC_PORT1		0x310B4000
+
+/*
+ * Timer Configuration Register Bits
+ */
+#define TIMER_EMU_RUN		0x8000
+#define TIMER_BPER_EN		0x4000
+#define TIMER_BWID_EN		0x2000
+#define TIMER_BDLY_EN		0x1000
+#define TIMER_OUT_DIS		0x0800
+#define TIMER_TIN_SEL		0x0400
+#define TIMER_CLK_SEL		0x0300
+#define TIMER_CLK_SCLK		0x0000
+#define TIMER_CLK_ALT_CLK0	0x0100
+#define TIMER_CLK_ALT_CLK1	0x0300
+#define TIMER_PULSE_HI		0x0080
+#define TIMER_SLAVE_TRIG	0x0040
+#define TIMER_IRQ_MODE		0x0030
+#define TIMER_IRQ_ACT_EDGE	0x0000
+#define TIMER_IRQ_DLY		0x0010
+#define TIMER_IRQ_WID_DLY	0x0020
+#define TIMER_IRQ_PER		0x0030
+#define TIMER_MODE		0x000f
+#define TIMER_MODE_WDOG_P	0x0008
+#define TIMER_MODE_WDOG_W	0x0009
+#define TIMER_MODE_PWM_CONT	0x000c
+#define TIMER_MODE_PWM		0x000d
+#define TIMER_MODE_WDTH		0x000a
+#define TIMER_MODE_WDTH_D	0x000b
+#define TIMER_MODE_EXT_CLK	0x000e
+#define TIMER_MODE_PININT	0x000f
+
+#define __BFP(m) u16 m; u16 __pad_##m
+
+struct gptimer3 {
+	__BFP(config);
+	uint32_t counter;
+	uint32_t period;
+	uint32_t width;
+	uint32_t delay;
+};
+
+struct sc5xx_gptimer {
+	int id;
+	int irq;
+	int reserved;
+	int int_enable;
+	void __iomem *io_base;
+	void __iomem *cgu0_ctl;
+	unsigned long isr_count;
+	struct platform_device *pdev;
+	struct list_head node;
+};
+
+struct gptimer3_group_regs {
+	__BFP(run);
+	__BFP(enable);
+	__BFP(disable);
+	__BFP(stop_cfg);
+	__BFP(stop_cfg_set);
+	__BFP(stop_cfg_clr);
+	__BFP(data_imsk);
+	__BFP(stat_imsk);
+	__BFP(tr_msk);
+	__BFP(tr_ie);
+	__BFP(data_ilat);
+	__BFP(stat_ilat);
+	__BFP(err_status);
+	__BFP(bcast_per);
+	__BFP(bcast_wid);
+	__BFP(bcast_dly);
+};
+
+/* The actual gptimer API */
+struct sc5xx_gptimer *gptimer_request(int id);
+int gptimer_free(struct sc5xx_gptimer *timer);
+void set_gptimer_pwidth(struct sc5xx_gptimer *timer, uint32_t width);

include/linux/soc/adi/cpu.h line 105

Quoted 10 lines
include/linux/soc/adi/cpu.h new file +10 -0
+void set_gptimer_period(struct sc5xx_gptimer *timer, uint32_t period);
+uint32_t get_gptimer_count(struct sc5xx_gptimer *timer);
+void set_gptimer_config(struct sc5xx_gptimer *timer, uint16_t config);
+void enable_gptimers(uint16_t mask);
+void disable_gptimers(uint16_t mask);
+void map_gptimers(void);
+uint16_t get_gptimer_status(void);
+void set_gptimer_status(uint16_t value);
+void set_spu_securep_msec(uint16_t n, bool msec);
+void platform_ipi_init(void);

All these do not exist.

Best regards,
Krzysztof

#7 lore raw

PATCH 2/21 reset: Add driver for ADI ADSP-SC5xx reset controller

In reply to Arturs Artamonovs

Adding support for ADI ADSP reset controller. This driver allows trigger a software reset.

---
 drivers/reset/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/reset/Makefile +1 -0
index 27b0bbdfcc044ba58de9df09725ddef7b601c3ea..4d9e83b7ab38287336175d3804f9d2d4d2894595 100644
@@ -4,6 +4,7 @@ obj-y += hisilicon/
 obj-y += starfive/
 obj-y += sti/
 obj-y += tegra/
+obj-$(CONFIG_RESET_SC5XX) += reset-sc5xx.o
 obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
 obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
 obj-$(CONFIG_RESET_AXS10X) += reset-axs10x.o
Signature · 1 line
2.25.1
maintainer
#8 lore raw

Re: [PATCH 02/21] reset: Add driver for ADI ADSP-SC5xx reset controller

Quoted 12 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Adding support for ADI ADSP reset controller. This driver allows trigger a software reset.

Quoted 3 lines
---
 drivers/reset/Makefile | 1 +
 1 file changed, 1 insertion(+)

It looks like you accidentally dropped the actual driver during a rebase, this is only the Makefile change.

Arnd

#9 lore raw

PATCH 3/21 dt-bindigs: arm64: adi,sc598 bindings

In reply to Arturs Artamonovs

Bindigs for ADI ADSP-SC5xx reset controller

---
 .../bindings/soc/adi/adi,reset-controller.yaml     | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +38 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7a6df1cfb709d818d5e3dbcd202938d6aaaaaa9b
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/adi/adi,reset-controller.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Reset Controller for SC5XX processor family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  SHARC and ARM core reset control unit for starting/stopping/resetting
+  processors
+
+properties:
+  compatible:
+    enum:
+      - adi,reset-controller
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    rcu: rcu@3108c000 {
+      compatible = "adi,reset-controller";
+      reg = <0x3108c000 0x1000>;
+      status = "okay";
+    };
+
Signature · 1 line
2.25.1
maintainer
#10 lore raw

Re: [PATCH 03/21] dt-bindigs: arm64: adi,sc598 bindings

Quoted 1 line · Arturs Artamonovs

Bindigs for ADI ADSP-SC5xx reset controller

Typo. Here and the subject. Please write complete sentences.

Quoted 21 lines
---
 .../bindings/soc/adi/adi,reset-controller.yaml     | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7a6df1cfb709d818d5e3dbcd202938d6aaaaaa9b
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +10 -0
+$id: http://devicetree.org/schemas/soc/adi/adi,reset-controller.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Reset Controller for SC5XX processor family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |

Don't need '|'

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 15

Quoted 2 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +2 -0
+  SHARC and ARM core reset control unit for starting/stopping/resetting
+  processors

Complete sentences for top-level description.

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 20

Quoted 5 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +5 -0
+
+properties:
+  compatible:
+    enum:
+      - adi,reset-controller

Too generic.

Quoted 6 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +6 -0
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 36

Quoted 10 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +10 -0
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    rcu: rcu@3108c000 {
+      compatible = "adi,reset-controller";
+      reg = <0x3108c000 0x1000>;
+      status = "okay";

Don't need status in examples.

Shouldn't a reset controller use the reset binding (i.e. #reset-cells)?

All you patches seem to have similar issues, so I'm not going to comment on all of them. Please read the documentation in Documentation/devicetree/bindings/. It doesn't seem like you have.

Rob

#11 lore raw

Re: [PATCH 03/21] dt-bindigs: arm64: adi,sc598 bindings

In reply to Arturs Artamonovs
Quoted 3 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Bindigs for ADI ADSP-SC5xx reset controller

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters

It is dt-bindings: soc: adi:... if it was in soc.

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml

Quoted 13 lines
---
 .../bindings/soc/adi/adi,reset-controller.yaml     | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml +0 -0

Nope, don't just dump stuff to soc. This is reset controller so goes to reset.

Quoted 28 lines

new file mode 100644
index 0000000000000000000000000000000000000000..7a6df1cfb709d818d5e3dbcd202938d6aaaaaa9b

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +23 -0
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/adi/adi,reset-controller.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Reset Controller for SC5XX processor family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  SHARC and ARM core reset control unit for starting/stopping/resetting
+  processors
+
+properties:
+  compatible:
+    enum:
+      - adi,reset-controller
+
+  reg:
+    maxItems: 1

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +10 -0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    rcu: rcu@3108c000 {

Drop unused label.

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 36

Quoted 3 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +3 -0
+      compatible = "adi,reset-controller";
+      reg = <0x3108c000 0x1000>;
+      status = "okay";

Drop

Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml line 38

Quoted 3 lines
Documentation/devicetree/bindings/soc/adi/adi,reset-controller.yaml new file +2 -0
+    };
+

Best regards,
Krzysztof

#12 lore raw

PATCH 4/21 dt-bindings: arm64: adi,sc598: Add ADSP-SC598 SoC bindings

In reply to Arturs Artamonovs

add SoC ADSP-SC5xx

---
 .../devicetree/bindings/arm/analog/adi,sc5xx.yaml  | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml new file +24 -0
new file mode 100644
index 0000000000000000000000000000000000000000..fc37242b32b9ca9b82fd5b3e0288642e8c4fd9f0
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/analog/adi,sc5xx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices SC59X 64-Bit ARM-based Processor Families
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+properties:
+  $nodename:
+    const: '/'
+  compatible:
+    description: SC59X 64-Bit Boards
+    items:
+      - enum:
+          - adi,sc598-som-ezkit                # Analog Devices SC598 EZKit
+          - adi,sc598-som-ezlite               # Analog Devices SC598 EZLite
+      - const: adi,sc59x-64
+
+additionalProperties: true
Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH 04/21] dt-bindings: arm64: adi,sc598: Add ADSP-SC598 SoC bindings

Quoted 4 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

add SoC ADSP-SC5xx

Quoted 8 lines
---
 .../devicetree/bindings/arm/analog/adi,sc5xx.yaml  | 24 ++++++++++++++++++++++

There is no arm64 prefix above. Fix subject.

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Quoted 20 lines
 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml new file +12 -0
new file mode 100644
index 0000000000000000000000000000000000000000..fc37242b32b9ca9b82fd5b3e0288642e8c4fd9f0
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/analog/adi,sc5xx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices SC59X 64-Bit ARM-based Processor Families
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+

Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml new file +10 -0
+properties:
+  $nodename:
+    const: '/'
+  compatible:
+    description: SC59X 64-Bit Boards
+    items:
+      - enum:
+          - adi,sc598-som-ezkit                # Analog Devices SC598 EZKit
+          - adi,sc598-som-ezlite               # Analog Devices SC598 EZLite
+      - const: adi,sc59x-64

sc59x is incorrect. Enum above says sc598. Define what is the SoC here. You cannot have compatible for families.

Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml line 24

Quoted 3 lines
Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml new file +2 -0
+
+additionalProperties: true

Best regards,
Krzysztof

#14 lore raw

PATCH 5/21 clock:Add driver for ADI ADSP-SC5xx PLL

In reply to Arturs Artamonovs

Implements clock tree, no dynamic pll rate change.

---
 drivers/clk/adi/clk-adi-pll.c | 151 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/adi/clk.h         |  99 +++++++++++++++++++++++++++
 2 files changed, 250 insertions(+)
drivers/clk/adi/clk-adi-pll.c new file +151 -0
new file mode 100644
index 0000000000000000000000000000000000000000..39fcc78b3170c0aa5962af5268f499082efb3686
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * CGU PLL driver for ADI SC59X processors
+ *
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+
+#include "clk.h"
+
+struct clk_sc5xx_cgu_pll {
+	struct clk_hw hw;
+	void __iomem *base;
+	spinlock_t *lock;
+	int prepared;
+	u32 mask;
+	u32 msel;
+	u32 m_offset;
+	u8 shift;
+};
+
+struct clk_sc5xx_cgu_pll *to_clk_sc5xx_cgu_pll(struct clk_hw *hw)
+{
+	return container_of(hw, struct clk_sc5xx_cgu_pll, hw);
+}
+
+static long sc5xx_cgu_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+	unsigned long *parent_rate)
+{
+	struct clk_sc5xx_cgu_pll *pll = to_clk_sc5xx_cgu_pll(hw);
+	unsigned long m, m2, new_rate, nr2, prate2;
+	unsigned long prate = *parent_rate;
+	struct clk_hw *parent_hw;
+	int parent_inc;
+
+	parent_hw = clk_hw_get_parent(hw);
+
+	m = rate / prate;
+
+	if (m > pll->msel) {
+		/* cannot scale this far, need bigger input */
+		parent_inc = m / pll->msel;
+		prate = clk_hw_round_rate(parent_hw, prate * (parent_inc + 1));
+	} else if (m == 0) {
+		pr_err("%s: Cannot use VCO to reduce parent clock rate, requested %lu, clamping to %lu\n",
+			__func__, rate, prate);
+		return prate;
+	}
+
+	new_rate = prate * m;
+
+	if (new_rate != rate) {
+		/*
+		 * Check if we could get an integer match by halving parent rate since we
+		 * know at least about the DF bit before the VCO, although we don't know
+		 * if we're already using it or not
+		 */
+		prate2 = clk_hw_round_rate(parent_hw, prate / 2);
+		m2 = rate / prate2;
+		nr2 = prate * m2;
+		if (m2 <= pll->msel && nr2 == rate) {
+			m = m2;
+			new_rate = nr2;
+			prate = prate2;
+		}
+	}
+
+	*parent_rate = prate;
+	return new_rate;
+}
+
+static unsigned long sc5xx_cgu_pll_recalc_rate(struct clk_hw *hw,
+	unsigned long parent_rate)
+{
+	struct clk_sc5xx_cgu_pll *pll = to_clk_sc5xx_cgu_pll(hw);
+	u32 reg = readl(pll->base);
+	u32 m = ((reg & pll->mask) >> pll->shift) + pll->m_offset;
+
+	if (m == 0)
+		m = pll->msel;
+
+	return parent_rate * m;
+
+}
+
+static int sc5xx_cgu_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+	unsigned long parent_rate)
+{
+	struct clk_sc5xx_cgu_pll *pll = to_clk_sc5xx_cgu_pll(hw);
+	u32 m;
+
+	m = (rate / parent_rate) - pll->m_offset;
+
+	if (m >= pll->msel)
+		m = 0;
+
+	/* reminder for implementation: lock around read/modify to control reg */
+	pr_err("%s: set_rate not permitted yet, but we would write %d to m\n", __func__,
+		m);
+	return -ENOENT;
+}
+
+static const struct clk_ops clk_sc5xx_cgu_pll_ops = {
+	.recalc_rate = sc5xx_cgu_pll_recalc_rate,
+	.round_rate = sc5xx_cgu_pll_round_rate,
+	.set_rate = sc5xx_cgu_pll_set_rate,
+};
+
+struct clk *sc5xx_cgu_pll(const char *name, const char *parent_name,
+	void __iomem *base, u8 shift, u8 width, u32 m_offset,
+		spinlock_t *lock)
+{
+	struct clk_sc5xx_cgu_pll *pll;
+	struct clk *clk;
+	struct clk_init_data init;
+
+	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+	if (!pll)
+		return ERR_PTR(-ENOMEM);
+
+	init.name = name;
+	init.flags = CLK_SET_RATE_PARENT;
+	init.parent_names = &parent_name;
+	init.num_parents = 1;
+	init.ops = &clk_sc5xx_cgu_pll_ops;
+
+	pll->base = base;
+	pll->hw.init = &init;
+	pll->lock = lock;
+	pll->shift = shift;
+	pll->mask = GENMASK(width-1, 0) << shift;
+	pll->msel = pll->mask + 1;
+	pll->m_offset = m_offset;
+
+	clk = clk_register(NULL, &pll->hw);
+	if (IS_ERR(clk)) {
+		pr_err("%s: Failed to register, code %lu\n", __func__,
+			PTR_ERR(clk));
+	}
+
+	return clk;
+}
+
+MODULE_DESCRIPTION("Analog Devices CLock PLL driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Greg Malysa <[email protected]>");
+
drivers/clk/adi/clk.h new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#15 lore raw

Re: [PATCH 05/21] clock:Add driver for ADI ADSP-SC5xx PLL

Quoted 3 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Implements clock tree, no dynamic pll rate change.

This could use a little more detail.

Quoted 3 lines
 drivers/clk/adi/clk-adi-pll.c | 151 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/adi/clk.h         |  99 +++++++++++++++++++++++++++
 2 files changed, 250 insertions(+)

The header is only used in one file, to it's better to move all the contents into the driver itself.

Quoted 5 lines
drivers/clk/adi/clk.h new file +4 -0
+struct clk_sc5xx_cgu_pll *to_clk_sc5xx_cgu_pll(struct clk_hw *hw);
+
+struct clk *sc5xx_cgu_pll(const char *name, const char *parent_name,
+	void __iomem *base, u8 shift, u8 width, u32 m_offset, spinlock_t 

*lock);

Do these need to be global symbols? It's generally better to make all functions 'static' unless they need to be called from another file.

Arnd

#16 lore raw

Re: [PATCH 05/21] clock:Add driver for ADI ADSP-SC5xx PLL

In reply to Arturs Artamonovs
Quoted 9 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Implements clock tree, no dynamic pll rate change.

Quoted 4 lines
---
 drivers/clk/adi/clk-adi-pll.c | 151 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/adi/clk.h         |  99 +++++++++++++++++++++++++++
 2 files changed, 250 insertions(+)

How do you even build this code? Never built, so never tested?

Quoted 29 lines
drivers/clk/adi/clk-adi-pll.c new file +29 -0
+struct clk *sc5xx_cgu_pll(const char *name, const char *parent_name,
+	void __iomem *base, u8 shift, u8 width, u32 m_offset,
+		spinlock_t *lock)
+{
+	struct clk_sc5xx_cgu_pll *pll;
+	struct clk *clk;
+	struct clk_init_data init;
+
+	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+	if (!pll)
+		return ERR_PTR(-ENOMEM);
+
+	init.name = name;
+	init.flags = CLK_SET_RATE_PARENT;
+	init.parent_names = &parent_name;
+	init.num_parents = 1;
+	init.ops = &clk_sc5xx_cgu_pll_ops;
+
+	pll->base = base;
+	pll->hw.init = &init;
+	pll->lock = lock;
+	pll->shift = shift;
+	pll->mask = GENMASK(width-1, 0) << shift;
+	pll->msel = pll->mask + 1;
+	pll->m_offset = m_offset;
+
+	clk = clk_register(NULL, &pll->hw);
+	if (IS_ERR(clk)) {
+		pr_err("%s: Failed to register, code %lu\n", __func__,

drivers/clk/adi/clk-adi-pll.c line 151

Quoted 10 lines
drivers/clk/adi/clk-adi-pll.c new file +10 -0
+			PTR_ERR(clk));
+	}
+
+	return clk;
+}
+
+MODULE_DESCRIPTION("Analog Devices CLock PLL driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Greg Malysa <[email protected]>");
+

Multiple patches have messy blank line handling...

drivers/clk/adi/clk.h

Quoted 5 lines
drivers/clk/adi/clk.h new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e17aa719c2170149a6a1a60dd4390a29f06e7296

Best regards,
Krzysztof

#17 lore raw

PATCH 6/21 include: dt-binding: clock: add adi clock header file

In reply to Arturs Artamonovs

Add adi clock driver header file

---
 include/dt-bindings/clock/adi-sc5xx-clock.h | 93 +++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
include/dt-bindings/clock/adi-sc5xx-clock.h new file +93 -0
new file mode 100644
index 0000000000000000000000000000000000000000..723c11dc44f9741cff49dc2cb6c5232022abf00c
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * ADSP SC5xx clock device tree bindings
+ *
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#ifndef DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+#define DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+
+#define ADSP_SC598_CLK_DUMMY 0
+#define ADSP_SC598_CLK_SYS_CLKIN0 1
+#define ADSP_SC598_CLK_SYS_CLKIN1 2
+#define ADSP_SC598_CLK_CGU0_PLL_IN 3
+#define ADSP_SC598_CLK_CGU0_VCO_OUT 4
+#define ADSP_SC598_CLK_CGU0_PLLCLK 5
+#define ADSP_SC598_CLK_CGU1_IN 6
+#define ADSP_SC598_CLK_CGU1_PLL_IN 7
+#define ADSP_SC598_CLK_CGU1_VCO_OUT 8
+#define ADSP_SC598_CLK_CGU1_PLLCLK 9
+#define ADSP_SC598_CLK_CGU0_CDIV 10
+#define ADSP_SC598_CLK_CGU0_SYSCLK 11
+#define ADSP_SC598_CLK_CGU0_DDIV 12
+#define ADSP_SC598_CLK_CGU0_ODIV 13
+#define ADSP_SC598_CLK_CGU0_S0SELDIV 14
+#define ADSP_SC598_CLK_CGU0_S1SELDIV 15
+#define ADSP_SC598_CLK_CGU0_S1SELEXDIV 16
+#define ADSP_SC598_CLK_CGU0_S1SEL 17
+#define ADSP_SC598_CLK_CGU1_CDIV 18
+#define ADSP_SC598_CLK_CGU1_SYSCLK 19
+#define ADSP_SC598_CLK_CGU1_DDIV 20
+#define ADSP_SC598_CLK_CGU1_ODIV 21
+#define ADSP_SC598_CLK_CGU1_S0SELDIV 22
+#define ADSP_SC598_CLK_CGU1_S1SELDIV 23
+#define ADSP_SC598_CLK_CGU1_S0SELEXDIV 24
+#define ADSP_SC598_CLK_CGU1_S1SELEXDIV 25
+#define ADSP_SC598_CLK_CGU1_S0SEL 26
+#define ADSP_SC598_CLK_CGU1_S1SEL 27
+#define ADSP_SC598_CLK_CGU0_CCLK2 28
+#define ADSP_SC598_CLK_CGU0_CCLK0 29
+#define ADSP_SC598_CLK_CGU0_OCLK 30
+#define ADSP_SC598_CLK_CGU0_DCLK 31
+#define ADSP_SC598_CLK_CGU0_SCLK1 32
+#define ADSP_SC598_CLK_CGU0_SCLK0 33
+#define ADSP_SC598_CLK_CGU1_CCLK0 34
+#define ADSP_SC598_CLK_CGU1_OCLK 35
+#define ADSP_SC598_CLK_CGU1_DCLK 36
+#define ADSP_SC598_CLK_CGU1_SCLK1 37
+#define ADSP_SC598_CLK_CGU1_SCLK0 38
+#define ADSP_SC598_CLK_CGU1_CCLK2 39
+#define ADSP_SC598_CLK_DCLK0_HALF 40
+#define ADSP_SC598_CLK_DCLK1_HALF 41
+#define ADSP_SC598_CLK_CGU1_SCLK1_HALF 42
+#define ADSP_SC598_CLK_SHARC0_SEL 43
+#define ADSP_SC598_CLK_SHARC1_SEL 44
+#define ADSP_SC598_CLK_ARM_SEL 45
+#define ADSP_SC598_CLK_CDU_DDR_SEL 46
+#define ADSP_SC598_CLK_CAN_SEL 47
+#define ADSP_SC598_CLK_SPDIF_SEL 48
+#define ADSP_SC598_CLK_SPI_SEL 49
+#define ADSP_SC598_CLK_GIGE_SEL 50
+#define ADSP_SC598_CLK_LP_SEL 51
+#define ADSP_SC598_CLK_LP_DDR_SEL 52
+#define ADSP_SC598_CLK_OSPI_REFCLK_SEL 53
+#define ADSP_SC598_CLK_TRACE_SEL 54
+#define ADSP_SC598_CLK_EMMC_SEL 55
+#define ADSP_SC598_CLK_EMMC_TIMER_QMC_SEL 56
+#define ADSP_SC598_CLK_SHARC0 57
+#define ADSP_SC598_CLK_SHARC1 58
+#define ADSP_SC598_CLK_ARM 59
+#define ADSP_SC598_CLK_CDU_DDR 60
+#define ADSP_SC598_CLK_CAN 61
+#define ADSP_SC598_CLK_SPDIF 62
+#define ADSP_SC598_CLK_SPI 63
+#define ADSP_SC598_CLK_GIGE 64
+#define ADSP_SC598_CLK_LP 65
+#define ADSP_SC598_CLK_LP_DDR 66
+#define ADSP_SC598_CLK_OSPI_REFCLK 67
+#define ADSP_SC598_CLK_TRACE 68
+#define ADSP_SC598_CLK_EMMC 69
+#define ADSP_SC598_CLK_EMMC_TIMER_QMC 70
+#define ADSP_SC598_CLK_3PLL_PLL_IN 71
+#define ADSP_SC598_CLK_3PLL_VCO_OUT 72
+#define ADSP_SC598_CLK_3PLL_PLLCLK 73
+#define ADSP_SC598_CLK_3PLL_DDIV 74
+#define ADSP_SC598_CLK_DDR_SEL 75
+#define ADSP_SC598_CLK_DDR 76
+#define ADSP_SC598_CLK_CGU0_VCO_2_OUT 77
+#define ADSP_SC598_CLK_CGU1_VCO_2_OUT 78
+#define ADSP_SC598_CLK_3PLL_VCO_2_OUT 79
+#define ADSP_SC598_CLK_END 80
+
+#endif
Signature · 1 line
2.25.1
maintainer
#18 lore raw

Re: [PATCH 06/21] include: dt-binding: clock: add adi clock header file

Quoted 3 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add adi clock driver header file

Are you sure this is necessary? If the clk controller follows a logical structure, it's usually easier to identify individual clks by the way the hardware is laid out.

include/dt-bindings/clock/adi-sc5xx-clock.h line 15

Quoted 8 lines
include/dt-bindings/clock/adi-sc5xx-clock.h new file +8 -0
+#ifndef DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+#define DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+
+#define ADSP_SC598_CLK_DUMMY 0
+#define ADSP_SC598_CLK_SYS_CLKIN0 1
+#define ADSP_SC598_CLK_SYS_CLKIN1 2
+#define ADSP_SC598_CLK_CGU0_PLL_IN 3
+#define ADSP_SC598_CLK_CGU0_VCO_OUT 4

Unlike the DT compatible strings, these #defines don't have to be specific to a particular SoC, you could just reuse them for a family of chips even if they each use a slightly different subset. Maybe name them "ADSP_CLK_*" or "ADSP_SC5XX_CLK_*"?

Quoted 1 line

+#define ADSP_SC598_CLK_END 80

This should not be part of the binding, in particular you probably want to be able to extend this in order to support additional chips.

Arnd

#19 lore raw

Re: [PATCH 06/21] include: dt-binding: clock: add adi clock header file

In reply to Arturs Artamonovs
Quoted 3 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add adi clock driver header file

Useless on its own. This must be part of bindings patch.

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching. For bindings, the preferred subjects are explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters

Quoted 22 lines
---
 include/dt-bindings/clock/adi-sc5xx-clock.h | 93 +++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
include/dt-bindings/clock/adi-sc5xx-clock.h new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..723c11dc44f9741cff49dc2cb6c5232022abf00c
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * ADSP SC5xx clock device tree bindings
+ *
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */

include/dt-bindings/clock/adi-sc5xx-clock.h line 16

Quoted 10 lines
include/dt-bindings/clock/adi-sc5xx-clock.h new file +10 -0
+
+#ifndef DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+#define DT_BINDINGS_CLOCK_ADI_SC5XX_CLOCK_H
+
+#define ADSP_SC598_CLK_DUMMY 0
+#define ADSP_SC598_CLK_SYS_CLKIN0 1
+#define ADSP_SC598_CLK_SYS_CLKIN1 2
+#define ADSP_SC598_CLK_CGU0_PLL_IN 3
+#define ADSP_SC598_CLK_CGU0_VCO_OUT 4
+#define ADSP_SC598_CLK_CGU0_PLLCLK 5

That's quite unreadable code. Indent after define name.

Quoted 65 lines
include/dt-bindings/clock/adi-sc5xx-clock.h new file +65 -0
+#define ADSP_SC598_CLK_CGU1_IN 6
+#define ADSP_SC598_CLK_CGU1_PLL_IN 7
+#define ADSP_SC598_CLK_CGU1_VCO_OUT 8
+#define ADSP_SC598_CLK_CGU1_PLLCLK 9
+#define ADSP_SC598_CLK_CGU0_CDIV 10
+#define ADSP_SC598_CLK_CGU0_SYSCLK 11
+#define ADSP_SC598_CLK_CGU0_DDIV 12
+#define ADSP_SC598_CLK_CGU0_ODIV 13
+#define ADSP_SC598_CLK_CGU0_S0SELDIV 14
+#define ADSP_SC598_CLK_CGU0_S1SELDIV 15
+#define ADSP_SC598_CLK_CGU0_S1SELEXDIV 16
+#define ADSP_SC598_CLK_CGU0_S1SEL 17
+#define ADSP_SC598_CLK_CGU1_CDIV 18
+#define ADSP_SC598_CLK_CGU1_SYSCLK 19
+#define ADSP_SC598_CLK_CGU1_DDIV 20
+#define ADSP_SC598_CLK_CGU1_ODIV 21
+#define ADSP_SC598_CLK_CGU1_S0SELDIV 22
+#define ADSP_SC598_CLK_CGU1_S1SELDIV 23
+#define ADSP_SC598_CLK_CGU1_S0SELEXDIV 24
+#define ADSP_SC598_CLK_CGU1_S1SELEXDIV 25
+#define ADSP_SC598_CLK_CGU1_S0SEL 26
+#define ADSP_SC598_CLK_CGU1_S1SEL 27
+#define ADSP_SC598_CLK_CGU0_CCLK2 28
+#define ADSP_SC598_CLK_CGU0_CCLK0 29
+#define ADSP_SC598_CLK_CGU0_OCLK 30
+#define ADSP_SC598_CLK_CGU0_DCLK 31
+#define ADSP_SC598_CLK_CGU0_SCLK1 32
+#define ADSP_SC598_CLK_CGU0_SCLK0 33
+#define ADSP_SC598_CLK_CGU1_CCLK0 34
+#define ADSP_SC598_CLK_CGU1_OCLK 35
+#define ADSP_SC598_CLK_CGU1_DCLK 36
+#define ADSP_SC598_CLK_CGU1_SCLK1 37
+#define ADSP_SC598_CLK_CGU1_SCLK0 38
+#define ADSP_SC598_CLK_CGU1_CCLK2 39
+#define ADSP_SC598_CLK_DCLK0_HALF 40
+#define ADSP_SC598_CLK_DCLK1_HALF 41
+#define ADSP_SC598_CLK_CGU1_SCLK1_HALF 42
+#define ADSP_SC598_CLK_SHARC0_SEL 43
+#define ADSP_SC598_CLK_SHARC1_SEL 44
+#define ADSP_SC598_CLK_ARM_SEL 45
+#define ADSP_SC598_CLK_CDU_DDR_SEL 46
+#define ADSP_SC598_CLK_CAN_SEL 47
+#define ADSP_SC598_CLK_SPDIF_SEL 48
+#define ADSP_SC598_CLK_SPI_SEL 49
+#define ADSP_SC598_CLK_GIGE_SEL 50
+#define ADSP_SC598_CLK_LP_SEL 51
+#define ADSP_SC598_CLK_LP_DDR_SEL 52
+#define ADSP_SC598_CLK_OSPI_REFCLK_SEL 53
+#define ADSP_SC598_CLK_TRACE_SEL 54
+#define ADSP_SC598_CLK_EMMC_SEL 55
+#define ADSP_SC598_CLK_EMMC_TIMER_QMC_SEL 56
+#define ADSP_SC598_CLK_SHARC0 57
+#define ADSP_SC598_CLK_SHARC1 58
+#define ADSP_SC598_CLK_ARM 59
+#define ADSP_SC598_CLK_CDU_DDR 60
+#define ADSP_SC598_CLK_CAN 61
+#define ADSP_SC598_CLK_SPDIF 62
+#define ADSP_SC598_CLK_SPI 63
+#define ADSP_SC598_CLK_GIGE 64
+#define ADSP_SC598_CLK_LP 65
+#define ADSP_SC598_CLK_LP_DDR 66
+#define ADSP_SC598_CLK_OSPI_REFCLK 67
+#define ADSP_SC598_CLK_TRACE 68
+#define ADSP_SC598_CLK_EMMC 69
+#define ADSP_SC598_CLK_EMMC_TIMER_QMC 70

include/dt-bindings/clock/adi-sc5xx-clock.h line 91

Quoted 10 lines
include/dt-bindings/clock/adi-sc5xx-clock.h new file +10 -0
+#define ADSP_SC598_CLK_3PLL_PLL_IN 71
+#define ADSP_SC598_CLK_3PLL_VCO_OUT 72
+#define ADSP_SC598_CLK_3PLL_PLLCLK 73
+#define ADSP_SC598_CLK_3PLL_DDIV 74
+#define ADSP_SC598_CLK_DDR_SEL 75
+#define ADSP_SC598_CLK_DDR 76
+#define ADSP_SC598_CLK_CGU0_VCO_2_OUT 77
+#define ADSP_SC598_CLK_CGU1_VCO_2_OUT 78
+#define ADSP_SC598_CLK_3PLL_VCO_2_OUT 79
+#define ADSP_SC598_CLK_END 80

Drop this one. Not a binding.

Best regards,
Krzysztof

#20 lore raw

Re: [PATCH 06/21] include: dt-binding: clock: add adi clock header file

In reply to Arturs Artamonovs
Quoted 11 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add adi clock driver header file

---
 include/dt-bindings/clock/adi-sc5xx-clock.h | 93 +++++++++++++++++++++++++++++

Also, filename as compatible, which would be easily visible if you organized the patches correctly.

Best regards,
Krzysztof

#21 lore raw

PATCH 7/21 clock: Add driver for ADI ADSP-SC5xx clock

In reply to Arturs Artamonovs

Add ADSP-SC5xx clock driver

---
 drivers/clk/Kconfig             |   9 ++
 drivers/clk/Makefile            |   1 +
 drivers/clk/adi/Makefile        |   4 +
 drivers/clk/adi/clk-adi-sc598.c | 329 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 343 insertions(+)
drivers/clk/Kconfig +9 -0
index 983ef4f36d8c4387556d6b5d32f01dd4afa815a3..a3a076294c285d820f1c6922b872ff73174192c0 100644
@@ -42,6 +42,15 @@ config COMMON_CLK_WM831X
 
 source "drivers/clk/versatile/Kconfig"
 
+config COMMON_CLK_ADI_SC598
+	bool "Clock driver for ADI SC598 SoCs"
+	depends on OF && ARCH_SC59X_64
+	help
+	  This driver supports the system clocks on Analog Devices SC598-series
+	  SoCs. It includes CGU and CDU clocks and supports gating unused clocks.
+	  Modifying PLL configuration is not supported; that must be done prior
+	  to booting the kernel. Clock dividers after the PLLs may be configured.
+
 config CLK_HSDK
 	bool "PLL Driver for HSDK platform"
 	depends on ARC_SOC_HSDK || COMPILE_TEST
drivers/clk/Makefile +1 -0
index f793a16cad40bfff0d06989179e5401d7f3e69cc..9f48f81b9285ab19027cc287e62547a3c1332517 100644
@@ -84,6 +84,7 @@ obj-$(CONFIG_COMMON_CLK_XGENE)		+= clk-xgene.o
 
 # please keep this section sorted lexicographically by directory path name
 obj-y					+= actions/
+obj-y					+= adi/
 obj-y					+= analogbits/
 obj-$(CONFIG_COMMON_CLK_AT91)		+= at91/
 obj-$(CONFIG_ARCH_ARTPEC)		+= axis/
drivers/clk/adi/Makefile new file +4 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2a83dff54adaddd81f3f33bd962fe6302e14a8a7
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+#SC598
+obj-$(CONFIG_COMMON_CLK_ADI_SC598)  += clk-adi-pll.o
+obj-$(CONFIG_COMMON_CLK_ADI_SC598)  += clk-adi-sc598.o
drivers/clk/adi/clk-adi-sc598.c new file +329 -0

330 lines not on this page · raw message

Signature · 1 line
2.25.1
#22 lore raw

Re: [PATCH 07/21] clock: Add driver for ADI ADSP-SC5xx clock

kernel test robot noticed the following build warnings:

Hi Arturs,

kernel test robot noticed the following build warnings:

[auto build test WARNING on da3ea35007d0af457a0afc87e84fddaebc4e0b63]

url:    https://github.com/intel-lab-lkp/linux/commits/Arturs-Artamonovs-via-B4-Relay/arm64-Add-ADI-ADSP-SC598-SoC/20240913-022308
base:   da3ea35007d0af457a0afc87e84fddaebc4e0b63
patch link:    https://lore.kernel.org/r/20240912-test-v1-7-458fa57c8ccf%40analog.com
patch subject: [PATCH 07/21] clock: Add driver for ADI ADSP-SC5xx clock
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

includecheck warnings: (new ones prefixed by >>)

>> drivers/clk/adi/clk-adi-sc598.c: linux/clk.h is included more than once.

vim +9 drivers/clk/adi/clk-adi-sc598.c

   > 9	#include <linux/clk.h>
    10	#include <linux/clk-provider.h>
  > 11	#include <linux/clk.h>
    12	#include <linux/err.h>
    13	#include <linux/module.h>
    14	#include <linux/of_address.h>
    15	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#23 lore raw

PATCH 8/21 dt-bindings: clock: adi,sc5xx-clocks: add bindings

In reply to Arturs Artamonovs

Add ADSP-SC5xx clock bindings.

---
 .../bindings/clock/adi,sc5xx-clocks.yaml           | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)
Documentation/devicetree/bindings/clock/adi,sc5xx-clocks.yaml new file +65 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a092ebdefdcf89a635cdcf1073921efd28a38386
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/adi,sc5xx-clocks.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Clock Tree Drivers for Analog Devices ADSP-SC5XX Processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  These drivers read in the processors CDU (clock distribution unit)
+  and CGU (clock generation unit) values to determine various clock
+  rates
+
+properties:
+  compatible:
+    enum:
+      - adi,sc598-clocks # 64-Bit SC598 processor
+
+  '#clock-cells':
+    const: 1
+
+  reg:
+    minItems: 3
+    maxItems: 4
+
+  clocks:
+    description:
+      Specifies the CLKIN0 and CLKIN1 reference clock(s) from which the
+      output frequencies are derived via CDU+CGU
+    minItems: 2
+    maxItems: 2
+
+  clock-names:
+    description:
+      String reference names for CLKIN0 and CLKIN1
+    minItems: 2
+    maxItems: 2
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - '#clock-cells'
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    clk3: clocks@3108d000 {
+        compatible = "adi,sc598-clocks";
+        reg = <0x3108d000 0x1000>,
+              <0x3108e000 0x1000>,
+              <0x3108f000 0x1000>,
+              <0x310a9000 0x1000>;
+        #clock-cells = <1>;
+        clocks = <&sys_clkin0>, <&sys_clkin1>;
+        clock-names = "sys_clkin0", "sys_clkin1";
+        status = "okay";
+    };
+
Signature · 1 line
2.25.1
maintainer
#24 lore raw

Re: [PATCH 08/21] dt-bindings: clock: adi,sc5xx-clocks: add bindings

Quoted 23 lines · Arturs Artamonovs

Add ADSP-SC5xx clock bindings.

---
 .../bindings/clock/adi,sc5xx-clocks.yaml           | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)
Documentation/devicetree/bindings/clock/adi,sc5xx-clocks.yaml new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a092ebdefdcf89a635cdcf1073921efd28a38386
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/adi,sc5xx-clocks.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+

Documentation/devicetree/bindings/clock/adi,sc5xx-clocks.yaml line 16

Quoted 10 lines
Documentation/devicetree/bindings/clock/adi,sc5xx-clocks.yaml new file +10 -0
+title: Clock Tree Drivers for Analog Devices ADSP-SC5XX Processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  These drivers read in the processors CDU (clock distribution unit)
+  and CGU (clock generation unit) values to determine various clock
+  rates

That sounds like 2 h/w blocks, not 1. If so, the bindings should reflect that even if you want 1 driver to handle both.

Rob

#25 lore raw

PATCH 9/21 gpio: add driver for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs

Add ADSP-SC5xx GPIO driver.
- Support all GPIO ports
- Each gpio support seperate PINT interrupt controller

---
 drivers/gpio/Kconfig              |   8 +++
 drivers/gpio/Makefile             |   1 +
 drivers/gpio/gpio-adi-adsp-port.c | 145 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
drivers/gpio/Kconfig +8 -0
index 58f43bcced7c1f29fad5960771817f500ef67ce1..b02693f5b4cec95a59f19aa1bacf7ed72236865a 100644
@@ -147,6 +147,14 @@ config GPIO_74XX_MMIO
 	    8 bits:	74244 (Input), 74273 (Output)
 	    16 bits:	741624 (Input), 7416374 (Output)
 
+config GPIO_ADI_ADSP_PORT
+	bool "ADI ADSP PORT GPIO driver"
+	depends on OF_GPIO
+	select GPIO_GENERIC
+	help
+	  Say Y to enable the ADSP PORT-based GPIO driver for Analog Devices
+	  ADSP chips.
+
 config GPIO_ALTERA
 	tristate "Altera GPIO"
 	depends on OF_GPIO
drivers/gpio/Makefile +1 -0
index 64dd6d9d730d5a22564821df71375113e31fe057..fb02c7807a674c8a38d1128e6a25bb7c7f1f4aab 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_GPIO_104_IDI_48)		+= gpio-104-idi-48.o
 obj-$(CONFIG_GPIO_104_IDIO_16)		+= gpio-104-idio-16.o
 obj-$(CONFIG_GPIO_74X164)		+= gpio-74x164.o
 obj-$(CONFIG_GPIO_74XX_MMIO)		+= gpio-74xx-mmio.o
+obj-$(CONFIG_GPIO_ADI_ADSP_PORT)	+= gpio-adi-adsp-port.o
 obj-$(CONFIG_GPIO_ADNP)			+= gpio-adnp.o
 obj-$(CONFIG_GPIO_ADP5520)		+= gpio-adp5520.o
 obj-$(CONFIG_GPIO_AGGREGATOR)		+= gpio-aggregator.o
drivers/gpio/gpio-adi-adsp-port.c new file +145 -0

146 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#26 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

Quoted 10 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:
drivers/gpio/gpio-adi-adsp-port.c new file +9 -0
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/soc/adi/adsp-gpio-port.h>
+#include "gpiolib.h"
+
+static int adsp_gpio_direction_input(struct gpio_chip *chip, unsigned 

int offset)

drivers/gpio/gpio-adi-adsp-port.c line 21

Quoted 6 lines
drivers/gpio/gpio-adi-adsp-port.c new file +6 -0
+{
+	struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+
+	__adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_DIR_CLEAR);
+	__adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_INEN_SET);
+	return 0;

What is the purpose of these __adsp_gpio_writew() in a global header? Can't those be moved into this file directly?

Quoted 1 line

\ No newline at end of file

Whitespace damage?

Arnd

#27 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs
kernel test robot noticed the following build errors:

Hi Arturs,

kernel test robot noticed the following build errors:

[auto build test ERROR on da3ea35007d0af457a0afc87e84fddaebc4e0b63]

url:    https://github.com/intel-lab-lkp/linux/commits/Arturs-Artamonovs-via-B4-Relay/arm64-Add-ADI-ADSP-SC598-SoC/20240913-022308
base:   da3ea35007d0af457a0afc87e84fddaebc4e0b63
patch link:    https://lore.kernel.org/r/20240912-test-v1-9-458fa57c8ccf%40analog.com
patch subject: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform
config: arm64-randconfig-r071-20240914 (https://download.01.org/0day-ci/archive/20240914/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240914/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

aarch64-linux-ld: Unexpected GOT/PLT entries detected!
aarch64-linux-ld: Unexpected run-time procedure linkages detected!
aarch64-linux-ld: drivers/gpio/gpio-adi-adsp-port.o: in function `adsp_gpio_probe':

>> gpio-adi-adsp-port.c:(.text+0x1cc): undefined reference to `adsp_attach_pint_to_gpio'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#28 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs
Quoted 11 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC5xx GPIO driver.
- Support all GPIO ports
- Each gpio support seperate PINT interrupt controller

Your SoB chain is odd. Author is Greg, but Greg is not the first person in the chain? And no final SoB? This is really odd and not correct. I am not sure what you even want to say here.

...

drivers/gpio/gpio-adi-adsp-port.c line 145

Quoted 7 lines
drivers/gpio/gpio-adi-adsp-port.c new file +6 -0
+
+module_platform_driver(adsp_gpio_driver);
+
+MODULE_AUTHOR("Greg Malysa <[email protected]>");
+MODULE_DESCRIPTION("Analog Devices GPIO driver");
+MODULE_LICENSE("GPL v2");
\ No newline at end of file

Please review all your patches before sending for such stuff.

Best regards,
Krzysztof

#29 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs

Hi Arturs,

thanks for your patch!

Quoted 11 lines · On Thu, Sep 12, 2024 at 8:20 PM Arturs Artamonovs via B4 Relay…

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC5xx GPIO driver.
- Support all GPIO ports
- Each gpio support seperate PINT interrupt controller

(...)

drivers/gpio/Kconfig config GPIO_74XX_MMIO · line 153

Quoted 4 lines
drivers/gpio/Kconfig +4 -0
+config GPIO_ADI_ADSP_PORT
+       bool "ADI ADSP PORT GPIO driver"
+       depends on OF_GPIO
+       select GPIO_GENERIC

If you select this then you need to use it in the idiomatic way.

+#include <linux/soc/adi/adsp-gpio-port.h>

Drop this, just bring the contents into this file all register defines etc.

+#include "gpiolib.h"

No way, do this:
#include <linux/gpio/driver.h>

drivers/gpio/gpio-adi-adsp-port.c line 19

Quoted 5 lines
drivers/gpio/gpio-adi-adsp-port.c new file +5 -0
+static int adsp_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+
+       __adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_DIR_CLEAR);

Ah these __adsp_gpio_writew/readw things are too idiomatic. Just use the base and common writew() please.

Quoted 1 line

+ __adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_INEN_SET);

Interrupt enable in the direction function? No thanks, poke the interrupt registers in your irqchip if you make one (you currently do not) in this case I'd say just disable all interrupts in probe() using something like writew(base + ADSP_PORT_REG_INEN_SET, 0xffff) and be done with it.

drivers/gpio/gpio-adi-adsp-port.c line 77

Quoted 6 lines
drivers/gpio/gpio-adi-adsp-port.c new file +6 -0
+static int adsp_gpio_get_value(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+
+       return !!(__adsp_gpio_readw(port, ADSP_PORT_REG_DATA) & BIT(offset));
+}

This becomes a reimplemenation of generic GPIO.

drivers/gpio/gpio-adi-adsp-port.c line 89

Quoted 11 lines
drivers/gpio/gpio-adi-adsp-port.c new file +11 -0
+static int adsp_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+       irq_hw_number_t irq = offset + port->irq_offset;
+       int map = irq_find_mapping(port->irq_domain, irq);
+
+       if (map)
+               return map;
+
+       return irq_create_mapping(port->irq_domain, irq);
+}

This irqdomain in the "port" looks weird.

Implement the irqchip in the GPIO driver instead.

If the domain *has* to be external to the GPIO driver then you need to use hierarchical irqdomains.

drivers/gpio/gpio-adi-adsp-port.c line 103

Quoted 13 lines
drivers/gpio/gpio-adi-adsp-port.c new file +13 -0
+static int adsp_gpio_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct adsp_gpio_port *gpio;
+       int ret;
+
+       gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL);
+       if (!gpio)
+               return -ENOMEM;
+
+       gpio->regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(gpio->regs))
+               return PTR_ERR(gpio->regs);

So you have gpio->regs which is the base.

Quoted 10 lines
drivers/gpio/gpio-adi-adsp-port.c new file +10 -0
+       gpio->dev = dev;
+
+       ret = adsp_attach_pint_to_gpio(gpio);
+       if  (ret)
+               dev_err_probe(gpio->dev, ret, "error attaching interupt to gpio pin\n");
+
+       spin_lock_init(&gpio->lock);
+
+       gpio->gpio.label = "adsp-gpio";
+       gpio->gpio.direction_input = adsp_gpio_direction_input;

drivers/gpio/gpio-adi-adsp-port.c line 124

Quoted 10 lines
drivers/gpio/gpio-adi-adsp-port.c new file +10 -0
+       gpio->gpio.direction_output = adsp_gpio_direction_output;
+       gpio->gpio.get = adsp_gpio_get_value;
+       gpio->gpio.set = adsp_gpio_set_value;
+       gpio->gpio.to_irq = adsp_gpio_to_irq;
+       gpio->gpio.request = gpiochip_generic_request;
+       gpio->gpio.free = gpiochip_generic_free;
+       gpio->gpio.ngpio = ADSP_PORT_NGPIO;
+       gpio->gpio.parent = dev;
+       gpio->gpio.base = -1;
+       return devm_gpiochip_add_data(dev, &gpio->gpio, gpio);

Look in e.g. drivers/gpio/gpio-ftgpio010.c for an example of how to use generic GPIO (with an irqchip!). It will be something like:

        ret = bgpio_init(&g->gc, dev, 2,
                         gpio->regs + ADSP_PORT_REG_DATA,
                         gpio->regs + ADSP_PORT_REG_DATA_SET,
                         gpio->regs + ADSP_PORT_REG_DATA_CLEAR,
                         gpio->regs + ADSP_PORT_REG_DIR_SET,
                         gpio->regs + ADSP_PORT_REG_DIR_CLEAR,
                         0);
        if (ret) {
                dev_err(dev, "unable to init generic GPIO\n");
                goto dis_clk;
        }
        g->gc.label = dev_name(dev);
        g->gc.base = -1;
        g->gc.parent = dev;
        g->gc.owner = THIS_MODULE;
        /* ngpio is set by bgpio_init() */

You can augment the generic driver instance with an extra config function to set the special open drain bits.

Yours,
Linus Walleij

#30 lore raw

RE: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

Thanks for feedback Linus, will address that in next patch version

Quoted 168 lines

-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: Tuesday, October 1, 2024 1:45 PM
To: Artamonovs, Arturs <[email protected]>
Cc: Catalin Marinas <[email protected]>; Will Deacon <[email protected]>; Greg Malysa <[email protected]>; Philipp Zabel <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Agarwal, Utsav <[email protected]>; Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; Bartosz Golaszewski <[email protected]>; Thomas Gleixner <[email protected]>; Andi Shyti <[email protected]>; Greg Kroah-Hartman <[email protected]>; Jiri Slaby <[email protected]>; Arnd Bergmann <[email protected]>; Olof Johansson <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Linux Factory <[email protected]>; Nathan Barrett- Morrison <[email protected]>
Subject: Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

[External]

Hi Arturs,

thanks for your patch!

Quoted 11 lines · On Thu, Sep 12, 2024 at 8:20 PM Arturs Artamonovs via B4 Relay…

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC5xx GPIO driver.
- Support all GPIO ports
- Each gpio support seperate PINT interrupt controller

(...)

drivers/gpio/Kconfig config GPIO_74XX_MMIO · line 153

Quoted 4 lines
drivers/gpio/Kconfig +4 -0
+config GPIO_ADI_ADSP_PORT
+       bool "ADI ADSP PORT GPIO driver"
+       depends on OF_GPIO
+       select GPIO_GENERIC

If you select this then you need to use it in the idiomatic way.

+#include <linux/soc/adi/adsp-gpio-port.h>

Drop this, just bring the contents into this file all register defines etc.

+#include "gpiolib.h"

No way, do this:
#include <linux/gpio/driver.h>

drivers/gpio/gpio-adi-adsp-port.c line 19

Quoted 5 lines
drivers/gpio/gpio-adi-adsp-port.c new file +5 -0
+static int adsp_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+
+       __adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_DIR_CLEAR);

Ah these __adsp_gpio_writew/readw things are too idiomatic. Just use the base and common writew() please.

Quoted 1 line

+ __adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_INEN_SET);

Interrupt enable in the direction function? No thanks, poke the interrupt registers in your irqchip if you make one (you currently do not) in this case I'd say just disable all interrupts in probe() using something like writew(base + ADSP_PORT_REG_INEN_SET, 0xffff) and be done with it.

drivers/gpio/gpio-adi-adsp-port.c line 77

Quoted 6 lines
drivers/gpio/gpio-adi-adsp-port.c new file +6 -0
+static int adsp_gpio_get_value(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+
+       return !!(__adsp_gpio_readw(port, ADSP_PORT_REG_DATA) & BIT(offset));
+}

This becomes a reimplemenation of generic GPIO.

drivers/gpio/gpio-adi-adsp-port.c line 89

Quoted 11 lines
drivers/gpio/gpio-adi-adsp-port.c new file +11 -0
+static int adsp_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+       struct adsp_gpio_port *port = to_adsp_gpio_port(chip);
+       irq_hw_number_t irq = offset + port->irq_offset;
+       int map = irq_find_mapping(port->irq_domain, irq);
+
+       if (map)
+               return map;
+
+       return irq_create_mapping(port->irq_domain, irq);
+}

This irqdomain in the "port" looks weird.

Implement the irqchip in the GPIO driver instead.

If the domain *has* to be external to the GPIO driver then you need to use hierarchical irqdomains.

drivers/gpio/gpio-adi-adsp-port.c line 103

Quoted 13 lines
drivers/gpio/gpio-adi-adsp-port.c new file +13 -0
+static int adsp_gpio_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct adsp_gpio_port *gpio;
+       int ret;
+
+       gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL);
+       if (!gpio)
+               return -ENOMEM;
+
+       gpio->regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(gpio->regs))
+               return PTR_ERR(gpio->regs);

So you have gpio->regs which is the base.

drivers/gpio/gpio-adi-adsp-port.c

Quoted 5 lines
drivers/gpio/gpio-adi-adsp-port.c new file +5 -0
+       gpio->dev = dev;
+
+       ret = adsp_attach_pint_to_gpio(gpio);
+       if  (ret)
+               dev_err_probe(gpio->dev, ret, "error attaching interupt to gpio

pin\n");

Quoted 5 lines
drivers/gpio/gpio-adi-adsp-port.c new file +5 -0
+
+       spin_lock_init(&gpio->lock);
+
+       gpio->gpio.label = "adsp-gpio";
+       gpio->gpio.direction_input = adsp_gpio_direction_input;

drivers/gpio/gpio-adi-adsp-port.c line 124

Quoted 10 lines
drivers/gpio/gpio-adi-adsp-port.c new file +10 -0
+       gpio->gpio.direction_output = adsp_gpio_direction_output;
+       gpio->gpio.get = adsp_gpio_get_value;
+       gpio->gpio.set = adsp_gpio_set_value;
+       gpio->gpio.to_irq = adsp_gpio_to_irq;
+       gpio->gpio.request = gpiochip_generic_request;
+       gpio->gpio.free = gpiochip_generic_free;
+       gpio->gpio.ngpio = ADSP_PORT_NGPIO;
+       gpio->gpio.parent = dev;
+       gpio->gpio.base = -1;
+       return devm_gpiochip_add_data(dev, &gpio->gpio, gpio);

Look in e.g. drivers/gpio/gpio-ftgpio010.c for an example of how to use generic GPIO (with an irqchip!). It will be something like:

        ret = bgpio_init(&g->gc, dev, 2,
                         gpio->regs + ADSP_PORT_REG_DATA,
                         gpio->regs + ADSP_PORT_REG_DATA_SET,
                         gpio->regs + ADSP_PORT_REG_DATA_CLEAR,
                         gpio->regs + ADSP_PORT_REG_DIR_SET,
                         gpio->regs + ADSP_PORT_REG_DIR_CLEAR,
                         0);
        if (ret) {
                dev_err(dev, "unable to init generic GPIO\n");
                goto dis_clk;
        }
        g->gc.label = dev_name(dev);
        g->gc.base = -1;
        g->gc.parent = dev;
        g->gc.owner = THIS_MODULE;
        /* ngpio is set by bgpio_init() */

You can augment the generic driver instance with an extra config function to set the special open drain bits.

Yours,
Linus Walleij

#31 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

In reply to Linus Walleij

Hi Linus,

Thanks for the review.

Quoted 8 lines
Quoted 1 line

+ __adsp_gpio_writew(port, BIT(offset), ADSP_PORT_REG_INEN_SET);

Interrupt enable in the direction function? No thanks, poke the interrupt registers in your irqchip if you make one (you currently do not) in this case I'd say just disable all interrupts in probe() using something like writew(base + ADSP_PORT_REG_INEN_SET, 0xffff) and be done with it.

This will come up next time too so I wanted to mention that INEN here means "input enable." The PORT design has two registers for controlling pin direction, one to enable/disable output drivers (DIR) and one to enable input drivers (INEN) to be able to read the pin state from the gpio data register. If I recall the bare metal reference code toggled both but we can review if setting INEN for all pins and leaving it is acceptable as well to simplify things.

Thanks,
Greg

Signature · 2 lines
Greg Malysa
Timesys Corporation
#32 lore raw

Re: [PATCH 09/21] gpio: add driver for ADI ADSP-SC5xx platform

Quoted 7 lines · Greg Malysa
Quoted 6 lines

Interrupt enable in the direction function? No thanks, poke the interrupt registers in your irqchip if you make one (you currently do not) in this case I'd say just disable all interrupts in probe() using something like writew(base + ADSP_PORT_REG_INEN_SET, 0xffff) and be done with it.

Quoted 7 lines

This will come up next time too so I wanted to mention that INEN here means "input enable." The PORT design has two registers for controlling pin direction, one to enable/disable output drivers (DIR) and one to enable input drivers (INEN) to be able to read the pin state from the gpio data register. If I recall the bare metal reference code toggled both but we can review if setting INEN for all pins and leaving it is acceptable as well to simplify things.

Aha so that's what it means!

Yeah play around with it and see what you can come up with.

Perhaps you need to override the input/output enable callbacks with local versions rather than the gpio-mmio ones to set all bits. (This is possible to do after bgpio_init() but before adding the gpio_chip if necessary.)

Yours,
Linus Walleij

#33 lore raw

PATCH 10/21 dt-bindings: gpio: adi,adsp-port-gpio: add bindings

In reply to Arturs Artamonovs

Add ADSP-SC5xx GPIO driver bindings.

---
 .../bindings/gpio/adi,adsp-port-gpio.yaml          | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +69 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3d7899ce759193296ce787d09d742824277f37f8
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/adi,adsp-port-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices GPIO Port Driver for SC5XX-family processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Analog Devices GPIO Port Driver for SC5XX-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-port-gpio
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-ranges:
+    description: Associated pinmux controller and the GPIO range values
+
+  adi,pint:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Associated pin interrupt controller driver
+    items:
+      - items:
+          - description: phandle to pin interrupt controller driver
+          - description: interrupt value
+
+  reg:
+    description: PORT GPIO control registers
+
+required:
+  - compatible
+  - reg
+  - "#gpio-cells"
+  - gpio-controller
+  - gpio-ranges
+  - adi,pint
+
+additionalProperties: false
+
+examples:
+  - |
+    gpa: gport@31004000 {
+      compatible = "adi,adsp-port-gpio";
+      gpio-controller;
+      #gpio-cells = <2>;
+      reg = <0x31004000 0x7F>;
+      gpio-ranges = <&pinctrl0 0 0 16>;
+      adi,pint = <&pint0 1>;
+    };
+
+    gpb: gport@31004080 {
+      compatible = "adi,adsp-port-gpio";
+      gpio-controller;
+      #gpio-cells = <2>;
+      reg = <0x31004080 0x7F>;
+      gpio-ranges = <&pinctrl0 0 16 16>;
+      adi,pint = <&pint0 0>;
+    };
+...
Signature · 1 line
2.25.1
#34 lore raw

Re: [PATCH 10/21] dt-bindings: gpio: adi,adsp-port-gpio: add bindings

Quoted 22 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC5xx GPIO driver bindings.

---
 .../bindings/gpio/adi,adsp-port-gpio.yaml          | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3d7899ce759193296ce787d09d742824277f37f8
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +10 -0
+$id: http://devicetree.org/schemas/gpio/adi,adsp-port-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices GPIO Port Driver for SC5XX-family processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |

Do not need '|' unless you need to preserve formatting.

All review comments apply to all your patches.

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 19

Quoted 6 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +6 -0
+  Analog Devices GPIO Port Driver for SC5XX-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-port-gpio

No, this *must* be SoC-specific compatible. If you are unsure, just look at any other SoC (of course nothing ancient).

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 27

Quoted 8 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +8 -0
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-ranges:
+    description: Associated pinmux controller and the GPIO range values

That's useless comment. Just true, or min/maxItems

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 35

Quoted 8 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +8 -0
+
+  adi,pint:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: Associated pin interrupt controller driver
+    items:
+      - items:
+          - description: phandle to pin interrupt controller driver
+          - description: interrupt value

Hm? No, why would you put it here? And why this is not just interrupts property?

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 38

Quoted 3 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +3 -0
+
+  reg:
+    description: PORT GPIO control registers

Reg goes after compatible

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 42

Quoted 4 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +4 -0
+
+required:
+  - compatible
+  - reg

Look, here order is correct.

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 52

Quoted 10 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +10 -0
+  - "#gpio-cells"
+  - gpio-controller
+  - gpio-ranges
+  - adi,pint
+
+additionalProperties: false
+
+examples:
+  - |
+    gpa: gport@31004000 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Drop unused label.

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 56

Quoted 4 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +4 -0
+      compatible = "adi,adsp-port-gpio";
+      gpio-controller;
+      #gpio-cells = <2>;
+      reg = <0x31004000 0x7F>;

It is ALWAYS lowercase hex. This applies (just like all other comments) to all your DT-related code.

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 58

Quoted 2 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +2 -0
+      gpio-ranges = <&pinctrl0 0 0 16>;
+      adi,pint = <&pint0 1>;

Just one example. Drop the one below.

Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml line 69

Quoted 12 lines
Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml new file +11 -0
+    };
+
+    gpb: gport@31004080 {
+      compatible = "adi,adsp-port-gpio";
+      gpio-controller;
+      #gpio-cells = <2>;
+      reg = <0x31004080 0x7F>;
+      gpio-ranges = <&pinctrl0 0 16 16>;
+      adi,pint = <&pint0 0>;
+    };
+...

Best regards,
Krzysztof

#35 lore raw

PATCH 11/21 irqchip: Add irqchip for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs

Support seting extra indepdendent interrupt on pin activity.

---
 drivers/irqchip/Kconfig        |   9 ++
 drivers/irqchip/Makefile       |   2 +
 drivers/irqchip/irq-adi-adsp.c | 310 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 321 insertions(+)
drivers/irqchip/Kconfig +9 -0
index d078bdc48c38f13af9a129974f3b637dfee0e40f..1bc8f1bd45b3d2f69d2d0e6c8fa01b17b12ce241 100644
@@ -91,6 +91,15 @@ config ALPINE_MSI
 	select PCI_MSI
 	select GENERIC_IRQ_CHIP
 
+config ADI_ADSP_IRQ
+	bool "ADI PORT PINT Driver"
+	depends on OF
+	depends on (ARCH_SC59X_64 || ARCH_SC59X)
+	select IRQ_DOMAIN
+	help
+	  Say Y to enable the PORT-based PINT interrupt controller for
+	  Analog Devices ADSP devices.
+
 config AL_FIC
 	bool "Amazon's Annapurna Labs Fabric Interrupt Controller"
 	depends on OF
drivers/irqchip/Makefile +2 -0
index 15635812b2d6605a2dd3bb0e5fb3170ab2cb0f77..258a188676fd97e713f3cebe16e3d563add095f3 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IRQCHIP)			+= irqchip.o
 
+
+obj-$(CONFIG_ADI_ADSP_IRQ)		+= irq-adi-adsp.o
 obj-$(CONFIG_AL_FIC)			+= irq-al-fic.o
 obj-$(CONFIG_ALPINE_MSI)		+= irq-alpine-msi.o
 obj-$(CONFIG_ATH79)			+= irq-ath79-cpu.o
drivers/irqchip/irq-adi-adsp.c new file +310 -0

311 lines not on this page · raw message

Signature · 1 line
2.25.1
#36 lore raw

Re: [PATCH 11/21] irqchip: Add irqchip for ADI ADSP-SC5xx platform

kernel test robot noticed the following build warnings:

Hi Arturs,

kernel test robot noticed the following build warnings:

[auto build test WARNING on da3ea35007d0af457a0afc87e84fddaebc4e0b63]

url:    https://github.com/intel-lab-lkp/linux/commits/Arturs-Artamonovs-via-B4-Relay/arm64-Add-ADI-ADSP-SC598-SoC/20240913-022308
base:   da3ea35007d0af457a0afc87e84fddaebc4e0b63
patch link:    https://lore.kernel.org/r/20240912-test-v1-11-458fa57c8ccf%40analog.com
patch subject: [PATCH 11/21] irqchip: Add irqchip for ADI ADSP-SC5xx platform
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20240914/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bf684034844c660b778f0eba103582f582b710c9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240914/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/irqchip/irq-adi-adsp.c:3: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

* ADSP PINT PORT driver.
drivers/irqchip/irq-adi-adsp.c:51: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Each gpio device should be connected to one of the two valid pints with an
drivers/irqchip/irq-adi-adsp.c:152: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* This handles the GIC interrupt associated with this PINT being activated.

vim +3 drivers/irqchip/irq-adi-adsp.c

   > 3	 * ADSP PINT PORT driver.
     4	 *
     5	 * The default mapping is used for all PINTs, refer to the HRM to identify
     6	 * PORT mapping to PINTs. For example, PINT0 has PORT B (0-15) and PORT A
     7	 * (16-31).
     8	 *
     9	 * Copyright (C) 2022-2024, Analog Devices, Inc.
    10	 */
    11	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#37 lore raw

Re: [PATCH 11/21] irqchip: Add irqchip for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs
Quoted 20 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Support seting extra indepdendent interrupt on pin activity.

---
 drivers/irqchip/Kconfig        |   9 ++
 drivers/irqchip/Makefile       |   2 +
 drivers/irqchip/irq-adi-adsp.c | 310 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 321 insertions(+)
drivers/irqchip/Kconfig +0 -0
index d078bdc48c38f13af9a129974f3b637dfee0e40f..1bc8f1bd45b3d2f69d2d0e6c8fa01b17b12ce241 100644

drivers/irqchip/Kconfig config ALPINE_MSI · line 95

Quoted 5 lines
drivers/irqchip/Kconfig +2 -0
@@ -91,6 +91,15 @@ config ALPINE_MSI
 	select PCI_MSI
 	select GENERIC_IRQ_CHIP
 
+config ADI_ADSP_IRQ
+	bool "ADI PORT PINT Driver"

What is "PORT"?
What is "PINT"?

drivers/irqchip/Kconfig config ALPINE_MSI · line 97

Quoted 2 lines
drivers/irqchip/Kconfig +2 -0
+	depends on OF
+	depends on (ARCH_SC59X_64 || ARCH_SC59X)

Missing compile test.

drivers/irqchip/Kconfig config ALPINE_MSI · line 100

Quoted 3 lines
drivers/irqchip/Kconfig +3 -0
+	select IRQ_DOMAIN
+	help
+	  Say Y to enable the PORT-based PINT interrupt controller for

Expand acronyms here.

Quoted 10 lines
drivers/irqchip/Kconfig +2 -0
+	  Analog Devices ADSP devices.
+
 config AL_FIC
 	bool "Amazon's Annapurna Labs Fabric Interrupt Controller"
 	depends on OF
drivers/irqchip/Makefile +0 -0
index 15635812b2d6605a2dd3bb0e5fb3170ab2cb0f77..258a188676fd97e713f3cebe16e3d563add095f3 100644

drivers/irqchip/Makefile line 4

Quoted 4 lines
drivers/irqchip/Makefile +1 -0
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IRQCHIP)			+= irqchip.o
 
+

Why?

Quoted 3 lines
drivers/irqchip/Makefile +1 -0
+obj-$(CONFIG_ADI_ADSP_IRQ)		+= irq-adi-adsp.o
 obj-$(CONFIG_AL_FIC)			+= irq-al-fic.o
 obj-$(CONFIG_ALPINE_MSI)		+= irq-alpine-msi.o

...

Quoted 30 lines
drivers/irqchip/Makefile +30 -0
+
+static int adsp_pint_irq_set_type(struct irq_data *d, unsigned int type)
+{
+	struct adsp_pint *pint = irq_data_get_irq_chip_data(d);
+	unsigned int pos = BIT(d->hwirq);
+
+	switch (type) {
+	case IRQ_TYPE_PROBE:
+		type = IRQ_TYPE_EDGE_BOTH;
+		fallthrough;
+	case IRQ_TYPE_EDGE_BOTH:
+		/* start by looking for rising edge */
+		writel(pos, pint->regs + ADSP_PINT_REG_INVERT_CLEAR);
+		writel(pos, pint->regs + ADSP_PINT_REG_EDGE_SET);
+		return 0;
+
+	case IRQ_TYPE_EDGE_FALLING:
+		writel(pos, pint->regs + ADSP_PINT_REG_INVERT_SET);
+		writel(pos, pint->regs + ADSP_PINT_REG_EDGE_SET);
+		return 0;
+
+	case IRQ_TYPE_EDGE_RISING:
+		writel(pos, pint->regs + ADSP_PINT_REG_INVERT_CLEAR);
+		writel(pos, pint->regs + ADSP_PINT_REG_EDGE_SET);
+		return 0;
+
+	case IRQ_TYPE_LEVEL_HIGH:
+		writel(pos, pint->regs + ADSP_PINT_REG_INVERT_CLEAR);
+		writel(pos, pint->regs + ADSP_PINT_REG_EDGE_CLEAR);
+		return 0;

drivers/irqchip/Makefile

Quoted 10 lines
drivers/irqchip/Makefile +10 -0
+
+	case IRQ_TYPE_LEVEL_LOW:
+		writel(pos, pint->regs + ADSP_PINT_REG_INVERT_SET);
+		writel(pos, pint->regs + ADSP_PINT_REG_EDGE_CLEAR);
+		return 0;
+
+	default:
+		return -EINVAL;
+	}
+

Fix blank line issues everywhere.

Quoted 24 lines
drivers/irqchip/Makefile +24 -0
+}
+
+static int adsp_pint_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct adsp_pint *pint;
+
+	pint = devm_kzalloc(dev, sizeof(*pint), GFP_KERNEL);
+	if (!pint)
+		return -ENOMEM;
+
+	pint->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(pint->regs))
+		return PTR_ERR(pint->regs);
+
+	pint->chip.name = "adsp-pint";
+	pint->chip.irq_ack = adsp_pint_irq_ack;
+	pint->chip.irq_mask = adsp_pint_irq_mask;
+	pint->chip.irq_unmask = adsp_pint_irq_unmask;
+	pint->chip.irq_set_type = adsp_pint_irq_set_type;
+	// @todo potentially only SEC supports wake options, not gic
+
+	// @todo determine if we actually need a raw spinlock

drivers/irqchip/Makefile

Quoted 10 lines
drivers/irqchip/Makefile +10 -0
+
+	pint->domain = irq_domain_add_linear(np, ADSP_PINT_IRQS,
+		&adsp_irq_domain_ops, pint);
+	if (!pint->domain) {
+		dev_err(dev, "Could not create irq domain\n");
+		return -EINVAL;
+	}
+
+	pint->irq = platform_get_irq(pdev, 0);
+	if (!pint->irq) {

That's a bug, technically. Read the doc. Why -EINVAL is a valid interrupt?

Quoted 17 lines
drivers/irqchip/Makefile +17 -0
+		dev_err(dev, "Could not find parent interrupt for port\n");
+		return -EINVAL;
+	}
+
+	irq_set_chained_handler_and_data(pint->irq, adsp_pint_irq_handler, pint);
+	platform_set_drvdata(pdev, pint);
+
+	return 0;
+}
+
+static void adsp_pint_remove(struct platform_device *pdev)
+{
+	struct adsp_pint *pint = platform_get_drvdata(pdev);
+
+	irq_set_chained_handler_and_data(pint->irq, NULL, NULL);
+	irq_domain_remove(pint->domain);
+}

drivers/irqchip/Makefile

Quoted 10 lines
drivers/irqchip/Makefile +10 -0
+
+static const struct of_device_id adsp_pint_of_match[] = {
+	{ .compatible = "adi,adsp-pint" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, adsp_pint_of_match);
+
+static struct platform_driver adsp_pint_driver = {
+	.driver = {
+		.name = "adsp-port-pint",

Bindings are always before the users.

Best regards,
Krzysztof

#38 lore raw

Re: [PATCH 11/21] irqchip: Add irqchip for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs
Quoted 3 lines · Arturs Artamonovs via

From: Arturs Artamonovs <[email protected]>

Support seting extra indepdendent interrupt on pin activity.

So the subject says it adds a new interrupt chip. Now the changelog mumbles about support of something extra.

Please describe your changes properly and explain what this is about. Also spell check your change log.

drivers/irqchip/irq-adi-adsp.c line 42

Quoted 5 lines
drivers/irqchip/irq-adi-adsp.c new file +5 -0
+struct adsp_pint {
+	struct irq_chip chip;
+	void __iomem *regs;
+	struct irq_domain *domain;
+	unsigned int irq;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#struct-declarations-and-initializers

And please read and follow the rest of that document too.

Quoted 4 lines

+ * This relies on the default configuration of the hardware, which we do not
+ * expose an interface to change.
+ */
+int adsp_attach_pint_to_gpio(struct adsp_gpio_port *port)

Where is this function declared and where is it used?

Quoted 5 lines
drivers/irqchip/irq-adi-adsp.c new file +5 -0
+static void adsp_pint_dispatch_irq(struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct adsp_pint *pint = to_adsp_pint(chip);
+	unsigned int type = irqd_get_trigger_type(&desc->irq_data);

drivers/irqchip/irq-adi-adsp.c line 124

Quoted 10 lines
drivers/irqchip/irq-adi-adsp.c new file +10 -0
+	u32 pos = BIT(desc->irq_data.hwirq);
+
+	/* for both edge interrupt, toggle invert bit to catch next edge */
+	if (type == IRQ_TYPE_EDGE_BOTH) {
+		u32 invert = readl(pint->regs + ADSP_PINT_REG_INVERT_SET) & pos;
+
+		if (invert)
+			writel(pos, pint->regs + ADSP_PINT_REG_INVERT_CLEAR);
+		else
+			writel(pos, pint->regs + ADSP_PINT_REG_INVERT_SET);

What protects pint->regs against concurrent modifications?

drivers/irqchip/irq-adi-adsp.c line 185

Quoted 5 lines
drivers/irqchip/irq-adi-adsp.c new file +5 -0
+static void adsp_pint_irq_mask(struct irq_data *d)
+{
+	struct adsp_pint *pint = irq_data_get_irq_chip_data(d);
+
+	writel(BIT(d->hwirq), pint->regs + ADSP_PINT_REG_MASK_CLEAR);

Same question.

Quoted 12 lines
drivers/irqchip/irq-adi-adsp.c new file +12 -0
+static int adsp_pint_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct adsp_pint *pint;
+
+	pint = devm_kzalloc(dev, sizeof(*pint), GFP_KERNEL);
+	if (!pint)
+		return -ENOMEM;
+
+	pint->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(pint->regs))

drivers/irqchip/irq-adi-adsp.c line 257

Quoted 10 lines
drivers/irqchip/irq-adi-adsp.c new file +10 -0
+		return PTR_ERR(pint->regs);
+
+	pint->chip.name = "adsp-pint";
+	pint->chip.irq_ack = adsp_pint_irq_ack;
+	pint->chip.irq_mask = adsp_pint_irq_mask;
+	pint->chip.irq_unmask = adsp_pint_irq_unmask;
+	pint->chip.irq_set_type = adsp_pint_irq_set_type;
+	// @todo potentially only SEC supports wake options, not gic
+
+	// @todo determine if we actually need a raw spinlock

This should have been determined before posting, no?

drivers/irqchip/irq-adi-adsp.c line 260

Quoted 2 lines
drivers/irqchip/irq-adi-adsp.c new file +2 -0
+	pint->domain = irq_domain_add_linear(np, ADSP_PINT_IRQS,
+		&adsp_irq_domain_ops, pint);

devm_irq_domain_instantiate()

drivers/irqchip/irq-adi-adsp.c line 269

Quoted 9 lines
drivers/irqchip/irq-adi-adsp.c new file +9 -0
+	if (!pint->domain) {
+		dev_err(dev, "Could not create irq domain\n");
+		return -EINVAL;
+	}
+
+	pint->irq = platform_get_irq(pdev, 0);
+	if (!pint->irq) {
+		dev_err(dev, "Could not find parent interrupt for port\n");
+		return -EINVAL;

Then this would not leak the interrupt domain. Also why is this not checked _before_ instantiating the domain?

drivers/irqchip/irq-adi-adsp.c line 305

Quoted 5 lines
drivers/irqchip/irq-adi-adsp.c new file +5 -0
+static int __init adsp_pint_init(void)
+{
+	return platform_driver_register(&adsp_pint_driver);
+}
+

Pointless new line

drivers/irqchip/irq-adi-adsp.c line 310

Quoted 6 lines
drivers/irqchip/irq-adi-adsp.c new file +5 -0
+arch_initcall(adsp_pint_init);
+
+MODULE_DESCRIPTION("Analog Devices IRQChip driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Greg Malysa <[email protected]>");
\ No newline at end of file

This message has a meaning, no?

Thanks,

tglx

#39 lore raw

PATCH 12/21 dt-bindings: irqchip: adi,adsp-pint: add binding

In reply to Arturs Artamonovs
---
 .../interrupt-controller/adi,adsp-pint.yaml        | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +51 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b5ecf0cf1d2ceb580f45467ffe1550ae3280d1a3
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/adi,adsp-pint.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Port Pin Interrupt for SC5XX-family processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Analog Devices Port Pin Interrupt driver for SC5XX-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-pint
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/adi-sc5xx-clock.h>
+
+    pint0: pint@31005000 {
+      compatible = "adi,adsp-pint";
+      reg = <0x31005000 0xFF>;
+      interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
+    };
+
+    pint1: pint@31005100 {
+      compatible = "adi,adsp-pint";
+      reg = <0x31005100 0xFF>;
+      interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
+    };
+...
Signature · 1 line
2.25.1
#40 lore raw

Re: [PATCH 12/21] dt-bindings: irqchip: adi,adsp-pint: add binding

Quoted 2 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

You must always run checkpatch. We cannot take empty commit msgs, for obvious reasons.

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Instead describe the hardware.

Quoted 24 lines
---
 .../interrupt-controller/adi,adsp-pint.yaml        | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +9 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b5ecf0cf1d2ceb580f45467ffe1550ae3280d1a3
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/adi,adsp-pint.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Port Pin Interrupt for SC5XX-family processors
+
+maintainers:

Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml line 19

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +10 -0
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Analog Devices Port Pin Interrupt driver for SC5XX-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-pint

All previous comments apply.

Quoted 9 lines
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible

Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml line 38

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +10 -0
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/adi-sc5xx-clock.h>

Where do you user it?

Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml line 45

Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +7 -0
+
+    pint0: pint@31005000 {
+      compatible = "adi,adsp-pint";
+      reg = <0x31005000 0xFF>;
+      interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
+    };
+

All previous comments apply.

Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml line 51

Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml new file +6 -0
+    pint1: pint@31005100 {
+      compatible = "adi,adsp-pint";
+      reg = <0x31005100 0xFF>;
+      interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
+    };
+...

Best regards,
Krzysztof

#41 lore raw

PATCH 13/21 pinctrl: Add drivers for ADI ADSP-SC5xx platform

In reply to Arturs Artamonovs

Add ADSP-SC5xx pinctrler:
- Support switching GPIO pin functions.

---
 drivers/pinctrl/Kconfig        |  12 +
 drivers/pinctrl/Makefile       |   1 +
 drivers/pinctrl/pinctrl-adsp.c | 919 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 932 insertions(+)
drivers/pinctrl/Kconfig +12 -0
index 7e4f93a3bc7ac9bcafc92ddb795569d7cca6474d..ffc0946c5b416c29803e195016867aee8f09afe1 100644
@@ -31,6 +31,18 @@ config DEBUG_PINCTRL
 	help
 	  Say Y here to add some extra checks and diagnostics to PINCTRL calls.
 
+config PINCTRL_ADSP
+	bool "ADSP-SC5XX pinctrl driver"
+	depends on ARCH_SC59X_64
+	depends on OF
+	select PINMUX
+	select GPIOLIB
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the ADSP-SC5XX pinctrl driver. This is required for
+	  correct peripheral functionality on the SoC.
+
+
 config PINCTRL_AMD
 	bool "AMD GPIO pin control"
 	depends on HAS_IOMEM
drivers/pinctrl/Makefile +1 -0
index cc809669405ab6c6905fe0b2380f91b211a2d470..6b340bf0ee8c0267cbbdee3d14db605a340433c6 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_PINCONF)		+= pinconf.o
 obj-$(CONFIG_GENERIC_PINCONF)	+= pinconf-generic.o
 obj-$(CONFIG_OF)		+= devicetree.o
 
+obj-$(CONFIG_PINCTRL_ADSP)	+= pinctrl-adsp.o
 obj-$(CONFIG_PINCTRL_AMD)	+= pinctrl-amd.o
 obj-$(CONFIG_PINCTRL_APPLE_GPIO) += pinctrl-apple-gpio.o
 obj-$(CONFIG_PINCTRL_ARTPEC6)	+= pinctrl-artpec6.o
drivers/pinctrl/pinctrl-adsp.c new file +919 -0

920 lines not on this page · raw message

Signature · 1 line
2.25.1
#42 lore raw

Re: [PATCH 13/21] pinctrl: Add drivers for ADI ADSP-SC5xx platform

kernel test robot noticed the following build warnings:

Hi Arturs,

kernel test robot noticed the following build warnings:

[auto build test WARNING on da3ea35007d0af457a0afc87e84fddaebc4e0b63]

url:    https://github.com/intel-lab-lkp/linux/commits/Arturs-Artamonovs-via-B4-Relay/arm64-Add-ADI-ADSP-SC598-SoC/20240913-022308
base:   da3ea35007d0af457a0afc87e84fddaebc4e0b63
patch link:    https://lore.kernel.org/r/20240912-test-v1-13-458fa57c8ccf%40analog.com
patch subject: [PATCH 13/21] pinctrl: Add drivers for ADI ADSP-SC5xx platform
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20240914/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project bf684034844c660b778f0eba103582f582b710c9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240914/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/pinctrl/pinctrl-adsp.c:291: warning: Function parameter or struct member 'pctldev' not described in 'adsp_pinctrl_dt_node_to_map'
>> drivers/pinctrl/pinctrl-adsp.c:291: warning: Function parameter or struct member 'np' not described in 'adsp_pinctrl_dt_node_to_map'
>> drivers/pinctrl/pinctrl-adsp.c:291: warning: Function parameter or struct member 'map' not described in 'adsp_pinctrl_dt_node_to_map'
>> drivers/pinctrl/pinctrl-adsp.c:291: warning: Function parameter or struct member 'num_maps' not described in 'adsp_pinctrl_dt_node_to_map'
>> drivers/pinctrl/pinctrl-adsp.c:291: warning: expecting prototype for Handle device tree structures like(). Prototype was for adsp_pinctrl_dt_node_to_map() instead

vim +291 drivers/pinctrl/pinctrl-adsp.c

271
272 /**
273 * Handle device tree structures like:
274 *
275 * pinctrl_uart0_hwflow: uart0_hwflow_pins {
276 * pins_rxtx_ {
277 * pinmux = <1>, <2>;
278 * some-padconf-flag;
279 * };
280 * pins_hwflow {
281 * pinmux = <3>, <4>;
282 * some-other-padconf-flag;
283 * };
284 * };
285 *
286 * where &pinctrl_uart0_hwflow is passed as an entry in pinctrl-0 on uart driver and
287 * enables all sub-pins at once
288 */
289 static int adsp_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
290 struct device_node *np, struct pinctrl_map **map, unsigned int *num_maps)

 > 291	{

292 unsigned int reserved_maps;
293 struct device_node *child_np;
294 int ret;
295
296 reserved_maps = 0;
297 *map = NULL;
298 *num_maps = 0;
299
300 for_each_child_of_node(np, child_np) {
301 ret = adsp_pinctrl_dt_subnode_to_map(pctldev, child_np, map,
302 &reserved_maps, num_maps);
303 if (ret < 0)
304 goto exit;
305 }
306 return 0;
307
308 exit:
309 pinctrl_utils_free_map(pctldev, *map, *num_maps);
310 return ret;
311 }
312

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#43 lore raw

PATCH 14/21 dt-bindings: pinctrl: adi,adsp-pinctrl: add bindings

In reply to Arturs Artamonovs

Add PINCTRL driver bindings.

---
 .../bindings/pinctrl/adi,adsp-pinctrl.yaml         | 83 ++++++++++++++++++++++
 include/dt-bindings/pinctrl/adi-adsp.h             | 19 +++++
 2 files changed, 102 insertions(+)
Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml new file +83 -0
new file mode 100644
index 0000000000000000000000000000000000000000..073442b4f680bf536f631b4c17a1d3195c2233d6
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/adi,adsp-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Pinmuxing Control for SC5XX Processor Family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Pinmuxing Control Driver for Configuring Processor Pins/Pads
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-pinctrl
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 1
+
+  reg:
+    maxItems: 1
+
+  "adi,port-sizes":
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    maxItems: 9
+    description: Space delimited integer list denoting number of pins per port
+      Ports A-I exist, so this is up to 9 items long
+
+  "adi,no-drive-strength":
+    type: boolean
+    description: Indicate missing drive strength registers
+
+  "adi,no-pull-up-down":
+    type: boolean
+    description: Indicate missing pull up/down enable registers
+
+patternProperties:
+  '-pins$':
+    type: object
+    additionalProperties: false
+
+    properties:
+      pins:
+        type: object
+        description: |
+          A pinctrl node should contain a pin property, specifying the actual
+          pins to use.
+
+        properties:
+          pinmux:
+            $ref: /schemas/types.yaml#/definitions/uint32-array
+            description: |
+              pinmux is used to specify which of the available functionalities
+              for a given pin are actually used.
+
+        additionalProperties: false
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+  - reg
+  - "adi,port-sizes"
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl0: pinctrl@31004600 {
+      compatible = "adi,adsp-pinctrl";
+      #address-cells = <1>;
+      #size-cells = <1>;
+      reg = <0x31004600 0x400>;
+      adi,port-sizes = <16 16 16 16 16 16 16 16 7>;
+    };
+
include/dt-bindings/pinctrl/adi-adsp.h new file +19 -0
new file mode 100644
index 0000000000000000000000000000000000000000..dc5b86a0d9190acdd242a6ba4972c3aac7a61821
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0*/
+/*
+ * Macros for populating pinmux properties on the pincontroller
+ *
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#ifndef DT_BINDINGS_PINCTRL_ADI_ADSP_H
+#define DT_BINDINGS_PINCTRL_ADI_ADSP_H
+
+#define ADI_ADSP_PINFUNC_GPIO     0
+#define ADI_ADSP_PINFUNC_ALT0     1
+#define ADI_ADSP_PINFUNC_ALT1     2
+#define ADI_ADSP_PINFUNC_ALT2     3
+#define ADI_ADSP_PINFUNC_ALT3     4
+
+#define ADI_ADSP_PINMUX(port, pin, func) ((((port - 'A')*16 + pin) << 8) + func)
+
+#endif
Signature · 1 line
2.25.1
maintainer
#44 lore raw

Re: [PATCH 14/21] dt-bindings: pinctrl: adi,adsp-pinctrl: add bindings

Quoted 38 lines · Arturs Artamonovs

Add PINCTRL driver bindings.

---
 .../bindings/pinctrl/adi,adsp-pinctrl.yaml         | 83 ++++++++++++++++++++++
 include/dt-bindings/pinctrl/adi-adsp.h             | 19 +++++
 2 files changed, 102 insertions(+)
Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml new file +20 -0
new file mode 100644
index 0000000000000000000000000000000000000000..073442b4f680bf536f631b4c17a1d3195c2233d6
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/adi,adsp-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices Pinmuxing Control for SC5XX Processor Family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Pinmuxing Control Driver for Configuring Processor Pins/Pads
+
+properties:
+  compatible:
+    enum:
+      - adi,adsp-pinctrl
+

Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml new file +10 -0
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 1
+
+  reg:
+    maxItems: 1
+
+  "adi,port-sizes":

Don't need quotes.

Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml line 34

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml new file +4 -0
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    maxItems: 9
+    description: Space delimited integer list denoting number of pins per port
+      Ports A-I exist, so this is up to 9 items long

No constraints on the entries?

Quoted 55 lines
Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml new file +49 -0
+
+  "adi,no-drive-strength":
+    type: boolean
+    description: Indicate missing drive strength registers
+
+  "adi,no-pull-up-down":
+    type: boolean
+    description: Indicate missing pull up/down enable registers
+
+patternProperties:
+  '-pins$':
+    type: object
+    additionalProperties: false
+
+    properties:
+      pins:
+        type: object
+        description: |
+          A pinctrl node should contain a pin property, specifying the actual
+          pins to use.
+
+        properties:
+          pinmux:
+            $ref: /schemas/types.yaml#/definitions/uint32-array
+            description: |
+              pinmux is used to specify which of the available functionalities
+              for a given pin are actually used.
+
+        additionalProperties: false
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+  - reg
+  - "adi,port-sizes"
+
+additionalProperties: false
+
+examples:
+  - |
+    pinctrl0: pinctrl@31004600 {
+      compatible = "adi,adsp-pinctrl";
+      #address-cells = <1>;
+      #size-cells = <1>;
+      reg = <0x31004600 0x400>;
+      adi,port-sizes = <16 16 16 16 16 16 16 16 7>;
+    };
+
include/dt-bindings/pinctrl/adi-adsp.h new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..dc5b86a0d9190acdd242a6ba4972c3aac7a61821

include/dt-bindings/pinctrl/adi-adsp.h line 1

Quoted 1 line
include/dt-bindings/pinctrl/adi-adsp.h new file +1 -0
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0*/

Missing space ^

New bindings should be dual licensed.

Quoted 22 lines
include/dt-bindings/pinctrl/adi-adsp.h new file +18 -0
+/*
+ * Macros for populating pinmux properties on the pincontroller
+ *
+ * Copyright 2022-2024 - Analog Devices Inc.
+ */
+
+#ifndef DT_BINDINGS_PINCTRL_ADI_ADSP_H
+#define DT_BINDINGS_PINCTRL_ADI_ADSP_H
+
+#define ADI_ADSP_PINFUNC_GPIO     0
+#define ADI_ADSP_PINFUNC_ALT0     1
+#define ADI_ADSP_PINFUNC_ALT1     2
+#define ADI_ADSP_PINFUNC_ALT2     3
+#define ADI_ADSP_PINFUNC_ALT3     4
+
+#define ADI_ADSP_PINMUX(port, pin, func) ((((port - 'A')*16 + pin) << 8) + func)
+
+#endif
Signature · 2 lines
-- 
2.25.1
#45 lore raw

PATCH 15/21 i2c: Add driver for ADI ADSP-SC5xx platforms

In reply to Arturs Artamonovs

Add support for I2C on SC5xx

---
 drivers/i2c/busses/Kconfig       |  17 +
 drivers/i2c/busses/Makefile      |   1 +
 drivers/i2c/busses/i2c-adi-twi.c | 940 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 958 insertions(+)
drivers/i2c/busses/Kconfig +17 -0
index a22f9125322a723b31925fd86b26ef0b8d3b8a19..f672a2c715ca15ece74ee694596318976da88dfd 100644
@@ -518,6 +518,23 @@ config I2C_BRCMSTB
 
 	  If you do not need I2C interface, say N.
 
+config I2C_ADI_TWI
+     tristate "ADI TWI I2C support"
+     depends on ARCH_SC59X_64 || ARCH_SC59X
+     help
+       This is the I2C bus driver for ADI on-chip TWI interface.
+
+       This driver can also be built as a module.  If so, the module
+       will be called i2c-adi-twi.
+
+config I2C_ADI_TWI_CLK_KHZ
+    int "ADI TWI I2C clock (kHz)"
+    depends on I2C_ADI_TWI
+    range 21 400
+    default 50
+    help
+      The unit of the TWI clock is kHz.
+
 config I2C_CADENCE
 	tristate "Cadence I2C Controller"
 	depends on ARCH_ZYNQ || ARM64 || XTENSA || RISCV || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
index 78d0561339e5beadcb810196be1139a4248469b4..421d637cfbc91af5a69895e76a255b2ef47f4081 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_I2C_AU1550)	+= i2c-au1550.o
 obj-$(CONFIG_I2C_AXXIA)		+= i2c-axxia.o
 obj-$(CONFIG_I2C_BCM2835)	+= i2c-bcm2835.o
 obj-$(CONFIG_I2C_BCM_IPROC)	+= i2c-bcm-iproc.o
+obj-$(CONFIG_I2C_ADI_TWI)	+= i2c-adi-twi.o
 obj-$(CONFIG_I2C_CADENCE)	+= i2c-cadence.o
 obj-$(CONFIG_I2C_CBUS_GPIO)	+= i2c-cbus-gpio.o
 obj-$(CONFIG_I2C_CPM)		+= i2c-cpm.o
drivers/i2c/busses/i2c-adi-twi.c new file +940 -0

941 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#46 lore raw

Re: [PATCH 15/21] i2c: Add driver for ADI ADSP-SC5xx platforms

drivers/i2c/busses/Kconfig config I2C_BRCMSTB · line 536

Quoted 8 lines · On Thu, Sep 12, 2024, at 18:25, Arturs Artamonovs via B4 Relay wrote:
drivers/i2c/busses/Kconfig +8 -0
+
+config I2C_ADI_TWI_CLK_KHZ
+    int "ADI TWI I2C clock (kHz)"
+    depends on I2C_ADI_TWI
+    range 21 400
+    default 50
+    help
+      The unit of the TWI clock is kHz.

This does not look like something that should be a compile-time option, the kernel needs to be able to run on different configurations.

drivers/i2c/busses/i2c-adi-twi.c line 121

Quoted 7 lines
drivers/i2c/busses/i2c-adi-twi.c new file +7 -0
+
+static void adi_twi_handle_interrupt(struct adi_twi_iface *iface,
+					unsigned short twi_int_status,
+					bool polling)
+{
+	u16 writeValue;
+	unsigned short mast_stat = ioread16(&iface->regs_base->master_stat);

It's a bit unusual to use ioread16()/iowrite16() instead of the normal readw()/writew().

drivers/i2c/busses/i2c-adi-twi.c line 144

Quoted 11 lines
drivers/i2c/busses/i2c-adi-twi.c new file +11 -0
+			} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
+				   iface->cur_msg + 1 < iface->msg_num) {
+
+				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD) {
+					writeValue = ioread16(&iface->regs_base->master_ctl)
+							      | MDIR;
+					iowrite16(writeValue, &iface->regs_base->master_ctl);
+				} else {
+					writeValue = ioread16(&iface->regs_base->master_ctl)
+							      & ~MDIR;
+					iowrite16(writeValue, &iface->regs_base->master_ctl);

The use of a structure instead of register offset macros makes these lines rather long, especially at five levels of indentation. Maybe this can be restructured for readability.

drivers/i2c/busses/i2c-adi-twi.c

Quoted 9 lines
drivers/i2c/busses/i2c-adi-twi.c new file +9 -0
+		if (ioread16(&iface->regs_base->master_stat) & SDASEN) {
+			int cnt = 9;
+
+			do {
+				iowrite16(SCLOVR, &iface->regs_base->master_ctl);
+				udelay(6);
+				iowrite16(0, &iface->regs_base->master_ctl);
+				udelay(6);
+			} while ((ioread16(&iface->regs_base->master_stat) & SDASEN)

Since writes on device mappings are posted, the delay between the two iowrite16() is not really meaningful, unless you add another ioread16() or readw() before the delay. Mapping these with ioremap_np() should also work.

drivers/i2c/busses/i2c-adi-twi.c line 235

Quoted 6 lines
drivers/i2c/busses/i2c-adi-twi.c new file +6 -0
+			iowrite16(SDAOVR | SCLOVR, &iface->regs_base->master_ctl);
+			udelay(6);
+			iowrite16(SDAOVR, &iface->regs_base->master_ctl);
+			udelay(6);
+			iowrite16(0, &iface->regs_base->master_ctl);
+		}

Same here.

Quoted 20 lines
(quoted diff) +2 -0
+/* Interrupt handler */
+static irqreturn_t adi_twi_handle_all_interrupts(struct adi_twi_iface 

*iface,

drivers/i2c/busses/i2c-adi-twi.c new file +17 -0
+						 bool polling)
+{
+	irqreturn_t handled = IRQ_NONE;
+	unsigned short twi_int_status;
+
+	while (1) {
+		twi_int_status = ioread16(&iface->regs_base->int_stat);
+		if (!twi_int_status)
+			return handled;
+		/* Clear interrupt status */
+		iowrite16(twi_int_status, &iface->regs_base->int_stat);
+		adi_twi_handle_interrupt(iface, twi_int_status, polling);
+		handled = IRQ_HANDLED;
+	}
+}
+
+static irqreturn_t adi_twi_interrupt_entry(int irq, void *dev_id)

drivers/i2c/busses/i2c-adi-twi.c line 354

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+{
+	struct adi_twi_iface *iface = dev_id;
+	unsigned long flags;
+	irqreturn_t handled;
+
+	spin_lock_irqsave(&iface->lock, flags);
+	handled = adi_twi_handle_all_interrupts(iface, false);
+	spin_unlock_irqrestore(&iface->lock, flags);
+	return handled;
+}

Interrupt handlers are called with IRQs disabled, so no need to turn them off again.

drivers/i2c/busses/i2c-adi-twi.c line 782

Quoted 6 lines
drivers/i2c/busses/i2c-adi-twi.c new file +6 -0
+static SIMPLE_DEV_PM_OPS(i2c_adi_twi_pm,
+			 i2c_adi_twi_suspend, i2c_adi_twi_resume);
+#define I2C_ADI_TWI_PM_OPS	(&i2c_adi_twi_pm)
+#else
+#define I2C_ADI_TWI_PM_OPS	NULL
+#endif

Please convert to DEFINE_SIMPLE_DEV_PM_OPS() and remove the #ifdef.

drivers/i2c/busses/i2c-adi-twi.c line 792

Quoted 9 lines
drivers/i2c/busses/i2c-adi-twi.c new file +9 -0
+#ifdef CONFIG_OF
+static const struct of_device_id adi_twi_of_match[] = {
+	{
+		.compatible = "adi,twi",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, adi_twi_of_match);
+#endif

No need to optimize for non-CONFIG_OF builds, we don't support traditional board files on arm64.

drivers/i2c/busses/i2c-adi-twi.c line 811

Quoted 1 line
drivers/i2c/busses/i2c-adi-twi.c new file +1 -0
+	match = of_match_device(of_match_ptr(adi_twi_of_match), &pdev->dev);

This of_match_ptr() and the second one later should also get removed then.

Quoted 2 lines

\ No newline at end of file

Whitespace damage.

Arnd

#47 lore raw

Re: [PATCH 15/21] i2c: Add driver for ADI ADSP-SC5xx platforms

In reply to Arturs Artamonovs
Quoted 9 lines · On 12/09/2024 20:25, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add support for I2C on SC5xx

As in all patches - chain looks wrong.

Quoted 8 lines
---
 drivers/i2c/busses/Kconfig       |  17 +
 drivers/i2c/busses/Makefile      |   1 +
 drivers/i2c/busses/i2c-adi-twi.c | 940 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 958 insertions(+)

drivers/i2c/busses/i2c-adi-twi.c line 784

Quoted 8 lines
drivers/i2c/busses/i2c-adi-twi.c new file +8 -0
+static SIMPLE_DEV_PM_OPS(i2c_adi_twi_pm,
+			 i2c_adi_twi_suspend, i2c_adi_twi_resume);
+#define I2C_ADI_TWI_PM_OPS	(&i2c_adi_twi_pm)
+#else
+#define I2C_ADI_TWI_PM_OPS	NULL
+#endif
+
+#ifdef CONFIG_OF

Drop

Quoted 17 lines
drivers/i2c/busses/i2c-adi-twi.c new file +17 -0
+static const struct of_device_id adi_twi_of_match[] = {
+	{
+		.compatible = "adi,twi",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, adi_twi_of_match);
+#endif
+
+static int i2c_adi_twi_probe(struct platform_device *pdev)
+{
+	struct adi_twi_iface *iface;
+	struct i2c_adapter *p_adap;
+	struct resource *res;
+	const struct of_device_id *match;
+	struct device_node *node = pdev->dev.of_node;
+	int rc;

drivers/i2c/busses/i2c-adi-twi.c line 811

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+	unsigned int clkhilow;
+	u16 writeValue;
+
+	iface = devm_kzalloc(&pdev->dev, sizeof(*iface), GFP_KERNEL);
+	if (!iface)
+		return -ENOMEM;
+
+	spin_lock_init(&(iface->lock));
+
+	match = of_match_device(of_match_ptr(adi_twi_of_match), &pdev->dev);

Drop of_mathc_ptr

drivers/i2c/busses/i2c-adi-twi.c line 813

Quoted 2 lines
drivers/i2c/busses/i2c-adi-twi.c new file +2 -0
+	if (match) {
+		if (of_property_read_u32(node, "clock-khz",

Uh? I really do not get what is this.

drivers/i2c/busses/i2c-adi-twi.c line 814

Quoted 1 line
drivers/i2c/busses/i2c-adi-twi.c new file +1 -0
+			&iface->twi_clk))

Really odd alignment.

drivers/i2c/busses/i2c-adi-twi.c line 822

Quoted 8 lines
drivers/i2c/busses/i2c-adi-twi.c new file +8 -0
+			iface->twi_clk = 50;
+	} else
+		iface->twi_clk = CONFIG_I2C_ADI_TWI_CLK_KHZ;
+
+	iface->sclk = devm_clk_get(&pdev->dev, "sclk0");
+	if (IS_ERR(iface->sclk)) {
+		if (PTR_ERR(iface->sclk) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Missing i2c clock\n");

Eh... there is nowhere such code. Please work with upstream code, not downstream. When writing drivers take UPSTREAM driver as template. Whatever you have in downstream is not a good to send to us.

Syntax is return dev_err_probe.

drivers/i2c/busses/i2c-adi-twi.c line 833

Quoted 11 lines
drivers/i2c/busses/i2c-adi-twi.c new file +11 -0
+		return PTR_ERR(iface->sclk);
+	}
+
+	/* Find and map our resources */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res == NULL) {
+		dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
+		return -ENOENT;
+	}
+
+	iface->regs_base = devm_ioremap_resource(&pdev->dev, res);

Combine these two calls with proper helper.

drivers/i2c/busses/i2c-adi-twi.c line 840

Quoted 7 lines
drivers/i2c/busses/i2c-adi-twi.c new file +7 -0
+	if (IS_ERR(iface->regs_base)) {
+		dev_err(&pdev->dev, "Cannot map IO\n");
+		return PTR_ERR(iface->regs_base);
+	}
+
+	iface->irq = platform_get_irq(pdev, 0);
+	if (iface->irq < 0) {

Here you have correct, other patch has a bug. That makes me wonder about consistency of this code. There are several other hints that people wrote it with quite different coding style.

drivers/i2c/busses/i2c-adi-twi.c line 842

Quoted 2 lines
drivers/i2c/busses/i2c-adi-twi.c new file +2 -0
+		dev_err(&pdev->dev, "No IRQ specified\n");
+		return -ENOENT;

No. return the error. Anyway, that's never a correct errno. Read description of this errno: no such file. This is not a file you are getting here.

This comment applies to all your code.

Quoted 8 lines
drivers/i2c/busses/i2c-adi-twi.c new file +8 -0
+	}
+
+	p_adap = &iface->adap;
+	p_adap->nr = pdev->id;
+	strscpy(p_adap->name, pdev->name, sizeof(p_adap->name));
+	p_adap->algo = &adi_twi_algorithm;
+	p_adap->algo_data = iface;
+	p_adap->class = I2C_CLASS_DEPRECATED;

drivers/i2c/busses/i2c-adi-twi.c line 860

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+	p_adap->dev.parent = &pdev->dev;
+	p_adap->dev.of_node = node;
+	p_adap->timeout = 5 * HZ;
+	p_adap->retries = 3;
+
+	rc = devm_request_irq(&pdev->dev, iface->irq, adi_twi_interrupt_entry,
+		0, pdev->name, iface);
+	if (rc) {
+		dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq);
+		rc = -ENODEV;

???

Sorry, this driver is in really poor shape.

drivers/i2c/busses/i2c-adi-twi.c line 868

Quoted 8 lines
drivers/i2c/busses/i2c-adi-twi.c new file +8 -0
+		goto out_error;
+	}
+
+	/* Set TWI internal clock as 10MHz */
+	clk_prepare_enable(iface->sclk);
+	if (rc) {
+		dev_err(&pdev->dev, "Could not enable sclk\n");
+		goto out_error;

return

drivers/i2c/busses/i2c-adi-twi.c line 871

Quoted 3 lines
drivers/i2c/busses/i2c-adi-twi.c new file +3 -0
+	}
+
+	writeValue = ((clk_get_rate(iface->sclk) / 1000 / 1000 + 5) / 10) & 0x7F;

No camelCase. Please follow Linux coding style.

Quoted 14 lines
drivers/i2c/busses/i2c-adi-twi.c new file +14 -0
+	iowrite16(writeValue, &iface->regs_base->control);
+
+	/*
+	 * We will not end up with a CLKDIV=0 because no one will specify
+	 * 20kHz SCL or less in Kconfig now. (5 * 1000 / 20 = 250)
+	 */
+	clkhilow = ((10 * 1000 / iface->twi_clk) + 1) / 2;
+
+	/* Set Twi interface clock as specified */
+	writeValue = (clkhilow << 8) | clkhilow;
+	iowrite16(writeValue, &iface->regs_base->clkdiv);
+
+	/* Enable TWI */
+	writeValue = ioread16(&iface->regs_base->control) | TWI_ENA;

drivers/i2c/busses/i2c-adi-twi.c line 895

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+	iowrite16(writeValue, &iface->regs_base->control);
+
+	rc = i2c_add_numbered_adapter(p_adap);
+	if (rc < 0)
+		goto disable_clk;
+
+	platform_set_drvdata(pdev, iface);
+
+	dev_info(&pdev->dev, "ADI on-chip I2C TWI Controller, regs_base@%p\n",
+		iface->regs_base);

Drop. Driver should be silent on success.

drivers/i2c/busses/i2c-adi-twi.c line 900

Quoted 5 lines
drivers/i2c/busses/i2c-adi-twi.c new file +5 -0
+
+	return 0;
+
+disable_clk:
+	clk_disable_unprepare(iface->sclk);

devm_clk_get_enabled

drivers/i2c/busses/i2c-adi-twi.c line 902

Quoted 2 lines
drivers/i2c/busses/i2c-adi-twi.c new file +2 -0
+
+out_error:

Drop

Quoted 8 lines
drivers/i2c/busses/i2c-adi-twi.c new file +8 -0
+	return rc;
+}
+
+static void i2c_adi_twi_remove(struct platform_device *pdev)
+{
+	struct adi_twi_iface *iface = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(iface->sclk);

drivers/i2c/busses/i2c-adi-twi.c line 920

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+	i2c_del_adapter(&(iface->adap));
+}
+
+static struct platform_driver i2c_adi_twi_driver = {
+	.probe		= i2c_adi_twi_probe,
+	.remove		= i2c_adi_twi_remove,
+	.driver		= {
+		.name	= "i2c-adi-twi",
+		.pm	= I2C_ADI_TWI_PM_OPS,
+		.of_match_table = of_match_ptr(adi_twi_of_match),

Drop of_match_ptr. None of your other code has it, right? This should make you wonder.

Quoted 4 lines
drivers/i2c/busses/i2c-adi-twi.c new file +4 -0
+	},
+};
+
+static int __init i2c_adi_twi_init(void)

drivers/i2c/busses/i2c-adi-twi.c line 934

Quoted 10 lines
drivers/i2c/busses/i2c-adi-twi.c new file +10 -0
+{
+	return platform_driver_register(&i2c_adi_twi_driver);
+}
+
+static void __exit i2c_adi_twi_exit(void)
+{
+	platform_driver_unregister(&i2c_adi_twi_driver);
+}
+
+subsys_initcall(i2c_adi_twi_init);

No, i2c driver can be just module platform driver.

drivers/i2c/busses/i2c-adi-twi.c line 940

Quoted 6 lines
drivers/i2c/busses/i2c-adi-twi.c new file +6 -0
+module_exit(i2c_adi_twi_exit);
+
+MODULE_AUTHOR("Bryan Wu, Sonic Zhang");
+MODULE_DESCRIPTION("ADI on-chip I2C TWI Controller Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:i2c-adi-twi");

You should not need MODULE_ALIAS() in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries or MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for incomplete ID table.

Quoted 4 lines

\ No newline at end of file

Best regards,
Krzysztof

#48 lore raw

PATCH 16/21 dt-bindings: i2c: add i2c/twi driver documentation

In reply to Arturs Artamonovs

Add I2C driver bindings.

---
 Documentation/devicetree/bindings/i2c/adi,twi.yaml | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
Documentation/devicetree/bindings/i2c/adi,twi.yaml new file +71 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e935b09066cf806c89a796fdd5fe73ee0b644432
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/adi,twi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices I2C Peripheral for SC5XX Processor Family
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Analog Devices I2C Peripheral driver for SC5XX Processor Family
+
+properties:
+  compatible:
+    enum:
+      - adi,twi
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clock-khz:
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    maxItems: 1
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+  - reg
+  - interrupts
+  - clock-khz
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/adi-sc5xx-clock.h>
+
+    i2c0: twi@31001400 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      compatible = "adi,twi";
+      reg = <0x31001400 0xFF>;
+      interrupts = <GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>;
+      clock-khz = <100>;
+      clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+      clock-names = "sclk0";
+      status = "disabled";
+    };
+
Signature · 1 line
2.25.1
maintainer
#49 lore raw

Re: [PATCH 16/21] dt-bindings: i2c: add i2c/twi driver documentation

Documentation/devicetree/bindings/i2c/adi,twi.yaml line 20

Quoted 6 lines · On Thu, Sep 12, 2024, at 18:25, Arturs Artamonovs via B4 Relay wrote:
Documentation/devicetree/bindings/i2c/adi,twi.yaml new file +6 -0
+
+properties:
+  compatible:
+    enum:
+      - adi,twi
+

The "adi,twi" string is not specific enough to identify a particular implementation, the name should either include the version of the IP block that was used in each chip, or (if that is not public knowledge) the identifier of the chip it was integrated in.

Arnd

#50 lore raw

PATCH 17/21 serial: adi,uart: Add driver for ADI ADSP-SC5xx

In reply to Arturs Artamonovs

Adding UART driver,supports all ADSP-SC5xx SoC family
- Support FIFO mode
- Support earlyprintk
- Support Enable Divide By One support, for higher clock resolutions.

---
 drivers/tty/serial/Kconfig       |   19 +-
 drivers/tty/serial/Makefile      |    1 +
 drivers/tty/serial/adi_uart.c    | 1045 ++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/serial_core.h |    3 +
 4 files changed, 1067 insertions(+), 1 deletion(-)
drivers/tty/serial/Kconfig +18 -1
index 28e4beeabf8f373fc76e09ea7d1c9d55a66f4964..1d1d8fc808969c721d5931127d9294fb17d9c249 100644
@@ -471,6 +471,23 @@ config SERIAL_SA1100_CONSOLE
 	  your boot loader (lilo or loadlin) about how to pass options to the
 	  kernel at boot time.)
 
+config SERIAL_ADI_UART
+	tristate "ADI uart serial port support"
+	depends on ARCH_SC59X = y || ARCH_SC59X_64 = y
+	select SERIAL_CORE
+	select SERIAL_CORE_CONSOLE
+	help
+	  Add support for the built-in adi uart driver.
+
+config SERIAL_ADI_UART_CONSOLE
+	bool "Console on ADI uart serial port"
+	depends on SERIAL_ADI_UART
+	default y
+	select SERIAL_CORE_CONSOLE
+	help
+	  If you have enabled the ADI UART serial port, you can
+	  make it the console by answering Y to this option.
+
 config SERIAL_IMX
 	tristate "IMX serial port support"
 	depends on ARCH_MXC || COMPILE_TEST
@@ -771,7 +788,7 @@ config SERIAL_CPM
 	depends on CPM2 || CPM1
 	select SERIAL_CORE
 	help
-	  This driver supports the SCC and SMC serial ports on Motorola 
+	  This driver supports the SCC and SMC serial ports on Motorola
 	  embedded PowerPC that contain a CPM1 (8xx) or CPM2 (8xxx)
 
 config SERIAL_CPM_CONSOLE
drivers/tty/serial/Makefile +1 -0
index 6ff74f0a9530c4f6e058a848f74084f3b63a730a..9d4920b51b55af70c285d9bcaef53cc01a69b898 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_SERIAL_JSM)		+= jsm/
 obj-$(CONFIG_SERIAL_LANTIQ)		+= lantiq.o
 obj-$(CONFIG_SERIAL_LITEUART)		+= liteuart.o
 obj-$(CONFIG_SERIAL_HS_LPC32XX)		+= lpc32xx_hs.o
+obj-$(CONFIG_SERIAL_ADI_UART)		+= adi_uart.o
 obj-$(CONFIG_SERIAL_MAX3100)		+= max3100.o
 obj-$(CONFIG_SERIAL_MAX310X)		+= max310x.o
 obj-$(CONFIG_SERIAL_MCF)		+= mcf.o
drivers/tty/serial/adi_uart.c new file +1045 -0

1,046 lines not on this page · raw message

include/uapi/linux/serial_core.h +3 -0
index 9c007a106330b90b92cbcf60a9ac806b290d6d44..ce3c50dfa5cacd09eb30e93e408c2d92992ac755 100644
@@ -109,6 +109,9 @@
 /* Xilinx uartlite */
 #define PORT_UARTLITE	74
 
+/* Blackfin */
+#define PORT_BFIN	75
+
 /* Broadcom BCM7271 UART */
 #define PORT_BCM7271	76
 
Signature · 1 line
2.25.1
#51 lore raw

PATCH 18/21 dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation

In reply to Arturs Artamonovs

Add serial driver bindings.

---
 .../devicetree/bindings/serial/adi,uart.yaml       | 85 ++++++++++++++++++++++
 1 file changed, 85 insertions(+)
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +85 -0
new file mode 100644
index 0000000000000000000000000000000000000000..de58059efa7e21acaa5b7f4984ffadca18f7f53a
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/adi,uart4.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices UART Driver for SC5XX-family processors
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |
+  Analog Devices UART Driver for SC59X-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,uart
+
+  reg:
+    maxItems: 1
+
+  dmas:
+    maxItems: 2
+    minItems: 2
+    description: TX and RX DMA cluster numbers
+
+  dma-names:
+    maxItems: 2
+    minItems: 2
+    description: DMA channel names (tx and rx)
+
+  clocks:
+    maxItems: 1
+    description: Clock being used for UART
+
+  clock-names:
+    maxItems: 1
+    description: Clock name (sclk0)
+
+  interrupt-names:
+    minItems: 3
+    maxItems: 3
+    description: Interrupt names (tx + rx + status)
+
+  interrupts:
+    minItems: 3
+    maxItems: 3
+    description: GIC interrupt numbers
+
+  adi,use-edbo:
+    type: boolean
+    description: Enable divide by one in divisor
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupt-names
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/adi-sc5xx-clock.h>
+
+    uart0: uart@31003000 {
+      compatible = "adi,uart";
+      reg = <0x31003000 0x40>;
+      clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+      clock-names = "sclk0";
+      interrupt-parent = <&gic>;
+      interrupt-names = "tx", "rx", "status";
+      interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+                   <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
+                   <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+      adi,use-edbo;
+      status = "disabled";
+    };
+
Signature · 1 line
2.25.1
#52 lore raw

Re: [PATCH 18/21] dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation

Quoted 8 lines · Arturs Artamonovs

Add serial driver bindings.

Quoted 4 lines
---
 .../devicetree/bindings/serial/adi,uart.yaml       | 85 ++++++++++++++++++++++
 1 file changed, 85 insertions(+)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/serial/adi,uart.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename
$id: http://devicetree.org/schemas/serial/adi,uart4.yaml
file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/serial/adi,uart.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

maintainer
#53 lore raw

Re: [PATCH 18/21] dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation

In reply to Arturs Artamonovs
Quoted 1 line · Arturs Artamonovs

Add serial driver bindings.

Don''t need 'documentation' in the the subject. That's redundant with 'dt-bindings'.

Quoted 2 lines

Your S-o-b goes last since you are sending the patch.

Quoted 1 line

Not clear what Utsav's role was. Needs Co-developed-by?

Quoted 14 lines
---
 .../devicetree/bindings/serial/adi,uart.yaml       | 85 ++++++++++++++++++++++
 1 file changed, 85 insertions(+)
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..de58059efa7e21acaa5b7f4984ffadca18f7f53a

Documentation/devicetree/bindings/serial/adi,uart.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +7 -0
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/adi,uart4.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices UART Driver for SC5XX-family processors

Bindings aren't a driver.

Documentation/devicetree/bindings/serial/adi,uart.yaml line 13

Quoted 6 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +6 -0
+
+maintainers:
+  - Arturs Artamonovs <[email protected]>
+  - Utsav Agarwal <[email protected]>
+
+description: |

Don't need '|'.

Documentation/devicetree/bindings/serial/adi,uart.yaml line 19

Quoted 6 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +6 -0
+  Analog Devices UART Driver for SC59X-family processors
+
+properties:
+  compatible:
+    enum:
+      - adi,uart

Only 1 UART implementation for all of Analog Devices ever.

compatibles should be specific to SoC.

Documentation/devicetree/bindings/serial/adi,uart.yaml line 32

Quoted 13 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +13 -0
+
+  reg:
+    maxItems: 1
+
+  dmas:
+    maxItems: 2
+    minItems: 2
+    description: TX and RX DMA cluster numbers
+
+  dma-names:
+    maxItems: 2
+    minItems: 2
+    description: DMA channel names (tx and rx)

Names need to be constraints, not freeform text. Plenty of examples to look at...

Documentation/devicetree/bindings/serial/adi,uart.yaml line 36

Quoted 4 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +4 -0
+
+  clocks:
+    maxItems: 1
+    description: Clock being used for UART

That's obvious. Drop description or say something unique to this device.

Quoted 8 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +8 -0
+
+  clock-names:
+    maxItems: 1
+    description: Clock name (sclk0)
+
+  interrupt-names:
+    minItems: 3
+    maxItems: 3

Documentation/devicetree/bindings/serial/adi,uart.yaml line 54

Quoted 10 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +10 -0
+    description: Interrupt names (tx + rx + status)
+
+  interrupts:
+    minItems: 3
+    maxItems: 3
+    description: GIC interrupt numbers
+
+  adi,use-edbo:
+    type: boolean
+    description: Enable divide by one in divisor

Versus divide by ???

Quoted 8 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +8 -0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupt-names
+  - interrupts

Documentation/devicetree/bindings/serial/adi,uart.yaml line 72

Quoted 10 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/adi-sc5xx-clock.h>
+
+    uart0: uart@31003000 {

serial@...

Drop unused labels.

Documentation/devicetree/bindings/serial/adi,uart.yaml line 83

Quoted 11 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +11 -0
+      compatible = "adi,uart";
+      reg = <0x31003000 0x40>;
+      clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+      clock-names = "sclk0";
+      interrupt-parent = <&gic>;
+      interrupt-names = "tx", "rx", "status";
+      interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+                   <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
+                   <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+      adi,use-edbo;
+      status = "disabled";

Examples should be enabled. Drop.

Quoted 6 lines
Documentation/devicetree/bindings/serial/adi,uart.yaml new file +2 -0
+    };
+
Signature · 2 lines
-- 
2.25.1
#54 lore raw

PATCH 19/21 arm64: dts: adi: sc598: add device tree

In reply to Arturs Artamonovs

Add ADI SC598-EZKIT device tree.
Support UART console as output.

---
 arch/arm64/boot/dts/Makefile                |   1 +
 arch/arm64/boot/dts/adi/Makefile            |   2 +
 arch/arm64/boot/dts/adi/sc598-som-ezkit.dts |  14 ++
 arch/arm64/boot/dts/adi/sc598-som.dtsi      |  58 +++++
 arch/arm64/boot/dts/adi/sc59x-64.dtsi       | 367 ++++++++++++++++++++++++++++
 5 files changed, 442 insertions(+)
arch/arm64/boot/dts/Makefile +1 -0
index 21cd3a87f385309c3a655a67a3bee5f0abed7545..9b3996a8e01d8e7d264c44c075d7a50ee350ba44 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 subdir-y += actions
+subdir-y += adi
 subdir-y += airoha
 subdir-y += allwinner
 subdir-y += altera
arch/arm64/boot/dts/adi/Makefile new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1bf54bc97095e1ea3577953d379746fbc0ea02a9
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_ARCH_SC59X_64) += sc598-som-ezkit.dtb
arch/arm64/boot/dts/adi/sc598-som-ezkit.dts new file +14 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a8db6d5ea764f917faa6839d3d4f0b5217b927b8
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2021-2024 - Analog Devices Inc.
+ * Author: Nathan Barrett-Morrison <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "sc598-som.dtsi"
+
+/ {
+	model = "ADI 64-bit SC598 SOM EZ Kit";
+	compatible = "adi,sc598-som-ezkit", "adi,sc59x-64";
+};
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +58 -0

58 lines not on this page · raw message

arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +367 -0

367 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#55 lore raw

Re: [PATCH 19/21] arm64: dts: adi: sc598: add device tree

Review

Quoted 6 lines · On Thu, Sep 12, 2024, at 18:25, Arturs Artamonovs via B4 Relay wrote:
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +4 -0
+/ {
+	chosen {
+		stdout-path = &uart1;
+		bootargs = "earlycon=adi_uart,0x31003000 console=ttySC0,115200 

mem=224M";

(quoted diff) +1 -0
+	};

You should not need the mem= and earlycon= arguments, as that data is already part of the stdout-path property and the memory node.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 25

Quoted 5 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +5 -0
+	aliases {
+		serial0 = &uart0;
+		serial2 = &uart2;
+		serial3 = &uart3;
+	};

The aliases are board specific, please only list the ones that are actually enabled and wired on on a particular board, and make the aliases match the labels on the board rather than the internal components of hte chip.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 36

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+	cpus {
+		#address-cells = <0x2>;
+		#size-cells = <0x0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a55";
+			reg = <0x0 0x0>;
+			enable-method = "spin-table";
+			cpu-release-addr = <0x0 0xdeadbeef>;

Is that the actual address? It looks like some placeholder that should not have been here.

Arnd

#56 lore raw

Re: [PATCH 19/21] arm64: dts: adi: sc598: add device tree

In reply to Arturs Artamonovs
Quoted 47 lines · On 12/09/2024 20:25, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADI SC598-EZKIT device tree.
Support UART console as output.

---
 arch/arm64/boot/dts/Makefile                |   1 +
 arch/arm64/boot/dts/adi/Makefile            |   2 +
 arch/arm64/boot/dts/adi/sc598-som-ezkit.dts |  14 ++
 arch/arm64/boot/dts/adi/sc598-som.dtsi      |  58 +++++
 arch/arm64/boot/dts/adi/sc59x-64.dtsi       | 367 ++++++++++++++++++++++++++++
 5 files changed, 442 insertions(+)
arch/arm64/boot/dts/Makefile +1 -0
index 21cd3a87f385309c3a655a67a3bee5f0abed7545..9b3996a8e01d8e7d264c44c075d7a50ee350ba44 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 subdir-y += actions
+subdir-y += adi
 subdir-y += airoha
 subdir-y += allwinner
 subdir-y += altera
arch/arm64/boot/dts/adi/Makefile new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1bf54bc97095e1ea3577953d379746fbc0ea02a9
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+dtb-$(CONFIG_ARCH_SC59X_64) += sc598-som-ezkit.dtb
arch/arm64/boot/dts/adi/sc598-som-ezkit.dts new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a8db6d5ea764f917faa6839d3d4f0b5217b927b8
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2021-2024 - Analog Devices Inc.

arch/arm64/boot/dts/adi/sc598-som-ezkit.dts line 13

Quoted 10 lines
arch/arm64/boot/dts/adi/sc598-som-ezkit.dts new file +10 -0
+ * Author: Nathan Barrett-Morrison <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "sc598-som.dtsi"
+
+/ {
+	model = "ADI 64-bit SC598 SOM EZ Kit";
+	compatible = "adi,sc598-som-ezkit", "adi,sc59x-64";

Where is adi,sc598-som-ezlite?

Quoted 13 lines
arch/arm64/boot/dts/adi/sc598-som-ezkit.dts new file +1 -0
+};
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +6 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3b90f367db1a24de1e1dddc4db3c219736c5b90f
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2021-2024 - Analog Devices Inc.
+ * Author: Nathan Barrett-Morrison <[email protected]>
+ */
+

arch/arm64/boot/dts/adi/sc598-som.dtsi line 16

Quoted 10 lines
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +10 -0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/pinctrl/adi-adsp.h>
+#include "sc59x-64.dtsi"
+
+/ {
+	chosen {
+		stdout-path = &uart1;
+		bootargs = "earlycon=adi_uart,0x31003000 console=ttySC0,115200 mem=224M";

Drop entire bootargs. Look how other SoCs do it, if you need port speed.

arch/arm64/boot/dts/adi/sc598-som.dtsi line 29

Quoted 13 lines
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +13 -0
+	};
+
+	memory@90000000 {
+		device_type = "memory";
+		reg = <0x90000000 0x0e000000>;
+	};
+
+	memory@20040000 {
+		device_type = "memory";
+		reg = <0x20040000 0x40000>;
+	};
+
+	scb: scb-bus {

What is this?

arch/arm64/boot/dts/adi/sc598-som.dtsi line 30

Quoted 1 line
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +1 -0
+		sec: sec@31089000 {

And this?

arch/arm64/boot/dts/adi/sc598-som.dtsi line 33

Quoted 3 lines
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +3 -0
+			adi,sharc-cores = <2>;
+		};
+	};

Drop entire node.

arch/arm64/boot/dts/adi/sc598-som.dtsi line 34

Quoted 1 line
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +1 -0
+

Fix redundant blank lines.

Quoted 39 lines
arch/arm64/boot/dts/adi/sc598-som.dtsi new file +24 -0
+};
+
+&uart0 {
+	pinctrl-0 = <&uart0_default>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
+&i2c0 {
+	status = "okay";
+};
+
+&i2c1 {
+	status = "disabled";
+};
+
+&pinctrl0 {
+	uart0_default: uart0-default-pins {
+		pins {
+			pinmux = <ADI_ADSP_PINMUX('A', 6, ADI_ADSP_PINFUNC_ALT1)>,
+				 <ADI_ADSP_PINMUX('A', 7, ADI_ADSP_PINFUNC_ALT1)>;
+		};
+	};
+};
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +9 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4a9aa08b4acb0936c97e683562e05da063a4e193
@@ -0,0 +1,367 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2021-2024 - Analog Devices Inc.
+ * Author: Nathan Barrett-Morrison <[email protected]>
+ */
+
+#include <dt-bindings/clock/adi-sc5xx-clock.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/interrupt-controller/irq.h>

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 19

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+
+/ {
+	model = "ADI 64-bit SC59X";
+	compatible = "adi,sc59x-64";
+
+	interrupt-parent = <&gic>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen { };

Drop

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 25

Quoted 6 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +6 -0
+
+	aliases {
+		serial0 = &uart0;
+		serial2 = &uart2;
+		serial3 = &uart3;
+	};

Drop or move to board DTS. Not a property of the SoC.

Quoted 6 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +6 -0
+
+	cpus {
+		#address-cells = <0x2>;
+		#size-cells = <0x0>;
+
+		cpu0: cpu@0 {

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 41

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+			device_type = "cpu";
+			compatible = "arm,cortex-a55";
+			reg = <0x0 0x0>;
+			enable-method = "spin-table";
+			cpu-release-addr = <0x0 0xdeadbeef>;
+			clocks = <&clk ADSP_SC598_CLK_ARM>, <&clk ADSP_SC598_CLK_DDR>;
+		};
+	};
+
+	pmu {

Order nodes alphabetically. See DTS coding style.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 47

Quoted 6 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +6 -0
+		compatible = "arm,armv8-pmuv3";
+		interrupts = <GIC_PPI 7 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-parent = <&gic>;
+	};
+
+	gic: interrupt-controller@31200000 {

This cannot be outside of SoC. See writing-bindings and DTS coding style.

Quoted 7 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +7 -0
+		compatible = "arm,gic-v3";
+		#interrupt-cells = <3>;
+		interrupt-controller;
+		reg = <0x31200000 0x40000>, /* GIC Dist */
+		      <0x31240000 0x40000>; /* GICR */
+	};
+

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 64

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+	timer {
+		compatible = "arm,armv8-timer";
+		interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>, /* Physical Secure */
+			     <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>, /* Physical Non-Secure */
+			     <GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>, /* Virtual */
+			     <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>; /* Hypervisor */
+	};
+
+	clocks {
+		sys_clkin0: oscillator@1 {

There is no way you tested it. It's obvious W=1 warning.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 71

Quoted 7 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +7 -0
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <25000000>;
+			clock-output-names = "sys_clkin0";
+		};
+
+		sys_clkin1: oscillator@2 {

How are these properties of the SoC? Where are they located physically? See DTS coding style.

Quoted 7 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +7 -0
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <25000000>;
+			clock-output-names = "sys_clkin1";
+		};
+	};
+

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 88

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+	clk: clocks@3108d000 {
+		compatible = "adi,sc598-clocks";
+		reg = <0x3108d000 0x1000>,
+		      <0x3108e000 0x1000>,
+		      <0x3108f000 0x1000>,
+		      <0x310a9000 0x1000>;
+		#clock-cells = <1>;
+		clocks = <&sys_clkin0>, <&sys_clkin1>;
+		clock-names = "sys_clkin0", "sys_clkin1";
+		status = "okay";

Drop... everywhere.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 91

Quoted 3 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +3 -0
+	};
+
+	scb: scb-bus {

What is scb-bus?

See DTS coding style or any other SoC. This is supposed to be just sco@ with proper unit address.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 100

Quoted 9 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +9 -0
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		rcu: rcu@3108c000 {
+			compatible = "adi,reset-controller";
+			reg = <0x3108c000 0x1000>;
+			status = "okay";

Oh...

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 103

Quoted 3 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +3 -0
+		};
+
+		sec: sec@31089000 {

Random order of nodes? See DTS coding style.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 110

Quoted 7 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +7 -0
+			compatible = "adi,system-event-controller";
+			reg = <0x31089000 0x1000>;
+			adi,rcu = <&rcu>;
+			status = "okay";
+		};
+
+		uart0: uart@31003000 {

Never tested.

It does not look like you tested the DTS against bindings. Please run make dtbs_check W=1 (see Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).

Quoted 46 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +46 -0
+			compatible = "adi,uart";
+			reg = <0x31003000 0x40>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			interrupt-parent = <&gic>;
+			interrupt-names = "tx", "rx", "status";
+			interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+			adi,use-edbo;
+			status = "disabled";
+		};
+
+		uart1: uart@31003400 {
+			compatible = "adi,uart";
+			reg = <0x31003400 0x40>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			interrupt-parent = <&gic>;
+			interrupt-names = "tx", "rx", "status";
+			interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
+			adi,use-edbo;
+			status = "disabled";
+		};
+
+		uart2: uart@31003800 {
+			compatible = "adi,uart";
+			reg = <0x31003800 0x40>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			interrupt-parent = <&gic>;
+			interrupt-names = "tx", "rx", "status";
+			interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>;
+			adi,use-edbo;
+			status = "disabled";
+		};
+
+		uart3: uart@31003c00 {
+			compatible = "adi,uart";
+			reg = <0x31003C00 0x40>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 166

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+			interrupt-parent = <&gic>;
+			interrupt-names = "tx", "rx", "status";
+			interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 149 IRQ_TYPE_LEVEL_HIGH>;
+			adi,use-edbo;
+			status = "disabled";
+		};
+
+		i2c0: twi@31001400 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Completely wrong order of properties. Please follow DTS coding style.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 169

Quoted 3 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +3 -0
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "adi,twi";

You cannot have generic compatibles in the SoC.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 170

Quoted 1 line
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +1 -0
+			reg = <0x31001400 0xFF>;

I already commented on lower case hex.

Quoted 66 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +66 -0
+			interrupts = <GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>;
+			clock-khz = <100>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			status = "disabled";
+		};
+
+		i2c1: twi@31001500 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "adi,twi";
+			reg = <0x31001500 0xFF>;
+			interrupts = <GIC_SPI 151 IRQ_TYPE_LEVEL_HIGH>;
+			clock-khz = <100>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			status = "disabled";
+		};
+
+		i2c3: twi@31001000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "adi,twi";
+			reg = <0x31001000 0xFF>;
+			interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+			clock-khz = <100>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			status = "disabled";
+		};
+
+		i2c4: twi@31001100 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "adi,twi";
+			reg = <0x31001100 0xFF>;
+			interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+			clock-khz = <100>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			status = "disabled";
+		};
+
+		i2c5: twi@31001200 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "adi,twi";
+			reg = <0x31001200 0xFF>;
+			interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
+			clock-khz = <100>;
+			clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>;
+			clock-names = "sclk0";
+			status = "disabled";
+		};
+
+		pinctrl0: pinctrl@31004600 {
+			compatible = "adi,adsp-pinctrl";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x31004600 0x400>;
+			adi,port-sizes = <16 16 16 16 16 16 16 16 7>;
+		};
+
+		pint0: pint@31005000 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005000 0xFF>;

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 246

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+			interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint1: pint@31005100 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005100 0xFF>;
+			interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint2: pint@31005200 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Quoted 26 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +26 -0
+			compatible = "adi,adsp-pint";
+			reg = <0x31005200 0xFF>;
+			interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint3: pint@31005300 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005300 0xFF>;
+			interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint4: pint@31005400 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005400 0xFF>;
+			interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint5: pint@31005500 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005500 0xFF>;
+			interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint6: pint@31005600 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005600 0xFF>;

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 282

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		pint7: pint@31005700 {
+			compatible = "adi,adsp-pint";
+			reg = <0x31005700 0xFF>;
+			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
+		};
+
+		gpa: gport@31004000 {

Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Quoted 73 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +73 -0
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004000 0x7F>;
+			gpio-ranges = <&pinctrl0 0 0 16>;
+			adi,pint = <&pint0 1>;
+			status = "okay";
+		};
+
+		gpb: gport@31004080 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004080 0x7F>;
+			gpio-ranges = <&pinctrl0 0 16 16>;
+			adi,pint = <&pint0 0>;
+			status = "okay";
+		};
+
+		gpc: gport@31004100 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004100 0x7F>;
+			gpio-ranges = <&pinctrl0 0 32 16>;
+			adi,pint = <&pint2 1>;
+			status = "okay";
+		};
+
+		gpd: gport@31004180 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004180 0x7F>;
+			gpio-ranges = <&pinctrl0 0 48 16>;
+			adi,pint = <&pint2 0>;
+		};
+
+		gpe: gport@31004200 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004200 0x7F>;
+			gpio-ranges = <&pinctrl0 0 64 16>;
+			adi,pint = <&pint4 1>;
+		};
+
+		gpf: gport@31004280 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004280 0x7F>;
+			gpio-ranges = <&pinctrl0 0 80 16>;
+			adi,pint = <&pint4 0>;
+		};
+
+		gpg: gport@31004300 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004300 0x7F>;
+			gpio-ranges = <&pinctrl0 0 96 16>;
+			adi,pint = <&pint6 1>;
+		};
+
+		gph: gport@31004380 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004380 0x7F>;
+			gpio-ranges = <&pinctrl0 0 112 16>;
+			adi,pint = <&pint6 0>;
+		};

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 365

Quoted 10 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +10 -0
+
+		gpi: gport@31004400 {
+			compatible = "adi,adsp-port-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+			reg = <0x31004400 0x7F>;
+			gpio-ranges = <&pinctrl0 0 128 7>;
+			adi,pint = <&pint7 1>;
+		};
+

All your patches have such sloppy blank lines here and there.

arch/arm64/boot/dts/adi/sc59x-64.dtsi line 367

Quoted 3 lines
arch/arm64/boot/dts/adi/sc59x-64.dtsi new file +2 -0
+	};
+};

Best regards,
Krzysztof

#57 lore raw

PATCH 20/21 arm64: defconfig: sc598 add minimal changes

In reply to Arturs Artamonovs

Add ADSP-SC598 defconfig

---
 arch/arm64/configs/defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/configs/defconfig +6 -0
index 362df939026383a26ee23485d1ec25b252b90d5d..7801dd7d7d65bc504dc6e2945f92f261f2911115 100644
@@ -67,6 +67,7 @@ CONFIG_ARCH_SEATTLE=y
 CONFIG_ARCH_INTEL_SOCFPGA=y
 CONFIG_ARCH_STM32=y
 CONFIG_ARCH_SYNQUACER=y
+CONFIG_ARCH_SC59X_64=y
 CONFIG_ARCH_TEGRA=y
 CONFIG_ARCH_TESLA_FSD=y
 CONFIG_ARCH_SPRD=y
@@ -473,6 +474,7 @@ CONFIG_SERIAL_8250_OMAP=y
 CONFIG_SERIAL_8250_MT6577=y
 CONFIG_SERIAL_8250_UNIPHIER=y
 CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SERIAL_ADI_UART=y
 CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
 CONFIG_SERIAL_MESON=y
@@ -513,6 +515,7 @@ CONFIG_TCG_TIS_I2C_CR50=m
 CONFIG_TCG_TIS_I2C_INFINEON=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MUX=y
+CONFIG_I2C_ADI_TWI=y
 CONFIG_I2C_MUX_PCA954x=y
 CONFIG_I2C_BCM2835=m
 CONFIG_I2C_CADENCE=m
@@ -539,6 +542,7 @@ CONFIG_I2C_UNIPHIER_F=y
 CONFIG_I2C_RCAR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SPI=y
+CONFIG_SPI_ADI=y
 CONFIG_SPI_ARMADA_3700=y
 CONFIG_SPI_BCM2835=m
 CONFIG_SPI_BCM2835AUX=m
@@ -637,6 +641,7 @@ CONFIG_PINCTRL_SM8450_LPASS_LPI=m
 CONFIG_PINCTRL_SC8280XP_LPASS_LPI=m
 CONFIG_PINCTRL_SM8550_LPASS_LPI=m
 CONFIG_PINCTRL_SM8650_LPASS_LPI=m
+CONFIG_GPIO_ADI_ADSP_PORT=y
 CONFIG_GPIO_ALTERA=m
 CONFIG_GPIO_DAVINCI=y
 CONFIG_GPIO_DWAPB=y
@@ -1512,6 +1517,7 @@ CONFIG_RESET_QCOM_AOSS=y
 CONFIG_RESET_QCOM_PDC=m
 CONFIG_RESET_RZG2L_USBPHY_CTRL=y
 CONFIG_RESET_TI_SCI=y
+CONFIG_RESET_SC5XX=y
 CONFIG_PHY_XGENE=y
 CONFIG_PHY_CAN_TRANSCEIVER=m
 CONFIG_PHY_SUN4I_USB=y
Signature · 1 line
2.25.1
maintainer
#58 lore raw

Re: [PATCH 20/21] arm64: defconfig: sc598 add minimal changes

Quoted 13 lines · On Thu, Sep 12, 2024, at 18:25, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC598 defconfig

arch/arm64/configs/defconfig +1 -0
@@ -513,6 +515,7 @@ CONFIG_TCG_TIS_I2C_CR50=m
 CONFIG_TCG_TIS_I2C_INFINEON=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MUX=y
+CONFIG_I2C_ADI_TWI=y
 CONFIG_I2C_MUX_PCA954x=y
 CONFIG_I2C_BCM2835=m
 CONFIG_I2C_CADENCE=m

arch/arm64/configs/defconfig CONFIG_I2C_UNIPHIER_F=y · line 548

Quoted 7 lines
arch/arm64/configs/defconfig +1 -0
@@ -539,6 +542,7 @@ CONFIG_I2C_UNIPHIER_F=y
 CONFIG_I2C_RCAR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SPI=y
+CONFIG_SPI_ADI=y
 CONFIG_SPI_ARMADA_3700=y
 CONFIG_SPI_BCM2835=m
 CONFIG_SPI_BCM2835AUX=m

These are usually not required for booting and should be made loadable modules if possible.

Arnd

#59 lore raw

Re: [PATCH 20/21] arm64: defconfig: sc598 add minimal changes

In reply to Arturs Artamonovs
Quoted 3 lines · On 12/09/2024 20:25, Arturs Artamonovs via B4 Relay wrote:

From: Arturs Artamonovs <[email protected]>

Add ADSP-SC598 defconfig

That's neither true nor helpful. Say more about hardware. That's a defconfig for all platforms, not only yours.

Quoted 8 lines

4 people contributed to simple defconfig? How?

Best regards,
Krzysztof

#60 lore raw

PATCH 21/21 MAINTAINERS: add adi sc5xx maintainers

In reply to Arturs Artamonovs

Add ADSP-SC598 maitaniners

---
 MAINTAINERS | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
MAINTAINERS +22 -0
index 10430778c998b57944c1a6c5f07d676127e47faa..a838a5392321602034755fafed720f68d3798c0b 100644
@@ -1934,6 +1934,28 @@ S:	Odd Fixes
 F:	arch/arm/boot/dts/airoha/
 F:	arch/arm64/boot/dts/airoha/
 
+ARM/ADI SoC Support
+M:	Arturs Artamonovs <[email protected]>
+M:	Greg Malysa <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/arm/analog/adi,sc5xx.yaml
+F:	Documentation/devicetree/bindings/clock/adi,sc5xx-clocks.yaml
+F:	Documentation/devicetree/bindings/gpio/adi,adsp-port-gpio.yaml
+F:	Documentation/devicetree/bindings/i2c/adi,twi.yaml
+F:	Documentation/devicetree/bindings/interrupt-controller/adi,adsp-pint.yaml
+F:	Documentation/devicetree/bindings/pinctrl/adi,adsp-pinctrl.yaml
+F:	Documentation/devicetree/bindings/serial/adi,uart.yaml
+F:	Documentation/devicetree/bindings/serial/adi,uart.yaml
+F:	Documentation/devicetree/bindings/soc/adi/*
+F:	arch/arm64/boot/dts/adi/*
+F:	drivers/clk/adi/*
+F:	drivers/gpio/gpio-adi-adsp-port.c
+F:	drivers/i2c/busses/i2c-adi-twi.c
+F:	drivers/irqchip/irq-adi-adsp.c
+F:	drivers/soc/adi/*
+F:	drivers/tty/serial/adi_uart.c
+
+
 ARM/Allwinner SoC Clock Support
 M:	Emilio López <[email protected]>
 S:	Maintained
Signature · 1 line
2.25.1
#61 lore raw
In reply to Arturs Artamonovs
Quoted 85 lines · Arturs Artamonovs

This set of patches based on ADI fork of Linux Kerenl that support family of ADSP-SC5xx SoC's and used by customers for some time . Patch series contains minimal set of changes to add ADSP-SC598 support to upstream kernel. This series include UART,I2C,IRQCHIP,RCU drivers and device-tree to be able boot on EV-SC598-SOM board into serial shell and able to reset the board. Current SOM board requires I2C expander to enable UART output.

UART,I2C and PINCTRL drivers are based on old Blackfin drivers with ADSP-SC5xx related bug fixes and improvments.

---
Arturs Artamonovs (21):
arm64: Add ADI ADSP-SC598 SoC
reset: Add driver for ADI ADSP-SC5xx reset controller
dt-bindigs: arm64: adi,sc598 bindings
dt-bindings: arm64: adi,sc598: Add ADSP-SC598 SoC bindings clock:Add driver for ADI ADSP-SC5xx PLL
include: dt-binding: clock: add adi clock header file
clock: Add driver for ADI ADSP-SC5xx clock
dt-bindings: clock: adi,sc5xx-clocks: add bindings
gpio: add driver for ADI ADSP-SC5xx platform
dt-bindings: gpio: adi,adsp-port-gpio: add bindings
irqchip: Add irqchip for ADI ADSP-SC5xx platform
dt-bindings: irqchip: adi,adsp-pint: add binding
pinctrl: Add drivers for ADI ADSP-SC5xx platform
dt-bindings: pinctrl: adi,adsp-pinctrl: add bindings
i2c: Add driver for ADI ADSP-SC5xx platforms
dt-bindings: i2c: add i2c/twi driver documentation
serial: adi,uart: Add driver for ADI ADSP-SC5xx
dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation
arm64: dts: adi: sc598: add device tree
arm64: defconfig: sc598 add minimal changes
MAINTAINERS: add adi sc5xx maintainers

 .../devicetree/bindings/arm/analog/adi,sc5xx.yaml  |   24 +
 .../bindings/clock/adi,sc5xx-clocks.yaml           |   65 ++
 .../bindings/gpio/adi,adsp-port-gpio.yaml          |   69 ++
 Documentation/devicetree/bindings/i2c/adi,twi.yaml |   71 ++
 .../interrupt-controller/adi,adsp-pint.yaml        |   51 +
 .../bindings/pinctrl/adi,adsp-pinctrl.yaml         |   83 ++
 .../devicetree/bindings/serial/adi,uart.yaml       |   85 ++
 .../bindings/soc/adi/adi,reset-controller.yaml     |   38 +
 MAINTAINERS                                        |   22 +
 arch/arm64/Kconfig.platforms                       |   13 +
 arch/arm64/boot/dts/Makefile                       |    1 +
 arch/arm64/boot/dts/adi/Makefile                   |    2 +
 arch/arm64/boot/dts/adi/sc598-som-ezkit.dts        |   14 +
 arch/arm64/boot/dts/adi/sc598-som.dtsi             |   58 ++
 arch/arm64/boot/dts/adi/sc59x-64.dtsi              |  367 +++++++
 arch/arm64/configs/defconfig                       |    6 +
 drivers/clk/Kconfig                                |    9 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/adi/Makefile                           |    4 +
 drivers/clk/adi/clk-adi-pll.c                      |  151 +++
 drivers/clk/adi/clk-adi-sc598.c                    |  329 ++++++
 drivers/clk/adi/clk.h                              |   99 ++
 drivers/gpio/Kconfig                               |    8 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-adi-adsp-port.c                  |  145 +++
 drivers/i2c/busses/Kconfig                         |   17 +
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-adi-twi.c                   |  940 ++++++++++++++++++
 drivers/irqchip/Kconfig                            |    9 +
 drivers/irqchip/Makefile                           |    2 +
 drivers/irqchip/irq-adi-adsp.c                     |  310 ++++++
 drivers/pinctrl/Kconfig                            |   12 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-adsp.c                     |  919 +++++++++++++++++
 drivers/reset/Makefile                             |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/adi/Makefile                           |    5 +
 drivers/soc/adi/system.c                           |  257 +++++
 drivers/tty/serial/Kconfig                         |   19 +-
 drivers/tty/serial/Makefile                        |    1 +
 drivers/tty/serial/adi_uart.c                      | 1045 ++++++++++++++++++++
 include/dt-bindings/clock/adi-sc5xx-clock.h        |   93 ++
 include/dt-bindings/pinctrl/adi-adsp.h             |   19 +
 include/linux/soc/adi/adsp-gpio-port.h             |   85 ++
 include/linux/soc/adi/cpu.h                        |  107 ++
 include/linux/soc/adi/rcu.h                        |   55 ++
 include/linux/soc/adi/sc59x.h                      |  147 +++
 include/linux/soc/adi/system_config.h              |   65 ++
 include/uapi/linux/serial_core.h                   |    3 +
 49 files changed, 5829 insertions(+), 1 deletion(-)
Quoted 10 lines

---
base-commit: da3ea35007d0af457a0afc87e84fddaebc4e0b63
change-id: 20240909-test-8ec5f76fe6d2

Best regards,
--
Arturs Artamonovs <[email protected]>

My bot found new DTB warnings on the .dts files added or changed in this series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:

  pip3 install dtschema --upgrade

New warnings running 'make CHECK_DTBS=y adi/sc598-som-ezkit.dtb' for [email protected]:

arch/arm64/boot/dts/adi/sc598-som-ezkit.dtb: /scb-bus/sec@31089000: failed to match any schema with compatible: ['adi,system-event-controller']

#62 lore raw
Quoted 110 lines · Rob Herring (Arm)
Quoted 85 lines · Arturs Artamonovs

This set of patches based on ADI fork of Linux Kerenl that support family of ADSP-SC5xx SoC's and used by customers for some time . Patch series contains minimal set of changes to add ADSP-SC598 support to upstream kernel. This series include UART,I2C,IRQCHIP,RCU drivers and device-tree to be able boot on EV-SC598-SOM board into serial shell and able to reset the board. Current SOM board requires I2C expander to enable UART output.

UART,I2C and PINCTRL drivers are based on old Blackfin drivers with ADSP-SC5xx related bug fixes and improvments.

---
Arturs Artamonovs (21):
arm64: Add ADI ADSP-SC598 SoC
reset: Add driver for ADI ADSP-SC5xx reset controller
dt-bindigs: arm64: adi,sc598 bindings
dt-bindings: arm64: adi,sc598: Add ADSP-SC598 SoC bindings clock:Add driver for ADI ADSP-SC5xx PLL
include: dt-binding: clock: add adi clock header file
clock: Add driver for ADI ADSP-SC5xx clock
dt-bindings: clock: adi,sc5xx-clocks: add bindings
gpio: add driver for ADI ADSP-SC5xx platform
dt-bindings: gpio: adi,adsp-port-gpio: add bindings
irqchip: Add irqchip for ADI ADSP-SC5xx platform
dt-bindings: irqchip: adi,adsp-pint: add binding
pinctrl: Add drivers for ADI ADSP-SC5xx platform
dt-bindings: pinctrl: adi,adsp-pinctrl: add bindings
i2c: Add driver for ADI ADSP-SC5xx platforms
dt-bindings: i2c: add i2c/twi driver documentation
serial: adi,uart: Add driver for ADI ADSP-SC5xx
dt-bindings: serial: adi,uart4: add adi,uart4 driver documentation
arm64: dts: adi: sc598: add device tree
arm64: defconfig: sc598 add minimal changes
MAINTAINERS: add adi sc5xx maintainers

 .../devicetree/bindings/arm/analog/adi,sc5xx.yaml  |   24 +
 .../bindings/clock/adi,sc5xx-clocks.yaml           |   65 ++
 .../bindings/gpio/adi,adsp-port-gpio.yaml          |   69 ++
 Documentation/devicetree/bindings/i2c/adi,twi.yaml |   71 ++
 .../interrupt-controller/adi,adsp-pint.yaml        |   51 +
 .../bindings/pinctrl/adi,adsp-pinctrl.yaml         |   83 ++
 .../devicetree/bindings/serial/adi,uart.yaml       |   85 ++
 .../bindings/soc/adi/adi,reset-controller.yaml     |   38 +
 MAINTAINERS                                        |   22 +
 arch/arm64/Kconfig.platforms                       |   13 +
 arch/arm64/boot/dts/Makefile                       |    1 +
 arch/arm64/boot/dts/adi/Makefile                   |    2 +
 arch/arm64/boot/dts/adi/sc598-som-ezkit.dts        |   14 +
 arch/arm64/boot/dts/adi/sc598-som.dtsi             |   58 ++
 arch/arm64/boot/dts/adi/sc59x-64.dtsi              |  367 +++++++
 arch/arm64/configs/defconfig                       |    6 +
 drivers/clk/Kconfig                                |    9 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/adi/Makefile                           |    4 +
 drivers/clk/adi/clk-adi-pll.c                      |  151 +++
 drivers/clk/adi/clk-adi-sc598.c                    |  329 ++++++
 drivers/clk/adi/clk.h                              |   99 ++
 drivers/gpio/Kconfig                               |    8 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-adi-adsp-port.c                  |  145 +++
 drivers/i2c/busses/Kconfig                         |   17 +
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-adi-twi.c                   |  940 ++++++++++++++++++
 drivers/irqchip/Kconfig                            |    9 +
 drivers/irqchip/Makefile                           |    2 +
 drivers/irqchip/irq-adi-adsp.c                     |  310 ++++++
 drivers/pinctrl/Kconfig                            |   12 +
 drivers/pinctrl/Makefile                           |    1 +
 drivers/pinctrl/pinctrl-adsp.c                     |  919 +++++++++++++++++
 drivers/reset/Makefile                             |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/adi/Makefile                           |    5 +
 drivers/soc/adi/system.c                           |  257 +++++
 drivers/tty/serial/Kconfig                         |   19 +-
 drivers/tty/serial/Makefile                        |    1 +
 drivers/tty/serial/adi_uart.c                      | 1045 ++++++++++++++++++++
 include/dt-bindings/clock/adi-sc5xx-clock.h        |   93 ++
 include/dt-bindings/pinctrl/adi-adsp.h             |   19 +
 include/linux/soc/adi/adsp-gpio-port.h             |   85 ++
 include/linux/soc/adi/cpu.h                        |  107 ++
 include/linux/soc/adi/rcu.h                        |   55 ++
 include/linux/soc/adi/sc59x.h                      |  147 +++
 include/linux/soc/adi/system_config.h              |   65 ++
 include/uapi/linux/serial_core.h                   |    3 +
 49 files changed, 5829 insertions(+), 1 deletion(-)
Quoted 10 lines

---
base-commit: da3ea35007d0af457a0afc87e84fddaebc4e0b63
change-id: 20240909-test-8ec5f76fe6d2

Best regards,
--
Arturs Artamonovs <[email protected]>

My bot found new DTB warnings on the .dts files added or changed in this series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:

Quoted 6 lines
  pip3 install dtschema --upgrade

New warnings running 'make CHECK_DTBS=y adi/sc598-som-ezkit.dtb' for [email protected]:

arch/arm64/boot/dts/adi/sc598-som-ezkit.dtb: /scb-bus/sec@31089000: failed to match any schema with compatible: ['adi,system-event-controller']

This must be addressed and fixed.

Best regards,
Krzysztof

maintainer
#63 lore raw
In reply to Arturs Artamonovs
Quoted 11 lines · On Thu, Sep 12, 2024, at 18:24, Arturs Artamonovs via B4 Relay wrote:

This set of patches based on ADI fork of Linux Kerenl that support family of ADSP-SC5xx
SoC's and used by customers for some time . Patch series contains minimal set
of changes to add ADSP-SC598 support to upstream kernel. This series include
UART,I2C,IRQCHIP,RCU drivers and device-tree to be able boot on EV-SC598-SOM
board into serial shell and able to reset the board. Current SOM board requires I2C expander to enable UART output.

Quoted 4 lines

UART,I2C and PINCTRL drivers are based on old Blackfin drivers with ADSP-SC5xx related bug fixes and improvments.

Hi Arturs,

Thanks for your submission. I've done a first pass of a review now, but the drivers will all need a more detailed review from the subsystem maintainers as well.

For the drivers/soc and include/linux/soc portions, I need to do second review round when you have added a description about what these are used for, ideally I would hope that most of those can disappear from the final series when the required bits are moved into other drivers.

I commented on one of the bindings about the compatible string, but later saw that the same issue is present in all of the bindings, which each need a more specific identifier for a particular piece of hardware they are compatible with.

Arnd

#64 lore raw
In reply to Arturs Artamonovs
Quoted 7 lines · On 12/09/2024 20:24, Arturs Artamonovs via B4 Relay wrote:

This set of patches based on ADI fork of Linux Kerenl that support family of ADSP-SC5xx SoC's and used by customers for some time . Patch series contains minimal set of changes to add ADSP-SC598 support to upstream kernel. This series include UART,I2C,IRQCHIP,RCU drivers and device-tree to be able boot on EV-SC598-SOM board into serial shell and able to reset the board. Current SOM board requires I2C expander to enable UART output.

Quoted 5 lines

UART,I2C and PINCTRL drivers are based on old Blackfin drivers with ADSP-SC5xx related bug fixes and improvments.

---

For new platform, be sure you have 0 warnings:
1. Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings.

2. Also check for warnings when building with W=1. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

3. Fix all compile test warning reported by LKP and check for common configs, regardless of reports.

4. Please run make dtbs_check W=1 (see Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).

5. Please run scripts/checkpatch.pl and fix reported warnings. Then please run scripts/checkpatch.pl --strict and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run.

Best regards,
Krzysztof