From: Weiting Lee <weiting.lee@airoha.com>
To: <netdev@vger.kernel.org>
Cc: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>,
<davem@davemloft.net>, <kuba@kernel.org>, <edumazet@google.com>,
<pabeni@redhat.com>, <linux-kernel@vger.kernel.org>,
<bjorn@mork.no>, <ericwouds@gmail.com>, <frank-w@public-files.de>,
<joseph.lin@airoha.com>, <wenshin.chung@airoha.com>,
<lucien.jheng@airoha.com>, <albert-al.lee@airoha.com>,
Weiting Lee <weiting.lee@airoha.com>
Subject: [PATCH v3 net-next] net: phy: air_en8811h: select LED GPIO pins based on AN8811HB package variant
Date: Mon, 7 Sep 2026 09:56:37 +0800 [thread overview]
Message-ID: <20260907015638.2875763-1-weiting.lee@airoha.com> (raw)
In-Reply-To: <20260828050537.2728253-1-weiting.lee@airoha.com>
The AN8811HB comes in two package variants, AN8811HBCN and AN8811HBN,
which use different GPIO pins to drive LED outputs. AN8811HBCN uses
GPIOs 0, 1, and 15, while AN8811HBN uses GPIOs 3, 4, and 5. Using a
fixed GPIO assignment causes incorrect LED behavior on one of the
variants.
Read the package variant from the read-only silicon identification bits
in AN8811HB_HWTRAP2 at probe time and store it in priv->is_an8811hbcn.
Add an8811hb_led_gpio_setup() to configure the correct GPIO output pins
and select lines based on the detected variant, and call it from
config_init.
Signed-off-by: Weiting Lee <weiting.lee@airoha.com>
---
v2 -> v3:
- Rebase on top of net-next commit 3498acda6b68
("net: phy: air_en8811h: restore AN8811HB LED GPIO after MCU restart")
- an8811hb_led_gpio_setup() now covers the AN8811HBN (345) case that
commit restored, replacing its direct GPIO_OUTPUT_345 restore call
v1 -> v2:
- Rename pkg_sel to is_an8811hbcn (bool) for clarity
- Remove phydev_info log to avoid spamming the kernel log
- Fix commit message: HWTRAP2 bits are read-only silicon
identification, not a hardware strap pin
v1: https://lore.kernel.org/netdev/20260827054156.2681908-1-weiting.lee@airoha.com/
v2: https://lore.kernel.org/netdev/20260828050537.2728253-1-weiting.lee@airoha.com/
drivers/net/phy/air_en8811h.c | 67 ++++++++++++++++++++++++++++++++---
1 file changed, 63 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/air_en8811h.c b/drivers/net/phy/air_en8811h.c
index 38eb18f0e9bb..ae24c41f538a 100644
--- a/drivers/net/phy/air_en8811h.c
+++ b/drivers/net/phy/air_en8811h.c
@@ -145,10 +145,22 @@
#define AN8811HB_GPIO_OUTPUT 0x5cf8b8
#define AN8811HB_GPIO_OUTPUT_345 (BIT(3) | BIT(4) | BIT(5))
+#define AN8811HB_GPIO_OUTPUT_0115 (BIT(0) | BIT(1) | BIT(15))
+
+#define AN8811HB_GPIO_SEL1 0x5cf8bc
+#define AN8811HB_GPIO_SEL1_0_MASK GENMASK(3, 0)
+#define AN8811HB_GPIO_SEL1_1_MASK GENMASK(7, 4)
+#define AN8811HB_GPIO_SEL1_0 BIT(0)
+#define AN8811HB_GPIO_SEL1_1 0
+
+#define AN8811HB_GPIO_SEL2 0x5cf8c0
+#define AN8811HB_GPIO_SEL2_15_MASK GENMASK(31, 28)
+#define AN8811HB_GPIO_SEL2_15 BIT(29)
#define AN8811HB_HWTRAP1 0x5cf910
#define AN8811HB_HWTRAP2 0x5cf914
#define AN8811HB_HWTRAP2_CKO BIT(28)
+#define AN8811HB_HWTRAP2_PKG GENMASK(14, 12)
#define AN8811HB_CLK_DRV 0x5cf9e4
#define AN8811HB_CLK_DRV_CKO_MASK GENMASK(14, 12)
@@ -202,6 +214,7 @@ struct en8811h_priv {
struct phy_device *phydev;
unsigned int cko_is_enabled;
struct mdio_device *pbusdev;
+ bool is_an8811hbcn;
};
enum {
@@ -1071,10 +1084,49 @@ static int en8811h_leds_setup(struct phy_device *phydev)
return ret;
}
+static int an8811hb_led_gpio_setup(struct phy_device *phydev)
+{
+ struct en8811h_priv *priv = phydev->priv;
+ int ret;
+
+ if (priv->is_an8811hbcn) {
+ /* AN8811HBCN: LED GPIOs are 0, 1, 15 */
+ ret = air_phy_buckpbus_reg_modify(phydev, AN8811HB_GPIO_OUTPUT,
+ AN8811HB_GPIO_OUTPUT_0115,
+ AN8811HB_GPIO_OUTPUT_0115);
+ if (ret < 0)
+ return ret;
+
+ ret = air_phy_buckpbus_reg_modify(phydev, AN8811HB_GPIO_SEL1,
+ AN8811HB_GPIO_SEL1_0_MASK |
+ AN8811HB_GPIO_SEL1_1_MASK,
+ AN8811HB_GPIO_SEL1_0 |
+ AN8811HB_GPIO_SEL1_1);
+ if (ret < 0)
+ return ret;
+
+ ret = air_phy_buckpbus_reg_modify(phydev, AN8811HB_GPIO_SEL2,
+ AN8811HB_GPIO_SEL2_15_MASK,
+ AN8811HB_GPIO_SEL2_15);
+ if (ret < 0)
+ return ret;
+ } else {
+ /* AN8811HBN: LED GPIOs are 3, 4, 5 */
+ ret = air_phy_buckpbus_reg_modify(phydev, AN8811HB_GPIO_OUTPUT,
+ AN8811HB_GPIO_OUTPUT_345,
+ AN8811HB_GPIO_OUTPUT_345);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int an8811hb_probe(struct phy_device *phydev)
{
struct mdio_device *mdiodev;
struct en8811h_priv *priv;
+ u32 reg_val;
int ret;
priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct en8811h_priv),
@@ -1115,6 +1167,12 @@ static int an8811hb_probe(struct phy_device *phydev)
/* MDIO_DEVS1/2 empty, so set mmds_present bits here */
phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_AN;
+ /* Detect package variant */
+ ret = air_phy_buckpbus_reg_read(phydev, AN8811HB_HWTRAP2, ®_val);
+ if (ret < 0)
+ goto err_dev_create;
+ priv->is_an8811hbcn = FIELD_GET(AN8811HB_HWTRAP2_PKG, reg_val);
+
ret = en8811h_leds_setup(phydev);
if (ret < 0)
goto err_dev_create;
@@ -1263,10 +1321,11 @@ static int an8811hb_config_init(struct phy_device *phydev)
return ret;
}
- /* Restore LED GPIO output enables after MCU initialization. */
- ret = air_phy_buckpbus_reg_modify(phydev, AN8811HB_GPIO_OUTPUT,
- AN8811HB_GPIO_OUTPUT_345,
- AN8811HB_GPIO_OUTPUT_345);
+ ret = an8811hb_led_gpio_setup(phydev);
+ if (ret < 0) {
+ phydev_err(phydev, "Failed to set up LED GPIO: %d\n", ret);
+ return ret;
+ }
return ret;
}
--
2.43.0
next prev parent reply other threads:[~2026-09-07 1:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 5:41 [PATCH] net: phy: air_en8811h: select LED GPIO pins based on AN8811HB package variant Weiting Lee
2026-08-27 18:01 ` Andrew Lunn
2026-08-28 5:05 ` [PATCH v2 net-next] " Weiting Lee
2026-08-28 13:07 ` Andrew Lunn
2026-08-31 6:58 ` 回覆: " WeiTing Lee (李威霆)
2026-09-07 1:56 ` Weiting Lee [this message]
2026-09-09 16:57 ` [PATCH v3 " netdev-bot+sashiko
2026-09-10 13:15 ` Paolo Abeni
2026-09-10 13:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907015638.2875763-1-weiting.lee@airoha.com \
--to=weiting.lee@airoha.com \
--cc=albert-al.lee@airoha.com \
--cc=andrew@lunn.ch \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ericwouds@gmail.com \
--cc=frank-w@public-files.de \
--cc=hkallweit1@gmail.com \
--cc=joseph.lin@airoha.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lucien.jheng@airoha.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wenshin.chung@airoha.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox