linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Murray <andrew.murray@arm.com>
To: Anvesh Salveru <anvesh.s@samsung.com>
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
Date: Thu, 21 Nov 2019 16:08:43 +0000	[thread overview]
Message-ID: <20191121160842.GC43905@e119886-lin.cambridge.arm.com> (raw)
In-Reply-To: <1574306408-4360-2-git-send-email-anvesh.s@samsung.com>

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 <anvesh.s@samsung.com>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  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
> 

  reply	other threads:[~2019-11-21 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191121032031epcas5p29659e014c9ff4564b24c9b1457d6b0b7@epcas5p2.samsung.com>
2019-11-21  3:20 ` [PATCH v4 0/2] Add support to handle ZRX-DC Compliant PHYs Anvesh Salveru
     [not found]   ` <CGME20191121032036epcas5p1ec12cabed1104c131a3cab202a180c21@epcas5p1.samsung.com>
2019-11-21  3:20     ` [PATCH v4 1/2] phy: core: add phy_property_present method Anvesh Salveru
2019-11-21 16:08       ` Andrew Murray [this message]
2019-11-22  2:42         ` Pankaj Dubey
     [not found]   ` <CGME20191121032041epcas5p433066ebc6a07b73a1949da26e55e9b2f@epcas5p4.samsung.com>
2019-11-21  3:20     ` [PATCH v4 2/2] PCI: dwc: add support to handle ZRX-DC Compliant PHYs Anvesh Salveru
2019-11-21 13:55       ` Gustavo Pimentel
2019-11-22  2:35         ` Pankaj Dubey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191121160842.GC43905@e119886-lin.cambridge.arm.com \
    --to=andrew.murray@arm.com \
    --cc=anvesh.s@samsung.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=pankaj.dubey@samsung.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).