public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Add the capability to read firmware binary names from dts for Airoha NPU driver
@ 2026-01-12 10:00 Lorenzo Bianconi
  2026-01-12 10:00 ` [PATCH net-next 1/2] dt-bindings: net: airoha: npu: Add firmware-name property Lorenzo Bianconi
  2026-01-12 10:00 ` [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts Lorenzo Bianconi
  0 siblings, 2 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2026-01-12 10:00 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: netdev, devicetree, linux-arm-kernel, linux-mediatek

This is a preliminary patch to enable NPU offloading for MT7996 (Eagle)
chipset since it requires a different binary with respect to the one
used for MT7992 on the EN7581 SoC.

---
Lorenzo Bianconi (2):
      dt-bindings: net: airoha: npu: Add firmware-name property
      net: airoha: npu: Add the capability to read firmware names from dts

 .../devicetree/bindings/net/airoha,en7581-npu.yaml |  7 ++++
 drivers/net/ethernet/airoha/airoha_npu.c           | 42 ++++++++++++++++++----
 2 files changed, 43 insertions(+), 6 deletions(-)
---
base-commit: bc87b14594e30720a5c1546c24e0f5f08d34eb40
change-id: 20260107-airoha-npu-firmware-name-34e5002a1a3f

Best regards,
-- 
Lorenzo Bianconi <lorenzo@kernel.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 1/2] dt-bindings: net: airoha: npu: Add firmware-name property
  2026-01-12 10:00 [PATCH net-next 0/2] Add the capability to read firmware binary names from dts for Airoha NPU driver Lorenzo Bianconi
