From patchwork Fri Jul 28 09:28:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9868195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8BECB6038C for ; Fri, 28 Jul 2017 09:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74844288B9 for ; Fri, 28 Jul 2017 09:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68D76288BD; Fri, 28 Jul 2017 09:32:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED808288BB for ; Fri, 28 Jul 2017 09:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Hu1fvo7/dnJ37NoAqTqb3K+BX7Nv9PQ2ffHBPe3MnyU=; b=ZC96gADIx4pAkOuxpJEWLa4/A9 7nsisNF9pSl1Q2Jpk1WXghw2a75D+lkFnblHKTC5t+ZGtuY4ClhV0qgXbuVl9MNnW+4XsoiBXe8BC zT4G/V3Nn5m63SgO+zWUAN3LoLpUh10Ikw1Goeg3+/g4UZVGMDSjlsEkrRa9CEHqmxANfby2/iGk1 5keA45djxPm51d6guo0sakwO33lD4xu0f5gyWPZ1XEkI2v+fXSmoluk81BoxAYnOaLy+PhVkoH9xp Si8UX/b0SM+pLTIOaDlrLpYpXPyphHXFDPGUQoUKrR8cyPa5uR96s55s2pu/rleVQ3nV23/zG5+4m c3frnxFQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1db1cz-0006oR-Vy; Fri, 28 Jul 2017 09:32:14 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1db1c6-0005uv-J1 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jul 2017 09:31:21 +0000 Received: by mail-wm0-x244.google.com with SMTP id 184so26677096wmo.3 for ; Fri, 28 Jul 2017 02:30:58 -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=MvxCDf62v4NMWxQ5gQNpWtDk0Iiw/EyfHToUP7iDycA=; b=aBFbXp4WjPvKIEs2SandLvPvRcHSv2mfi8G9kavOghBkQMAQL+DdDAbwegzyIc7IKB 2lqfv7v5a2CljPD9eH+HqBrGgVbKxxdAG3exABzBSMlVBVAph7qSD+qoRSsTGnpnzahG 5daVbrE5C2eLJlftJ7hvfHU4sqb6fU18FBDEBhdh1DpJE49WXMkAQ4x0ZGSRAG6cah1E coD7Y7YPor0b5Hjfu5Cmk8scDHn1j1ix1kWG2VqGpyH5R37aqr60GhKKRTCV3BKODRT9 mkDram/zYhOJvAzcGERE+RjU+hRUEs64WM2LkOkfiNj0EV4pRdsyQf7HuY904l6P45yY N1lQ== 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=MvxCDf62v4NMWxQ5gQNpWtDk0Iiw/EyfHToUP7iDycA=; b=m7XqDW85T13nVeJhrN8meRE2HJDObYiBHvL3q3NdzS4TkshuX1w29t0DfyC9VgIbpL vQgqz3iyw2KEdJ8/ECDoECQPpcY0cjEsK0qzj8mf4lKhnQEwfz8qyj6QRU+PKdbwZm3v DWDlaLDYoysibZFPUFPt+bMtPqFGZ41C5KK+c/v4x4ms1DIgGG4ItqwILrfEp3oG64c3 g8ogXm079OOaTceolXJGKS2lZs34yQidYym+Guy8Xe056kXGLb3C/oZzI7e8P8fAxT6y iW/5cfrevtI3OpHqJTzti5T42wI46UYKIAahBSQwN3PIqY9SYlss/667Oo35bKmb3u2U Ed+g== X-Gm-Message-State: AIVw112Gbtv+BDNXmVYrs7YwKSdTfma0vMgbU/AuHs/s81rsAN9bfKaD Wg6mseHmVaXWPw== X-Received: by 10.28.37.193 with SMTP id l184mr5662931wml.24.1501234256865; Fri, 28 Jul 2017 02:30:56 -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 189sm2485985wmh.0.2017.07.28.02.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Jul 2017 02:30:56 -0700 (PDT) From: Corentin Labbe To: robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@free-electrons.com, wens@csie.org, linux@armlinux.org.uk, peppe.cavallaro@st.com, alexandre.torgue@st.com Subject: [PATCH 3/3] net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible Date: Fri, 28 Jul 2017 11:28:18 +0200 Message-Id: <20170728092818.23419-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170728092818.23419-1-clabbe.montjoie@gmail.com> References: <20170728092818.23419-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170728_023118_846118_D6B03385 X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-arm-kernel@lists.infradead.org, icenowy@aosc.io MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 its compatible. Since the phy_mode of the internal PHY does need to be know, the variant internal_phy member is converted to a boolean. Signed-off-by: Corentin Labbe --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index fffd6d5fc907..04f7ddd802b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -48,7 +48,7 @@ */ struct emac_variant { u32 default_syscon_value; - int internal_phy; + bool 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, + .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, + .internal_phy = true, .support_mii = true }; static const struct emac_variant emac_variant_a83t = { .default_syscon_value = 0, - .internal_phy = 0, + .internal_phy = false, .support_mii = true, .support_rgmii = true }; static const struct emac_variant emac_variant_a64 = { .default_syscon_value = 0, - .internal_phy = 0, + .internal_phy = false, .support_mii = true, .support_rmii = true, .support_rgmii = true @@ -889,6 +889,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev) struct sunxi_priv_data *gmac; struct device *dev = &pdev->dev; int ret; + static const struct of_device_id internal_phys[] = { + { .compatible = "allwinner,sun8i-h3-ephy" }, + { .compatible = "allwinner,sun8i-v3s-ephy" }, + }; ret = stmmac_get_platform_resources(pdev, &stmmac_res); if (ret) @@ -932,7 +936,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_match_node(internal_phys, plat_dat->phy_node)) { 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);