From patchwork Mon Jul 15 15:34:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 2827666 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3DD33C0AB2 for ; Mon, 15 Jul 2013 17:04:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 094CE20278 for ; Mon, 15 Jul 2013 17:04:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 90FD92008F for ; Mon, 15 Jul 2013 17:04:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UykrJ-0005Qj-Uy; Mon, 15 Jul 2013 15:38:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UykoM-0000DY-U6; Mon, 15 Jul 2013 15:35:39 +0000 Received: from mail.free-electrons.com ([94.23.35.102]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UyknS-000061-6C for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2013 15:34:44 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 95767BAE; Mon, 15 Jul 2013 17:34:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 042257CC; Mon, 15 Jul 2013 17:34:12 +0200 (CEST) From: Thomas Petazzoni To: Grant Likely , Rob Herring , "David S. Miller" , Florian Fainelli Subject: [RFC PATCH 1/3] of: provide a binding for the 'fixed-link' property Date: Mon, 15 Jul 2013 17:34:08 +0200 Message-Id: <1373902450-11857-2-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1373902450-11857-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1373902450-11857-1-git-send-email-thomas.petazzoni@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130715_113442_619593_6C56ECFE X-CRM114-Status: GOOD ( 18.40 ) X-Spam-Score: -2.3 (--) Cc: Lior Amsalem , netdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Ezequiel Garcia , Gregory Clement , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Some Ethernet MACs have a "fixed link", and are not connected to a normal MDIO-managed PHY device. For those situations, a Device Tree binding allows to describe a "fixed link", as a "fixed-link" property of the Ethernet device Device Tree node. This patch adds: * A documentation for the Device Tree property "fixed-link". * A of_phy_register_fixed_link() OF helper, which provided an OF node that contains a "fixed-link" property, registers the corresponding fixed PHY. * Removes the warning on the of_phy_connect_fixed_link() that says new drivers should not use it, since Grant Likely indicated that this "fixed-link" property is indeed the way to go. Signed-off-by: Thomas Petazzoni --- .../devicetree/bindings/net/fixed-link.txt | 26 ++++++++++++++++ drivers/of/of_mdio.c | 36 +++++++++++++++++++--- include/linux/of_mdio.h | 10 ++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/fixed-link.txt diff --git a/Documentation/devicetree/bindings/net/fixed-link.txt b/Documentation/devicetree/bindings/net/fixed-link.txt new file mode 100644 index 0000000..25a009a --- /dev/null +++ b/Documentation/devicetree/bindings/net/fixed-link.txt @@ -0,0 +1,26 @@ +Fixed link Device Tree binding +------------------------------ + +Some Ethernet MACs have a "fixed link", and are not connected to a +normal MDIO-managed PHY device. For those situations, a Device Tree +binding allows to describe a "fixed link". + +Such a fixed link situation is described within an Ethernet device +Device Tree node using a 'fixed-link' property, composed of 5 +elements: + + 1. A fake PHY ID, which must be unique accross all fixed-link PHYs in + the system. + 2. The duplex (1 for full-duplex, 0 for half-duplex) + 3. The speed (10, 100, 1000) + 4. The pause setting (1 for enabled, 0 for disabled) + 5. The asym pause setting (1 for enabled, 0 for disabled) + +Example: + +ethernet@0 { + ... + fixed-link = <1 1 1000 0 0>; + ... +}; + diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index d5a57a9..66d5591 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -215,10 +216,6 @@ EXPORT_SYMBOL(of_phy_connect); * @dev: pointer to net_device claiming the phy * @hndlr: Link state callback for the network device * @iface: PHY data interface type - * - * This function is a temporary stop-gap and will be removed soon. It is - * only to support the fs_enet, ucc_geth and gianfar Ethernet drivers. Do - * not call this function from new drivers. */ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, void (*hndlr)(struct net_device *), @@ -247,3 +244,34 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, return IS_ERR(phy) ? NULL : phy; } EXPORT_SYMBOL(of_phy_connect_fixed_link); + +#if defined(CONFIG_FIXED_PHY) +/** + * of_phy_register_fixed_link - Parse fixed-link property and register a dummy phy + * @np: pointer to the OF device node that contains the "fixed-link" + * property for which a dummy phy should be registered. + */ +#define FIXED_LINK_PROPERTIES_COUNT 5 +int of_phy_register_fixed_link(struct device_node *np) +{ + struct fixed_phy_status status = {}; + u32 fixed_link_props[FIXED_LINK_PROPERTIES_COUNT]; + int ret; + + ret = of_property_read_u32_array(np, "fixed-link", + fixed_link_props, + FIXED_LINK_PROPERTIES_COUNT); + if (ret < 0) + return ret; + + status.link = 1; + status.duplex = fixed_link_props[1]; + status.speed = fixed_link_props[2]; + status.pause = fixed_link_props[3]; + status.asym_pause = fixed_link_props[4]; + + return fixed_phy_add(PHY_POLL, fixed_link_props[0], + &status); +} +EXPORT_SYMBOL(of_phy_register_fixed_link); +#endif diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index 8163107..bf6efea 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h @@ -57,4 +57,14 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np) } #endif /* CONFIG_OF */ +#if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) +extern int of_phy_register_fixed_link(struct device_node *np); +#else +static inline int of_phy_register_fixed_link(struct device_node *np) +{ + return -ENOSYS; +} +#endif + + #endif /* __LINUX_OF_MDIO_H */