All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Add support for Microchip LAN75xx and LAN78xx
Date: Tue, 18 Apr 2017 18:47:09 +0200	[thread overview]
Message-ID: <41b5d514-4245-62bb-d4d8-123675461362@denx.de> (raw)
In-Reply-To: <6AF1B4F019F8804DB17BB6F30B56F026BDC0C1@CHN-SV-EXMX02.mchp-main.com>

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

  reply	other threads:[~2017-04-18 16:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 19:23 [U-Boot] [PATCH] Add support for Microchip LAN75xx and LAN78xx Yuiko.Oshino at microchip.com
2017-04-14 12:35 ` Marek Vasut
2017-04-18 15:58   ` Yuiko.Oshino at microchip.com
2017-04-18 16:47     ` Marek Vasut [this message]
2017-05-03 14:20       ` Yuiko.Oshino at microchip.com
2017-04-18 18:18 ` Simon Glass
2017-05-05 20:58 ` Joe Hershberger
2017-05-10 15:25   ` Yuiko.Oshino at microchip.com
2017-05-24 15:14     ` Yuiko.Oshino at microchip.com
2017-05-30 16:54       ` Joe Hershberger
2017-05-25 16:43     ` Joe Hershberger

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=41b5d514-4245-62bb-d4d8-123675461362@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.