2022-08-04 21:20:59

by Daniel Kestrel

[permalink] [raw]
Subject: [PATCH v5 0/3] Add support for WASP SoC on AVM router boards

There is a popular set of Lantiq xrx200 router boards by AVM in
Germany (AVM Fritzbox 3390, 3490, 5490, 5491 and 7490) which
have the strange implementation of having the wifi cards
connected to a separate memory only ATH79 based SoC. It has no
persistent storage and no access to any resource on the Lantiq
host, but is connect to the Lantiq GSWIP switch on an additional
fixed internal network port.
This kernel module is to support booting the secondary SoC called
Wireless Assistant Support Processor (WASP).
After turning it on, a small network boot firmware is sent to
the SoC by using mdio and when it is started, an initramfs
linux image is sent to the SoC using raw ethernet frames.

The whole procedure takes about 6 seconds, if there is no error.
So far tested on 3490, 5490 and 7490 devices based on OpenWrt, 3390
takes about 20 seconds.

Patch 1/3 adds the vendor name
Patch 2/3 adds the dt-bindings
Patch 3/3 adds the remoteproc driver

To build and run, there is OpenWrt PR 5075.

Please review.

Changes in v5:
- Replace names for properties and descriptions as requested in the
device tree documentation and change the driver to accept them
- Change example in the device tree documentation
- Restructure constants and defines in the beginning of the driver
source for better readability
- Combine m_start_addr and m_exec_addr into a single constant and
change avm_wasp_netboot_write_header to use only this one constant
- Change variable startup_gpio to power_gpio in driver

Changes in v4:
- Fix compiler warnings with W=2 option

Changes in v3:
- Replace generic avm,fritzboxx490-wasp with actual device names for
device tree documentation and change the driver to accept them
- Add maxItems to device tree documentation
- Change example in the device tree documentation
- Fix wait time to make the Wasp upload work for 3390 more reliable
- Enable the SOC on driver load, use reset instead of disable/enable
while driver is loaded and disable on unloading the driver
- Change some messages printed to adhere to standards (e.g. remove !)

Changes in v2:
- Remove firmware names from dt-binding and add as kmod parameters
- Rename other bindings with vender prefix and fix gpios suffix
- Change descriptions in dt-binding
- Replace/Remove asynch load of firmware with request_firmware_direct
- Fix comments to use the errno define instead of the number
- Implement wait loops with read_poll_timeout() macro
- Wrap read_poll_timeout() macro in function saving 6k module size
- Return -ETIMEDOUT for all errors returned by read_poll_timeout
- Replace mdio writes/reads with mdiobus_write and mdiobus_read and add
return codes and their handling
- Remove mutex for mdiobus_lock and add return code checking for mdio ops
- Replaced the mdio register array with directly specifying registers
- As a result of the previous 3 changes remove the functions for mdio
- Consolidate error messages for mdio writes into a single one saved 1k
for module size
- Replaced mdelay with usleep_range saved 0,7k module size
- Remove unneeded include <linux/interrupt.h> and <linux/error.h>
- Wrap all blocks with {} and fix some indentation errors
- Change const len in to size_t in avm_wasp_netboot_write_chunk
- Make all methods static to fix kernel bot warning
- Change read variable name in avm_wasp_load_initramfs_image
- Change ssize_t variables to size_t in avm_wasp_load_initramfs_image
- avm_wasp_netboot_write_chunk change for loop for 2 byte divisibility
- Change uint32_t to u32
- Change int count = -1 to u32 with U32_MAX initialisation
- Add check for firmware len divisable by 4
- Replace big endian bit shift operations with be32_to_cpu
- Change loop to write 14 byte firmware chuncks like suggested
- Change WASP_CHUNK_SIZE to ARRAY_SIZE(mac_data) for readability
- Change int done to boolean
- Change unsigned ints to u32
- Change int to size_t for send_len
- Use int for numbytes because kernel_recvmsg returns error or number
- Two sockets are not needed, so reduce to one socket usage
- Remove struct timeval definition, replace with __kernel_old_timeval
- __kernel_old_timeval is depracated, but arch mips is 32bit platform
- Replace &avmwasp->pdev->dev with local dev
- Check if wasp network interface is up and fail if not in start method
- Remove setsockopt for SO_REUSEADDR and SO_BINDTODEVICE
- Remove packet_counter
- Move firmware and firmware_end out of RESP_DISCOVER to make sure that
they are initialized if RESP_DISCOVER is not happening first
- indend break;
- Move second half of the send/receive paket while loop to RESP_OK and
let RESP_DISCOVER fall through
- Remove bringing up the wasp network interface
- Check if wasp network interface is up in probe and defer if not
- Remove the check for the root device and replace it with match data
for WASP device identification
- Move of_read and find of mdio bus to rproc_start but delete reference
after using it in the rproc_start method
- Replace dev_set_drvdata with platform_set_drvdata
- Remove avm_wasp_rproc_boot_addr because its not needed and move
setting the fw struct pointer to avm_wasp_rproc_load
- Move avm_wasp.h definitions to kernel module

Reported-by: kernel test robot <[email protected]>