@ 2026-01-12 10:00 ` Lorenzo Bianconi
  2026-01-12 10:00 ` [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts Lorenzo Bianconi
  1 sibling, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2026-01-12 10:00 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: netdev, devicetree, linux-arm-kernel, linux-mediatek

Add firmware-name property in order to introduce the capability to
specify the firmware names used for RiscV core/Data section binaries.
This is a preliminary patch to enable NPU offloading for MT7996 (Eagle)
chipset since it requires a different binary with respect to the one
used for MT7992 on EN7581 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
index 59c57f58116b568092446e6cfb7b6bd3f4f47b82..e008cf92e0975b43b433030908c35340361bc71c 100644
--- a/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
+++ b/Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
@@ -58,6 +58,11 @@ properties:
       - const: tx-pkt
       - const: tx-bufid
 
+  firmware-name:
+    items:
+      - description: Firmware name of RiscV core
+      - description: Firmware name of Data section
+
 required:
   - compatible
   - reg
@@ -95,5 +100,7 @@ examples:
         memory-region = <&npu_firmware>, <&npu_pkt>, <&npu_txpkt>,
                         <&npu_txbufid>;
         memory-region-names = "firmware", "pkt", "tx-pkt", "tx-bufid";
+        firmware-name = "airoha/en7581_npu_rv32.bin",
+                        "airoha/en7581_npu_data.bin";
       };
     };

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 10:00 [PATCH net-next 0/2] Add the capability to read firmware binary names from dts for Airoha NPU driver Lorenzo Bianconi
  2026-01-12 10:00 ` [PATCH net-next 1/2] dt-bindings: net: airoha: npu: Add firmware-name property Lorenzo Bianconi
@ 2026-01-12 10:00 ` Lorenzo Bianconi
  2026-01-12 13:30   ` Andrew Lunn
  1 sibling, 1 reply; 8+ messages in thread
From: Lorenzo Bianconi @ 2026-01-12 10:00 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Lorenzo Bianconi
  Cc: netdev, devicetree, linux-arm-kernel, linux-mediatek

Introduce the capability to read the firmware binary names from device-tree
using the firmware-name property if available.
This is a preliminary patch to enable NPU offloading for MT7996 (Eagle)
chipset since it requires a different binary with respect to the one
used for MT7992 on the EN7581 SoC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/airoha/airoha_npu.c | 42 +++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
index 22f72c146065998d5450477f664ed308b1569aa3..bba30582787babd77083c7456349f0af76afc505 100644
--- a/drivers/net/ethernet/airoha/airoha_npu.c
+++ b/drivers/net/ethernet/airoha/airoha_npu.c
@@ -195,18 +195,18 @@ static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id,
 }
 
 static int airoha_npu_load_firmware(struct device *dev, void __iomem *addr,
-				    const struct airoha_npu_fw *fw_info)
+				    const char *fw_name, int fw_max_size)
 {
 	const struct firmware *fw;
 	int ret;
 
-	ret = request_firmware(&fw, fw_info->name, dev);
+	ret = request_firmware(&fw, fw_name, dev);
 	if (ret)
 		return ret == -ENOENT ? -EPROBE_DEFER : ret;
 
-	if (fw->size > fw_info->max_size) {
+	if (fw->size > fw_max_size) {
 		dev_err(dev, "%s: fw size too overlimit (%zu)\n",
-			fw_info->name, fw->size);
+			fw_name, fw->size);
 		ret = -E2BIG;
 		goto out;
 	}
@@ -218,6 +218,28 @@ static int airoha_npu_load_firmware(struct device *dev, void __iomem *addr,
 	return ret;
 }
 
+static int
+airoha_npu_load_firmware_from_dts(struct device *dev, void __iomem *addr,
+				  void __iomem *base)
+{
+	const char *fw_names[2];
+	int ret;
+
+	ret = of_property_read_string_array(dev->of_node, "firmware-name",
+					    fw_names, ARRAY_SIZE(fw_names));
+	if (ret != ARRAY_SIZE(fw_names))
+		return -EINVAL;
+
+	ret = airoha_npu_load_firmware(dev, addr, fw_names[0],
+				       NPU_EN7581_FIRMWARE_RV32_MAX_SIZE);
+	if (ret)
+		return ret;
+
+	return airoha_npu_load_firmware(dev, base + REG_NPU_LOCAL_SRAM,
+					fw_names[1],
+					NPU_EN7581_FIRMWARE_DATA_MAX_SIZE);
+}
+
 static int airoha_npu_run_firmware(struct device *dev, void __iomem *base,
 				   struct resource *res)
 {
@@ -233,14 +255,22 @@ static int airoha_npu_run_firmware(struct device *dev, void __iomem *base,
 	if (IS_ERR(addr))
 		return PTR_ERR(addr);
 
+	/* Try to load firmware images using the firmware names provided via
+	 * dts if available.
+	 */
+	if (of_find_property(dev->of_node, "firmware-name", NULL))
+		return airoha_npu_load_firmware_from_dts(dev, addr, base);
+
 	/* Load rv32 npu firmware */
-	ret = airoha_npu_load_firmware(dev, addr, &soc->fw_rv32);
+	ret = airoha_npu_load_firmware(dev, addr, soc->fw_rv32.name,
+				       soc->fw_rv32.max_size);
 	if (ret)
 		return ret;
 
 	/* Load data npu firmware */
 	return airoha_npu_load_firmware(dev, base + REG_NPU_LOCAL_SRAM,
-					&soc->fw_data);
+					soc->fw_data.name,
+					soc->fw_data.max_size);
 }
 
 static irqreturn_t airoha_npu_mbox_handler(int irq, void *npu_instance)

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 10:00 ` [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts Lorenzo Bianconi
@ 2026-01-12 13:30   ` Andrew Lunn
  2026-01-12 13:35     ` Lorenzo Bianconi
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2026-01-12 13:30 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	netdev, devicetree, linux-arm-kernel, linux-mediatek

On Mon, Jan 12, 2026 at 11:00:08AM +0100, Lorenzo Bianconi wrote:
> Introduce the capability to read the firmware binary names from device-tree
> using the firmware-name property if available.
> This is a preliminary patch to enable NPU offloading for MT7996 (Eagle)
> chipset since it requires a different binary with respect to the one
> used for MT7992 on the EN7581 SoC.

When i look at

airoha_npu.c

i see:

#define NPU_EN7581_FIRMWARE_DATA                "airoha/en7581_npu_data.bin"
#define NPU_EN7581_FIRMWARE_RV32                "airoha/en7581_npu_rv32.bin"
#define NPU_AN7583_FIRMWARE_DATA                "airoha/an7583_npu_data.bin"
#define NPU_AN7583_FIRMWARE_RV32                "airoha/an7583_npu_rv32.bin"

static const struct airoha_npu_soc_data en7581_npu_soc_data = {
        .fw_rv32 = {
                .name = NPU_EN7581_FIRMWARE_RV32,
                .max_size = NPU_EN7581_FIRMWARE_RV32_MAX_SIZE,
        },
        .fw_data = {
                .name = NPU_EN7581_FIRMWARE_DATA,
                .max_size = NPU_EN7581_FIRMWARE_DATA_MAX_SIZE,
        },
};

static const struct airoha_npu_soc_data an7583_npu_soc_data = {
        .fw_rv32 = {
                .name = NPU_AN7583_FIRMWARE_RV32,
                .max_size = NPU_EN7581_FIRMWARE_RV32_MAX_SIZE,
        },
        .fw_data = {
                .name = NPU_AN7583_FIRMWARE_DATA,
                .max_size = NPU_EN7581_FIRMWARE_DATA_MAX_SIZE,
        },
};

static const struct of_device_id of_airoha_npu_match[] = {
        { .compatible = "airoha,en7581-npu", .data = &en7581_npu_soc_data },
        { .compatible = "airoha,an7583-npu", .data = &an7583_npu_soc_data },
        { /* sentinel */ }
};

Why cannot this scheme be extended with another compatible?

    Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 13:30   ` Andrew Lunn
@ 2026-01-12 13:35     ` Lorenzo Bianconi
  2026-01-12 14:11       ` Andrew Lunn
  2026-01-13  8:11       ` Krzysztof Kozlowski
  0 siblings, 2 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2026-01-12 13:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	netdev, devicetree, linux-arm-kernel, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]

