[PATCH 2/8] pci: pcie_dw_rockchip: Use regulator_set_enable_if_allowed

Jonas Karlman jonas at kwiboo.se
Tue May 9 14:45:40 CEST 2023


Hi Kever,

On 2023-05-09 13:58, Kever Yang wrote:
> Hi Jonas,
> 
> On 2023/4/23 02:19, Jonas Karlman wrote:
>> The vpcie3v3 regulator is typically a fixed regulator controlled using
>> gpio. Change to use enable and disable calls on the regulator instead
>> of trying to set a voltage value.
>>
>> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
>> ---
>>   drivers/pci/pcie_dw_rockchip.c | 17 +++++++----------
>>   1 file changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c
>> index 225af400ba70..a5b900f95981 100644
>> --- a/drivers/pci/pcie_dw_rockchip.c
>> +++ b/drivers/pci/pcie_dw_rockchip.c
>> @@ -288,21 +288,16 @@ static int rockchip_pcie_init_port(struct udevice *dev)
>>   	struct rk_pcie *priv = dev_get_priv(dev);
>>   
>>   	/* Set power and maybe external ref clk input */
>> -	if (priv->vpcie3v3) {
>> -		ret = regulator_set_value(priv->vpcie3v3, 3300000);
>> -		if (ret) {
>> -			dev_err(priv->dw.dev, "failed to enable vpcie3v3 (ret=%d)\n",
>> -				ret);
>> -			return ret;
>> -		}
>> +	ret = regulator_set_enable_if_allowed(priv->vpcie3v3, true);
>> +	if (ret && ret != -ENOSYS) {
>> +		dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n", ret);
>> +		return ret;
>>   	}
>>   
>> -	udelay(MACRO_US * 1000);
> 
> Why remove this udelay?
> 
> This may help the power stable before we can access pcie phy.

I removed this to closer match the linux driver, if a delay is
needed it can be added using e.g. the startup-delay-us prop of
a fixed regulator.

  startup-delay-us:
    description: startup time in microseconds

Based on testing on Rock 3A, CM3, Quartz64, SoQuartz, Odroid-M1 and
Rock 5B a delay using startup-delay-us did not seem necessary.

Regards,
Jonas

> 
> Thanks,
> 
> - Kever
> 
>> -
>>   	ret = generic_phy_init(&priv->phy);
>>   	if (ret) {
>>   		dev_err(dev, "failed to init phy (ret=%d)\n", ret);
>> -		return ret;
>> +		goto err_disable_regulator;
>>   	}
>>   
>>   	ret = generic_phy_power_on(&priv->phy);
>> @@ -345,6 +340,8 @@ err_power_off_phy:
>>   	generic_phy_power_off(&priv->phy);
>>   err_exit_phy:
>>   	generic_phy_exit(&priv->phy);
>> +err_disable_regulator:
>> +	regulator_set_enable_if_allowed(priv->vpcie3v3, false);
>>   
>>   	return ret;
>>   }



More information about the U-Boot mailing list