From patchwork Sat Apr 9 03:00:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1615111 X-Patchwork-Delegate: yszhou4tech@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=jsDQsfP5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=XN7lyik0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kb0LZ3CCyz9sDX for ; Sat, 9 Apr 2022 13:03:34 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OBganVOAT5EO0zr3PK05nqVW2mvwEPC0u6mjI30PNIk=; b=jsDQsfP5TCrBIg hrjSGybmUm7xTd3YTnRfJhOeFnZsky2pUx/ZF0dFNfsWdKqW6gVDGtIzGxOeRFQW/a+CURFNcMNVb aqwzXsIdCVcrD6E1UUPaxf+HR8nBXjSEXa2/QKjW/VTTJsWK+fzx83gQBeVcFQo+Bi1V/8Mm7Nqrs yHXjImnzpioujaQzmLMwfTfZyUEGc6QDGL/4FTYVCXOQlSdwq8WahYJifIHonjh2wB0W2kp2jVXbI mienbaCQVHo2fHnPSr5i935YMUS33wqNh1qqR+/d2KZFFXohcKj66qab8rgvpz6sGl++pzD80sDKz +/rt5OI2t+2elc5Hn04Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd1L6-001m8A-Pn; Sat, 09 Apr 2022 03:00:40 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd1Ky-001m65-1p for openwrt-devel@lists.openwrt.org; Sat, 09 Apr 2022 03:00:34 +0000 Received: by mail-pj1-x102e.google.com with SMTP id nt14-20020a17090b248e00b001ca601046a4so13545845pjb.0 for ; Fri, 08 Apr 2022 20:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=17d8eMYjtjQ5vU0MkzUNUG4lZ6jisrqb6pgCVue9SL8=; b=XN7lyik0sal6aXns2cv1wgElE21wLVCMqm03BSfccpMsrdYna5wx6babtcvq8HnMb9 IThRn+lW5jnZMVIu40pY8RiF2Un0pNokJOF3L72+yk6q4KANdeRbfPs9FWBbQ0r+5qer DZLvyVkTFjJT9FVGKe7IF1FH6zQ5XOjG1GCxYTt6KO5xLZ/j3FcAYXyKP5jt3JjTqivA 6a0CBinnyOTEPiyPcz6Z/I4hW+DEqwu7s/sBdrOq4WqfS/clfYunH94ffanhOakAQ5WJ S9duwD73oKuFYBOxCsOnbPAhuXh6xZuhM5sGKwlD2X956LNvKYWKLN9b/jhVe/7hXEQd MZSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=17d8eMYjtjQ5vU0MkzUNUG4lZ6jisrqb6pgCVue9SL8=; b=13pNJL8sNEIK2TNE8S4s/a84nRPg76x8Uf4kvfup0TgtASomAE3z5wpfjzC8sUhXwD bt0E4rXhBNLp5sE3PPe37neZ7F92xhbVjIKBlnkU7bsgxK0w7LmBWVH6vmRrAT/G3t5L 9XJ31F1jhOpHPlxg+41tcXpHGDU++gN6uEhUmKkK8VD9lnORsPCKVGqf8d3KUhEW+Okl hOo1iw1XTLRStFPLYI2ZnYBLScrcUPxDJOaj97kbqEqG2gDuB5j077OpEtEBtP8ypiv/ z9QbHCEgkwejWd0LsQI+FYqpzYl87IfigjAFYzzjuZiqF7HZwJn2xpDscrrMv4YColLU 3p2w== X-Gm-Message-State: AOAM532OP+TxpooVq5T3Z3d7QdjkMdoFR5xW3sZl/Yj1Hdgqk7YRBSGt otpMX5EbNgf6julpN+L1dspmMFUrGOVabg== X-Google-Smtp-Source: ABdhPJxocKN6kKH0Cc7JvvkfRtKq0PwJM6bQVhXWWvZYo8yXb3N2LJvd+bbK0nQyiv7BO/g1njAoAQ== X-Received: by 2002:a17:902:f349:b0:156:a80b:a53f with SMTP id q9-20020a170902f34900b00156a80ba53fmr22324737ple.7.1649473230141; Fri, 08 Apr 2022 20:00:30 -0700 (PDT) Received: from localhost.localdomain ([45.77.200.130]) by smtp.gmail.com with ESMTPSA id k187-20020a636fc4000000b003983a01b896sm22733472pgc.90.2022.04.08.20.00.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2022 20:00:29 -0700 (PDT) From: Yousong Zhou To: ynezz@true.cz Cc: openwrt-devel@lists.openwrt.org, Yousong Zhou Subject: [RFC 1/2] ath79: add nvmem cell mac-address-ascii support Date: Sat, 9 Apr 2022 11:00:04 +0800 Message-Id: <20220409030005.30505-2-yszhou4tech@gmail.com> In-Reply-To: <20220409030005.30505-1-yszhou4tech@gmail.com> References: <20220409030005.30505-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220408_200032_246386_708AF0CB X-CRM114-Status: GOOD ( 19.19 ) 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 is needed for devices with mac address stored in ascii format, e.g. HiWiFi HC6361 to be ported in the following patch. Signed-off-by: Yousong Zhou --- ...of_net-add-mac-address-ascii-support.patch | 103 ++++++++++++++++++ .../408-mtd-redboot_partition_scan.patch | 4 +- ...of_net-add-mac-address-ascii-support.patch | [...] 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 [2607:f8b0:4864:20:0:0:0:102e 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [yszhou4tech[at]gmail.com] -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 is needed for devices with mac address stored in ascii format, e.g. HiWiFi HC6361 to be ported in the following patch. Signed-off-by: Yousong Zhou --- ...of_net-add-mac-address-ascii-support.patch | 103 ++++++++++++++++++ .../408-mtd-redboot_partition_scan.patch | 4 +- ...of_net-add-mac-address-ascii-support.patch | 103 ++++++++++++++++++ ...et-dsa-mt7530-support-MDB-operations.patch | 8 +- ...net-dsa-mt7530-add-interrupt-support.patch | 26 ++--- 5 files changed, 225 insertions(+), 19 deletions(-) create mode 100644 target/linux/ath79/patches-5.10/600-of_net-add-mac-address-ascii-support.patch create mode 100644 target/linux/ath79/patches-5.15/600-of_net-add-mac-address-ascii-support.patch diff --git a/target/linux/ath79/patches-5.10/600-of_net-add-mac-address-ascii-support.patch b/target/linux/ath79/patches-5.10/600-of_net-add-mac-address-ascii-support.patch new file mode 100644 index 0000000000..8849afb4d6 --- /dev/null +++ b/target/linux/ath79/patches-5.10/600-of_net-add-mac-address-ascii-support.patch @@ -0,0 +1,103 @@ +Index: linux-5.15.31/net/ethernet/eth.c +=================================================================== +--- linux-5.15.31.orig/net/ethernet/eth.c ++++ linux-5.15.31/net/ethernet/eth.c +@@ -544,6 +544,63 @@ int eth_platform_get_mac_address(struct + } + EXPORT_SYMBOL(eth_platform_get_mac_address); + ++static void *nvmem_cell_get_mac_address(struct nvmem_cell *cell) ++{ ++ size_t len; ++ void *mac; ++ ++ mac = nvmem_cell_read(cell, &len); ++ if (IS_ERR(mac)) ++ return PTR_ERR(mac); ++ if (len != ETH_ALEN) { ++ kfree(mac); ++ return ERR_PTR(-EINVAL); ++ } ++ return mac; ++} ++ ++static void *nvmem_cell_get_mac_address_ascii(struct nvmem_cell *cell) ++{ ++ size_t len; ++ int ret; ++ void *mac_ascii; ++ u8 *mac; ++ ++ mac_ascii = nvmem_cell_read(cell, &len); ++ if (IS_ERR(mac_ascii)) ++ return PTR_ERR(mac_ascii); ++ if (len != ETH_ALEN*2+5) { ++ kfree(mac_ascii); ++ return ERR_PTR(-EINVAL); ++ } ++ mac = kmalloc(ETH_ALEN, GFP_KERNEL); ++ if (!mac) { ++ kfree(mac_ascii); ++ return ERR_PTR(-ENOMEM); ++ } ++ ret = sscanf(mac_ascii, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", ++ &mac[0], &mac[1], &mac[2], ++ &mac[3], &mac[4], &mac[5]); ++ kfree(mac_ascii); ++ if (ret == ETH_ALEN) ++ return mac; ++ kfree(mac); ++ return ERR_PTR(-EINVAL); ++} ++ ++static struct nvmem_cell_mac_address_property { ++ char *name; ++ void *(*read)(struct nvmem_cell *); ++} nvmem_cell_mac_address_properties[] = { ++ { ++ .name = "mac-address", ++ .read = nvmem_cell_get_mac_address, ++ }, { ++ .name = "mac-address-ascii", ++ .read = nvmem_cell_get_mac_address_ascii, ++ }, ++}; ++ + /** + * nvmem_get_mac_address - Obtain the MAC address from an nvmem cell named + * 'mac-address' associated with given device. +@@ -557,19 +614,23 @@ int nvmem_get_mac_address(struct device + { + struct nvmem_cell *cell; + const void *mac; +- size_t len; ++ struct nvmem_cell_mac_address_property *property; ++ int i; + +- cell = nvmem_cell_get(dev, "mac-address"); +- if (IS_ERR(cell)) +- return PTR_ERR(cell); +- +- mac = nvmem_cell_read(cell, &len); +- nvmem_cell_put(cell); +- +- if (IS_ERR(mac)) +- return PTR_ERR(mac); ++ for (i = 0; i < ARRAY_SIZE(nvmem_cell_mac_address_properties); i++) { ++ property = &nvmem_cell_mac_address_properties[i]; ++ cell = nvmem_cell_get(dev, property->name); ++ if (IS_ERR(cell)) { ++ if (i == ARRAY_SIZE(nvmem_cell_mac_address_properties) - 1) ++ return PTR_ERR(cell); ++ continue; ++ } ++ mac = property->read(cell); ++ nvmem_cell_put(cell); ++ break; ++ } + +- if (len != ETH_ALEN || !is_valid_ether_addr(mac)) { ++ if (!is_valid_ether_addr(mac)) { + kfree(mac); + return -EINVAL; + } diff --git a/target/linux/ath79/patches-5.15/408-mtd-redboot_partition_scan.patch b/target/linux/ath79/patches-5.15/408-mtd-redboot_partition_scan.patch index 905c1319db..07c0a258ae 100644 --- a/target/linux/ath79/patches-5.15/408-mtd-redboot_partition_scan.patch +++ b/target/linux/ath79/patches-5.15/408-mtd-redboot_partition_scan.patch @@ -19,7 +19,7 @@ return -EIO; } offset -= master->erasesize; -@@ -108,10 +113,6 @@ nogood: +@@ -108,10 +114,6 @@ nogood: goto nogood; } } @@ -30,7 +30,7 @@ pr_notice("Searching for RedBoot partition table in %s at offset 0x%lx\n", master->name, offset); -@@ -183,6 +184,12 @@ nogood: +@@ -183,6 +185,12 @@ nogood: } if (i == numslots) { /* Didn't find it */ diff --git a/target/linux/ath79/patches-5.15/600-of_net-add-mac-address-ascii-support.patch b/target/linux/ath79/patches-5.15/600-of_net-add-mac-address-ascii-support.patch new file mode 100644 index 0000000000..8849afb4d6 --- /dev/null +++ b/target/linux/ath79/patches-5.15/600-of_net-add-mac-address-ascii-support.patch @@ -0,0 +1,103 @@ +Index: linux-5.15.31/net/ethernet/eth.c +=================================================================== +--- linux-5.15.31.orig/net/ethernet/eth.c ++++ linux-5.15.31/net/ethernet/eth.c +@@ -544,6 +544,63 @@ int eth_platform_get_mac_address(struct + } + EXPORT_SYMBOL(eth_platform_get_mac_address); + ++static void *nvmem_cell_get_mac_address(struct nvmem_cell *cell) ++{ ++ size_t len; ++ void *mac; ++ ++ mac = nvmem_cell_read(cell, &len); ++ if (IS_ERR(mac)) ++ return PTR_ERR(mac); ++ if (len != ETH_ALEN) { ++ kfree(mac); ++ return ERR_PTR(-EINVAL); ++ } ++ return mac; ++} ++ ++static void *nvmem_cell_get_mac_address_ascii(struct nvmem_cell *cell) ++{ ++ size_t len; ++ int ret; ++ void *mac_ascii; ++ u8 *mac; ++ ++ mac_ascii = nvmem_cell_read(cell, &len); ++ if (IS_ERR(mac_ascii)) ++ return PTR_ERR(mac_ascii); ++ if (len != ETH_ALEN*2+5) { ++ kfree(mac_ascii); ++ return ERR_PTR(-EINVAL); ++ } ++ mac = kmalloc(ETH_ALEN, GFP_KERNEL); ++ if (!mac) { ++ kfree(mac_ascii); ++ return ERR_PTR(-ENOMEM); ++ } ++ ret = sscanf(mac_ascii, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", ++ &mac[0], &mac[1], &mac[2], ++ &mac[3], &mac[4], &mac[5]); ++ kfree(mac_ascii); ++ if (ret == ETH_ALEN) ++ return mac; ++ kfree(mac); ++ return ERR_PTR(-EINVAL); ++} ++ ++static struct nvmem_cell_mac_address_property { ++ char *name; ++ void *(*read)(struct nvmem_cell *); ++} nvmem_cell_mac_address_properties[] = { ++ { ++ .name = "mac-address", ++ .read = nvmem_cell_get_mac_address, ++ }, { ++ .name = "mac-address-ascii", ++ .read = nvmem_cell_get_mac_address_ascii, ++ }, ++}; ++ + /** + * nvmem_get_mac_address - Obtain the MAC address from an nvmem cell named + * 'mac-address' associated with given device. +@@ -557,19 +614,23 @@ int nvmem_get_mac_address(struct device + { + struct nvmem_cell *cell; + const void *mac; +- size_t len; ++ struct nvmem_cell_mac_address_property *property; ++ int i; + +- cell = nvmem_cell_get(dev, "mac-address"); +- if (IS_ERR(cell)) +- return PTR_ERR(cell); +- +- mac = nvmem_cell_read(cell, &len); +- nvmem_cell_put(cell); +- +- if (IS_ERR(mac)) +- return PTR_ERR(mac); ++ for (i = 0; i < ARRAY_SIZE(nvmem_cell_mac_address_properties); i++) { ++ property = &nvmem_cell_mac_address_properties[i]; ++ cell = nvmem_cell_get(dev, property->name); ++ if (IS_ERR(cell)) { ++ if (i == ARRAY_SIZE(nvmem_cell_mac_address_properties) - 1) ++ return PTR_ERR(cell); ++ continue; ++ } ++ mac = property->read(cell); ++ nvmem_cell_put(cell); ++ break; ++ } + +- if (len != ETH_ALEN || !is_valid_ether_addr(mac)) { ++ if (!is_valid_ether_addr(mac)) { + kfree(mac); + return -EINVAL; + } diff --git a/target/linux/generic/backport-5.10/770-v5.15-net-dsa-mt7530-support-MDB-operations.patch b/target/linux/generic/backport-5.10/770-v5.15-net-dsa-mt7530-support-MDB-operations.patch index 5d91d5a657..7143748eee 100644 --- a/target/linux/generic/backport-5.10/770-v5.15-net-dsa-mt7530-support-MDB-operations.patch +++ b/target/linux/generic/backport-5.10/770-v5.15-net-dsa-mt7530-support-MDB-operations.patch @@ -14,7 +14,7 @@ Signed-off-by: DENG Qingfang --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c -@@ -1000,9 +1000,6 @@ mt753x_cpu_port_enable(struct dsa_switch +@@ -998,9 +998,6 @@ mt753x_cpu_port_enable(struct dsa_switch mt7530_write(priv, MT7530_PVC_P(port), PORT_SPEC_TAG); @@ -24,7 +24,7 @@ Signed-off-by: DENG Qingfang /* Set CPU port number */ if (priv->id == ID_MT7621) mt7530_rmw(priv, MT7530_MFC, CPU_MASK, CPU_EN | CPU_PORT(port)); -@@ -1138,6 +1135,20 @@ mt7530_stp_state_set(struct dsa_switch * +@@ -1131,6 +1128,20 @@ mt7530_stp_state_set(struct dsa_switch * } static int @@ -45,7 +45,7 @@ Signed-off-by: DENG Qingfang mt7530_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *bridge) { -@@ -1357,6 +1368,63 @@ err: +@@ -1331,6 +1342,63 @@ err: } static int @@ -109,7 +109,7 @@ Signed-off-by: DENG Qingfang mt7530_vlan_cmd(struct mt7530_priv *priv, enum mt7530_vlan_cmd cmd, u16 vid) { struct mt7530_dummy_poll p; -@@ -2794,11 +2862,15 @@ static const struct dsa_switch_ops mt753 +@@ -2745,11 +2813,15 @@ static const struct dsa_switch_ops mt753 .port_change_mtu = mt7530_port_change_mtu, .port_max_mtu = mt7530_port_max_mtu, .port_stp_state_set = mt7530_stp_state_set, diff --git a/target/linux/generic/backport-5.10/772-v5.14-net-dsa-mt7530-add-interrupt-support.patch b/target/linux/generic/backport-5.10/772-v5.14-net-dsa-mt7530-add-interrupt-support.patch index 9890015301..1ee2e1cac4 100644 --- a/target/linux/generic/backport-5.10/772-v5.14-net-dsa-mt7530-add-interrupt-support.patch +++ b/target/linux/generic/backport-5.10/772-v5.14-net-dsa-mt7530-add-interrupt-support.patch @@ -27,7 +27,7 @@ Signed-off-by: David S. Miller #include #include #include -@@ -602,18 +603,14 @@ mt7530_mib_reset(struct dsa_switch *ds) +@@ -600,18 +601,14 @@ mt7530_mib_reset(struct dsa_switch *ds) mt7530_write(priv, MT7530_MIB_CCR, CCR_MIB_ACTIVATE); } @@ -48,7 +48,7 @@ Signed-off-by: David S. Miller return mdiobus_write_nested(priv->bus, port, regnum, val); } -@@ -791,9 +788,8 @@ out: +@@ -789,9 +786,8 @@ out: } static int @@ -59,7 +59,7 @@ Signed-off-by: David S. Miller int devad; int ret; -@@ -809,10 +805,9 @@ mt7531_ind_phy_read(struct dsa_switch *d +@@ -807,10 +803,9 @@ mt7531_ind_phy_read(struct dsa_switch *d } static int @@ -71,7 +71,7 @@ Signed-off-by: David S. Miller int devad; int ret; -@@ -828,6 +823,22 @@ mt7531_ind_phy_write(struct dsa_switch * +@@ -826,6 +821,22 @@ mt7531_ind_phy_write(struct dsa_switch * return ret; } @@ -94,7 +94,7 @@ Signed-off-by: David S. Miller static void mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) -@@ -1824,6 +1835,210 @@ mt7530_setup_gpio(struct mt7530_priv *pr +@@ -1793,6 +1804,210 @@ mt7530_setup_gpio(struct mt7530_priv *pr return devm_gpiochip_add_data(dev, gc, priv); } @@ -305,7 +305,7 @@ Signed-off-by: David S. Miller static int mt7530_setup(struct dsa_switch *ds) { -@@ -2798,24 +3013,20 @@ static int +@@ -2749,24 +2964,20 @@ static int mt753x_setup(struct dsa_switch *ds) { struct mt7530_priv *priv = ds->priv; @@ -340,7 +340,7 @@ Signed-off-by: David S. Miller } static int mt753x_get_mac_eee(struct dsa_switch *ds, int port, -@@ -2852,8 +3063,6 @@ static const struct dsa_switch_ops mt753 +@@ -2803,8 +3014,6 @@ static const struct dsa_switch_ops mt753 .get_tag_protocol = mtk_get_tag_protocol, .setup = mt753x_setup, .get_strings = mt7530_get_strings, @@ -349,7 +349,7 @@ Signed-off-by: David S. Miller .get_ethtool_stats = mt7530_get_ethtool_stats, .get_sset_count = mt7530_get_sset_count, .set_ageing_time = mt7530_set_ageing_time, -@@ -3036,6 +3245,9 @@ mt7530_remove(struct mdio_device *mdiode +@@ -2987,6 +3196,9 @@ mt7530_remove(struct mdio_device *mdiode dev_err(priv->dev, "Failed to disable io pwr: %d\n", ret); @@ -369,7 +369,7 @@ Signed-off-by: David S. Miller #define MT7530_CPU_PORT 6 #define MT7530_NUM_FDB_RECORDS 2048 #define MT7530_ALL_MEMBERS 0xff -@@ -401,6 +402,12 @@ enum mt7531_sgmii_force_duplex { +@@ -392,6 +393,12 @@ enum mt7531_sgmii_force_duplex { #define SYS_CTRL_SW_RST BIT(1) #define SYS_CTRL_REG_RST BIT(0) @@ -382,7 +382,7 @@ Signed-off-by: David S. Miller /* Register for PHY Indirect Access Control */ #define MT7531_PHY_IAC 0x701C #define MT7531_PHY_ACS_ST BIT(31) -@@ -722,6 +729,8 @@ static const char *p5_intf_modes(unsigne +@@ -713,6 +720,8 @@ static const char *p5_intf_modes(unsigne } } @@ -391,7 +391,7 @@ Signed-off-by: David S. Miller /* struct mt753x_info - This is the main data structure for holding the specific * part for each supported device * @sw_setup: Holding the handler to a device initialization -@@ -746,8 +755,8 @@ struct mt753x_info { +@@ -737,8 +746,8 @@ struct mt753x_info { enum mt753x_id id; int (*sw_setup)(struct dsa_switch *ds); @@ -402,7 +402,7 @@ Signed-off-by: David S. Miller int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface); int (*cpu_port_config)(struct dsa_switch *ds, int port); bool (*phy_mode_supported)(struct dsa_switch *ds, int port, -@@ -781,6 +790,10 @@ struct mt753x_info { +@@ -772,6 +781,10 @@ struct mt753x_info { * registers * @p6_interface Holding the current port 6 interface * @p5_intf_sel: Holding the current port 5 interface select @@ -413,7 +413,7 @@ Signed-off-by: David S. Miller */ struct mt7530_priv { struct device *dev; -@@ -802,6 +815,9 @@ struct mt7530_priv { +@@ -793,6 +806,9 @@ struct mt7530_priv { struct mt7530_port ports[MT7530_NUM_PORTS]; /* protect among processes for registers access*/ struct mutex reg_mutex; From patchwork Sat Apr 9 03:00:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1615109 X-Patchwork-Delegate: yszhou4tech@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=Reu5eau9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=MDxLwr6V; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kb0LN4hbvz9sDX for ; Sat, 9 Apr 2022 13:03:24 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1RyKapjmfpp5ac2ySQWjLXGA2MKCPMvI5Nbcw1CIk+Q=; b=Reu5eau9n6koPM 1mEZHfGMmnH64P/SCMdrkVoTDLYA7MzCcLx85nNcsgBd1TiZSa39kpAJO9goasCMhL5NShBFdo6zJ 0BsfyzkZ58u8gBwM3qi0iLjkIpLdt90er/LxN9mAiu+O6GG/GHFYI3IfCnmULrOW9xsdfISYdkeYH JFIq7pOhjoIJ4XiLyuZwTROrPfs0e/lgdcJC/k6LKustysZWtld4+4QAtgiLnfXFZxWehACHeqUXW 4b2TRU8SviBoM5TLvZGLDI4d7zXiQ6CFPht8diHA2IshXcGx9eA+pOj9OHyltypJtGgZ8jNH7cmT+ PJqSFza82WKdIe2Cg/Ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd1LL-001mBA-0d; Sat, 09 Apr 2022 03:00:55 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nd1L9-001m8g-Gs for openwrt-devel@lists.openwrt.org; Sat, 09 Apr 2022 03:00:45 +0000 Received: by mail-pl1-x636.google.com with SMTP id k13so4268730plk.12 for ; Fri, 08 Apr 2022 20:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2UrudsKUsEtYtYW2freWnttRV8dmsfZkQSXZ9d5xnx8=; b=MDxLwr6VpnJ5t+okeYxUWBi8AvQIXf/AplO3Lm6t1HJ9Gaeb6wyzwgb1RQRo6nNsHp GB3PCU5MymRoCovTrQiSLEgMUvfLAmtbx4MuwpDxfY7orp6tGUYW26KHZa9IaDGXr9ar GunolcXMCz4j9GjPycBCZVF3Y0qkYAJRWLuxDbqSy/GZiiyAxZinNBdHxcjk+/RAxGaA f/1dqalCSbPEaE+LbLl2ErZRnnYtiUC+dadqsEyYNPXUI2IMrWkTCAdRqHdImHwxnFPE yfvzJZ2ZgSMoSAQqrlzW6b72uKGHySl3GrU1hic/9F0QBKCnKbi6SwJPL28ukTcGDRwj Xsmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2UrudsKUsEtYtYW2freWnttRV8dmsfZkQSXZ9d5xnx8=; b=3AwJHsrJyz/ISeDwwYdLPJR5g04JKn93iGDPLNkiSbWRjaJcFjtpO1/pszAxXBTq6K L5pv8cr1CsAcFrhG90oaWxbJ/KefVI8K63Xm+SiBZL0xkYFVDh3y7NKeU7epmXBeWJlT QgTzTiK918ydK6YxQf4YB2bdGGTOU+iFVsuZlHwpmjuqxJ0LSViW1Yla7TYoIHWYL90J Yp2i5gJmy7EQjB4BXV/4MLsD+nMU2iMMEzJHCPW1o1j3XvN17TJVFxnjcoWD8usStw+J w1m4YACV6MRgyA0pgwiTqSRg9ObWpKVL1racCpLCXqp1T8ol25ozfZFWZeK+jzDrIWWF MADg== X-Gm-Message-State: AOAM531231aYavTzxAXSiuVSEF4EArp60BYTLveX0G+Y8EdwFCFNjXDl CTcZrL/K9fffCwAwGZpQHMQ= X-Google-Smtp-Source: ABdhPJyq/SsGR7pMG6ebZivs1zW1+WczHfmiF0j1TGqI4I1+NvfhSUxTZd3C48GHGibMrnPIcNBMYA== X-Received: by 2002:a17:90b:3ec3:b0:1c7:24c4:e28f with SMTP id rm3-20020a17090b3ec300b001c724c4e28fmr25654974pjb.191.1649473242530; Fri, 08 Apr 2022 20:00:42 -0700 (PDT) Received: from localhost.localdomain ([45.77.200.130]) by smtp.gmail.com with ESMTPSA id k187-20020a636fc4000000b003983a01b896sm22733472pgc.90.2022.04.08.20.00.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Apr 2022 20:00:42 -0700 (PDT) From: Yousong Zhou To: ynezz@true.cz Cc: openwrt-devel@lists.openwrt.org, Yousong Zhou Subject: [RFC 2/2] ath79: port HiWiFi HC6361 from ar71xx Date: Sat, 9 Apr 2022 11:00:05 +0800 Message-Id: <20220409030005.30505-3-yszhou4tech@gmail.com> In-Reply-To: <20220409030005.30505-1-yszhou4tech@gmail.com> References: <20220409030005.30505-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220408_200043_615244_D4253830 X-CRM114-Status: GOOD ( 13.72 ) 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: The device was added for ar71xx target and dropped during the ath79 transition, mainly because of the ascii mac address stored in bdinfo partition Device page, http://wiki.openwrt.org/toh/hiwifi/hc6361 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 [2607:f8b0:4864:20:0:0:0:636 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [yszhou4tech[at]gmail.com] -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 The device was added for ar71xx target and dropped during the ath79 transition, mainly because of the ascii mac address stored in bdinfo partition Device page, http://wiki.openwrt.org/toh/hiwifi/hc6361 The vendor u-boot image accepts sysupgrade.bin image with specific requirements, including having squashfs signature "hsqs" at file offset 0x140000. This is not possible now that OpenWrt kernel image is at least 2MB with the signature at offset 0x240000. Installation of current build of OpenWrt now requires a bootstrap step of installing an earlier version first. - If the vendor u-boot accepts sysupgrade image, hc6361 image of LEDE release should work - If the vendor u-boot accepts only verified flashsmt image, install the one in the above device page. The image is based on Barrier Breaker SHA256SUM of the flashsmt image 81b193b95ea5f8e5c30cd62fa9facf275f39233be4fdeed7038f3deed2736156 After the bootstrap step, current build of OpenWrt can be installed there fine. Signed-off-by: Yousong Zhou --- .../linux/ath79/dts/ar9331_hiwifi_hc6361.dts | 156 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 4 + target/linux/ath79/image/generic.mk | 12 ++ 3 files changed, 172 insertions(+) create mode 100644 target/linux/ath79/dts/ar9331_hiwifi_hc6361.dts diff --git a/target/linux/ath79/dts/ar9331_hiwifi_hc6361.dts b/target/linux/ath79/dts/ar9331_hiwifi_hc6361.dts new file mode 100644 index 0000000000..05d3f6730e --- /dev/null +++ b/target/linux/ath79/dts/ar9331_hiwifi_hc6361.dts @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9331.dtsi" + +#include +#include + +/ { + model = "HiWiFi HC6361"; + compatible = "hiwifi,hc6361", "qca,ar9331"; + + aliases { + serial0 = &uart; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + label = "blue:system"; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + wlan { + label = "blue:wlan"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + }; + wan { + label = "blue:wan"; + gpios = <&gpio 27 GPIO_ACTIVE_LOW>; + }; + }; + + reg_usb_vbus: regulator { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + enable-active-high; + gpio = <&gpio 20 GPIO_ACTIVE_HIGH>; + }; +}; + +&spi { + status = "okay"; + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + uboot: partition@0 { + reg = <0x0 0x10000>; + label = "u-boot"; + read-only; + }; + + bdinfo: partition@10000 { + reg = <0x10000 0x10000>; + label = "bdinfo"; + read-only; + }; + + firmware: partition@20000 { + compatible = "denx,uimage"; + reg = <0x20000 0xfc0000>; + label = "firmware"; + }; + + backup: partition@fe0000 { + reg = <0xfe0000 0x10000>; + label = "backup"; + read-only; + }; + + art: partition@ff0000 { + reg = <0xff0000 0x10000>; + label = "art"; + read-only; + }; + }; + }; +}; + +&gpio { + status = "okay"; +}; + +&uart { + status = "okay"; +}; + +&usb { + status = "okay"; + dr_mode = "host"; + vbus-supply = <®_usb_vbus>; +}; + +&usb_phy { + status = "okay"; +}; + +ð0 { + status = "okay"; + + nvmem-cells = <&macaddr_bdinfo_18a>; + nvmem-cell-names = "mac-address-ascii"; + mac-address-increment = <1>; +}; + +ð1 { + status = "okay"; + + nvmem-cells = <&macaddr_bdinfo_18a>; + nvmem-cell-names = "mac-address-ascii"; +}; + +&wmac { + status = "okay"; + mtd-cal-data = <&art 0x1000>; + + nvmem-cells = <&macaddr_bdinfo_18a>; + nvmem-cell-names = "mac-address-ascii"; + mac-address-increment = <2>; +}; + +&bdinfo { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_18a: macaddr@18a { + reg = <0x18a 0x11>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 2ce489b0d1..ec5160f455 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -246,6 +246,10 @@ glinet,gl-x750) hak5,lan-turtle) ucidef_set_led_netdev "wan" "WAN" "orange:system" "eth1" ;; +hiwifi,hc6361) + ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1" + ucidef_set_led_wlan "wlan" "WLAN" "blue:wlan" "phy0tpt" + ;; joyit,jt-or750i) ucidef_set_led_default "ath10k" "ath10k-disable" "ath10k-phy0" "0" ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 769c0ee1da..8a34a3b344 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -1387,6 +1387,18 @@ define Device/hak5_wifi-pineapple-nano endef TARGET_DEVICES += hak5_wifi-pineapple-nano +define Device/hiwifi_hc6361 + SOC := ar9331 + DEVICE_VENDOR := HiWiFi + DEVICE_MODEL := HC6361 + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-chipidea2 kmod-usb-storage \ + kmod-fs-ext4 kmod-nls-iso8859-1 e2fsprogs + BOARDNAME := HiWiFi-HC6361 + KERNEL := kernel-bin | append-dtb | lzma | uImage lzma | pad-to $$(BLOCKSIZE) + IMAGE_SIZE := 16128k +endef +TARGET_DEVICES += hiwifi_hc6361 + define Device/iodata_etg3-r SOC := ar9342 DEVICE_VENDOR := I-O DATA