> On Mon, Jan 12, 2026 at 11:00:08AM +0100, Lorenzo Bianconi wrote:
> > Introduce the capability to read the firmware binary names from device-tree
> > using the firmware-name property if available.
> > This is a preliminary patch to enable NPU offloading for MT7996 (Eagle)
> > chipset since it requires a different binary with respect to the one
> > used for MT7992 on the EN7581 SoC.
> 
> When i look at
> 
> airoha_npu.c
> 
> i see:
> 
> #define NPU_EN7581_FIRMWARE_DATA                "airoha/en7581_npu_data.bin"
> #define NPU_EN7581_FIRMWARE_RV32                "airoha/en7581_npu_rv32.bin"
> #define NPU_AN7583_FIRMWARE_DATA                "airoha/an7583_npu_data.bin"
> #define NPU_AN7583_FIRMWARE_RV32                "airoha/an7583_npu_rv32.bin"
> 
> static const struct airoha_npu_soc_data en7581_npu_soc_data = {
>         .fw_rv32 = {
>                 .name = NPU_EN7581_FIRMWARE_RV32,
>                 .max_size = NPU_EN7581_FIRMWARE_RV32_MAX_SIZE,
>         },
>         .fw_data = {
>                 .name = NPU_EN7581_FIRMWARE_DATA,
>                 .max_size = NPU_EN7581_FIRMWARE_DATA_MAX_SIZE,
>         },
> };
> 
> static const struct airoha_npu_soc_data an7583_npu_soc_data = {
>         .fw_rv32 = {
>                 .name = NPU_AN7583_FIRMWARE_RV32,
>                 .max_size = NPU_EN7581_FIRMWARE_RV32_MAX_SIZE,
>         },
>         .fw_data = {
>                 .name = NPU_AN7583_FIRMWARE_DATA,
>                 .max_size = NPU_EN7581_FIRMWARE_DATA_MAX_SIZE,
>         },
> };
> 
> static const struct of_device_id of_airoha_npu_match[] = {
>         { .compatible = "airoha,en7581-npu", .data = &en7581_npu_soc_data },
>         { .compatible = "airoha,an7583-npu", .data = &an7583_npu_soc_data },
>         { /* sentinel */ }
> };
> 
> Why cannot this scheme be extended with another compatible?

