From patchwork Thu Feb 16 12:48:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9577117 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 4152E600F6 for ; Thu, 16 Feb 2017 12:59:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2978A285C2 for ; Thu, 16 Feb 2017 12:59:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C851285C5; Thu, 16 Feb 2017 12:59:18 +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 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 C555D285C2 for ; Thu, 16 Feb 2017 12:59:17 +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=ZEfchSJsDdELiarosVFP7wJ8FviM5cIHU6CvYCYiUUE=; b=KOo3aAvu37whLk98+CcX7aVnCR 7DEiTxyLQddi6AgkvK3DAN7sEAGFuZE5KShmLUVL8pJIl/zr3X+Yq86K2KikZFE4uO6KWvsYG9FSv D9PZvEf5ygrcrMAjGw7e2K1kl2Y/AJu8HQa73hy4VjzZC6zfpv+HM6HL3vLCB38563bmxI38t3bxy JdfiANqaNlfIBktYPmov/3jVZew/SnNJ/9p4KeG9ZGs1qAzbFFkz4k8rqy7VYAS4iXdtnB/IZ9veb bnK9GykKo82YGrHvx2fFjEzZEUcaB9Qpw3mMk50Jc+r0i+a1X2JjZTysd0mtaCo730pitZygKNYja qtqawjLQ==; 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 1ceLeS-0008JY-05; Thu, 16 Feb 2017 12:59:12 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ceLX7-0001Ky-VL for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 12:51:40 +0000 Received: by mail-wm0-x241.google.com with SMTP id c85so2988515wmi.1 for ; Thu, 16 Feb 2017 04:51:17 -0800 (PST) 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=EDePlRpAnz9xSk9hgCZv7Y/dqCCbk2TXpGt5O1b1GDQ=; b=aYwOxzGnhFu+z7K/R0oS9HRlh9WZO/iuujCNt+8bV0S+g7ECLVSO4hgwMP1lbSFWch RuiyEKHTdKioEy7HluCBRhny5YAFUkbbQp2g0OvgKm7m6kQcwEBLDzpTE0sZ/sM/L+Bi PhZsoQOAVZaj4ul/IqHPxvUogLJRjclg5PQ9KROfFTLQY8vMaVChHXssgx9qzb1Bq86B 1govIw9tQbhnON/NR2m+ISeycKD/WLEJb+41/D3Vto8xqbABdkMK/tlwrsAFBlCSLp/U t6dfT4cdOav1SH/p93HekWDEv4W+DlBqZQcVJRA/+DmP570Qudhxl39IY9NeQrcxDkrr hBig== 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=EDePlRpAnz9xSk9hgCZv7Y/dqCCbk2TXpGt5O1b1GDQ=; b=DDRfJeI8SUL5LCTf4BgIQocGB3NPi9dTLbLb9vzX/v5jztS3m1qyBck2otXNNmJ8qk rtIRptU9UahSll4DmEkwVqRpY3sqsVUwujnnqtpI4R3RZCa6PJh3o1XWV2K1YMsgjwm7 EmW0fZsz5JitU3qB6R1mMB3B5aJh6/xuiSjwgqwWG990GI53IM4LQ6mzLdAAy/cQMtwa o0gE6giEQk/WuI+g1kMhT1Y5vNzooDarPUeiBKAG/pcy2oVUXom/y5Kyr0MjInUYeAWm ZrJ/wKqpvpciyUdY+++Qs6V5APkasRs4R++W4qI6lTuwymDnyX3tWAZIrwoOWOIVqSsk i2oQ== X-Gm-Message-State: AMke39l1oMiTKNBNCBymyrbnV3njuXKl1SYjdVm2ScuuyRwLRpW5BQejol34TBxue0dYOQ== X-Received: by 10.28.5.72 with SMTP id 69mr2238818wmf.6.1487249476123; Thu, 16 Feb 2017 04:51:16 -0800 (PST) Received: from Red.local (LFbn-1-7035-57.w90-116.abo.wanadoo.fr. [90.116.208.57]) by smtp.googlemail.com with ESMTPSA id o143sm144705wmd.3.2017.02.16.04.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Feb 2017 04:51:15 -0800 (PST) From: Corentin Labbe To: peppe.cavallaro@st.com, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@free-electrons.com, wens@csie.org, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, alexandre.torgue@st.com Subject: [PATCH 01/21] net-next: stmmac add optional init_phy function Date: Thu, 16 Feb 2017 13:48:39 +0100 Message-Id: <20170216124859.14346-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170216124859.14346-1-clabbe.montjoie@gmail.com> References: <20170216124859.14346-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170216_045138_163094_BB65E017 X-CRM114-Status: GOOD ( 11.09 ) 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 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 For dwmac-sun8i, some actions must be done for enabling attached PHY. Thoses actions must be done after stmmac_probe_config_dt() and at start of stmmac_init_phy(). The best way to handle that is to add an optional init_phy() function. Signed-off-by: Corentin Labbe --- drivers/net/ethernet/stmicro/stmmac/common.h | 3 +++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 144fe84..daaafa9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -483,6 +483,9 @@ struct stmmac_ops { bool loopback); void (*pcs_rane)(void __iomem *ioaddr, bool restart); void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv); + /* optional function for powering/init PHY */ + int (*init_phy)(struct net_device *ndev); + void (*uninit_phy)(struct net_device *ndev); }; /* PTP and HW Timer helpers */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3cbe096..942efb7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -820,10 +820,18 @@ static int stmmac_init_phy(struct net_device *dev) char bus_id[MII_BUS_ID_SIZE]; int interface = priv->plat->interface; int max_speed = priv->plat->max_speed; + int ret; + priv->oldlink = 0; priv->speed = SPEED_UNKNOWN; priv->oldduplex = DUPLEX_UNKNOWN; + if (priv->hw->mac->init_phy) { + ret = priv->hw->mac->init_phy(dev); + if (ret) + return ret; + } + if (priv->plat->phy_node) { phydev = of_phy_connect(dev, priv->plat->phy_node, &stmmac_adjust_link, 0, interface); @@ -1892,6 +1900,9 @@ static int stmmac_release(struct net_device *dev) phy_disconnect(dev->phydev); } + if (priv->hw->mac->uninit_phy) + priv->hw->mac->uninit_phy(dev); + netif_stop_queue(dev); napi_disable(&priv->napi);