From: Peter Mamonov <pmamonov@gmail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net/phy: marvell: import support for 88E1111 from the Linux
Date: Mon, 13 Mar 2017 12:32:03 +0300 [thread overview]
Message-ID: <20170313093203.GC1864@berta> (raw)
In-Reply-To: <20170312121049.GC25192@mail.ovh.net>
Hi,
On Sun, Mar 12, 2017 at 01:10:49PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
>
> Why 2 patches?
The first patch is missing a few lines of code, so I've sent the second version.
Sorry, I should mention it in the message.
Regards,
Peter
>
> Best Regards,
> J/
> On 18:18 Fri 10 Mar , pmamonov@gmail.com wrote:
> > From: Peter Mamonov <pmamonov@gmail.com>
> >
> > Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> > ---
> > drivers/net/phy/marvell.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 126 insertions(+)
> >
> > diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> > index 38b2ad31f..ea5a4a9be 100644
> > --- a/drivers/net/phy/marvell.c
> > +++ b/drivers/net/phy/marvell.c
> > @@ -31,6 +31,22 @@
> > #define MII_M1011_PHY_STATUS_RESOLVED BIT(11)
> > #define MII_M1011_PHY_STATUS_LINK BIT(10)
> >
> > +#define MII_M1111_PHY_LED_CONTROL 0x18
> > +#define MII_M1111_PHY_LED_DIRECT 0x4100
> > +#define MII_M1111_PHY_LED_COMBINE 0x411c
> > +#define MII_M1111_PHY_EXT_CR 0x14
> > +#define MII_M1111_RX_DELAY 0x80
> > +#define MII_M1111_TX_DELAY 0x2
> > +#define MII_M1111_PHY_EXT_SR 0x1b
> > +
> > +#define MII_M1111_HWCFG_MODE_MASK 0xf
> > +#define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
> > +#define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
> > +#define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
> > +#define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
> > +#define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
> > +#define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
> > +
> > #define MII_M1111_COPPER 0
> > #define MII_M1111_FIBER 1
> >
> > @@ -402,6 +418,107 @@ static int m88e1540_config_init(struct phy_device *phydev)
> > return marvell_config_init(phydev);
> > }
> >
> > +static int m88e1111_config_init(struct phy_device *phydev)
> > +{
> > + int err;
> > + int temp;
> > +
> > + if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
> > + (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
> > + (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
> > + (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
> > +
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
> > + if (temp < 0)
> > + return temp;
> > +
> > + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
> > + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
> > + } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
> > + temp &= ~MII_M1111_TX_DELAY;
> > + temp |= MII_M1111_RX_DELAY;
> > + } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
> > + temp &= ~MII_M1111_RX_DELAY;
> > + temp |= MII_M1111_TX_DELAY;
> > + }
> > +
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
> > + if (err < 0)
> > + return err;
> > +
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> > + if (temp < 0)
> > + return temp;
> > +
> > + temp &= ~(MII_M1111_HWCFG_MODE_MASK);
> > +
> > + if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
> > + temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
> > + else
> > + temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
> > +
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > + if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> > + if (temp < 0)
> > + return temp;
> > +
> > + temp &= ~(MII_M1111_HWCFG_MODE_MASK);
> > + temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
> > + temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
> > +
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > + if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
> > + if (temp < 0)
> > + return temp;
> > + temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
> > + if (err < 0)
> > + return err;
> > +
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> > + if (temp < 0)
> > + return temp;
> > + temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
> > + temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> > + if (err < 0)
> > + return err;
> > +
> > + /* soft reset */
> > + err = phy_write(phydev, MII_BMCR, BMCR_RESET);
> > + if (err < 0)
> > + return err;
> > + do
> > + temp = phy_read(phydev, MII_BMCR);
> > + while (temp & BMCR_RESET);
> > +
> > + temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> > + if (temp < 0)
> > + return temp;
> > + temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
> > + temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
> > + err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> > + if (err < 0)
> > + return err;
> > + }
> > +
> > + err = marvell_of_reg_init(phydev);
> > + if (err < 0)
> > + return err;
> > +
> > + return phy_write(phydev, MII_BMCR, BMCR_RESET);
> > +}
> > +
> > static int m88e1121_config_init(struct phy_device *phydev)
> > {
> > u16 reg;
> > @@ -502,6 +619,15 @@ static int m88e1510_config_init(struct phy_device *phydev)
> >
> > static struct phy_driver marvell_drivers[] = {
> > {
> > + .phy_id = MARVELL_PHY_ID_88E1111,
> > + .phy_id_mask = MARVELL_PHY_ID_MASK,
> > + .drv.name = "Marvell 88E1111",
> > + .features = PHY_GBIT_FEATURES,
> > + .config_init = &m88e1111_config_init,
> > + .config_aneg = &genphy_config_aneg,
> > + .read_status = &marvell_read_status,
> > + },
> > + {
> > .phy_id = MARVELL_PHY_ID_88E1121R,
> > .phy_id_mask = MARVELL_PHY_ID_MASK,
> > .drv.name = "Marvell 88E1121R",
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-03-13 9:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 15:02 pmamonov
2017-03-10 15:18 ` pmamonov
2017-03-12 12:10 ` Jean-Christophe PLAGNIOL-VILLARD
2017-03-13 9:32 ` Peter Mamonov [this message]
2017-03-14 7:19 ` Sascha Hauer
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=20170313093203.GC1864@berta \
--to=pmamonov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=plagnioj@jcrosoft.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