developer | 394d5eb | 2023-04-14 16:46:45 +0800 | [diff] [blame^] | 1 | From patchwork Tue Jun 23 14:30:07 2020 |
| 2 | Content-Type: text/plain; charset="utf-8" |
| 3 | MIME-Version: 1.0 |
| 4 | Content-Transfer-Encoding: 7bit |
| 5 | X-Patchwork-Submitter: Antoine Tenart <antoine.tenart@bootlin.com> |
| 6 | X-Patchwork-Id: 1315292 |
| 7 | X-Patchwork-Delegate: davem@davemloft.net |
| 8 | Return-Path: <netdev-owner@vger.kernel.org> |
| 9 | X-Original-To: patchwork-incoming-netdev@ozlabs.org |
| 10 | Delivered-To: patchwork-incoming-netdev@ozlabs.org |
| 11 | Authentication-Results: ozlabs.org; |
| 12 | spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org |
| 13 | (client-ip=23.128.96.18; helo=vger.kernel.org; |
| 14 | envelope-from=netdev-owner@vger.kernel.org; receiver=<UNKNOWN>) |
| 15 | Authentication-Results: ozlabs.org; |
| 16 | dmarc=none (p=none dis=none) header.from=bootlin.com |
| 17 | Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) |
| 18 | by ozlabs.org (Postfix) with ESMTP id 49rpjP0BTdz9sRN |
| 19 | for <patchwork-incoming-netdev@ozlabs.org>; |
| 20 | Wed, 24 Jun 2020 00:35:37 +1000 (AEST) |
| 21 | Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand |
| 22 | id S1732957AbgFWOf1 (ORCPT |
| 23 | <rfc822;patchwork-incoming-netdev@ozlabs.org>); |
| 24 | Tue, 23 Jun 2020 10:35:27 -0400 |
| 25 | Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35381 "EHLO |
| 26 | relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org |
| 27 | with ESMTP id S1732900AbgFWOfX (ORCPT |
| 28 | <rfc822;netdev@vger.kernel.org>); Tue, 23 Jun 2020 10:35:23 -0400 |
| 29 | X-Originating-IP: 90.76.143.236 |
| 30 | Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr |
| 31 | [90.76.143.236]) |
| 32 | (Authenticated sender: antoine.tenart@bootlin.com) |
| 33 | by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 38BE860006; |
| 34 | Tue, 23 Jun 2020 14:35:19 +0000 (UTC) |
| 35 | From: Antoine Tenart <antoine.tenart@bootlin.com> |
| 36 | To: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, |
| 37 | hkallweit1@gmail.com, richardcochran@gmail.com, |
| 38 | alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com |
| 39 | Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, |
| 40 | thomas.petazzoni@bootlin.com, allan.nielsen@microchip.com, |
| 41 | foss@0leil.net, antoine.tenart@bootlin.com |
| 42 | Subject: [PATCH net-next v4 1/8] net: phy: add support for a common probe |
| 43 | between shared PHYs |
| 44 | Date: Tue, 23 Jun 2020 16:30:07 +0200 |
| 45 | Message-Id: <20200623143014.47864-2-antoine.tenart@bootlin.com> |
| 46 | X-Mailer: git-send-email 2.26.2 |
| 47 | In-Reply-To: <20200623143014.47864-1-antoine.tenart@bootlin.com> |
| 48 | References: <20200623143014.47864-1-antoine.tenart@bootlin.com> |
| 49 | MIME-Version: 1.0 |
| 50 | Sender: netdev-owner@vger.kernel.org |
| 51 | Precedence: bulk |
| 52 | List-ID: <netdev.vger.kernel.org> |
| 53 | X-Mailing-List: netdev@vger.kernel.org |
| 54 | |
| 55 | Shared PHYs (PHYs in the same hardware package) may have shared |
| 56 | registers and their drivers would usually need to share information. |
| 57 | There is currently a way to have a shared (part of the) init, by using |
| 58 | phy_package_init_once(). This patch extends the logic to share parts of |
| 59 | the probe to allow sharing the initialization of locks or resources |
| 60 | retrieval. |
| 61 | |
| 62 | Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> |
| 63 | Reviewed-by: Andrew Lunn <andrew@lunn.ch> |
| 64 | --- |
| 65 | include/linux/phy.h | 18 +++++++++++++++--- |
| 66 | 1 file changed, 15 insertions(+), 3 deletions(-) |
| 67 | |
| 68 | diff --git a/include/linux/phy.h b/include/linux/phy.h |
| 69 | index 9248dd2ce4ca..457489f1951c 100644 |
| 70 | --- a/include/linux/phy.h |
| 71 | +++ b/include/linux/phy.h |
| 72 | @@ -244,7 +244,8 @@ struct phy_package_shared { |
| 73 | }; |
| 74 | |
| 75 | /* used as bit number in atomic bitops */ |
| 76 | -#define PHY_SHARED_F_INIT_DONE 0 |
| 77 | +#define PHY_SHARED_F_INIT_DONE 0 |
| 78 | +#define PHY_SHARED_F_PROBE_DONE 1 |
| 79 | |
| 80 | /* |
| 81 | * The Bus class for PHYs. Devices which provide access to |
| 82 | @@ -1558,14 +1559,25 @@ static inline int __phy_package_write(struct phy_device *phydev, |
| 83 | return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); |
| 84 | } |
| 85 | |
| 86 | -static inline bool phy_package_init_once(struct phy_device *phydev) |
| 87 | +static inline bool __phy_package_set_once(struct phy_device *phydev, |
| 88 | + unsigned int b) |
| 89 | { |
| 90 | struct phy_package_shared *shared = phydev->shared; |
| 91 | |
| 92 | if (!shared) |
| 93 | return false; |
| 94 | |
| 95 | - return !test_and_set_bit(PHY_SHARED_F_INIT_DONE, &shared->flags); |
| 96 | + return !test_and_set_bit(b, &shared->flags); |
| 97 | +} |
| 98 | + |
| 99 | +static inline bool phy_package_init_once(struct phy_device *phydev) |
| 100 | +{ |
| 101 | + return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE); |
| 102 | +} |
| 103 | + |
| 104 | +static inline bool phy_package_probe_once(struct phy_device *phydev) |
| 105 | +{ |
| 106 | + return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE); |
| 107 | } |
| 108 | |
| 109 | extern struct bus_type mdio_bus_type; |