yes, that is another possibility I was thinking of but then I found
"firwmare-name" property was quite a common approach.
Something like:

static const struct of_device_id of_airoha_npu_match[] = {
	...
	{ .compatible = "airoha,en7581-npu-7996", .data = &en7581_7996_npu_soc_data },
	...
};

What do you think?

Regards,
Lorenzo

> 
>     Andrew

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 13:35     ` Lorenzo Bianconi
@ 2026-01-12 14:11       ` Andrew Lunn
  2026-01-12 14:40         ` Lorenzo Bianconi
  2026-01-13  8:11       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2026-01-12 14:11 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	netdev, devicetree, linux-arm-kernel, linux-mediatek

> > Why cannot this scheme be extended with another compatible?
> 
> yes, that is another possibility I was thinking of but then I found
> "firwmare-name" property was quite a common approach.
> Something like:

Having two different ways of doing the same thing in one driver just
add unneeded complexity. Please just key of the compatible like all
other devices this driver supports.

    Andrew

---
pw-bot: cr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 14:11       ` Andrew Lunn
@ 2026-01-12 14:40         ` Lorenzo Bianconi
  0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2026-01-12 14:40 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	netdev, devicetree, linux-arm-kernel, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

> > > Why cannot this scheme be extended with another compatible?
> > 
> > yes, that is another possibility I was thinking of but then I found
> > "firwmare-name" property was quite a common approach.
> > Something like:
> 
> Having two different ways of doing the same thing in one driver just
> add unneeded complexity. Please just key of the compatible like all
> other devices this driver supports.
> 
>     Andrew

ack, I will fix it in v2.

Regards,
Lorenzo

> 
> ---
> pw-bot: cr

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts
  2026-01-12 13:35     ` Lorenzo Bianconi
  2026-01-12 14:11       ` Andrew Lunn
@ 2026-01-13  8:11       ` Krzysztof Kozlowski
  1 sibling, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-13  8:11 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, netdev, devicetree, linux-arm-kernel,
	linux-mediatek

On Mon, Jan 12, 2026 at 02:35:57PM +0100, Lorenzo Bianconi wrote:
> > static const struct of_device_id of_airoha_npu_match[] = {
> >         { .compatible = "airoha,en7581-npu", .data = &en7581_npu_soc_data },
> >         { .compatible = "airoha,an7583-npu", .data = &an7583_npu_soc_data },
> >         { /* sentinel */ }
> > };
> > 
> > Why cannot this scheme be extended with another compatible?
> 
> yes, that is another possibility I was thinking of but then I found
> "firwmare-name" property was quite a common approach.

"firmware-name" is for cases when the firmware is per board, not per
SoC.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-13  8:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 10:00 [PATCH net-next 0/2] Add the capability to read firmware binary names from dts for Airoha NPU driver Lorenzo Bianconi
2026-01-12 10:00 ` [PATCH net-next 1/2] dt-bindings: net: airoha: npu: Add firmware-name property Lorenzo Bianconi
2026-01-12 10:00 ` [PATCH net-next 2/2] net: airoha: npu: Add the capability to read firmware names from dts Lorenzo Bianconi
2026-01-12 13:30   ` Andrew Lunn
2026-01-12 13:35     ` Lorenzo Bianconi
2026-01-12 14:11       ` Andrew Lunn
2026-01-12 14:40         ` Lorenzo Bianconi
2026-01-13  8:11       ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox