Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3425340ybc; Thu, 21 Nov 2019 08:10:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzA3ZGJ3Xym4IC4DDip3Ce2pdlYQJc0HJx8g0/iA26Safv1oCdVOHBjr4KJ5EX9ALXcYFol X-Received: by 2002:a2e:8ed6:: with SMTP id e22mr8386612ljl.3.1574352626217; Thu, 21 Nov 2019 08:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574352626; cv=none; d=google.com; s=arc-20160816; b=yixBh3gOBhcx6LkEyRvbpseFXk6GfIN0+COZSAFcQqBmmdnkWZHeTzAIz0STuv5UXT RGa3gDHuPlWob8SPdI7eJ982Ez++xOcN/t21OE8uJtrRYkGlmScyYWgHvOuU6753A8zB vK4UMef/MjAwMpGd8iRhzFyTBjDSFU9B50komQlqUKTZnS15LOXvlo1JJQNdPYmL3eKI UZ0Zk7zQ6yUu6yFQv233bzJetO67Fr5icI2WfPVZmq6F7jk8br4jZWVM9Z4junC9iKMb 9Pn4Io7D7JQdf5smw49J21AcGEb3a4rKGBkFWobgMZPB60j3DVXknA6h9MZzgkLls3YC gKdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7nEqgVEMwcVqHeVOq76sPYn7bXACpHXmLKYMct8PYVA=; b=BfV5XShqgy/wqd2BfbqHOHZrDn44jLRKsMZFYBzcFWJw+banBqa+8hbY09rK79zQ8S BXADHzf2s8AQCscPLocplZMO8yPVeDmclmwJnOd8lHRXvfZCoJBBkJb4vHhP7YwYT3fV SElfiyLVYi7Q8l0XWIAxTqH97+CA7oHEnD5xFP4D5OPsUhTW7Ysc11TgeqGSFDvfY9J/ zH3vvNDpoVHON+3mdOt6V7lBKjOAhIjGWkY8pfTldImfF6fh4/fyayJbUsu8n6wcZLiK hCz++Gzhs7y36TYkXash10PjW8GsPvWovPRxl7bxUNQpystbfxjFTTxqQKmRcFADfwVW G/Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu26si2130548ejb.228.2019.11.21.08.09.58; Thu, 21 Nov 2019 08:10:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbfKUQIr (ORCPT + 99 others); Thu, 21 Nov 2019 11:08:47 -0500 Received: from foss.arm.com ([217.140.110.172]:58734 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbfKUQIq (ORCPT ); Thu, 21 Nov 2019 11:08:46 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B5679328; Thu, 21 Nov 2019 08:08:45 -0800 (PST) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2DCA13F52E; Thu, 21 Nov 2019 08:08:45 -0800 (PST) Date: Thu, 21 Nov 2019 16:08:43 +0000 From: Andrew Murray To: Anvesh Salveru Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, pankaj.dubey@samsung.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, kishon@ti.com, robh+dt@kernel.org, mark.rutland@arm.com Subject: Re: [PATCH v4 1/2] phy: core: add phy_property_present method Message-ID: <20191121160842.GC43905@e119886-lin.cambridge.arm.com> References: <1574306408-4360-1-git-send-email-anvesh.s@samsung.com> <1574306408-4360-2-git-send-email-anvesh.s@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1574306408-4360-2-git-send-email-anvesh.s@samsung.com> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 21, 2019 at 08:50:07AM +0530, Anvesh Salveru wrote: > In some platforms, we need information of phy properties in > the controller drivers. This patch adds a new phy_property_present() > method which can be used to check if some property exists in PHY > or not. > > In case of DesignWare PCIe controller, we need to write into controller > register to specify about ZRX-DC compliance property of the PHY, which > reduces the power consumption during lower power states. > > Signed-off-by: Anvesh Salveru > Signed-off-by: Pankaj Dubey > --- > drivers/phy/phy-core.c | 26 ++++++++++++++++++++++++++ > include/linux/phy/phy.h | 8 ++++++++ > 2 files changed, 34 insertions(+) > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index b04f4fe..0a62eca 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -420,6 +420,32 @@ int phy_calibrate(struct phy *phy) > EXPORT_SYMBOL_GPL(phy_calibrate); > > /** > + * phy_property_present() - checks if the property is present in PHY > + * @phy: the phy returned by phy_get() > + * @property: name of the property to check > + * > + * Used to check if the given property is present in PHY. PHY drivers > + * can implement this callback function to expose PHY properties to > + * controller drivers. > + * > + * Returns: true if property exists, false otherwise > + */ > +bool phy_property_present(struct phy *phy, const char *property) > +{ > + bool ret; > + > + if (!phy || !phy->ops->property_present) > + return false; > + > + mutex_lock(&phy->mutex); > + ret = phy->ops->property_present(phy, property); I don't understand why it is necessary to require every phy driver to implement this. Why can't the phy-core driver look up the device node of the given phy? Thanks, Andrew Murray > + mutex_unlock(&phy->mutex); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(phy_property_present); > + > +/** > * phy_configure() - Changes the phy parameters > * @phy: the phy returned by phy_get() > * @opts: New configuration to apply > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h > index 15032f14..3dd8f3c 100644 > --- a/include/linux/phy/phy.h > +++ b/include/linux/phy/phy.h > @@ -61,6 +61,7 @@ union phy_configure_opts { > * @reset: resetting the phy > * @calibrate: calibrate the phy > * @release: ops to be performed while the consumer relinquishes the PHY > + * @property_present: check if some property is present in PHY > * @owner: the module owner containing the ops > */ > struct phy_ops { > @@ -103,6 +104,7 @@ struct phy_ops { > int (*reset)(struct phy *phy); > int (*calibrate)(struct phy *phy); > void (*release)(struct phy *phy); > + bool (*property_present)(struct phy *phy, const char *property); > struct module *owner; > }; > > @@ -217,6 +219,7 @@ static inline enum phy_mode phy_get_mode(struct phy *phy) > } > int phy_reset(struct phy *phy); > int phy_calibrate(struct phy *phy); > +bool phy_property_present(struct phy *phy, const char *property); > static inline int phy_get_bus_width(struct phy *phy) > { > return phy->attrs.bus_width; > @@ -354,6 +357,11 @@ static inline int phy_calibrate(struct phy *phy) > return -ENOSYS; > } > > +static inline bool phy_property_present(struct phy *phy, const char *property) > +{ > + return false; > +} > + > static inline int phy_configure(struct phy *phy, > union phy_configure_opts *opts) > { > -- > 2.7.4 >