From patchwork Fri Aug 18 12:21:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 803211 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KdkCSckq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xYj2K5p1Lz9sPt for ; Fri, 18 Aug 2017 22:24:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbdHRMYJ (ORCPT ); Fri, 18 Aug 2017 08:24:09 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38584 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751017AbdHRMYH (ORCPT ); Fri, 18 Aug 2017 08:24:07 -0400 Received: by mail-wr0-f193.google.com with SMTP id 49so7222826wrw.5; Fri, 18 Aug 2017 05:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vd4hUpml01skHHEZohjv1DS1M9bSt1JCiybFmIsfTCM=; b=KdkCSckqWDcGe5Y6z2h7rYw4d1bUIFtvRI//vOd1ma8Zfc2+rNGdkVcb55TcAoNOQy pH2sL2fltMWHcsJs1T4mqYzi4MUMWSfjcdB06ivRC3Wxp7WZwjdZNvTnKWxUslM4xWLl Yt0elDWxtpkY8s1nF2BkiycKL//sQ1LXNm0ML1v6GopTGet/gmXf72aBXpyDxPfB/efO M+3QC/12vUZ1AzCc/XO8LqTJ773Zok9V+WQk77NduVnkVueRMtKcvwE3DsH3hMFkk4em WP5wwdGk2//ZilWzbHmi3auFr6/PDIu9F9jdNo9eW0elU+5FveaErTKlo4XZxJCp899z HbAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vd4hUpml01skHHEZohjv1DS1M9bSt1JCiybFmIsfTCM=; b=Ylfqwo2iJ7V0GP0BevHQR1jXuNBuTpEaJM5EVsEJfcHqdvwJ24x2kdmA5VMw1bLKHv BCNMWYWKPS6Q+iZaqjOJWyLzePPGGnrBmOJu/5FVBQgZG8E+QasTRWuR7fjjDBr40elJ z9RulKGdspdRo9NuXBIe8WQK2r0lFcyKLqCCZKXcSAZ/pAofzbM8OZeVtYe6y5fyXLB9 hD/lq62SeF0PVzqt5LhnInN2+l/fEUeTnJZQcxoOdVL5F7orLBhJs5xqGhK9gx5ffdRU 3RnQrb3gj0eJ5VLFBW0n6qdeVawfvl3rcbd6ZEdSJTr4Vy7MJ39LBFwJOH+dENVumE3y x3wg== X-Gm-Message-State: AHYfb5ggEMcJXDLuP4t8xxUrkx5r+SKY5dXnzQTiev8MNXwf/nvm3Z3v AL9YMxSzHwTXXw== X-Received: by 10.223.162.204 with SMTP id t12mr4989472wra.2.1503059045691; Fri, 18 Aug 2017 05:24:05 -0700 (PDT) Received: from Red.local (LFbn-1-7109-228.w90-116.abo.wanadoo.fr. [90.116.45.228]) by smtp.googlemail.com with ESMTPSA id b23sm7754738wrd.40.2017.08.18.05.24.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Aug 2017 05:24:05 -0700 (PDT) From: Corentin Labbe To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, wens@csie.org, peppe.cavallaro@st.com, alexandre.torgue@st.com Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Corentin Labbe Subject: [PATCH v3 2/4] net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated Date: Fri, 18 Aug 2017 14:21:16 +0200 Message-Id: <20170818122118.4925-3-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170818122118.4925-1-clabbe.montjoie@gmail.com> References: <20170818122118.4925-1-clabbe.montjoie@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The current way to find if the phy is internal is to compare DT phy-mode and emac_variant/internal_phy. But it will negate a possible future SoC where an external PHY use the same phy mode than the internal one. This patch adds a new way to find if the PHY is internal, via the phy-is-integrated property. Since the internal_phy variable does not need anymore to contain the xMII mode used by the internal PHY, it is still used for knowing the presence of an internal PHY, so it is modified to a boolean soc_has_internal_phy. Signed-off-by: Corentin Labbe Acked-by: Chen-Yu Tsai Reviewed-by: Florian Fainelli --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index fffd6d5fc907..672553b652bd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -41,14 +41,14 @@ * This value is used for disabling properly EMAC * and used as a good starting value in case of the * boot process(uboot) leave some stuff. - * @internal_phy: Does the MAC embed an internal PHY + * @soc_has_internal_phy: Does the MAC embed an internal PHY * @support_mii: Does the MAC handle MII * @support_rmii: Does the MAC handle RMII * @support_rgmii: Does the MAC handle RGMII */ struct emac_variant { u32 default_syscon_value; - int internal_phy; + bool soc_has_internal_phy; bool support_mii; bool support_rmii; bool support_rgmii; @@ -75,7 +75,7 @@ struct sunxi_priv_data { static const struct emac_variant emac_variant_h3 = { .default_syscon_value = 0x58000, - .internal_phy = PHY_INTERFACE_MODE_MII, + .soc_has_internal_phy = true, .support_mii = true, .support_rmii = true, .support_rgmii = true @@ -83,20 +83,20 @@ static const struct emac_variant emac_variant_h3 = { static const struct emac_variant emac_variant_v3s = { .default_syscon_value = 0x38000, - .internal_phy = PHY_INTERFACE_MODE_MII, + .soc_has_internal_phy = true, .support_mii = true }; static const struct emac_variant emac_variant_a83t = { .default_syscon_value = 0, - .internal_phy = 0, + .soc_has_internal_phy = false, .support_mii = true, .support_rgmii = true }; static const struct emac_variant emac_variant_a64 = { .default_syscon_value = 0, - .internal_phy = 0, + .soc_has_internal_phy = false, .support_mii = true, .support_rmii = true, .support_rgmii = true @@ -648,7 +648,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv) "Current syscon value is not the default %x (expect %x)\n", val, reg); - if (gmac->variant->internal_phy) { + if (gmac->variant->soc_has_internal_phy) { if (!gmac->use_internal_phy) { /* switch to external PHY interface */ reg &= ~H3_EPHY_SELECT; @@ -932,7 +932,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev) } plat_dat->interface = of_get_phy_mode(dev->of_node); - if (plat_dat->interface == gmac->variant->internal_phy) { + if (of_property_read_bool(plat_dat->phy_node, "phy-is-integrated")) { dev_info(&pdev->dev, "Will use internal PHY\n"); gmac->use_internal_phy = true; gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);