netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: shh.xie@gmail.com, netdev@vger.kernel.org, davem@davemloft.net
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Subject: Re: [PATCH] phylib: add driver for aquantia phy
Date: Thu, 23 Jul 2015 21:39:23 -0700	[thread overview]
Message-ID: <55B1C17B.1000704@gmail.com> (raw)
In-Reply-To: <1437709605-42980-1-git-send-email-shh.xie@gmail.com>

Le 07/23/15 20:46, shh.xie@gmail.com a écrit :
> From: Shaohui Xie <Shaohui.Xie@freescale.com>
> 
> This patch added driver to support Aquantia PHYs AQ1202, AQ2104, AQR105,
> AQR405, which accessed through clause 45.

Could you prefix your patches with "net: phy: " in the future to be
consistent with what is typically used?

See comments below

> 
> Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
> ---

[snip]

> +static int aquantia_read_status(struct phy_device *phydev)
> +{
> +	int reg;
> +
> +	phydev->speed = SPEED_10000;
> +	phydev->duplex = DUPLEX_FULL;
> +
> +	reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
> +	reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
> +	if (reg & MDIO_STAT1_LSTATUS)
> +		phydev->link = 1;
> +	else
> +		phydev->link = 0;
> +
> +	reg = phy_read_mmd(phydev, MDIO_MMD_AN, 0xc800);
> +	mdelay(10);
> +	reg = phy_read_mmd(phydev, MDIO_MMD_AN, 0xc800);
> +	if (reg == 0x9)
> +		phydev->speed = SPEED_2500;
> +	else if (reg == 0x5)
> +		phydev->speed = SPEED_1000;
> +	else if (reg == 0x3)
> +		phydev->speed = SPEED_100;

Could we use a switch/case here? How about 10Mbits/sec and duplex are we
guaranteed to be full-duplex at e.g: 100 or 10Mbits/sec?

> +
> +	return 0;
> +}
> +
> +static struct phy_driver aquantia_driver[] = {
> +{
> +	.phy_id		= PHY_ID_AQ1202,
> +	.phy_id_mask	= 0xfffffff0,
> +	.name		= "Aquantia AQ1202",
> +	.features	= PHY_GBIT_FEATURES,

If these are 10GbE PHYs, should not we start defining a new features
bitmask here to reflect that accordingly? That way MAC

> +	.soft_reset	= aquantia_soft_reset,
> +	.aneg_done	= aquantia_aneg_done,
> +	.config_init    = aquantia_config_init,
> +	.config_aneg    = aquantia_config_aneg,
> +	.read_status	= aquantia_read_status,
> +	.driver		= { .owner = THIS_MODULE,},
> +},
> +{
> +	.phy_id		= PHY_ID_AQ2104,
> +	.phy_id_mask	= 0xfffffff0,
> +	.name		= "Aquantia AQ2104",
> +	.features	= PHY_GBIT_FEATURES,
> +	.soft_reset	= aquantia_soft_reset,
> +	.aneg_done	= aquantia_aneg_done,
> +	.config_init    = aquantia_config_init,
> +	.config_aneg    = aquantia_config_aneg,
> +	.read_status	= aquantia_read_status,
> +	.driver		= { .owner = THIS_MODULE,},
> +},
> +{
> +	.phy_id		= PHY_ID_AQR105,
> +	.phy_id_mask	= 0xfffffff0,
> +	.name		= "Aquantia AQR105",
> +	.features	= PHY_GBIT_FEATURES,
> +	.soft_reset	= aquantia_soft_reset,
> +	.aneg_done	= aquantia_aneg_done,
> +	.config_init    = aquantia_config_init,
> +	.config_aneg    = aquantia_config_aneg,
> +	.read_status	= aquantia_read_status,
> +	.driver		= { .owner = THIS_MODULE,},
> +},
> +{
> +	.phy_id		= PHY_ID_AQR405,
> +	.phy_id_mask	= 0xfffffff0,
> +	.name		= "Aquantia AQR405",
> +	.features	= PHY_GBIT_FEATURES,
> +	.soft_reset	= aquantia_soft_reset,
> +	.aneg_done	= aquantia_aneg_done,
> +	.config_init    = aquantia_config_init,
> +	.config_aneg    = aquantia_config_aneg,
> +	.read_status	= aquantia_read_status,
> +	.driver		= { .owner = THIS_MODULE,},
> +},
> +};
> +
> +static int __init aquantia_init(void)
> +{
> +	return phy_drivers_register(aquantia_driver,
> +				    ARRAY_SIZE(aquantia_driver));
> +}
> +
> +static void __exit aquantia_exit(void)
> +{
> +	return phy_drivers_unregister(aquantia_driver,
> +				      ARRAY_SIZE(aquantia_driver));
> +}
> +
> +module_init(aquantia_init);
> +module_exit(aquantia_exit);
> +
> +static struct mdio_device_id __maybe_unused aquantia_tbl[] = {
> +	{ PHY_ID_AQ1202, 0xfffffff0 },
> +	{ PHY_ID_AQ2104, 0xfffffff0 },
> +	{ PHY_ID_AQR105, 0xfffffff0 },
> +	{ PHY_ID_AQR405, 0xfffffff0 },
> +	{ }
> +};
> +
> +MODULE_DEVICE_TABLE(mdio, aquantia_tbl);
> +
> +MODULE_DESCRIPTION("Aquantia PHY driver");
> +MODULE_AUTHOR("Shaohui Xie <Shaohui.Xie@freescale.com>");
> +MODULE_LICENSE("GPL v2");
> 


-- 
Florian

  reply	other threads:[~2015-07-24  4:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24  3:46 [PATCH] phylib: add driver for aquantia phy shh.xie
2015-07-24  4:39 ` Florian Fainelli [this message]
2015-07-27  8:30   ` Shaohui Xie
2015-07-27 21:49     ` Florian Fainelli
2015-07-28  2:23       ` Shaohui Xie

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=55B1C17B.1000704@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=Shaohui.Xie@freescale.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shh.xie@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).