[PATCH 3/8] net: dwc_eth_qos: Add option "snps,reset-gpio" phy-rst gpio for stm32

David Wu david.wu at rock-chips.com
Sat May 9 04:59:26 CEST 2020


Hi Patrice,

在 2020/4/30 下午11:47, Patrice CHOTARD 写道:
>> @@ -701,6 +702,15 @@ static int eqos_start_resets_stm32(struct udevice *dev)
>>   
>>   	debug("%s(dev=%p):\n", __func__, dev);
>>   	if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) {
>> +		ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0);
>> +		if (ret < 0) {
>> +			pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d",
>> +			       ret);
>> +			return ret;
>> +		}
>> +
>> +		udelay(eqos->reset_delays[0]);
>> +
> not related to this patch subject
>>   		ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 1);
>>   		if (ret < 0) {
>>   			pr_err("dm_gpio_set_value(phy_reset, assert) failed: %d",
>> @@ -708,7 +718,7 @@ static int eqos_start_resets_stm32(struct udevice *dev)
>>   			return ret;
>>   		}
>>   
>> -		udelay(2);
>> +		udelay(eqos->reset_delays[1]);
>>   
>>   		ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0);
>>   		if (ret < 0) {

>> @@ -1712,11 +1724,29 @@ static int eqos_probe_resources_stm32(struct udevice *dev)
>>   		if (ret)
>>   			pr_warn("gpio_request_by_name(phy reset) not provided %d",
>>   				ret);
>> +		else
>> +			eqos->reset_delays[1] = 2;
> this is not the correct place to set default value. It must be set in case we can't get value from DT below

No, three cases below, it is second case, and we can see udelay(2) in 
eqos_start_resets_stm32(), here we are to be compatible with the original.

- If there is not phy rst, reset_delays is 0;
- If "reset-gpios exists in phy node, reset_delays [1] = 2;
- "snps, reset-gpio" exists in DT, reset_delays is obtained from DT

>>   
>>   		eqos->phyaddr = ofnode_read_u32_default(phandle_args.node,
>>   							"reg", -1);
>>   	}
>>   
>> +	if (!dm_gpio_is_valid(&eqos->phy_reset_gpio)) {
>> +		int reset_flags = GPIOD_IS_OUT;
>> +
>> +		if (dev_read_bool(dev, "snps,reset-active-low"))
>> +			reset_flags |= GPIOD_ACTIVE_LOW;
>> +
>> +		ret = gpio_request_by_name(dev, "snps,reset-gpio", 0,
>> +					   &eqos->phy_reset_gpio, reset_flags);
>> +		if (ret == 0)
>> +			ret = dev_read_u32_array(dev, "snps,reset-delays-us",
>> +						 eqos->reset_delays, 3);
> in case "snps,reset-delays-us" is not in present DT, all resets-delays are set to 0, see my remark above
>> +		else
>> +			pr_warn("gpio_request_by_name(snps,reset-gpio) failed: %d",
>> +				ret);
>> +	}
>> +
>>   	debug("%s: OK\n", __func__);
>>   	return 0;
>>   




More information about the U-Boot mailing list