From nobody Thu Oct 05 15:35:12 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S1bGn2VZxz4vnNy; Thu, 5 Oct 2023 15:35:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S1bGn10Wnz4dnM; Thu, 5 Oct 2023 15:35:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696520113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iBohuhs2sFnHoz3vFVR7Bh6ij6aRWUNEKwVmhNvUUfA=; b=AoZQVjuKbgfyBL+WPpYjtdglgK5WueEBs0wkxQOoZFfZM4m4k56PWxS9ml8tpd0l2HDSZp 38DIfCoFHkp6izAxECS+Uu7LCO4ESPbPr4N4S6TYSxZ2lnv/2h2cT1l+uqm7SuI1Fuyy+0 oiM98lgJmBeFELWx7yS20yi1nTCCN2KiXcP4WSMy7LJf8mWKU6QQVb1RUdz1BQCsfFfCGJ MPDs5eHTGH28SHMsTjvgWmg5DtVeWEjjZRQKPKNqo0Wcdx+P3ZwhjGdFku+DdiGRy3HtRO V4t7izEQvUyAfnSfcRHYxmfeoxkvdGo6ilhNRJhQ1dRNGWmli/tCNlyoXAGSdA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696520113; a=rsa-sha256; cv=none; b=QjPXVnjA2RaBew6uVEQAndob6Fbx5Qo777PDJC5sVuc8KUBOrcu7Ttk89eq281zu2aOzpz hGpaiMmjGgrS2zWZgSNRao1LlmPSaKBEYslLW+8xRPko+IKfJNk8FLMYghZYdwWtR/r0W3 e5A6gPH/I9FUwqi1NRZdpqtstEmRQA9iP6/pKgO4RWv9Q+3TIBCqmtvhcXu2Ka0zCUSU2G JO1eW+n98UGyPyTbBfr4vBa9hGn23v3D1JAOUOcny8K7+g314Du1ulQ1hx+g91i/OGKtzR x7mmlu95clBlPU9Lo5uFkNp/rxork8dVq8Aeo8l+ML7Y9OX3h6XyP14oxV3yPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696520113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iBohuhs2sFnHoz3vFVR7Bh6ij6aRWUNEKwVmhNvUUfA=; b=KbgWCHnDTLq0A9o2wYGS5X7BIAQft0/dJbD6S7xlDM2peXwt96Sifo0f2nknQwbEOdzEWx YqS7iVyScuPHLUaPsXu+5bBgyco3WwoFqQaXJvoO/ncqX3G1pr8wUEAjfQMSYxOuY9m0ad LKnamr6ljQ2TtHv8vHcjyDis+ajLAoDp/dSTNBR46giuU7XdWJaXvhp1yJavo9+hxhq9Qf JH7Z/UoHc7wBG0jU0Hbn6GTnUMlOz03JjsUQhjXE5+LSNdGfWswq2SzWEEzuoDbxkWDj4Q SE7TlU8sj75m6hmuk1EFWLqXKzkEEJHjaS6ZkMLseAkLzWjJpWY9KLtb3xK8lw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S1bGm6vDjz1QCX; Thu, 5 Oct 2023 15:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 395FZCmB013000; Thu, 5 Oct 2023 15:35:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 395FZCZO012997; Thu, 5 Oct 2023 15:35:12 GMT (envelope-from git) Date: Thu, 5 Oct 2023 15:35:12 GMT Message-Id: <202310051535.395FZCZO012997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 801fb66a7e34 - main - dwc: Do not re-invent phy mode type List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 801fb66a7e34c340f23d82f2b375feee4bd87df4 Auto-Submitted: auto-generated The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=801fb66a7e34c340f23d82f2b375feee4bd87df4 commit 801fb66a7e34c340f23d82f2b375feee4bd87df4 Author: Emmanuel Vadot AuthorDate: 2023-10-04 16:29:11 +0000 Commit: Emmanuel Vadot CommitDate: 2023-10-05 15:34:40 +0000 dwc: Do not re-invent phy mode type Directly uses the MII_CONTYPE_* No functional changes intended. --- sys/dev/dwc/dwc1000_reg.h | 5 ----- sys/dev/dwc/if_dwc.c | 8 ++------ sys/dev/dwc/if_dwc_aw.c | 9 +++++++-- sys/dev/dwc/if_dwc_rk.c | 24 ++++++++++++++++-------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/sys/dev/dwc/dwc1000_reg.h b/sys/dev/dwc/dwc1000_reg.h index 1f0957b688ac..40ba8156ea5d 100644 --- a/sys/dev/dwc/dwc1000_reg.h +++ b/sys/dev/dwc/dwc1000_reg.h @@ -34,11 +34,6 @@ #ifndef __DWC1000_REG_H__ #define __DWC1000_REG_H__ -#define PHY_MODE_UNKNOWN 0x0 -#define PHY_MODE_RMII 0x1 -#define PHY_MODE_RGMII 0x2 -#define PHY_MODE_MII 0x3 - #define MAC_CONFIGURATION 0x0 #define CONF_JD (1 << 22) /* jabber timer disable */ #define CONF_BE (1 << 21) /* Frame Burst Enable */ diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 0e18d57a4c23..58e4d3cd5a6b 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -509,18 +509,14 @@ dwc_attach(device_t dev) sc->mactype = IF_DWC_MAC_TYPE(dev); sc->node = ofw_bus_get_node(dev); - switch (mii_fdt_get_contype(sc->node)) { + sc->phy_mode = mii_fdt_get_contype(sc->node); + switch (sc->phy_mode) { case MII_CONTYPE_RGMII: case MII_CONTYPE_RGMII_ID: case MII_CONTYPE_RGMII_RXID: case MII_CONTYPE_RGMII_TXID: - sc->phy_mode = PHY_MODE_RGMII; - break; case MII_CONTYPE_RMII: - sc->phy_mode = PHY_MODE_RMII; - break; case MII_CONTYPE_MII: - sc->phy_mode = PHY_MODE_MII; break; default: device_printf(dev, "Unsupported MII type\n"); diff --git a/sys/dev/dwc/if_dwc_aw.c b/sys/dev/dwc/if_dwc_aw.c index e6cf30f91fc3..5ad1d14b385b 100644 --- a/sys/dev/dwc/if_dwc_aw.c +++ b/sys/dev/dwc/if_dwc_aw.c @@ -36,6 +36,8 @@ #include +#include + #include #include @@ -76,10 +78,13 @@ a20_if_dwc_init(device_t dev) /* Configure PHY for MII or RGMII mode */ switch(sc->phy_mode) { - case PHY_MODE_RGMII: + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: + case MII_CONTYPE_RGMII_RXID: + case MII_CONTYPE_RGMII_TXID: tx_parent_name = "gmac_int_tx"; break; - case PHY_MODE_MII: + case MII_CONTYPE_MII: tx_parent_name = "mii_phy_tx"; break; default: diff --git a/sys/dev/dwc/if_dwc_rk.c b/sys/dev/dwc/if_dwc_rk.c index d05352a27793..51edd2450b42 100644 --- a/sys/dev/dwc/if_dwc_rk.c +++ b/sys/dev/dwc/if_dwc_rk.c @@ -38,6 +38,8 @@ #include #include +#include + #include #include @@ -175,7 +177,7 @@ rk3328_set_delays(struct if_dwc_rk_softc *sc) uint32_t reg; uint32_t tx, rx; - if (sc->base.phy_mode != PHY_MODE_RGMII) + if (!mii_contype_is_rgmii(sc->base.phy_mode)) return; reg = SYSCON_READ_4(sc->grf, RK3328_GRF_MAC_CON0); @@ -210,7 +212,10 @@ rk3328_set_speed(struct if_dwc_rk_softc *sc, int speed) uint32_t reg; switch (sc->base.phy_mode) { - case PHY_MODE_RGMII: + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: + case MII_CONTYPE_RGMII_RXID: + case MII_CONTYPE_RGMII_TXID: switch (speed) { case IFM_1000_T: case IFM_1000_SX: @@ -230,7 +235,7 @@ rk3328_set_speed(struct if_dwc_rk_softc *sc, int speed) SYSCON_WRITE_4(sc->grf, RK3328_GRF_MAC_CON1, ((MAC_CON1_GMAC2IO_GMII_CLK_SEL_MASK << 16) | reg)); break; - case PHY_MODE_RMII: + case MII_CONTYPE_RMII: switch (speed) { case IFM_100_TX: reg = MAC_CON1_GMAC2IO_RMII_CLK_SEL_25 | @@ -260,12 +265,15 @@ rk3328_set_phy_mode(struct if_dwc_rk_softc *sc) { switch (sc->base.phy_mode) { - case PHY_MODE_RGMII: + case MII_CONTYPE_RGMII: + case MII_CONTYPE_RGMII_ID: + case MII_CONTYPE_RGMII_RXID: + case MII_CONTYPE_RGMII_TXID: SYSCON_WRITE_4(sc->grf, RK3328_GRF_MAC_CON1, ((MAC_CON1_GMAC2IO_INTF_SEL_MASK | MAC_CON1_GMAC2IO_RMII_MODE_MASK) << 16) | MAC_CON1_GMAC2IO_INTF_RGMII); break; - case PHY_MODE_RMII: + case MII_CONTYPE_RMII: SYSCON_WRITE_4(sc->grf, sc->integrated_phy ? RK3328_GRF_MAC_CON2 : RK3328_GRF_MAC_CON1, ((MAC_CON1_GMAC2IO_INTF_SEL_MASK | MAC_CON1_GMAC2IO_RMII_MODE_MASK) << 16) | MAC_CON1_GMAC2IO_INTF_RMII | MAC_CON1_GMAC2IO_RMII_MODE); @@ -286,7 +294,7 @@ rk3399_set_delays(struct if_dwc_rk_softc *sc) { uint32_t reg, tx, rx; - if (sc->base.phy_mode != PHY_MODE_RGMII) + if (!mii_contype_is_rgmii(sc->base.phy_mode)) return; reg = SYSCON_READ_4(sc->grf, RK3399_GRF_SOC_CON6); @@ -416,7 +424,7 @@ if_dwc_rk_init_clocks(device_t dev) /* Optional clock */ clk_get_by_ofw_name(dev, 0, "clk_mac_speed", &sc->clk_mac_speed); - if (sc->base.phy_mode == PHY_MODE_RMII) { + if (sc->base.phy_mode == MII_CONTYPE_RMII) { if (clk_get_by_ofw_name(dev, 0, "mac_clk_rx", &sc->mac_clk_rx) != 0) { device_printf(sc->base.dev, "could not get mac_clk_rx clock\n"); sc->mac_clk_rx = NULL; @@ -448,7 +456,7 @@ if_dwc_rk_init_clocks(device_t dev) } } - if (sc->base.phy_mode == PHY_MODE_RMII) { + if (sc->base.phy_mode == MII_CONTYPE_RMII) { if (sc->mac_clk_rx) clk_enable(sc->mac_clk_rx); if (sc->clk_mac_ref)