Daniel Kestrel (3):
dt-bindings: vendor-prefixes: Add AVM
dt-bindings: remoteproc: Add AVM WASP
remoteproc: Add AVM WASP driver

.../bindings/remoteproc/avm,wasp-rproc.yaml | 61 +
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
drivers/remoteproc/Kconfig | 10 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/avm_wasp.c | 1051 +++++++++++++++++
5 files changed, 1125 insertions(+)
create mode 100644 Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml
create mode 100644 drivers/remoteproc/avm_wasp.c

--
2.17.1



2022-08-04 21:21:59

by Daniel Kestrel

[permalink] [raw]
Subject: [PATCH v5 1/3] dt-bindings: vendor-prefixes: Add AVM

Add vendor prefix for AVM Computersysteme Vertriebs GmbH (http://www.avm.de/en)

Signed-off-by: Daniel Kestrel <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 294093d45a23..0be52bb27f2b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -153,6 +153,8 @@ patternProperties:
description: avia semiconductor
"^avic,.*":
description: Shanghai AVIC Optoelectronics Co., Ltd.
+ "^avm,.*":
+ description: AVM Computersysteme Vertriebs GmbH
"^avnet,.*":
description: Avnet, Inc.
"^awinic,.*":
--
2.17.1


2022-08-04 21:23:31

by Daniel Kestrel

[permalink] [raw]
Subject: [PATCH v5 2/3] dt-bindings: remoteproc: Add AVM WASP

AVM Fritzbox router boards may contain an additional ATH79
based SoC that has the wifi cards connected.
This patch adds bindings for this remote processor.

Signed-off-by: Daniel Kestrel <[email protected]>
---
.../bindings/remoteproc/avm,wasp-rproc.yaml | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml

diff --git a/Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml b/Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml
new file mode 100644
index 000000000000..2fd4ffb53945
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/remoteproc/avm,wasp-rproc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AVM WASP processor controller bindings
+
+maintainers:
+ - Daniel Kestrel <[email protected]>
+
+description: |
+ This document defines the bindings for the remoteproc component that loads and
+ boots firmwares on the AVM Wireless Assistant Support Processor (WASP) SoC
+ that is attached to some AVM Fritzbox devices (3390, 3490, 5490, 5491, 7490).
+
+properties:
+ compatible:
+ enum:
+ - avm,fritzbox3390-wasp
+ - avm,fritzbox3490-wasp
+ - avm,fritzbox5490-wasp
+ - avm,fritzbox5491-wasp
+ - avm,fritzbox7490-wasp
+
+ mdio-device:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: Lantiq GSWIP switch mdio.
+
+ link-interface:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: Network interface, where the WASP SoC is connected to.
+
+ reset-gpios:
+ description: Gpio to reset the WASP SoC to initial state.
+ maxItems: 1
+
+ power-gpios:
+ description: Gpio to power the WASP SoC on and off.
+ maxItems: 1
+
+required:
+ - compatible
+ - mdio-device
+ - link-interface
+ - reset-gpios
+ - power-gpios
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ remoteproc {
+ compatible = "avm,fritzbox7490-wasp";
+ mdio-device = <&gswip_mdio>;
+ link-interface = <&port5>;
+ reset-gpios = <&gpio 34 GPIO_ACTIVE_HIGH>;
+ power-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+ };
--
2.17.1


2022-08-09 19:38:42

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v5 2/3] dt-bindings: remoteproc: Add AVM WASP

On Thu, 04 Aug 2022 23:08:05 +0200, Daniel Kestrel wrote:
> AVM Fritzbox router boards may contain an additional ATH79
> based SoC that has the wifi cards connected.
> This patch adds bindings for this remote processor.
>
> Signed-off-by: Daniel Kestrel <[email protected]>
> ---
> .../bindings/remoteproc/avm,wasp-rproc.yaml | 61 +++++++++++++++++++
> 1 file changed, 61 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml
>

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

2022-10-24 18:59:06

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH v5 0/3] Add support for WASP SoC on AVM router boards

Hi Daniel,

I have started to review this patchset. I expect the process to take several
days and will clearly let you know when I am done.

Thanks,
Mathieu

