From patchwork Mon Mar 30 09:27:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 1263837 X-Patchwork-Delegate: narmstrong@baylibre.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=gAXRyYBv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rRvn5Nm2z9sPR for ; Mon, 30 Mar 2020 20:28:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34923818E7; Mon, 30 Mar 2020 11:27:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="gAXRyYBv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35F5E818CF; Mon, 30 Mar 2020 11:27:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D062B8065F for ; Mon, 30 Mar 2020 11:27:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=narmstrong@baylibre.com Received: by mail-wr1-x442.google.com with SMTP id u10so20677902wro.7 for ; Mon, 30 Mar 2020 02:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EzZmmAYt6MavNnf5jh0NVmKdaimu/G7mTQnj8H8rE+Q=; b=gAXRyYBvB9NpcSC7YHQUU832rq9WpQTX6LthIqx3ivcW0xgHmceiEENFigv0NJSdI+ 2XxkS0S2DhdH5mm1kSLSI5qDachGOT+HGu8K2PFMNmavgGvjYx7zRRs3jULFLFGSkX7E crzjhSiCaTADpdq7I3qyViINzmoTW48jBXB5EQNKT96AF1IdLs/2tx4epdrH5ISQYRju ThSNBZjuswst40sDAW2HGPejQxkIevBYIgPPX4niGljIIQPxVnGY/nUZyHc6nl7XnnId QMnCFtyiX+z5J9M359Bi4M73vGu7SBUocI6io7eQrXXGusxt9+TwJUynYBNFdix3yZsT HSKQ== 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=EzZmmAYt6MavNnf5jh0NVmKdaimu/G7mTQnj8H8rE+Q=; b=og69OkMYbV0zcAIqxt/xYYMnEH5/7c35+BFUZKXnCbHO71NagzntqAFijXjF+h5qeP lC2xZhnH9C2Huu9zouFnW3ebhnS//wve1upxggnkkulf95UgCi7N/GpDj62sOCb9hE51 319pQ70K9KbxirKqYcCLkQspfDcD79IDEQRZktP5aJXA7x41Pb8ZM7bmgGyOjgHiwzbZ zh9Z5WoXKh2rKcBMMlCaCOJys6HAGW1boPCq6/YfU7x/Ku5wwgbRPCbdYhlIdkSYLv9s ZnOynZqFT8E8RcWnXbvj18g/qyVLVukeQRV/es1+a3xbzuuPi1yXemcdyrUtouABn5yd 88yA== X-Gm-Message-State: ANhLgQ2Ovp6sn+bXJLkmA0wGeK38ynTMCUHQRyFEaB0gIclULgoZCGMU hOa2iGyVncx8RTJHtWtrX9Rdxn1bnoC9XQ== X-Google-Smtp-Source: ADFU+vvXCfmncKY6++Jzk4iz6LwkPlqHKSxc0JllZk/cMkPzU52KQMh/idnVmTdcpJhKrTlBKYo51w== X-Received: by 2002:a5d:4f86:: with SMTP id d6mr13573133wru.315.1585560463955; Mon, 30 Mar 2020 02:27:43 -0700 (PDT) Received: from bender.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id 98sm21842318wrk.52.2020.03.30.02.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 02:27:43 -0700 (PDT) From: Neil Armstrong To: u-boot@lists.denx.de, marex@denx.de Cc: u-boot-amlogic@groups.io, Neil Armstrong Subject: [PATCH 01/10] generic-phy: add generic_phy_get_by_node() Date: Mon, 30 Mar 2020 11:27:23 +0200 Message-Id: <20200330092732.7198-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200330092732.7198-1-narmstrong@baylibre.com> References: <20200330092732.7198-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add generic_phy_get_by_node() to get a PHY phandle from a node instead of a udevice. Signed-off-by: Neil Armstrong Reviewed-by: Tom Rini --- drivers/phy/phy-uclass.c | 17 ++++++++++++----- include/generic-phy.h | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index e201a90c8c..de2c3d2b8e 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -31,20 +31,20 @@ static int generic_phy_xlate_offs_flags(struct phy *phy, return 0; } -int generic_phy_get_by_index(struct udevice *dev, int index, - struct phy *phy) +int generic_phy_get_by_node(ofnode node, int index, struct phy *phy) { struct ofnode_phandle_args args; struct phy_ops *ops; struct udevice *phydev; int i, ret; - debug("%s(dev=%p, index=%d, phy=%p)\n", __func__, dev, index, phy); + debug("%s(node=%s, index=%d, phy=%p)\n", + __func__, ofnode_get_name(node), index, phy); assert(phy); phy->dev = NULL; - ret = dev_read_phandle_with_args(dev, "phys", "#phy-cells", 0, index, - &args); + ret = ofnode_parse_phandle_with_args(node, "phys", "#phy-cells", 0, + index, &args); if (ret) { debug("%s: dev_read_phandle_with_args failed: err=%d\n", __func__, ret); @@ -88,6 +88,12 @@ int generic_phy_get_by_index(struct udevice *dev, int index, err: return ret; +} + +int generic_phy_get_by_index(struct udevice *dev, int index, + struct phy *phy) +{ + return generic_phy_get_by_node(dev_ofnode(dev), index, phy); } int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, diff --git a/include/generic-phy.h b/include/generic-phy.h index 95caf58341..5873ffb2e0 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -193,6 +193,33 @@ int generic_phy_power_off(struct phy *phy); int generic_phy_get_by_index(struct udevice *user, int index, struct phy *phy); +/** + * generic_phy_get_by_node() - Get a PHY device by integer index on ofnode + * + * @node: the device node + * @index: The index in the list of available PHYs + * @phy: A pointer to the PHY port + * + * This looks up a PHY device for a client device based on its ofnode and on + * its position in the list of the possible PHYs. + * + * example: + * usb1: usb_otg_ss@xxx { + * compatible = "xxx"; + * reg = ; + * . + * . + * phys = <&usb2_phy>, <&usb3_phy>; + * . + * . + * }; + * the USB2 phy can be accessed by passing index '0' and the USB3 phy can + * be accessed by passing index '1' + * + * @return 0 if OK, or a negative error code + */ +int generic_phy_get_by_node(ofnode node, int index, struct phy *phy); + /** * generic_phy_get_by_name() - Get a PHY device by its name. *