[U-Boot] [PATCH] Add support for Microchip LAN75xx and LAN78xx

Yuiko.Oshino at microchip.com Yuiko.Oshino at microchip.com
Wed May 3 14:20:00 UTC 2017


>-----Original Message-----
>From: Marek Vasut [mailto:marex at denx.de]
>Sent: Tuesday, April 18, 2017 12:47 PM
>To: u-boot at lists.denx.de
>Cc: Yuiko Oshino - C18177; Simon Glass; Joe Hershberger
>Subject: Re: [PATCH] Add support for Microchip LAN75xx and LAN78xx
>
>On 04/18/2017 05:58 PM, Yuiko.Oshino at microchip.com wrote:
>
>[...]
>
>>>> +int lan7x_update_flowcontrol(struct usb_device *udev,
>>>> +			     struct ueth_data *dev,
>>>> +			     uint32_t *flow, uint32_t *fct_flow) {
>>>> +	uint32_t lcladv, rmtadv, ctrl1000, stat1000;
>>>> +	uint32_t advertising = 0, lp_advertising = 0, nego = 0;
>>>> +	uint32_t duplex = 0;
>>>> +	u8 cap = 0;
>>>
>>> Shouldn't this be split into drivers/net/phy and be part of phylib ?
>>> This code looks kinda familiar and similar to what I saw there ...
>>
>> All I need is to get the auto negotiated duplex mode so that I can set the flow
>control.
>> I am going to use our device specific status registers instead of the standard
>registers to get the duplex status to simplify the situation.
>
>OK, CCing Joe, I clearly don't know enough to judge if this is good or not :)
>

Joe, could you please review this and reply back?
I can read only one of our vendor specific registers to get the duplex used. (Although the register offset is not compatible between those two device families).
Please let me know what you think.
Thank you in advance.
Yuiko 

>>>> +	lcladv = lan7x_mdio_read(udev, dev->phy_id, MII_ADVERTISE);
>>>> +	advertising = lan7x_mii_get_an(lcladv);
>>>> +
>>>> +	rmtadv = lan7x_mdio_read(udev, dev->phy_id, MII_LPA);
>>>> +	lp_advertising = lan7x_mii_get_an(rmtadv);
>>>> +
>>>> +	ctrl1000 = lan7x_mdio_read(udev, dev->phy_id, MII_CTRL1000);
>>>> +	stat1000 = lan7x_mdio_read(udev, dev->phy_id, MII_STAT1000);
>>>> +
>>>> +	if (ctrl1000 & ADVERTISE_1000HALF)
>>>> +		advertising |= ADVERTISED_1000baseT_Half;
>>>> +
>>>> +	if (ctrl1000 & ADVERTISE_1000FULL)
>>>> +		advertising |= ADVERTISED_1000baseT_Full;
>>>> +
>>>> +	if (stat1000 & LPA_1000HALF)
>>>> +		lp_advertising |= ADVERTISED_1000baseT_Half;
>>>> +
>>>> +	if (stat1000 & LPA_1000FULL)
>>>> +		lp_advertising |= ADVERTISED_1000baseT_Full;
>>>> +
>>>> +	nego = advertising & lp_advertising;
>>>> +
>>>> +	debug("LAN7x linked at ");
>>>> +
>>>> +	if (nego & (ADVERTISED_1000baseT_Full |
>>> ADVERTISED_1000baseT_Half)) {
>>>> +		debug("1000 ");
>>>> +		duplex = !!(nego & ADVERTISED_1000baseT_Full);
>>>> +
>>>> +	} else if (nego & (ADVERTISED_100baseT_Full |
>>>> +		   ADVERTISED_100baseT_Half)) {
>>>> +		debug("100 ");
>>>> +		duplex = !!(nego & ADVERTISED_100baseT_Full);
>>>> +	} else {
>>>> +		debug("10 ");
>>>> +		duplex = !!(nego & ADVERTISED_10baseT_Full);
>>>> +	}
>>>> +
>>>> +	if (duplex == DUPLEX_FULL)
>>>> +		debug("full dup ");
>>>> +	else
>>>> +		debug("half dup ");
>>>> +
>>>> +	if (duplex == DUPLEX_FULL) {
>>>> +		if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) {
>>>> +			cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
>>>> +		} else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) {
>>>> +			if (lcladv & ADVERTISE_PAUSE_CAP)
>>>> +				cap = FLOW_CTRL_RX;
>>>> +			else if (rmtadv & LPA_PAUSE_CAP)
>>>> +				cap = FLOW_CTRL_TX;
>>>> +		}
>>>> +		debug("TX Flow ");
>>>> +		if (cap & FLOW_CTRL_TX) {
>>>> +			*flow = (FLOW_CR_TX_FCEN | 0xFFFF);
>>>> +			/* set fct_flow thresholds to 20% and 80% */
>>>> +			*fct_flow = (((MAX_RX_FIFO_SIZE * 2) / (10 * 512))
>>>> +					& 0x7FUL);
>>>
>
>The rest is fine, thanks!
>
>--
>Best regards,
>Marek Vasut


More information about the U-Boot mailing list