On Thu, Aug 04, 2022 at 11:08:03PM +0200, Daniel Kestrel wrote:
> There is a popular set of Lantiq xrx200 router boards by AVM in
> Germany (AVM Fritzbox 3390, 3490, 5490, 5491 and 7490) which
> have the strange implementation of having the wifi cards
> connected to a separate memory only ATH79 based SoC. It has no
> persistent storage and no access to any resource on the Lantiq
> host, but is connect to the Lantiq GSWIP switch on an additional
> fixed internal network port.
> This kernel module is to support booting the secondary SoC called
> Wireless Assistant Support Processor (WASP).
> After turning it on, a small network boot firmware is sent to
> the SoC by using mdio and when it is started, an initramfs
> linux image is sent to the SoC using raw ethernet frames.
>
> The whole procedure takes about 6 seconds, if there is no error.
> So far tested on 3490, 5490 and 7490 devices based on OpenWrt, 3390
> takes about 20 seconds.
>
> Patch 1/3 adds the vendor name
> Patch 2/3 adds the dt-bindings
> Patch 3/3 adds the remoteproc driver
>
> To build and run, there is OpenWrt PR 5075.
>
> Please review.
>
> Changes in v5:
> - Replace names for properties and descriptions as requested in the
> device tree documentation and change the driver to accept them
> - Change example in the device tree documentation
> - Restructure constants and defines in the beginning of the driver
> source for better readability
> - Combine m_start_addr and m_exec_addr into a single constant and
> change avm_wasp_netboot_write_header to use only this one constant
> - Change variable startup_gpio to power_gpio in driver
>
> Changes in v4:
> - Fix compiler warnings with W=2 option
>
> Changes in v3:
> - Replace generic avm,fritzboxx490-wasp with actual device names for
> device tree documentation and change the driver to accept them
> - Add maxItems to device tree documentation
> - Change example in the device tree documentation
> - Fix wait time to make the Wasp upload work for 3390 more reliable
> - Enable the SOC on driver load, use reset instead of disable/enable
> while driver is loaded and disable on unloading the driver
> - Change some messages printed to adhere to standards (e.g. remove !)
>
> Changes in v2:
> - Remove firmware names from dt-binding and add as kmod parameters
> - Rename other bindings with vender prefix and fix gpios suffix
> - Change descriptions in dt-binding
> - Replace/Remove asynch load of firmware with request_firmware_direct
> - Fix comments to use the errno define instead of the number
> - Implement wait loops with read_poll_timeout() macro
> - Wrap read_poll_timeout() macro in function saving 6k module size
> - Return -ETIMEDOUT for all errors returned by read_poll_timeout
> - Replace mdio writes/reads with mdiobus_write and mdiobus_read and add
> return codes and their handling
> - Remove mutex for mdiobus_lock and add return code checking for mdio ops
> - Replaced the mdio register array with directly specifying registers
> - As a result of the previous 3 changes remove the functions for mdio
> - Consolidate error messages for mdio writes into a single one saved 1k
> for module size
> - Replaced mdelay with usleep_range saved 0,7k module size
> - Remove unneeded include <linux/interrupt.h> and <linux/error.h>
> - Wrap all blocks with {} and fix some indentation errors
> - Change const len in to size_t in avm_wasp_netboot_write_chunk
> - Make all methods static to fix kernel bot warning
> - Change read variable name in avm_wasp_load_initramfs_image
> - Change ssize_t variables to size_t in avm_wasp_load_initramfs_image
> - avm_wasp_netboot_write_chunk change for loop for 2 byte divisibility
> - Change uint32_t to u32
> - Change int count = -1 to u32 with U32_MAX initialisation
> - Add check for firmware len divisable by 4
> - Replace big endian bit shift operations with be32_to_cpu
> - Change loop to write 14 byte firmware chuncks like suggested
> - Change WASP_CHUNK_SIZE to ARRAY_SIZE(mac_data) for readability
> - Change int done to boolean
> - Change unsigned ints to u32
> - Change int to size_t for send_len
> - Use int for numbytes because kernel_recvmsg returns error or number
> - Two sockets are not needed, so reduce to one socket usage
> - Remove struct timeval definition, replace with __kernel_old_timeval
> - __kernel_old_timeval is depracated, but arch mips is 32bit platform
> - Replace &avmwasp->pdev->dev with local dev
> - Check if wasp network interface is up and fail if not in start method
> - Remove setsockopt for SO_REUSEADDR and SO_BINDTODEVICE
> - Remove packet_counter
> - Move firmware and firmware_end out of RESP_DISCOVER to make sure that
> they are initialized if RESP_DISCOVER is not happening first
> - indend break;
> - Move second half of the send/receive paket while loop to RESP_OK and
> let RESP_DISCOVER fall through
> - Remove bringing up the wasp network interface
> - Check if wasp network interface is up in probe and defer if not
> - Remove the check for the root device and replace it with match data
> for WASP device identification
> - Move of_read and find of mdio bus to rproc_start but delete reference
> after using it in the rproc_start method
> - Replace dev_set_drvdata with platform_set_drvdata
> - Remove avm_wasp_rproc_boot_addr because its not needed and move
> setting the fw struct pointer to avm_wasp_rproc_load
> - Move avm_wasp.h definitions to kernel module
>
> Reported-by: kernel test robot <[email protected]>
>
> Daniel Kestrel (3):
> dt-bindings: vendor-prefixes: Add AVM
> dt-bindings: remoteproc: Add AVM WASP
> remoteproc: Add AVM WASP driver
>
> .../bindings/remoteproc/avm,wasp-rproc.yaml | 61 +
> .../devicetree/bindings/vendor-prefixes.yaml | 2 +
> drivers/remoteproc/Kconfig | 10 +
> drivers/remoteproc/Makefile | 1 +
> drivers/remoteproc/avm_wasp.c | 1051 +++++++++++++++++
> 5 files changed, 1125 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/remoteproc/avm,wasp-rproc.yaml
> create mode 100644 drivers/remoteproc/avm_wasp.c
>
> --
> 2.17.1
>