From patchwork Sun Aug 6 20:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1817562 X-Patchwork-Delegate: linus.walleij@linaro.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0THXPL+Y; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MaBhodrh; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RJrrJ07dBz1yXs for ; Mon, 7 Aug 2023 06:38:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=COaL7z6GxAaCk0cuiARmGYRWcTLR9U4y94dxpMyGmO0=; b=0THXPL+YICwtL0 DliGOydjaJxLfKX6cgRdfluSYqpGCY9UCzNxPUG92MO+U0u93vnCR0oM67+GxzKSMBdSOL1eFKCX3 MyjeNfIQ6Lz4SF97iHCrMwTF0jocdL/ubOLbsPT+juQpM8VUBBYe8Tbj2//vkd2xP0HU7q2gZrg9O ZNBNH2JYbg6j6jjeHX6dsog1bzrwi+hqZ74o+AaElIoOQhpRPASBH8dx7NI3lJHfRzvJPPZNNGyLG Esk8I8G/XT6ZcpZmgdn5OnFheZIBlAx/hvC8wDhL24EDkg9jDjEUC9L7vwABN9tnoxjIZmAMKIVyN J3bjYquQc/PhlOHsJGgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qSkUH-00FlqK-2A; Sun, 06 Aug 2023 20:36:29 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qSkUC-00FloZ-2J for openwrt-devel@lists.openwrt.org; Sun, 06 Aug 2023 20:36:26 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b9c0391749so62378051fa.0 for ; Sun, 06 Aug 2023 13:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691354181; x=1691958981; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=76OGL3l0KEKULxEfy5NLDu7oc/kvm3/12o8v8cwwFJs=; b=MaBhodrh/nxdWXbQ/ti3br4MSBcA6g7CX10E8JW4DzyB2LROu1RUCKVDisdpvwi6Ew TZcIhEgiyhveuKhEjgfQE6HEsFguGHwj4ebLZXGCzCA8cH0f4hOoOgw4C/Pmi0JUEUuO XaOqMaW7wrDd2T+P8DXugrNmizCNFW+PM8o7XK8baOXzlMzqhAGcJyJhFko+oKj4DBfz j8Tuc4OjIbW9NIE/sZWEC13CWpRmQpBN4G87bEHb4nYkuU1QhmemOi/VKt9N+m5qUdv5 t/tkd+2u0qcNTzvFH9KiRqvUxRhhK8wuG4WwVoZE+bO9wZXQn3WlXmCnD7zCGev1RqJA 1Hgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691354181; x=1691958981; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=76OGL3l0KEKULxEfy5NLDu7oc/kvm3/12o8v8cwwFJs=; b=R9HPe8hXjb5ynZBzA6nQenpyWV8KqET1leCGVng+J64aNS/pliMxVt3yTFScqwZn+y w3oSXFnWHv0p04KCR/LrCdUwyHwfcrBnZSMHK+fkQlLQmw9lxgFJ3wrClI+AHg8DJtSY olaozQC9q4Gnseupc0v8xQpS9J1oFMIYDBMII9GNCxqfQdbsUIM+yeEkKLPj0oE+OpkZ 5RG9qHc7MKHWRXq288XErfCfhb1n3FQORMGCX/cfnD24QXUQ4aeamLW7MeFEuxnzsfVK 4b25qO7HeFwhCsIYCebg1K09O6R9+1NPkMziSdj7Cl2/80TdKmyDP5/BWdEeL91jnk+s dK+w== X-Gm-Message-State: AOJu0Ywf0SEV5yd5RmYJVQJ6aKljuGtskHZGUx+1YLikdxQU5G1cJwuq tc+m5rg5kpn2AnM0J6Tz4Qya+FwTZKiomZRygLo= X-Google-Smtp-Source: AGHT+IHXhEBM9Vzlq/uRJvIBk+Pv3akJsc3Cc6XpgZ1l7mQFqsnZn+gce72vIKj8KnH4NgtHSrAbug== X-Received: by 2002:a05:6512:3b8f:b0:4f9:56a9:b98e with SMTP id g15-20020a0565123b8f00b004f956a9b98emr6091955lfv.58.1691354181423; Sun, 06 Aug 2023 13:36:21 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id i26-20020ac2523a000000b004fe36b790a1sm1236259lfl.128.2023.08.06.13.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 13:36:21 -0700 (PDT) From: Linus Walleij Date: Sun, 06 Aug 2023 22:36:12 +0200 Subject: [PATCH 2/2] bmips: Add Inteno XG6846 target MIME-Version: 1.0 Message-Id: <20230806-xg6846-v1-2-e6340de2df72@linaro.org> References: <20230806-xg6846-v1-0-e6340de2df72@linaro.org> In-Reply-To: <20230806-xg6846-v1-0-e6340de2df72@linaro.org> To: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , =?utf-8?q?Daniel_Gonz=C3=A1lez_Cabanelas?= , Sieng Piaw Liew Cc: openwrt-devel@lists.openwrt.org, Linus Walleij X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230806_133624_756668_5890787F X-CRM114-Status: GOOD ( 26.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This add a device tree and build options for the XG6846 switch/router to the BMIPS target. Hardware: - SoC: Broadcom BCM6328 - CPU: BMIPS4350 V7.5 - RAM: 64 MB DDR - NOR Flash: 16 MB parallel (CFE and OS) - Ethernet LAN: 4x 1Gbit - Ethernet WAN: 2x 1Gbit, fiber and TP - Buttons: reset - LED [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This add a device tree and build options for the XG6846 switch/router to the BMIPS target. Hardware: - SoC: Broadcom BCM6328 - CPU: BMIPS4350 V7.5 - RAM: 64 MB DDR - NOR Flash: 16 MB parallel (CFE and OS) - Ethernet LAN: 4x 1Gbit - Ethernet WAN: 2x 1Gbit, fiber and TP - Buttons: reset - LEDs: 7 or 8, power and USB LEDs are GPIO-based, the LAN LEDs are controlled by the Marvell DSA Switch. - USB: on some versions - UART: yes It is possible to boot the initramfs version openwrt-bmips-bcm6328-inteno_xg6846-initramfs.elf from CFE by breaking the boot on the UART console and download it from a TFTP server such as: CFE> r 192.168.1.2:openwrt-bmips-bcm6328-inteno_xg6846-initramfs.elf Installation to target flash is not yet possible because the firmware format deviates from the Broadcom standard: it is based on the standard format generated by the "imagetag" tool, but some stuff is off and images don't flash or boot so this needs further work. The Broadcom image creation tool bcmImageBuilder has been patched to take a new command line option such as this: --image-version 4125XG6846_ITT12023725 then this ends up as a string at offset 142-191 in the BCM tag normally used for "rsa-signature" and "information1". There may be other differences as well. We will need to work on this. This device is called a "managed ethernet switch" by the vendor and "media converter" or "fiber modem" by some of the ISPs using it: the main purpose is to convert fiber connections to ethernet, most devices just act as switches bridging the fiber SFP to ethernet TP. The device has a Marvell MV88E6352 DSA switch managed by a BCM6328 BMIPS SoC. This port makes it possible to use the XG6846 to grab an IP number from the fiber connection and use all four LAN connections out, turning it into a proper router. This support is based mostly on the observations by the people on the forum thread "Help with Inteno XG6846" where users NPeca75, mrhaav, systemcrash and csom helped out to reverse engineer the device. Then I made it work on the BMIPS target, figured out the two-level switch hierarchy and settings. Link: https://forum.openwrt.org/t/help-with-inteno-xg6846/68276/14 Signed-off-by: Linus Walleij --- .../bcm6328/base-files/etc/board.d/02_network | 3 + target/linux/bmips/dts/bcm6328-inteno-xg6846.dts | 307 +++++++++++++++++++++ target/linux/bmips/image/bcm6328.mk | 13 + 3 files changed, 323 insertions(+) diff --git a/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network b/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network index 391e38c4dcb9..5b908cd9677e 100644 --- a/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network +++ b/target/linux/bmips/bcm6328/base-files/etc/board.d/02_network @@ -9,6 +9,9 @@ arcadyan,ar7516) ucidef_set_bridge_device switch ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; +inteno,xg6846) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan ext1" + ;; comtrend,ar-5381u |\ comtrend,ar-5387un |\ nucom,r5010unv2) diff --git a/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts b/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts new file mode 100644 index 000000000000..cf1a4eecd4eb --- /dev/null +++ b/target/linux/bmips/dts/bcm6328-inteno-xg6846.dts @@ -0,0 +1,307 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +/* + * Devicetree for the Inteno XG6846 router, mostly used as a + * media converter from fiber to twisted pair ethernet + * "fiber modem" in many households in Sweden. The Marvell + * switch has one of its ports connected to an SFP (Small Form + * Factor pluggable) optical fiber receiver, which is bridged + * to the twisted pair connector LAN1. + * + * This device tree is inspired by research from the OpenWrt + * and Sweclockers forums, including contributions from + * NPeca75, mrhaav and csom. + * + * Some devices have a USB type A host receptacle mounted, + * some do not. + */ +#include "bcm6328.dtsi" +#include +#include + +/ { + model = "Inteno XG6846"; + compatible = "inteno,xg6846", "brcm,bcm6328"; + + /* OpenWrt-specific aliases */ + aliases { + led-boot = &led_pwr_red; + led-failsafe = &led_pwr_red; + led-running = &led_pwr_green; + led-upgrade = &led_pwr_red; + }; + + chosen { + bootargs = "rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200"; + stdout-path = "serial0:115200n8"; + }; + + /* + * This I2C port is connected to the SFP and reflects the EEPROM etc + * inside the SFP module. If the module is not plugged in, consequently + * nothing will be found on the bus. + */ + i2c0: i2c-sfp { + compatible = "i2c-gpio"; + sda-gpios = <&gpio 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio 19 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + #address-cells = <1>; + #size-cells = <0>; + }; + + /* This I2C bus is used for the external CATV connector (usually unused) */ + i2c1: i2c-catv { + compatible = "i2c-gpio"; + sda-gpios = <&gpio 23 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + scl-gpios = <&gpio 7 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; + #address-cells = <1>; + #size-cells = <0>; + }; + + sfp0: sfp0 { + compatible = "sff,sfp"; + i2c-bus = <&i2c0>; + los-gpios = <&gpio 29 GPIO_ACTIVE_HIGH>; + }; + + keys { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <20>; + + reset { + label = "reset"; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; +}; + +&hsspi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + /* + * HW 1.0-1.1: Spansion S25FL128S1 + * HW 1.3: Winbond W25Q128 + * + * Fast Read Data max speed is 50MHz, see the Winbond W25Q128 + * datasheet table 9.5 "AC Electrical Characteristics", we can + * use this speed because the chip supports fast reads. Older + * HW has different NOR chips, I assume they can all do fast + * reads. + */ + spi-max-frequency = <104000000>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; + m25p,fast-read; + reg = <0>; + + #address-cells = <1>; + #size-cells = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cfe: partition@0 { + label = "cfe"; + reg = <0x0000000 0x0010000>; + read-only; + }; + + partition@10000 { + compatible = "brcm,bcm963xx-imagetag"; + reg = <0x010000 0xfe0000>; + label = "firmware"; + }; + + partition@ff0000 { + reg = <0xff0000 0x010000>; + label = "nvram"; + }; + }; + }; +}; + +&cfe { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_cfe_6a0: macaddr@6a0 { + reg = <0x6a0 0x6>; + }; +}; + +ðernet { + status = "okay"; + + nvmem-cells = <&macaddr_cfe_6a0>; + nvmem-cell-names = "mac-address"; +}; + +&switch0 { + dsa,member = <0 0>; + + ports { + switch0port4: port@4 { + reg = <4>; + label = "extsw"; + + phy-mode = "rgmii"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; +}; + +&mdio_ext { + switch1: switch@0 { + /* The switch is not using any external IRQ, sadly */ + compatible = "marvell,mv88e6085"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + interrupt-controller; + #interrupt-cells = <2>; + dsa,member = <1 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + phy-handle = <&lan1phy>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-handle = <&lan2phy>; + }; + + port@2 { + reg = <2>; + label = "lan3"; + phy-handle = <&lan3phy>; + }; + + port@3 { + reg = <3>; + label = "lan4"; + phy-handle = <&lan4phy>; + }; + + port@4 { + reg = <4>; + label = "ext1"; + phy-handle = <&ext1phy>; + }; + + port@5 { + reg = <5>; + phy-mode = "rgmii-id"; + label = "wan"; + sfp = <&sfp0>; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + port@6 { + reg = <6>; + phy-mode = "rgmii-id"; + label = "cpu"; + ethernet = <&switch0port4>; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + lan1phy: ethernet-phy@0 { + reg = <0>; + interrupt-parent = <&switch1>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + lan2phy: ethernet-phy@1 { + reg = <1>; + interrupt-parent = <&switch1>; + interrupts = <1 IRQ_TYPE_LEVEL_HIGH>; + }; + lan3phy: ethernet-phy@2 { + reg = <2>; + interrupt-parent = <&switch1>; + interrupts = <2 IRQ_TYPE_LEVEL_HIGH>; + }; + lan4phy: ethernet-phy@3 { + reg = <3>; + interrupt-parent = <&switch1>; + interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; + }; + ext1phy: ethernet-phy@4 { + reg = <4>; + interrupt-parent = <&switch1>; + interrupts = <4 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&leds { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pcie_clkreq>, /* GPIO16 LED USB */ + <&pinctrl_ephy1_spd_led>, /* GPIO18 LED PWR red */ + <&pinctrl_ephy3_spd_led>; /* GPIO20 LED PWR green */ + + /* On board variants without USB this LED is not mounted */ + led_usb_green: led@16 { + reg = <16>; + active-low; + label = "green:usb"; + default-state = "off"; + }; + + /* + * LED 18 and 20 drive the same physical LED, the PWR + * LED that can be both red and green. + */ + led_pwr_red: led@18 { + reg = <18>; + active-low; + label = "red:pwr"; + default-state = "off"; + }; + + led_pwr_green: led@20 { + reg = <20>; + active-low; + label = "green:pwr"; + default-state = "off"; + }; + +}; + +&pinctrl { +}; diff --git a/target/linux/bmips/image/bcm6328.mk b/target/linux/bmips/image/bcm6328.mk index fd0cf16dbb00..dc60b5d0cbd4 100644 --- a/target/linux/bmips/image/bcm6328.mk +++ b/target/linux/bmips/image/bcm6328.mk @@ -39,6 +39,19 @@ define Device/comtrend_ar-5387un endef TARGET_DEVICES += comtrend_ar-5387un +define Device/inteno_xg6846 + $(Device/bcm63xx-cfe-legacy) + DEVICE_VENDOR := Inteno + DEVICE_MODEL := XG6846 + CHIP_ID := 6328 + CFE_BOARD_ID := 96328avng + FLASH_MB := 16 + DEVICE_PACKAGES := $(USB2_PACKAGES) \ + kmod-i2c-core kmod-i2c-gpio \ + kmod-leds-bcm6328 kmod-sfp +endef +TARGET_DEVICES += inteno_xg6846 + define Device/nucom_r5010unv2 $(Device/bcm63xx-cfe) DEVICE_VENDOR := NuCom