[U-Boot] [PATCH] Add support for Microchip LAN75xx and LAN78xx
Marek Vasut
marex at denx.de
Tue Apr 18 16:47:09 UTC 2017
On 04/18/2017 05:58 PM, Yuiko.Oshino at microchip.com wrote:
[...]
>>> +/* MAC ADDRESS PERFECT FILTER For LAN75xx */
>>> +#define LAN75XX_ADDR_FILTX 0x300
>>> +#define LAN75XX_ADDR_FILTX_FB_VALID BIT(31)
>>> +
>>> +#ifndef CONFIG_DM_ETH
>>
>> I'd just make this depend on DM and scrap the non-DM part. It's not worth
>> the hassle .
>
> Okay, please let me confirm that I can delete all #ifndef CONFIG_DM_ETH stuff and remove non-DM code?
> Do I still need to keep #ifdef CONFIG_DM_ETH to avoid build errors?
Make it depend on DM_ETH and be done with it. We're moving toward DM anyway.
I'm CCing Simon , so wait for his confirmation on this.
>>> +/* local vars */
>>> +static int curr_eth_dev; /* index for name of next device detected */
>>> +
>>> +/* local defines */
>>> +#define LAN75XX_BASE_NAME "lan75xx"
>>> +#endif
>>> +
>>> +/*
>>> + * Lan75xx infrastructure commands
>>> + */
[...]
>>> +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 :)
>>> + 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