From patchwork Mon Jun 22 09:37:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1E92C433E0 for ; Mon, 22 Jun 2020 09:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9132B2071A for ; Mon, 22 Jun 2020 09:43:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="JohkqRDO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbgFVJn0 (ORCPT ); Mon, 22 Jun 2020 05:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbgFVJlZ (ORCPT ); Mon, 22 Jun 2020 05:41:25 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A91C061798 for ; Mon, 22 Jun 2020 02:41:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g10so14196613wmh.4 for ; Mon, 22 Jun 2020 02:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jZFWs1jjiaVnSG438fJkY7s38xrX7YeHfB9snWv0f6M=; b=JohkqRDOkStLwOQBjn7GAxxxqeMmpsJpexC5Nvm3ZMZvZkzc6ARClZYDLYdCfBzdNP R+QJVrGl3nve0LVt+ru6aBGSu24D+tdHE1WXHHZuvA5Ccg3nHihCl36U5ScPUL7gEh57 udVFjmWNOm6E0bczq/erJCZqK+GBkdblmTaRS2wxUujd7J+4fpcSfkvXc70p5jeaQvh0 r7uqyKqpQR2LYCzlfV/PSR3Z3SvvEaicHAEj11kmaMKkCWH4prC3PqUu8JFXFO7jY4OE 2ZItHe0laJ0Lf9dSzMlvGGUIslglMGg/vMwUmi0/DI2fZnDGPbhyK9nizsa0eDmyC4EL qmEg== 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:mime-version:content-transfer-encoding; bh=jZFWs1jjiaVnSG438fJkY7s38xrX7YeHfB9snWv0f6M=; b=bHTF+uE9Th0Kbv9bKyyq7rSen1Kd2VHWBGIl5k9wuQ+kWugUGYCFciz8n4z+7spC92 qchKnD+DCcESzv1rR6WuNwhCsunfvC4DbPdixQMoL8bt6xtH9BRUXDFDBOY/nug1DTEI HrQ3/slkyesp/biozeJV66K5TjxMzHJZrEoylEbO4xVgDeVCN6AOm+PfB/k33V70MEjB LA/7hHzL69BivsgpsSRmYoGlkC/5TEnLOJ2rwQFoiM3QtOckpgaYG8l+tSSPc4RR86IG YU/tQnCHhUjSdo6nLrRh9nJ7A0kQEgVuDxCpMj8fPf512krfdnJbFAXuf1GmtdHZVk5L SoBw== X-Gm-Message-State: AOAM532QqrMjOXY7S7n3T0O+jQ37HcbWxjMWGxKFFCUGLCQOBGiVdFJ6 mCVkqNacFz9VsFUpXeCfTk5faA== X-Google-Smtp-Source: ABdhPJyC1ihQ/cFNQCt/b68/kb0LNRNlp3xUizgD1UJeHr9htbQzK5ESNt14EIs0DoIuJdIEW8DsUQ== X-Received: by 2002:a05:600c:2294:: with SMTP id 20mr18307854wmf.51.1592818883659; Mon, 22 Jun 2020 02:41:23 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:23 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 01/15] net: phy: arrange headers in mdio_bus.c alphabetically Date: Mon, 22 Jun 2020 11:37:30 +0200 Message-Id: <20200622093744.13685-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski Keeping the headers in alphabetical order is better for readability and allows to easily see if given header is already included. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/mdio_bus.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 6ceee82b2839..296cf9771483 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -8,32 +8,32 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include +#include +#include #include #include +#include #include -#include -#include -#include -#include -#include -#include +#include #include +#include #define CREATE_TRACE_POINTS #include From patchwork Mon Jun 22 09:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BC3EC433DF for ; Mon, 22 Jun 2020 09:41:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEC1520732 for ; Mon, 22 Jun 2020 09:41:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="SP7AoO6j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726993AbgFVJlc (ORCPT ); Mon, 22 Jun 2020 05:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbgFVJl3 (ORCPT ); Mon, 22 Jun 2020 05:41:29 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C97C061799 for ; Mon, 22 Jun 2020 02:41:26 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g75so6113982wme.5 for ; Mon, 22 Jun 2020 02:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bqh6HxDlaYo+eDyI7otJcwguVt4xZOU026/4uSBRTYc=; b=SP7AoO6jktrfliyzCx/xTv9Acl8xJ9sY7iCwKrfwfyNggXkndAn+GiE89e2CakhX93 EtFpneu7Irbs7xZzUb0hX6BSHQi3UozkzhV+p6SQq9kyi9aHVpBp5CBCwNTmulsZslat S7C/Z8dksydKPXBjvs5GBreCNnBfxtAnumAazOf9/1wvwfZCe7m8JALCSbuOLvoF5Rou xBK1gJiM8i95SvZeb+tQiaOslV7j4IZb68JOC/jIisPOWeaDQtMQzPIITSrjs4DzZlJ8 MzF704Nbnte2Zw7NGj8nJyLAt5+AEeIUcZgDNWKDwvTp1MOa2y3CoFw3Vypbd5fd3vFk FLZg== 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:mime-version:content-transfer-encoding; bh=bqh6HxDlaYo+eDyI7otJcwguVt4xZOU026/4uSBRTYc=; b=Q9jNIVSzSZ3YSSAmFGNVfdvzeXIUo0ZwItQ/Mv2P2J2RBo0kNfKTBumIoNhAMbaoNo K15bCn0eCcm3rd0NG501Ud1blJPp4M3kMJMoLqyyX+mjyuOxCOCnfSglQtyobBvLa05k NHSnTcAe6xhRzFU1MaiPEBENjTQQhSwAVpHBDxnXck7sARF/srw9mhtgFtg/V90UiTCU NaoAdWr9Dpr253EWszQjvfq+g8bZT+bPTQf2YVWpNwz5ZTkXKaW30VJTdQ5I4PLRcPIa gsQc8glLdoC2vyjQ+lLBBwzsagrtkq89iQeHdeClUsC//yUZ1Zl22mFWVwf1QJNXOi24 I4Yg== X-Gm-Message-State: AOAM531V51zJ+KEGNeKH/QmbSsnne6wfbzevIKAV81R8sqxq7TheguZV 442LnmquKVu7kSVU67y1f3Cbgw== X-Google-Smtp-Source: ABdhPJxp7i5US20/aRii1o/KsIXINrL2pr4jmYkXOUQGOXKf71p0QdlmezcpuamEmuUdwfDNh3u4dA== X-Received: by 2002:a1c:a3c5:: with SMTP id m188mr17121192wme.152.1592818885393; Mon, 22 Jun 2020 02:41:25 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:24 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 02/15] net: phy: arrange headers in mdio_device.c alphabetically Date: Mon, 22 Jun 2020 11:37:31 +0200 Message-Id: <20200622093744.13685-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski Keeping the headers in alphabetical order is better for readability and allows to easily see if given header is already included. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/mdio_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index c1d345c3cab3..f60443e48622 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -6,6 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include void mdio_device_free(struct mdio_device *mdiodev) { From patchwork Mon Jun 22 09:37:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90C91C433E1 for ; Mon, 22 Jun 2020 09:43:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 721BB20716 for ; Mon, 22 Jun 2020 09:43:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="A2nZUOgn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgFVJnU (ORCPT ); Mon, 22 Jun 2020 05:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbgFVJlc (ORCPT ); Mon, 22 Jun 2020 05:41:32 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20FC2C061794 for ; Mon, 22 Jun 2020 02:41:32 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id a6so13983893wrm.4 for ; Mon, 22 Jun 2020 02:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cfUc+TkUAgqz9MdoL32AGr8CBlEvrLInm5v62775Pps=; b=A2nZUOgnmx1UP+ORv6aiykQQt+lLSQ1KO7Odnx9nMWmPGWBB/9zwG2qDldAgXJmqFF xP5a4eGOadOLgU5l8x7N7j9+z2XQcTH/rFKkU1WWhZmJmVhXF2hTLLfHyQ5etAtMHKmX GzjJGiUtKBqAj3ZO+9U33Aqe6H7sc3uFms0oEry7uZGxugnSgJBjckjsDuq2/0a7BeEq I4qul8QuxKe+CEztgYEFZDIF1pwVYkuHKS4ZkApg+YQ/TcNclWYBEankibn6cVK3MPY7 ZU+9DUlAqUZCkiO9dP4Q1H37N9frUcXcUiOti5AX0YjukaK8I91Rvini9mJsIrmoYDWK Og9w== 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:mime-version:content-transfer-encoding; bh=cfUc+TkUAgqz9MdoL32AGr8CBlEvrLInm5v62775Pps=; b=ZepFSFnRYH9mVbvxzdgC04ac1m5d4sRaW1+H0oSoe3Qxfy8RG8oyq/cgY8geieAo33 F++mArhrC2vXm+TBDo+07e2jzZIP/qy5viyp2uH1sHCsqHSzZWnikj2Abt3xz5bJy1Tl nhXRR7jczSAoN7KPOukF6FrkbefrSB4j3BnoxyaWQBokUzOhsjodugtlhfegXOgbmhcV NIQHL8B7zQb5332BymQsHoA8Z94KsE7G3eajD7IYYq3/7tdZePgQrYqSsVUpdsSbAhEj xyrkA/SGC97HnK6kdA9NaupZYwqizukJw/+8pUJAnzXPUuV1QjjHnRf7wpvvnKYRra9N 4y9A== X-Gm-Message-State: AOAM533Fa9O44HCetYqpvWLj8Akhuh8lymflrkrphVWVETwWspYaEugr KX1615o3tO5etSr8/ZKayVVyxg== X-Google-Smtp-Source: ABdhPJzkmYuQpu0uNoygH8mU35nl1Z6nB3WJ2gtz2NCWG24AiJQNaa6UhDtUjU6DEUC2R04sQUctyQ== X-Received: by 2002:a5d:470a:: with SMTP id y10mr5777035wrq.405.1592818890889; Mon, 22 Jun 2020 02:41:30 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:30 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 05/15] net: phy: reset the PHY even if probe() is not implemented Date: Mon, 22 Jun 2020 11:37:34 +0200 Message-Id: <20200622093744.13685-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski Currently we only call phy_device_reset() if the PHY driver implements the probe() callback. This is not mandatory and many drivers (e.g. realtek) don't need probe() for most devices but still can have reset GPIOs defined. There's no reason to depend on the presence of probe() here so pull the reset code out of the if clause. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/phy_device.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 1b4df12c70ad..f6985db08340 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2690,16 +2690,13 @@ static int phy_probe(struct device *dev) mutex_lock(&phydev->lock); - if (phydev->drv->probe) { - /* Deassert the reset signal */ - phy_device_reset(phydev, 0); + /* Deassert the reset signal */ + phy_device_reset(phydev, 0); + if (phydev->drv->probe) { err = phydev->drv->probe(phydev); - if (err) { - /* Assert the reset signal */ - phy_device_reset(phydev, 1); + if (err) goto out; - } } /* Start out supporting everything. Eventually, @@ -2761,6 +2758,10 @@ static int phy_probe(struct device *dev) phydev->state = PHY_READY; out: + /* Assert the reset signal */ + if (err) + phy_device_reset(phydev, 1); + mutex_unlock(&phydev->lock); return err; @@ -2779,12 +2780,12 @@ static int phy_remove(struct device *dev) sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus = NULL; - if (phydev->drv && phydev->drv->remove) { + if (phydev->drv && phydev->drv->remove) phydev->drv->remove(phydev); - /* Assert the reset signal */ - phy_device_reset(phydev, 1); - } + /* Assert the reset signal */ + phy_device_reset(phydev, 1); + phydev->drv = NULL; return 0; From patchwork Mon Jun 22 09:37:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B45C9C433E0 for ; Mon, 22 Jun 2020 09:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 934B120720 for ; Mon, 22 Jun 2020 09:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="A0YsIPLN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbgFVJm6 (ORCPT ); Mon, 22 Jun 2020 05:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbgFVJlg (ORCPT ); Mon, 22 Jun 2020 05:41:36 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B64C061796 for ; Mon, 22 Jun 2020 02:41:35 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id g18so6882344wrm.2 for ; Mon, 22 Jun 2020 02:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GfxRtzTQEG/5B2vcAI0+WR3x7R55kmvGCSrvKLTEK2Q=; b=A0YsIPLNyYjq0ssEvXKicqSfckLBHv0GVryALC9d+AV98+m0KCKKpxY0AwyeTaC/SV 4ewNSwSYjUQsP4yxHm8UWF9gryWmZ5NreLHL6eNRWjMmIjJRCWiNutTjs4Dj5nQbR/al xKYExJnhmZzF3ijNBmLN0+9cPyr9XfVrG4iIqj5hbRDxQ5onbhon50y62e0SSGhWhkuw rmocxlBQDpuSpCL4KghX633TaDScTSjnEqyd5R5g43WJlC81zN4EIN3Bn8mQId8I8MeF 8+2wsc96b1npN8idQoXobDeawhU/GfrNBYEANPkdYosOat1y3XLGX18/UsW4P4z0HqDS YNGA== 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:mime-version:content-transfer-encoding; bh=GfxRtzTQEG/5B2vcAI0+WR3x7R55kmvGCSrvKLTEK2Q=; b=mn9ggnO5KshHCI2pPw5FZyg+jzHZ8vb7bfqdS8sZsJNn6B55VInsxdguRBZz2sEzlT PrnBOeQnAixCCw6MM5GkQMQDPIV0LBTKE4p38LZtmVZBSGHbGeqX4yMEsKwk3bE7Mb/z b/uHWefGHzesfZ14Djuf9riN0KqHBEN96qV+lD1nTEhaPs9UFWv2BdlfoxUSXj26Y/ex +oBUHsYt72iccyXAYi09c58G1GwPrCT+B5UpGlUsil3Z9fa+2MVUV8h3voM5kHZEQtWf sQyVJ4pIxlQlMfApwwwVmkh008uRL212+dDcYMupp7TddODG/r6L6oSUFet6JUV8l2C4 6ibw== X-Gm-Message-State: AOAM533GPE3h/3ASU+4mL4QclhAyPDYE0yKuk2/KV2yd7KsvyJNiLS2z nlF6QvGfwsBPNXiB2CR8/j1/Uw== X-Google-Smtp-Source: ABdhPJwe0PlqLfQqK/nfnfTmRDAPWRDDBJzvm26MZsgDYSHOQIM+GwOvMWfHdMQjezh7QNqFssNhEA== X-Received: by 2002:a5d:4bd2:: with SMTP id l18mr400661wrt.119.1592818894547; Mon, 22 Jun 2020 02:41:34 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:34 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 07/15] net: phy: split out the PHY driver request out of phy_device_create() Date: Mon, 22 Jun 2020 11:37:36 +0200 Message-Id: <20200622093744.13685-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski Move the code requesting the PHY driver module out of phy_device_create() into a separate helper. This will be later reused when we delay the module loading. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/phy_device.c | 71 ++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f6985db08340..8037a9663a85 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -558,7 +558,7 @@ static const struct device_type mdio_bus_phy_type = { .pm = MDIO_BUS_PHY_PM_OPS, }; -static int phy_request_driver_module(struct phy_device *dev, u32 phy_id) +static int phy_do_request_driver_module(struct phy_device *dev, u32 phy_id) { int ret; @@ -578,6 +578,40 @@ static int phy_request_driver_module(struct phy_device *dev, u32 phy_id) return 0; } +static int phy_request_driver_module(struct phy_device *phydev) +{ + int ret; + + /* Request the appropriate module unconditionally; don't + * bother trying to do so only if it isn't already loaded, + * because that gets complicated. A hotplug event would have + * done an unconditional modprobe anyway. + * We don't do normal hotplug because it won't work for MDIO + * -- because it relies on the device staying around for long + * enough for the driver to get loaded. With MDIO, the NIC + * driver will get bored and give up as soon as it finds that + * there's no driver _already_ loaded. + */ + if (phydev->is_c45) { + const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); + int i; + + for (i = 1; i < num_ids; i++) { + if (phydev->c45_ids.device_ids[i] == 0xffffffff) + continue; + + ret = phy_do_request_driver_module(phydev, + phydev->c45_ids.device_ids[i]); + if (ret) + break; + } + } else { + ret = phy_do_request_driver_module(phydev, phydev->phy_id); + } + + return ret; +} + struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids) @@ -622,38 +656,11 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, mutex_init(&dev->lock); INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); + device_initialize(&mdiodev->dev); - /* Request the appropriate module unconditionally; don't - * bother trying to do so only if it isn't already loaded, - * because that gets complicated. A hotplug event would have - * done an unconditional modprobe anyway. - * We don't do normal hotplug because it won't work for MDIO - * -- because it relies on the device staying around for long - * enough for the driver to get loaded. With MDIO, the NIC - * driver will get bored and give up as soon as it finds that - * there's no driver _already_ loaded. - */ - if (is_c45 && c45_ids) { - const int num_ids = ARRAY_SIZE(c45_ids->device_ids); - int i; - - for (i = 1; i < num_ids; i++) { - if (c45_ids->device_ids[i] == 0xffffffff) - continue; - - ret = phy_request_driver_module(dev, - c45_ids->device_ids[i]); - if (ret) - break; - } - } else { - ret = phy_request_driver_module(dev, phy_id); - } - - if (!ret) { - device_initialize(&mdiodev->dev); - } else { - kfree(dev); + ret = phy_request_driver_module(dev); + if (ret) { + phy_device_free(dev); dev = ERR_PTR(ret); } From patchwork Mon Jun 22 09:37:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07F74C433E0 for ; Mon, 22 Jun 2020 09:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D419C2074D for ; Mon, 22 Jun 2020 09:42:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="16VBF2La" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgFVJmg (ORCPT ); Mon, 22 Jun 2020 05:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgFVJlj (ORCPT ); Mon, 22 Jun 2020 05:41:39 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9FCC061797 for ; Mon, 22 Jun 2020 02:41:39 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id a6so13984321wrm.4 for ; Mon, 22 Jun 2020 02:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iUydfUf825zuTrP/3rZhTozCzOm5XJhrM7EVYTY3Zy4=; b=16VBF2LawpzpJUoGplW1VMeRQBY+6kIReg/qh3Of8JJozgK7KV3a/y36LFnx7JJaGG +hsOoIVXR9n9Bwou+9lQTjVGf6VkErBZk56xecuHPO9LNdA3N6A87+7oJpGaJZr91+Ep BI6yveOiwM810Bvvg/LZCi0sL3+aPo8rBLYFEgvj1FYJqgvMM+hLxuy3zExLOJZWyH7g i9vpiSlC5Y0qhPNWicv+/56I51GI/LMpey2/OgWMvENvikCSExdgLe04MjH5nquwHbgt vxVipAPH8T2Nok3B4y9B9ucBQNKyRuG9bYn8DcPmhCNY+VwarjwpEe+1IYtpzERMpzWD 8lyQ== 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:mime-version:content-transfer-encoding; bh=iUydfUf825zuTrP/3rZhTozCzOm5XJhrM7EVYTY3Zy4=; b=oXdras+0KQpD7Zt0CUINVlG/eWIzyn7HQ7AlooDJB8M1K1tNKv0CuV1U6ksKCx5Acb fIjhTM2YiuZWGvwFUcOgVpWysu/XM9I3Ly13QOzt83VAdKKy9lUuBh8yMZXyS0rCk5fz z26sEAFuahIXJcwde2eL/Mtq+tP7B8arcslJ0HcZkEYOLyHn802GPRKbgNmnhoS/B5OC 2geV8sotZPONmJPUaldpxAtZQzPsJ3P06FrQs1JI7MNEcZF5ldlbOsrdLXVkj/7O2wTl PR1pSXq1w6y8rNxsSQJCRKEuWfF3o0THQgVMnx1XtXiMqxbVF+yu2QaD9BS9aDAH12gp n71g== X-Gm-Message-State: AOAM5327rO5EAu92DriJRmsq3PJRKgR2JgX42todYpnjrHx9uLt3jWu/ gpDBQsmYts6H2xBOsoC3LycHbg== X-Google-Smtp-Source: ABdhPJw/YDc8BRLdz6R7EQpjrH3iix+fo/75QLcqChmbsRSUxGbc0J2kOfOhJKAo3W+XevgouG/a8A== X-Received: by 2002:adf:8168:: with SMTP id 95mr17445453wrm.104.1592818898066; Mon, 22 Jun 2020 02:41:38 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:37 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 09/15] net: phy: delay PHY driver probe until PHY registration Date: Mon, 22 Jun 2020 11:37:38 +0200 Message-Id: <20200622093744.13685-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski Currently the PHY ID is read without taking the PHY out of reset. This can only work if no resets are defined. This change delays the ID read until we're actually registering the PHY device - this is needed because earlier (when creating the device) we don't have a struct device yet with resets already configured. While we could use the of_ helpers for GPIO and resets, we will be adding PHY regulator support layer on and there are no regulator APIs that work without struct device. This means that phy_device_create() now only instantiates the device but doesn't request the relevant driver. If no phy_id is passed to phy_device_create() (for that we introduce a new define: PHY_ID_NONE) then the ID will be read inside phy_device_register(). Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/phy_device.c | 47 +++++++++++++++++++----------------- include/linux/phy.h | 1 + 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index eccbf6aea63d..94944fffa9bb 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -658,12 +658,6 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); device_initialize(&mdiodev->dev); - ret = phy_request_driver_module(dev); - if (ret) { - phy_device_free(dev); - dev = ERR_PTR(ret); - } - return dev; } EXPORT_SYMBOL(phy_device_create); @@ -813,30 +807,29 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id, return 0; } +static int phy_device_read_id(struct phy_device *phydev) +{ + struct mdio_device *mdiodev = &phydev->mdio; + + phydev->c45_ids.devices_in_package = 0; + memset(phydev->c45_ids.device_ids, 0xff, + sizeof(phydev->c45_ids.device_ids)); + + return get_phy_id(mdiodev->bus, mdiodev->addr, &phydev->phy_id, + phydev->is_c45, &phydev->c45_ids); +} + /** - * get_phy_device - reads the specified PHY device and returns its @phy_device - * struct + * get_phy_device - create a phy_device withoug PHY ID * @bus: the target MII bus * @addr: PHY address on the MII bus * @is_c45: If true the PHY uses the 802.3 clause 45 protocol * - * Description: Reads the ID registers of the PHY at @addr on the - * @bus, then allocates and returns the phy_device to represent it. + * Allocates a new phy_device for @addr on the @bus. */ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) { - struct phy_c45_device_ids c45_ids; - u32 phy_id = 0; - int r; - - c45_ids.devices_in_package = 0; - memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids)); - - r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids); - if (r) - return ERR_PTR(r); - - return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids); + return phy_device_create(bus, addr, PHY_ID_NONE, is_c45, NULL); } EXPORT_SYMBOL(get_phy_device); @@ -855,6 +848,16 @@ int phy_device_register(struct phy_device *phydev) /* Deassert the reset signal */ phy_device_reset(phydev, 0); + if (phydev->phy_id == PHY_ID_NONE) { + err = phy_device_read_id(phydev); + if (err) + goto err_unregister_mdio; + } + + err = phy_request_driver_module(phydev); + if (err) + goto err_unregister_mdio; + /* Run all of the fixups for this PHY */ err = phy_scan_fixups(phydev); if (err) { diff --git a/include/linux/phy.h b/include/linux/phy.h index 8c05d0fb5c00..2a695cd90c7c 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -742,6 +742,7 @@ struct phy_driver { #define PHY_ANY_ID "MATCH ANY PHY" #define PHY_ANY_UID 0xffffffff +#define PHY_ID_NONE 0 #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0) #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4) From patchwork Mon Jun 22 09:37:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59DEFC433E0 for ; Mon, 22 Jun 2020 09:41:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AF8F20738 for ; Mon, 22 Jun 2020 09:41:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="nHZDq84v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbgFVJlo (ORCPT ); Mon, 22 Jun 2020 05:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727771AbgFVJlo (ORCPT ); Mon, 22 Jun 2020 05:41:44 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27578C061798 for ; Mon, 22 Jun 2020 02:41:43 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id g21so10586437wmg.0 for ; Mon, 22 Jun 2020 02:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l2sxOAERFa0J25cQccVz8/lQJT3JNRbkHzrHyMtlOx8=; b=nHZDq84vKrJqy5xXpj2+rJ5h5VIM3n4oN76Uizc9jBhIW16xOrH3B0Km9mgWsk8Lu6 yvA1XNXVkC07+Pg/8MKlE82O8Zr8pe+ZvkBUKPDwUpNwKEh7ddGCtrK03jbkSOhkA97n 64Op9mOQmTRVdF209L3WgAXdk3JQpz6prmFcnirM5Mh85gqh4wj4HfX8Dj95q3jZ4lEF /r+V+9jWRk4x4oJaqpBir5uBrXH2h5nhtFaRbptwV37IBb0FqLh8jpU7Qs3q7UwE/NC6 FhTF3jLXUrGYuZgpSgC5QM7D/g7YPowxLmIGSyrPG0S+JZ6ohlL8NFMJuPMP9exEStSR efPw== 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:mime-version:content-transfer-encoding; bh=l2sxOAERFa0J25cQccVz8/lQJT3JNRbkHzrHyMtlOx8=; b=D1XMH3BZrwILcavBooiLN57EDCbjN0vJExRxTjvzKxNnE/vnQ8k86s84c2gdq0/FOw oXyeXxh4gUWf72Z4SVUNUGpwr7t43ToTFP/jh2nzGmrYV73OJ4fMQRjzAQ/Bhpo8sIAg 1FMgdITJODfPc6J+YtXbPzzaRnv00fslU4I4GuDY+gRC4qWFlzHpzRvwDbJrm/inzAsu rx8kR7rVtM8cGfnd0znfz1xrk9t/OctjBgVO8/DjxCBxfducju0GoiuOQm4oavohAqkD U6NSTcmQ/BmKKPXd9vPgqwa1Y9U5Qb1rHfCYOyhLgPGziaZLGQOrwMedlty8E4YZPGEr fjdw== X-Gm-Message-State: AOAM533AKZ5Xl6Fpjyj9Idc7tJRrYSwhf/WOGeUbxyNKirPgy8nczhpP HDwnUxeoDZG0zx8OLh1HwNm9fw== X-Google-Smtp-Source: ABdhPJzJR6KO8zeK/627bqE1LbuigMS0KsI1hp+YnRpdEX+tkt6lyQYjVo/pPkpTRjLvTnpZhm+r2Q== X-Received: by 2002:a7b:c156:: with SMTP id z22mr16903035wmi.43.1592818901772; Mon, 22 Jun 2020 02:41:41 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:41 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 11/15] net: phy: drop get_phy_device() Date: Mon, 22 Jun 2020 11:37:40 +0200 Message-Id: <20200622093744.13685-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski get_phy_device() has now become just a wrapper for phy_device_create() with the phy_id argument set to PHY_ID_NONE. Let's remove this function treewide and replace it with opencoded phy_device_create(). This has the advantage of being more explicit about the PHY not having the ID set when being created. Signed-off-by: Bartosz Golaszewski --- drivers/net/dsa/ocelot/felix_vsc9959.c | 3 ++- drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 5 +++-- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- drivers/net/ethernet/socionext/netsec.c | 3 ++- drivers/net/phy/fixed_phy.c | 2 +- drivers/net/phy/mdio-xgene.c | 2 +- drivers/net/phy/mdio_bus.c | 2 +- drivers/net/phy/phy_device.c | 14 -------------- drivers/net/phy/sfp.c | 2 +- drivers/of/of_mdio.c | 11 +++++++---- include/linux/phy.h | 7 ------- 11 files changed, 19 insertions(+), 34 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 1dd9e348152d..40c868382e03 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1183,7 +1183,8 @@ static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_USXGMII) is_c45 = true; - pcs = get_phy_device(felix->imdio, port, is_c45); + pcs = phy_device_create(felix->imdio, port, + PHY_ID_NONE, is_c45); if (IS_ERR(pcs)) continue; diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c index 46c3c1ca38d6..1117ed468abf 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c @@ -1017,8 +1017,9 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) } /* Create and connect to the PHY device */ - phydev = get_phy_device(phy_data->mii, phy_data->mdio_addr, - (phy_data->phydev_mode == XGBE_MDIO_MODE_CL45)); + phydev = phy_device_create(phy_data->mii, phy_data->mdio_addr, + PHY_ID_NONE, + phy_data->phydev_mode == XGBE_MDIO_MODE_CL45); if (IS_ERR(phydev)) { netdev_err(pdata->netdev, "get_phy_device failed\n"); return -ENODEV; diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c index 9a907947ba19..75fa6a855727 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c @@ -703,7 +703,7 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb, else return -ENODATA; - phy = get_phy_device(mdio, addr, is_c45); + phy = phy_device_create(mdio, addr, PHY_ID_NONE, is_c45); if (!phy || IS_ERR(phy)) return -EIO; diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 328bc38848bb..48c405d81000 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -1935,7 +1935,8 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) return ret; } - priv->phydev = get_phy_device(bus, phy_addr, false); + priv->phydev = phy_device_create(bus, phy_addr, + PHY_ID_NONE, false); if (IS_ERR(priv->phydev)) { ret = PTR_ERR(priv->phydev); dev_err(priv->dev, "get_phy_device err(%d)\n", ret); diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c index c4641b1704d6..9019f0035ef0 100644 --- a/drivers/net/phy/fixed_phy.c +++ b/drivers/net/phy/fixed_phy.c @@ -254,7 +254,7 @@ static struct phy_device *__fixed_phy_register(unsigned int irq, return ERR_PTR(ret); } - phy = get_phy_device(fmb->mii_bus, phy_addr, false); + phy = phy_device_create(fmb->mii_bus, phy_addr, PHY_ID_NONE, false); if (IS_ERR(phy)) { fixed_phy_del(phy_addr); return ERR_PTR(-EINVAL); diff --git a/drivers/net/phy/mdio-xgene.c b/drivers/net/phy/mdio-xgene.c index 34990eaa3298..6698e7caaf78 100644 --- a/drivers/net/phy/mdio-xgene.c +++ b/drivers/net/phy/mdio-xgene.c @@ -264,7 +264,7 @@ struct phy_device *xgene_enet_phy_register(struct mii_bus *bus, int phy_addr) { struct phy_device *phy_dev; - phy_dev = get_phy_device(bus, phy_addr, false); + phy_dev = phy_device_create(bus, phy_addr, PHY_ID_NONE, false); if (!phy_dev || IS_ERR(phy_dev)) return NULL; diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 296cf9771483..53e2fb0be7b9 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -742,7 +742,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) struct phy_device *phydev; int err; - phydev = get_phy_device(bus, addr, false); + phydev = phy_device_create(bus, addr, PHY_ID_NONE, false); if (IS_ERR(phydev)) return phydev; diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index ad7c4cd9d357..58923826838b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -817,20 +817,6 @@ static int phy_device_read_id(struct phy_device *phydev) phydev->is_c45, &phydev->c45_ids); } -/** - * get_phy_device - create a phy_device withoug PHY ID - * @bus: the target MII bus - * @addr: PHY address on the MII bus - * @is_c45: If true the PHY uses the 802.3 clause 45 protocol - * - * Allocates a new phy_device for @addr on the @bus. - */ -struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) -{ - return phy_device_create(bus, addr, PHY_ID_NONE, is_c45); -} -EXPORT_SYMBOL(get_phy_device); - /** * phy_device_register - Register the phy device on the MDIO bus * @phydev: phy_device structure to be added to the MDIO bus diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 73c2969f11a4..0b165d928762 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1431,7 +1431,7 @@ static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45) struct phy_device *phy; int err; - phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45); + phy = phy_device_create(sfp->i2c_mii, SFP_PHY_ADDR, PHY_ID_NONE, is_c45); if (phy == ERR_PTR(-ENODEV)) return PTR_ERR(phy); if (IS_ERR(phy)) { diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 63843037673c..af576d056e45 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -120,10 +120,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, is_c45 = of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"); - if (!is_c45 && !of_get_phy_id(child, &phy_id)) - phy = phy_device_create(mdio, addr, phy_id, 0); - else - phy = get_phy_device(mdio, addr, is_c45); + if (!is_c45) { + rc = of_get_phy_id(child, &phy_id); + if (rc) + phy_id = PHY_ID_NONE; + } + + phy = phy_device_create(mdio, addr, phy_id, is_c45); if (IS_ERR(phy)) { if (mii_ts) unregister_mii_timestamper(mii_ts); diff --git a/include/linux/phy.h b/include/linux/phy.h index 662919c1dd27..01d24a934ad1 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1215,16 +1215,9 @@ int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum, struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45); #if IS_ENABLED(CONFIG_PHYLIB) -struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else -static inline -struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) -{ - return NULL; -} - static inline int phy_device_register(struct phy_device *phy) { return 0; From patchwork Mon Jun 22 09:37:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B38DEC433DF for ; Mon, 22 Jun 2020 09:42:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FAE720732 for ; Mon, 22 Jun 2020 09:42:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="fwhLeGUT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbgFVJmN (ORCPT ); Mon, 22 Jun 2020 05:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbgFVJlp (ORCPT ); Mon, 22 Jun 2020 05:41:45 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD50AC061797 for ; Mon, 22 Jun 2020 02:41:44 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id a6so4109157wmm.0 for ; Mon, 22 Jun 2020 02:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H6LOSRZxGizpxzfF22Sv14N1k+l2XBln54kSc7WXTbU=; b=fwhLeGUTHzaOn5r0hKFAxOrI/4bP6cRMLAZ9vxuMsWmVTbLCLBfuv2c3zx2K+9WkzC 4510agGDHbhXy4FxLo2y6wSgQ64p20rVWdVPiqvbTzNx3rKJ0wAQIRkSuhTdzUPDyq33 EGJ7dP781SaoA69mOAe2VG//Mj+PraeucVuHaZFWBoluRKQxOPm81fI00ykep20zlmSB RPZYYFefMuTBJhmo6T+gCbA2sk4rO/dFZ8SsuCQmoiiBtm5IHQMXEHE2Tj3zbDGXmqd+ 33R1jARght4O0k5GCattCXLy0yW2yV908NCQr9OgF+g3eygrEUkhQhtDWFMWiBtAcU50 OBog== 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:mime-version:content-transfer-encoding; bh=H6LOSRZxGizpxzfF22Sv14N1k+l2XBln54kSc7WXTbU=; b=Yh1NPwg2x+wXN/OPwznyDEkfMwIokWnvnKx0+up4w5FeTwaTxJKc8EkjnX/mXqshvX PFm6ihbqyiT5mH94WUkbXcUwS00PwftvFvt1d489RuwvXpWL84y2cHzFPQA7ZXgurghp xqz/buK6uAJqhh0mbLvPZYuUb6LZcrdg5UaN2DaQDsKWW2kkJkdz2Dft/8o1Csq0f9/Y gPWNHSJ5JyRy8mEQHHVkFkLFypqqW4RVOvJqJyf1du3HlErI9o5Gwes88b075yynRz2B 8iLeExbcEB1Xkcxbl78IKuI2oW7yBH+g2XhqIiA0Xv0ZZq+LH+jHwEAUxAsn4w9tofVS Dd6A== X-Gm-Message-State: AOAM533HoKzjzxBTIA6ekWoRbRYOzkUU2kxM9Bev9xsx4FKA1QEgovEZ r8ohJwW4BTLeZFVLSZY1F8Be0w== X-Google-Smtp-Source: ABdhPJxKaZTzwaRgXjyD3lQOmmZEDuZrxf5WMvWd8aJTlxKoe6V5StaOUPB2OradOOO/ubvV2pVenA== X-Received: by 2002:a1c:1fd1:: with SMTP id f200mr17253456wmf.162.1592818903618; Mon, 22 Jun 2020 02:41:43 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:43 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 12/15] dt-bindings: mdio: add phy-supply property to ethernet phy node Date: Mon, 22 Jun 2020 11:37:41 +0200 Message-Id: <20200622093744.13685-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski The phy-supply property is often added to MAC nodes but this is wrong conceptually. These supplies should be part of the PHY node on the MDIO bus. Add phy-supply property at PHY level to mdio.yaml. Signed-off-by: Bartosz Golaszewski --- Documentation/devicetree/bindings/net/mdio.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml index d6a3bf8550eb..9c10012c2093 100644 --- a/Documentation/devicetree/bindings/net/mdio.yaml +++ b/Documentation/devicetree/bindings/net/mdio.yaml @@ -90,6 +90,10 @@ patternProperties: Delay after the reset was deasserted in microseconds. If this property is missing the delay will be skipped. + phy-supply: + description: + Phandle to the regulator that provides the supply voltage to the PHY. + required: - reg From patchwork Mon Jun 22 09:37:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 198693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E17C3C433E1 for ; Mon, 22 Jun 2020 09:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2EAE2071A for ; Mon, 22 Jun 2020 09:41:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="rox8r/P9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbgFVJlu (ORCPT ); Mon, 22 Jun 2020 05:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727809AbgFVJlu (ORCPT ); Mon, 22 Jun 2020 05:41:50 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E24C061797 for ; Mon, 22 Jun 2020 02:41:48 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id l17so14221660wmj.0 for ; Mon, 22 Jun 2020 02:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=39tcT1sImiChTRqBAQCitq8OvfITErWq/Xk+xRkWTtw=; b=rox8r/P9m0M75MrSrW0gaefUbBrzsyQiQQ+nuSUyw7jmgK72RdIrEAET+9NDW80nJV 6NoN3fQgrn8u3TAuYWY9vEZmFhT+PYmy+pixzcxBMoxFYd2WlDCvoisyxCnl9XIvgl4L 2UaUBXGdTuKrvDtQtBHE5L7odP4nDBB7nbDPbFnH6FoanY0lq1FWTQXI+whJq1jJA2hU Ot3SzrgslqAj4dfBjZPmBbOgClucsuSk5FJIDeFu2gEMTSGwLi4/f1DXekQJh5ClPfdx IiB0mjGPZS7Om5sXsEMBsr/HJQuJgLUO0T+W94WaGsZzXwZOeddJTllPhKS2Nil1ZvIb szOQ== 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:mime-version:content-transfer-encoding; bh=39tcT1sImiChTRqBAQCitq8OvfITErWq/Xk+xRkWTtw=; b=bnq6BrvNC0dNnPnKNq+JbFDCFVhbzl7J8a+DtCc7gFVb2xbjAHV58dpZ0Tv8vGh24R +1McllMWP8yR8myDlYhhA8TRzYG0XwYfXczVEQ00hz5evutjzsGIwo4HF4xdwrviQk4l lzoH4DIajaYMFq6a1VUJKVx+nXFp6E4VvJn908Fh3BklexBUiYFADfXmCVSo3UaRtZ/N J34hmO7g0r7FajVWI0m/z8kmd9xylkWvs96y+cHm22H/v6B/S2m2pWpJvfWRGCAoZ9b7 f+z513b7YYMRFhXWlXQ+YfrvheDReDdguhRxHXJjdp7EksFYhz+a/h46MNn45JOgbxWX yH5w== X-Gm-Message-State: AOAM53234seGg6l4fW6ilwyEc9PVqAXVqdhUSlpKGgnKnPgfoMDi0wWo N+dywlEw43dxHekpDYk8XhWhoQ== X-Google-Smtp-Source: ABdhPJxuZnlfHnNwpXMmEqVCYAbLPujZmk1SV/mDkcx4Z73yrAJcet27yegyTxUrUHZ6wyfJf9ZIqA== X-Received: by 2002:a1c:2d54:: with SMTP id t81mr18695221wmt.154.1592818907355; Mon, 22 Jun 2020 02:41:47 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id j24sm14392652wrd.43.2020.06.22.02.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 02:41:46 -0700 (PDT) From: Bartosz Golaszewski To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Rob Herring , Matthias Brugger , Microchip Linux Driver Support , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , Vivien Didelot , Tom Lendacky , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Frank Rowand , Philipp Zabel , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH 14/15] net: phy: add PHY regulator support Date: Mon, 22 Jun 2020 11:37:43 +0200 Message-Id: <20200622093744.13685-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200622093744.13685-1-brgl@bgdev.pl> References: <20200622093744.13685-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Bartosz Golaszewski The MDIO sub-system now supports PHY regulators. Let's reuse the code to extend this support over to the PHY device. Signed-off-by: Bartosz Golaszewski --- drivers/net/phy/phy_device.c | 49 ++++++++++++++++++++++++++++-------- include/linux/phy.h | 10 ++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 58923826838b..d755adb748a5 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -827,7 +827,12 @@ int phy_device_register(struct phy_device *phydev) err = mdiobus_register_device(&phydev->mdio); if (err) - return err; + goto err_out; + + /* Enable the PHY regulator */ + err = phy_device_power_on(phydev); + if (err) + goto err_unregister_mdio; /* Deassert the reset signal */ phy_device_reset(phydev, 0); @@ -846,22 +851,25 @@ int phy_device_register(struct phy_device *phydev) err = phy_scan_fixups(phydev); if (err) { phydev_err(phydev, "failed to initialize\n"); - goto out; + goto err_reset; } err = device_add(&phydev->mdio.dev); if (err) { phydev_err(phydev, "failed to add\n"); - goto out; + goto err_reset; } return 0; - out: +err_reset: /* Assert the reset signal */ phy_device_reset(phydev, 1); - + /* Disable the PHY regulator */ + phy_device_power_off(phydev); +err_unregister_mdio: mdiobus_unregister_device(&phydev->mdio); +err_out: return err; } EXPORT_SYMBOL(phy_device_register); @@ -883,6 +891,8 @@ void phy_device_remove(struct phy_device *phydev) /* Assert the reset signal */ phy_device_reset(phydev, 1); + /* Disable the PHY regulator */ + phy_device_power_off(phydev); mdiobus_unregister_device(&phydev->mdio); } @@ -1064,6 +1074,11 @@ int phy_init_hw(struct phy_device *phydev) { int ret = 0; + /* Enable the PHY regulator */ + ret = phy_device_power_on(phydev); + if (ret) + return ret; + /* Deassert the reset signal */ phy_device_reset(phydev, 0); @@ -1644,6 +1659,8 @@ void phy_detach(struct phy_device *phydev) /* Assert the reset signal */ phy_device_reset(phydev, 1); + /* Disable the PHY regulator */ + phy_device_power_off(phydev); } EXPORT_SYMBOL(phy_detach); @@ -2684,13 +2701,18 @@ static int phy_probe(struct device *dev) mutex_lock(&phydev->lock); + /* Enable the PHY regulator */ + err = phy_device_power_on(phydev); + if (err) + goto out; + /* Deassert the reset signal */ phy_device_reset(phydev, 0); if (phydev->drv->probe) { err = phydev->drv->probe(phydev); if (err) - goto out; + goto out_reset; } /* Start out supporting everything. Eventually, @@ -2708,7 +2730,7 @@ static int phy_probe(struct device *dev) } if (err) - goto out; + goto out_reset; if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported)) @@ -2751,11 +2773,16 @@ static int phy_probe(struct device *dev) /* Set the state to READY by default */ phydev->state = PHY_READY; -out: - /* Assert the reset signal */ - if (err) - phy_device_reset(phydev, 1); + mutex_unlock(&phydev->lock); + + return 0; +out_reset: + /* Assert the reset signal */ + phy_device_reset(phydev, 1); + /* Disable the PHY regulator */ + phy_device_power_off(phydev); +out: mutex_unlock(&phydev->lock); return err; diff --git a/include/linux/phy.h b/include/linux/phy.h index 01d24a934ad1..585ce8db32cf 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1291,6 +1291,16 @@ static inline void phy_device_reset(struct phy_device *phydev, int value) mdio_device_reset(&phydev->mdio, value); } +static inline int phy_device_power_on(struct phy_device *phydev) +{ + return mdio_device_power_on(&phydev->mdio); +} + +static inline int phy_device_power_off(struct phy_device *phydev) +{ + return mdio_device_power_off(&phydev->mdio); +} + #define phydev_err(_phydev, format, args...) \ dev_err(&_phydev->mdio.dev, format, ##args)