blob: 39b29ad286c9dc95475d78b2a44ec904b20fdc46 [file] [log] [blame]
developer394d5eb2023-04-14 16:46:45 +08001From patchwork Tue Jun 23 14:30:07 2020
2Content-Type: text/plain; charset="utf-8"
3MIME-Version: 1.0
4Content-Transfer-Encoding: 7bit
5X-Patchwork-Submitter: Antoine Tenart <antoine.tenart@bootlin.com>
6X-Patchwork-Id: 1315292
7X-Patchwork-Delegate: davem@davemloft.net
8Return-Path: <netdev-owner@vger.kernel.org>
9X-Original-To: patchwork-incoming-netdev@ozlabs.org
10Delivered-To: patchwork-incoming-netdev@ozlabs.org
11Authentication-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>)
15Authentication-Results: ozlabs.org;
16 dmarc=none (p=none dis=none) header.from=bootlin.com
17Received: 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)
21Received: (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
25Received: 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
29X-Originating-IP: 90.76.143.236
30Received: 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)
35From: Antoine Tenart <antoine.tenart@bootlin.com>
36To: 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
39Cc: 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
42Subject: [PATCH net-next v4 1/8] net: phy: add support for a common probe
43 between shared PHYs
44Date: Tue, 23 Jun 2020 16:30:07 +0200
45Message-Id: <20200623143014.47864-2-antoine.tenart@bootlin.com>
46X-Mailer: git-send-email 2.26.2
47In-Reply-To: <20200623143014.47864-1-antoine.tenart@bootlin.com>
48References: <20200623143014.47864-1-antoine.tenart@bootlin.com>
49MIME-Version: 1.0
50Sender: netdev-owner@vger.kernel.org
51Precedence: bulk
52List-ID: <netdev.vger.kernel.org>
53X-Mailing-List: netdev@vger.kernel.org
54
55Shared PHYs (PHYs in the same hardware package) may have shared
56registers and their drivers would usually need to share information.
57There is currently a way to have a shared (part of the) init, by using
58phy_package_init_once(). This patch extends the logic to share parts of
59the probe to allow sharing the initialization of locks or resources
60retrieval.
61
62Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
63Reviewed-by: Andrew Lunn <andrew@lunn.ch>
64---
65 include/linux/phy.h | 18 +++++++++++++++---
66 1 file changed, 15 insertions(+), 3 deletions(-)
67
68diff --git a/include/linux/phy.h b/include/linux/phy.h
69index 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;