All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
To: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Cc: bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
	tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	pawel.moll-5wv7dgnIgG8@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	nsekhar-l0cyMroinI0@public.gmane.org
Subject: Re: [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY
Date: Wed, 24 Jun 2015 16:56:37 +0530	[thread overview]
Message-ID: <558A93ED.9050104@ti.com> (raw)
In-Reply-To: <20150623175355.d80c1d6626439fbb6c26169c-l0cyMroinI0@public.gmane.org>

Hi,

On Tuesday 23 June 2015 08:23 PM, Roger Quadros wrote:
> Hi Kishon,
>
> On Tue, 23 Jun 2015 17:28:47 +0530
> Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> wrote:
>
>> Deprecate using phy-omap-control driver to power on/off the PHY and
>> use *syscon* framework to do the same.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
>> ---
>>   Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
>>   drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
>>   2 files changed, 86 insertions(+), 15 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> index f0f5537..d3ad3bf 100644
>> --- a/Documentation/devicetree/bindings/phy/ti-phy.txt
>> +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> @@ -77,8 +77,6 @@ Required properties:
>>      * "div-clk" - apll clock
>>
>>   Optional properties:
>> - - ctrl-module : phandle of the control module used by PHY driver to power on
>> -   the PHY.
>>    - id: If there are multiple instance of the same type, in order to
>>      differentiate between each instance "id" can be used (e.g., multi-lane PCIe
>>      PHY). If "id" is not provided, it is set to default value of '1'.
>> @@ -86,6 +84,14 @@ Optional properties:
>>      CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
>>      register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
>>
>> +Deprecated properties:
>> + - ctrl-module : phandle of the control module used by PHY driver to power on
>> +   the PHY.
>> +
>> +Recommended properies:
>> + - syscon-phy-power : phandle/offset pair. Phandle to the system control
>> +   module and the register offset to power on/off the PHY.
>> +
>>   This is usually a subnode of ocp2scp to which it is connected.
>>
>>   usb3phy@4a084400 {
>> diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
>> index d784426..78bac00 100644
>> --- a/drivers/phy/phy-ti-pipe3.c
>> +++ b/drivers/phy/phy-ti-pipe3.c
>> @@ -56,6 +56,15 @@
>>
>>   #define SATA_PLL_SOFT_RESET	BIT(18)
>>
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK	0x003FC000
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT	14
>> +
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK	0xFFC00000
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT	22
>> +
>> +#define PIPE3_PHY_TX_RX_POWERON		0x3
>> +#define PIPE3_PHY_TX_RX_POWEROFF	0x0
>> +
>>   /*
>>    * This is an Empirical value that works, need to confirm the actual
>>    * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
>> @@ -86,8 +95,10 @@ struct ti_pipe3 {
>>   	struct clk		*refclk;
>>   	struct clk		*div_clk;
>>   	struct pipe3_dpll_map	*dpll_map;
>> +	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
>>   	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
>>   	unsigned int		dpll_reset_reg; /* reg. index within syscon */
>> +	unsigned int		power_reg; /* power reg. index within syscon */
>>   	bool			sata_refclk_enabled;
>>   };
>>
>> @@ -144,18 +155,49 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
>>
>>   static int ti_pipe3_power_off(struct phy *x)
>>   {
>> +	u32 val;
>> +	int ret;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 0);
>> +	if (phy->phy_power_syscon) {
>> +		val = PIPE3_PHY_TX_RX_POWEROFF <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 0);
>> +	}
>>
>>   	return 0;
>>   }
>>
>>   static int ti_pipe3_power_on(struct phy *x)
>>   {
>> +	u32 val;
>> +	u32 mask;
>> +	int ret;
>> +	unsigned long rate;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 1);
>> +	if (phy->phy_power_syscon) {
>> +		rate = clk_get_rate(phy->sys_clk);
>
> what if clk_get_rate() returns 0?

hmm.. If '0' is an error value of clk_get_rate() then it would be good to 
return with an error message.
>
>> +		rate = rate / 1000000;
>> +		mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
>> +			  OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
>> +		val = PIPE3_PHY_TX_RX_POWERON <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +		val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 mask, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 1);
>> +	}
>>
>>   	return 0;
>>   }
>> @@ -417,19 +459,42 @@ static int ti_pipe3_probe(struct platform_device *pdev)
>>   		phy->div_clk = ERR_PTR(-ENODEV);
>>   	}
>>
>> -	control_node = of_parse_phandle(node, "ctrl-module", 0);
>> -	if (!control_node) {
>> -		dev_err(&pdev->dev, "Failed to get control device phandle\n");
>> -		return -EINVAL;
>> -	}
>> +	phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
>> +							"syscon-phy-power");
>> +	if (IS_ERR(phy->phy_power_syscon)) {
>> +		dev_info(&pdev->dev,
>> +			 "can't get syscon-phy-power, using control device\n");
>
> dev_dbg()? as we don't want to annoy old DT users?

okay.
>
>> +		phy->phy_power_syscon = NULL;
>> +
>> +		control_node = of_parse_phandle(node, "ctrl-module", 0);
>> +		if (!control_node) {
>> +			dev_err(&pdev->dev,
>> +				"Failed to get control device phandle\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	control_pdev = of_find_device_by_node(control_node);
>> -	if (!control_pdev) {
>> -		dev_err(&pdev->dev, "Failed to get control device\n");
>> -		return -EINVAL;
>> -	}
>> +		control_pdev = of_find_device_by_node(control_node);
>> +		if (!control_pdev) {
>> +			dev_err(&pdev->dev, "Failed to get control device\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	phy->control_dev = &control_pdev->dev;
>> +		phy->control_dev = &control_pdev->dev;
>> +	} else {
>> +		phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
>> +		if (IS_ERR(phy->sys_clk)) {
>> +			dev_err(&pdev->dev, "unable to get sysclk\n");
>> +			return -EINVAL;
>> +		}
>
> we're already doing this at another place in pipe3_probe. Let's do it at one place.

right, this can be improved.

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: kishon@ti.com (Kishon Vijay Abraham I)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY
Date: Wed, 24 Jun 2015 16:56:37 +0530	[thread overview]
Message-ID: <558A93ED.9050104@ti.com> (raw)
In-Reply-To: <20150623175355.d80c1d6626439fbb6c26169c@ti.com>

Hi,

On Tuesday 23 June 2015 08:23 PM, Roger Quadros wrote:
> Hi Kishon,
>
> On Tue, 23 Jun 2015 17:28:47 +0530
> Kishon Vijay Abraham I <kishon@ti.com> wrote:
>
>> Deprecate using phy-omap-control driver to power on/off the PHY and
>> use *syscon* framework to do the same.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>   Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
>>   drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
>>   2 files changed, 86 insertions(+), 15 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> index f0f5537..d3ad3bf 100644
>> --- a/Documentation/devicetree/bindings/phy/ti-phy.txt
>> +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> @@ -77,8 +77,6 @@ Required properties:
>>      * "div-clk" - apll clock
>>
>>   Optional properties:
>> - - ctrl-module : phandle of the control module used by PHY driver to power on
>> -   the PHY.
>>    - id: If there are multiple instance of the same type, in order to
>>      differentiate between each instance "id" can be used (e.g., multi-lane PCIe
>>      PHY). If "id" is not provided, it is set to default value of '1'.
>> @@ -86,6 +84,14 @@ Optional properties:
>>      CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
>>      register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
>>
>> +Deprecated properties:
>> + - ctrl-module : phandle of the control module used by PHY driver to power on
>> +   the PHY.
>> +
>> +Recommended properies:
>> + - syscon-phy-power : phandle/offset pair. Phandle to the system control
>> +   module and the register offset to power on/off the PHY.
>> +
>>   This is usually a subnode of ocp2scp to which it is connected.
>>
>>   usb3phy at 4a084400 {
>> diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
>> index d784426..78bac00 100644
>> --- a/drivers/phy/phy-ti-pipe3.c
>> +++ b/drivers/phy/phy-ti-pipe3.c
>> @@ -56,6 +56,15 @@
>>
>>   #define SATA_PLL_SOFT_RESET	BIT(18)
>>
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK	0x003FC000
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT	14
>> +
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK	0xFFC00000
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT	22
>> +
>> +#define PIPE3_PHY_TX_RX_POWERON		0x3
>> +#define PIPE3_PHY_TX_RX_POWEROFF	0x0
>> +
>>   /*
>>    * This is an Empirical value that works, need to confirm the actual
>>    * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
>> @@ -86,8 +95,10 @@ struct ti_pipe3 {
>>   	struct clk		*refclk;
>>   	struct clk		*div_clk;
>>   	struct pipe3_dpll_map	*dpll_map;
>> +	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
>>   	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
>>   	unsigned int		dpll_reset_reg; /* reg. index within syscon */
>> +	unsigned int		power_reg; /* power reg. index within syscon */
>>   	bool			sata_refclk_enabled;
>>   };
>>
>> @@ -144,18 +155,49 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
>>
>>   static int ti_pipe3_power_off(struct phy *x)
>>   {
>> +	u32 val;
>> +	int ret;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 0);
>> +	if (phy->phy_power_syscon) {
>> +		val = PIPE3_PHY_TX_RX_POWEROFF <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 0);
>> +	}
>>
>>   	return 0;
>>   }
>>
>>   static int ti_pipe3_power_on(struct phy *x)
>>   {
>> +	u32 val;
>> +	u32 mask;
>> +	int ret;
>> +	unsigned long rate;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 1);
>> +	if (phy->phy_power_syscon) {
>> +		rate = clk_get_rate(phy->sys_clk);
>
> what if clk_get_rate() returns 0?

hmm.. If '0' is an error value of clk_get_rate() then it would be good to 
return with an error message.
>
>> +		rate = rate / 1000000;
>> +		mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
>> +			  OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
>> +		val = PIPE3_PHY_TX_RX_POWERON <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +		val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 mask, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 1);
>> +	}
>>
>>   	return 0;
>>   }
>> @@ -417,19 +459,42 @@ static int ti_pipe3_probe(struct platform_device *pdev)
>>   		phy->div_clk = ERR_PTR(-ENODEV);
>>   	}
>>
>> -	control_node = of_parse_phandle(node, "ctrl-module", 0);
>> -	if (!control_node) {
>> -		dev_err(&pdev->dev, "Failed to get control device phandle\n");
>> -		return -EINVAL;
>> -	}
>> +	phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
>> +							"syscon-phy-power");
>> +	if (IS_ERR(phy->phy_power_syscon)) {
>> +		dev_info(&pdev->dev,
>> +			 "can't get syscon-phy-power, using control device\n");
>
> dev_dbg()? as we don't want to annoy old DT users?

okay.
>
>> +		phy->phy_power_syscon = NULL;
>> +
>> +		control_node = of_parse_phandle(node, "ctrl-module", 0);
>> +		if (!control_node) {
>> +			dev_err(&pdev->dev,
>> +				"Failed to get control device phandle\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	control_pdev = of_find_device_by_node(control_node);
>> -	if (!control_pdev) {
>> -		dev_err(&pdev->dev, "Failed to get control device\n");
>> -		return -EINVAL;
>> -	}
>> +		control_pdev = of_find_device_by_node(control_node);
>> +		if (!control_pdev) {
>> +			dev_err(&pdev->dev, "Failed to get control device\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	phy->control_dev = &control_pdev->dev;
>> +		phy->control_dev = &control_pdev->dev;
>> +	} else {
>> +		phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
>> +		if (IS_ERR(phy->sys_clk)) {
>> +			dev_err(&pdev->dev, "unable to get sysclk\n");
>> +			return -EINVAL;
>> +		}
>
> we're already doing this at another place in pipe3_probe. Let's do it at one place.

right, this can be improved.

Thanks
Kishon

WARNING: multiple messages have this Message-ID (diff)
From: Kishon Vijay Abraham I <kishon@ti.com>
To: Roger Quadros <rogerq@ti.com>
Cc: <bcousson@baylibre.com>, <tony@atomide.com>, <balbi@ti.com>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-omap@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-usb@vger.kernel.org>, <robh+dt@kernel.org>,
	<pawel.moll@arm.com>, <mark.rutland@arm.com>,
	<ijc+devicetree@hellion.org.uk>, <galak@codeaurora.org>,
	<linux@arm.linux.org.uk>, <gregkh@linuxfoundation.org>,
	<nsekhar@ti.com>
Subject: Re: [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY
Date: Wed, 24 Jun 2015 16:56:37 +0530	[thread overview]
Message-ID: <558A93ED.9050104@ti.com> (raw)
In-Reply-To: <20150623175355.d80c1d6626439fbb6c26169c@ti.com>

Hi,

On Tuesday 23 June 2015 08:23 PM, Roger Quadros wrote:
> Hi Kishon,
>
> On Tue, 23 Jun 2015 17:28:47 +0530
> Kishon Vijay Abraham I <kishon@ti.com> wrote:
>
>> Deprecate using phy-omap-control driver to power on/off the PHY and
>> use *syscon* framework to do the same.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>   Documentation/devicetree/bindings/phy/ti-phy.txt |   10 ++-
>>   drivers/phy/phy-ti-pipe3.c                       |   91 ++++++++++++++++++----
>>   2 files changed, 86 insertions(+), 15 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> index f0f5537..d3ad3bf 100644
>> --- a/Documentation/devicetree/bindings/phy/ti-phy.txt
>> +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> @@ -77,8 +77,6 @@ Required properties:
>>      * "div-clk" - apll clock
>>
>>   Optional properties:
>> - - ctrl-module : phandle of the control module used by PHY driver to power on
>> -   the PHY.
>>    - id: If there are multiple instance of the same type, in order to
>>      differentiate between each instance "id" can be used (e.g., multi-lane PCIe
>>      PHY). If "id" is not provided, it is set to default value of '1'.
>> @@ -86,6 +84,14 @@ Optional properties:
>>      CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0
>>      register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy.
>>
>> +Deprecated properties:
>> + - ctrl-module : phandle of the control module used by PHY driver to power on
>> +   the PHY.
>> +
>> +Recommended properies:
>> + - syscon-phy-power : phandle/offset pair. Phandle to the system control
>> +   module and the register offset to power on/off the PHY.
>> +
>>   This is usually a subnode of ocp2scp to which it is connected.
>>
>>   usb3phy@4a084400 {
>> diff --git a/drivers/phy/phy-ti-pipe3.c b/drivers/phy/phy-ti-pipe3.c
>> index d784426..78bac00 100644
>> --- a/drivers/phy/phy-ti-pipe3.c
>> +++ b/drivers/phy/phy-ti-pipe3.c
>> @@ -56,6 +56,15 @@
>>
>>   #define SATA_PLL_SOFT_RESET	BIT(18)
>>
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK	0x003FC000
>> +#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT	14
>> +
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK	0xFFC00000
>> +#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT	22
>> +
>> +#define PIPE3_PHY_TX_RX_POWERON		0x3
>> +#define PIPE3_PHY_TX_RX_POWEROFF	0x0
>> +
>>   /*
>>    * This is an Empirical value that works, need to confirm the actual
>>    * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status
>> @@ -86,8 +95,10 @@ struct ti_pipe3 {
>>   	struct clk		*refclk;
>>   	struct clk		*div_clk;
>>   	struct pipe3_dpll_map	*dpll_map;
>> +	struct regmap		*phy_power_syscon; /* ctrl. reg. acces */
>>   	struct regmap		*dpll_reset_syscon; /* ctrl. reg. acces */
>>   	unsigned int		dpll_reset_reg; /* reg. index within syscon */
>> +	unsigned int		power_reg; /* power reg. index within syscon */
>>   	bool			sata_refclk_enabled;
>>   };
>>
>> @@ -144,18 +155,49 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
>>
>>   static int ti_pipe3_power_off(struct phy *x)
>>   {
>> +	u32 val;
>> +	int ret;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 0);
>> +	if (phy->phy_power_syscon) {
>> +		val = PIPE3_PHY_TX_RX_POWEROFF <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 0);
>> +	}
>>
>>   	return 0;
>>   }
>>
>>   static int ti_pipe3_power_on(struct phy *x)
>>   {
>> +	u32 val;
>> +	u32 mask;
>> +	int ret;
>> +	unsigned long rate;
>>   	struct ti_pipe3 *phy = phy_get_drvdata(x);
>>
>> -	omap_control_phy_power(phy->control_dev, 1);
>> +	if (phy->phy_power_syscon) {
>> +		rate = clk_get_rate(phy->sys_clk);
>
> what if clk_get_rate() returns 0?

hmm.. If '0' is an error value of clk_get_rate() then it would be good to 
return with an error message.
>
>> +		rate = rate / 1000000;
>> +		mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
>> +			  OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
>> +		val = PIPE3_PHY_TX_RX_POWERON <<
>> +			PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
>> +		val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
>> +
>> +		ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
>> +					 mask, val);
>> +		if (ret < 0)
>> +			return ret;
>> +	} else {
>> +		omap_control_phy_power(phy->control_dev, 1);
>> +	}
>>
>>   	return 0;
>>   }
>> @@ -417,19 +459,42 @@ static int ti_pipe3_probe(struct platform_device *pdev)
>>   		phy->div_clk = ERR_PTR(-ENODEV);
>>   	}
>>
>> -	control_node = of_parse_phandle(node, "ctrl-module", 0);
>> -	if (!control_node) {
>> -		dev_err(&pdev->dev, "Failed to get control device phandle\n");
>> -		return -EINVAL;
>> -	}
>> +	phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node,
>> +							"syscon-phy-power");
>> +	if (IS_ERR(phy->phy_power_syscon)) {
>> +		dev_info(&pdev->dev,
>> +			 "can't get syscon-phy-power, using control device\n");
>
> dev_dbg()? as we don't want to annoy old DT users?

okay.
>
>> +		phy->phy_power_syscon = NULL;
>> +
>> +		control_node = of_parse_phandle(node, "ctrl-module", 0);
>> +		if (!control_node) {
>> +			dev_err(&pdev->dev,
>> +				"Failed to get control device phandle\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	control_pdev = of_find_device_by_node(control_node);
>> -	if (!control_pdev) {
>> -		dev_err(&pdev->dev, "Failed to get control device\n");
>> -		return -EINVAL;
>> -	}
>> +		control_pdev = of_find_device_by_node(control_node);
>> +		if (!control_pdev) {
>> +			dev_err(&pdev->dev, "Failed to get control device\n");
>> +			return -EINVAL;
>> +		}
>>
>> -	phy->control_dev = &control_pdev->dev;
>> +		phy->control_dev = &control_pdev->dev;
>> +	} else {
>> +		phy->sys_clk = devm_clk_get(phy->dev, "sysclk");
>> +		if (IS_ERR(phy->sys_clk)) {
>> +			dev_err(&pdev->dev, "unable to get sysclk\n");
>> +			return -EINVAL;
>> +		}
>
> we're already doing this at another place in pipe3_probe. Let's do it at one place.

right, this can be improved.

Thanks
Kishon

  parent reply	other threads:[~2015-06-24 11:26 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 11:58 [PATCH 00/17] Deprecate phy-omap-control and use SYSCON Kishon Vijay Abraham I
2015-06-23 11:58 ` Kishon Vijay Abraham I
2015-06-23 11:58 ` Kishon Vijay Abraham I
2015-06-23 11:58 ` [PATCH 01/17] phy: ti-pipe3: use ti_pipe3_power_off to power off the PHY during probe Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 14:47   ` Roger Quadros
2015-06-23 14:47     ` Roger Quadros
2015-06-23 14:47     ` Roger Quadros
2015-06-23 11:58 ` [PATCH 02/17] phy: ti-pipe3: use *syscon* framework to power on/off the PHY Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
     [not found]   ` <1435060743-5511-3-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-23 14:53     ` Roger Quadros
2015-06-23 14:53       ` Roger Quadros
2015-06-23 14:53       ` Roger Quadros
     [not found]       ` <20150623175355.d80c1d6626439fbb6c26169c-l0cyMroinI0@public.gmane.org>
2015-06-24 11:26         ` Kishon Vijay Abraham I [this message]
2015-06-24 11:26           ` Kishon Vijay Abraham I
2015-06-24 11:26           ` Kishon Vijay Abraham I
2015-06-23 11:58 ` [PATCH 03/17] phy: ti-pipe3: use *syscon* framework to set PCS value of " Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
     [not found]   ` <1435060743-5511-4-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 10:34     ` Roger Quadros
2015-06-24 10:34       ` Roger Quadros
2015-06-24 10:34       ` Roger Quadros
2015-06-24 13:16       ` Kishon Vijay Abraham I
2015-06-24 13:16         ` Kishon Vijay Abraham I
2015-06-24 13:16         ` Kishon Vijay Abraham I
     [not found]         ` <558AAD98.1090602-l0cyMroinI0@public.gmane.org>
2015-06-24 13:48           ` Roger Quadros
2015-06-24 13:48             ` Roger Quadros
2015-06-24 13:48             ` Roger Quadros
2015-06-23 11:58 ` [PATCH 04/17] phy: omap-usb2: use omap_usb_power_off to power off the PHY during probe Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
     [not found]   ` <1435060743-5511-5-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 10:58     ` Roger Quadros
2015-06-24 10:58       ` Roger Quadros
2015-06-24 10:58       ` Roger Quadros
2015-06-23 11:58 ` [PATCH 07/17] usb: musb: omap2430: use *syscon* framework to write to mailbox register Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-24 11:39   ` Roger Quadros
2015-06-24 11:39     ` Roger Quadros
2015-06-24 11:39     ` Roger Quadros
2015-06-24 13:21     ` Kishon Vijay Abraham I
2015-06-24 13:21       ` Kishon Vijay Abraham I
2015-06-24 13:21       ` Kishon Vijay Abraham I
     [not found]   ` <1435060743-5511-8-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 11:49     ` Tony Lindgren
2015-06-24 11:49       ` Tony Lindgren
2015-06-24 11:49       ` Tony Lindgren
     [not found]       ` <20150624114907.GF4156-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2015-06-24 13:06         ` Kishon Vijay Abraham I
2015-06-24 13:06           ` Kishon Vijay Abraham I
2015-06-24 13:06           ` Kishon Vijay Abraham I
2015-06-23 11:58 ` [PATCH 08/17] ARM: dts: dra7: Add dt node for the sycon pcie Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
     [not found]   ` <1435060743-5511-9-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 11:50     ` Roger Quadros
2015-06-24 11:50       ` Roger Quadros
2015-06-24 11:50       ` Roger Quadros
2015-06-24 11:56       ` Roger Quadros
2015-06-24 11:56         ` Roger Quadros
2015-06-24 11:56         ` Roger Quadros
     [not found]         ` <20150624145617.e5248d466fe5b2e0eb1ca087-l0cyMroinI0@public.gmane.org>
2015-06-24 12:09           ` Tony Lindgren
2015-06-24 12:09             ` Tony Lindgren
2015-06-24 12:09             ` Tony Lindgren
     [not found]             ` <20150624120938.GG4156-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2015-06-24 12:19               ` Roger Quadros
2015-06-24 12:19                 ` Roger Quadros
2015-06-24 12:19                 ` Roger Quadros
     [not found]                 ` <20150624151931.87252315d0e61ddfd55c4724-l0cyMroinI0@public.gmane.org>
2015-06-24 12:49                   ` Tony Lindgren
2015-06-24 12:49                     ` Tony Lindgren
2015-06-24 12:49                     ` Tony Lindgren
2015-06-24 13:30           ` Kishon Vijay Abraham I
2015-06-24 13:30             ` Kishon Vijay Abraham I
2015-06-24 13:30             ` Kishon Vijay Abraham I
2015-06-24 13:29       ` Kishon Vijay Abraham I
2015-06-24 13:29         ` Kishon Vijay Abraham I
2015-06-24 13:29         ` Kishon Vijay Abraham I
     [not found] ` <1435060743-5511-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-23 11:58   ` [PATCH 05/17] phy: omap-usb2: Add a new compatible string for USB2 PHY2 Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-24 11:03     ` Roger Quadros
2015-06-24 11:03       ` Roger Quadros
2015-06-24 11:03       ` Roger Quadros
     [not found]       ` <20150624140354.c3c1b0fc24dc37eae5097b4c-l0cyMroinI0@public.gmane.org>
2015-06-24 13:21         ` Kishon Vijay Abraham I
2015-06-24 13:21           ` Kishon Vijay Abraham I
2015-06-24 13:21           ` Kishon Vijay Abraham I
2015-06-23 11:58   ` [PATCH 06/17] phy: omap-usb2: use *syscon* framework to power on/off the PHY Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
     [not found]     ` <1435060743-5511-7-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 11:33       ` Roger Quadros
2015-06-24 11:33         ` Roger Quadros
2015-06-24 11:33         ` Roger Quadros
2015-06-24 12:59         ` Kishon Vijay Abraham I
2015-06-24 12:59           ` Kishon Vijay Abraham I
2015-06-24 12:59           ` Kishon Vijay Abraham I
2015-06-23 11:58   ` [PATCH 09/17] ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in SATA PHY node Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-24 12:06     ` Roger Quadros
2015-06-24 12:06       ` Roger Quadros
2015-06-24 12:06       ` Roger Quadros
     [not found]       ` <20150624150602.0e73fc8f9dda1624f22059db-l0cyMroinI0@public.gmane.org>
2015-06-24 12:12         ` Roger Quadros
2015-06-24 12:12           ` Roger Quadros
2015-06-24 12:12           ` Roger Quadros
     [not found]           ` <20150624151257.fe5f1594db1afe4c1da8027d-l0cyMroinI0@public.gmane.org>
2015-06-24 13:31             ` Kishon Vijay Abraham I
2015-06-24 13:31               ` Kishon Vijay Abraham I
2015-06-24 13:31               ` Kishon Vijay Abraham I
2015-06-23 11:58   ` [PATCH 10/17] ARM: dts: dra7: Use "syscon-phy-power" and "syscon-pcs" in PCIe " Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58   ` [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" compatible string for USB2 PHY2 Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` [PATCH 11/17] ARM: dts: dra7: Use "ti, dra7x-usb2-phy2" " Kishon Vijay Abraham I
     [not found]     ` <1435060743-5511-12-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 12:07       ` [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" " Roger Quadros
2015-06-24 12:07         ` Roger Quadros
2015-06-24 12:07         ` Roger Quadros
     [not found]         ` <20150624150750.9435096c85253cfe528ebbc3-l0cyMroinI0@public.gmane.org>
2015-06-24 13:10           ` Kishon Vijay Abraham I
2015-06-24 13:10             ` Kishon Vijay Abraham I
2015-06-24 13:10             ` [PATCH 11/17] ARM: dts: dra7: Use "ti, dra7x-usb2-phy2" " Kishon Vijay Abraham I
     [not found]             ` <558AAC47.2070305-l0cyMroinI0@public.gmane.org>
2015-06-24 13:50               ` [PATCH 11/17] ARM: dts: dra7: Use "ti,dra7x-usb2-phy2" " Roger Quadros
2015-06-24 13:50                 ` Roger Quadros
2015-06-24 13:50                 ` Roger Quadros
2015-06-23 11:58   ` [PATCH 13/17] ARM: dts: am4372: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58   ` [PATCH 14/17] ARM: dts: OMAP5: " Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:58     ` Kishon Vijay Abraham I
2015-06-23 11:59   ` [PATCH 16/17] ARM: dts: omap4: " Kishon Vijay Abraham I
2015-06-23 11:59     ` Kishon Vijay Abraham I
2015-06-23 11:59     ` Kishon Vijay Abraham I
2015-06-23 11:59   ` [PATCH 17/17] ARM: dts: omap4: Use "syscon-otghs" instead of "ctrl-module" in USB node Kishon Vijay Abraham I
2015-06-23 11:59     ` Kishon Vijay Abraham I
2015-06-23 11:59     ` Kishon Vijay Abraham I
     [not found]     ` <1435060743-5511-18-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-06-24 10:41       ` Tony Lindgren
2015-06-24 10:41         ` Tony Lindgren
2015-06-24 10:41         ` Tony Lindgren
2015-06-24 11:21         ` Kishon Vijay Abraham I
2015-06-24 11:21           ` Kishon Vijay Abraham I
2015-06-24 11:21           ` Kishon Vijay Abraham I
     [not found]           ` <558A92A5.5070506-l0cyMroinI0@public.gmane.org>
2015-06-24 11:46             ` Tony Lindgren
2015-06-24 11:46               ` Tony Lindgren
2015-06-24 11:46               ` Tony Lindgren
2015-06-24 12:02         ` Roger Quadros
2015-06-24 12:02           ` Roger Quadros
2015-06-24 12:02           ` Roger Quadros
2015-06-23 11:58 ` [PATCH 12/17] ARM: dts: dra7: Use "syscon-phy-power" instead of "ctrl-module" in USB PHY node Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:58   ` Kishon Vijay Abraham I
2015-06-23 11:59 ` [PATCH 15/17] ARM: dts: OMAP5: Use "syscon-phy-power" instead of "ctrl-module" in SATA " Kishon Vijay Abraham I
2015-06-23 11:59   ` Kishon Vijay Abraham I
2015-06-23 11:59   ` Kishon Vijay Abraham I

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=558A93ED.9050104@ti.com \
    --to=kishon-l0cymroini0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=nsekhar-l0cyMroinI0@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=rogerq-l0cyMroinI0@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.