Patchwork [U-Boot,v3,06/10] NET: phy: add 88E1310 PHY initialization

login
register
mail settings
Submitter Sebastian Hesselbarth
Date Jan. 16, 2013, 7:25 p.m.
Message ID <1358364328-14904-7-git-send-email-sebastian.hesselbarth@gmail.com>
Download mbox | patch
Permalink /patch/213026/
State New
Delegated to: Prafulla Wadaskar
Headers show

Comments

Sebastian Hesselbarth - Jan. 16, 2013, 7:25 p.m.
This adds PHY initialization for Marvell Alaska 88E1310 PHY.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: u-boot@lists.denx.de
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rabeeh Khoury <rabeeh@solid-run.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
Cc: Andy Fleming <afleming@gmail.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Daniel Stodden <daniel.stodden@gmail.com>
Cc: Luka Perkov <luka@openwrt.org>
---
 drivers/net/phy/marvell.c |   48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
Prafulla Wadaskar - Feb. 11, 2013, 3:39 a.m.
> -----Original Message-----
> From: Sebastian Hesselbarth [mailto:sebastian.hesselbarth@gmail.com]
> Sent: 17 January 2013 00:55
> To: Sebastian Hesselbarth
> Cc: u-boot@lists.denx.de; Rabeeh Khoury; Albert Aribaud; Prafulla
> Wadaskar; Andy Fleming; Joe Hershberger; Daniel Stodden; Luka Perkov
> Subject: [PATCH v3 06/10] NET: phy: add 88E1310 PHY initialization
> 
> This adds PHY initialization for Marvell Alaska 88E1310 PHY.
> 
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> ---
> Cc: u-boot@lists.denx.de
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Rabeeh Khoury <rabeeh@solid-run.com>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Prafulla Wadaskar <prafulla@marvell.com>
> Cc: Andy Fleming <afleming@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@gmail.com>
> Cc: Daniel Stodden <daniel.stodden@gmail.com>
> Cc: Luka Perkov <luka@openwrt.org>
> ---
>  drivers/net/phy/marvell.c |   48
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index 4b27198..1205166 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -89,6 +89,12 @@
> 
>  #define MIIM_88E1149_PHY_PAGE	29
> 
> +/* 88E1310 PHY defines */
> +#define MIIM_88E1310_PHY_LED_CTRL	16
> +#define MIIM_88E1310_PHY_IRQ_EN		18
> +#define MIIM_88E1310_PHY_RGMII_CTRL	21
> +#define MIIM_88E1310_PHY_PAGE		22
> +
>  /* Marvell 88E1011S */
>  static int m88e1011s_config(struct phy_device *phydev)
>  {
> @@ -394,6 +400,37 @@ static int m88e1149_config(struct phy_device
> *phydev)
>  	return 0;
>  }
> 
> +/* Marvell 88E1310 */
> +static int m88e1310_config(struct phy_device *phydev)
> +{
> +	u16 reg;
> +
> +	/* LED link and activity */
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
> +	reg = phy_read(phydev, MDIO_DEVAD_NONE,
> MIIM_88E1310_PHY_LED_CTRL);
> +	reg = (reg & ~0xf) | 0x1;
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_LED_CTRL,
> reg);
> +
> +	/* Set LED2/INT to INT mode, low active */
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
> +	reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN);
> +	reg = (reg & 0x77ff) | 0x0880;
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN, reg);
> +
> +	/* Set RGMII delay */
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0002);
> +	reg = phy_read(phydev, MDIO_DEVAD_NONE,
> MIIM_88E1310_PHY_RGMII_CTRL);
> +	reg |= 0x0030;
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_RGMII_CTRL,
> reg);
> +
> +	/* Ensure to return to page 0 */
> +	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0000);
> +
> +	genphy_config_aneg(phydev);
> +	phy_reset(phydev);
> +
> +	return 0;
> +}
> 
>  static struct phy_driver M88E1011S_driver = {
>  	.name = "Marvell 88E1011S",
> @@ -465,8 +502,19 @@ static struct phy_driver M88E1149S_driver = {
>  	.shutdown = &genphy_shutdown,
>  };
> 
> +static struct phy_driver M88E1310_driver = {
> +	.name = "Marvell 88E1310",
> +	.uid = 0x01410e90,
> +	.mask = 0xffffff0,
> +	.features = PHY_GBIT_FEATURES,
> +	.config = &m88e1310_config,
> +	.startup = &m88e1011s_startup,
> +	.shutdown = &genphy_shutdown,
> +};
> +
>  int phy_marvell_init(void)
>  {
> +	phy_register(&M88E1310_driver);

Please maintain an order here.

>  	phy_register(&M88E1149S_driver);
>  	phy_register(&M88E1145_driver);
>  	phy_register(&M88E1121R_driver);
> --
> 1.7.10.4

Regards...
Prafulla . . .

Patch

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 4b27198..1205166 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -89,6 +89,12 @@ 
 
 #define MIIM_88E1149_PHY_PAGE	29
 
+/* 88E1310 PHY defines */
+#define MIIM_88E1310_PHY_LED_CTRL	16
+#define MIIM_88E1310_PHY_IRQ_EN		18
+#define MIIM_88E1310_PHY_RGMII_CTRL	21
+#define MIIM_88E1310_PHY_PAGE		22
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {
@@ -394,6 +400,37 @@  static int m88e1149_config(struct phy_device *phydev)
 	return 0;
 }
 
+/* Marvell 88E1310 */
+static int m88e1310_config(struct phy_device *phydev)
+{
+	u16 reg;
+
+	/* LED link and activity */
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
+	reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_LED_CTRL);
+	reg = (reg & ~0xf) | 0x1;
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_LED_CTRL, reg);
+
+	/* Set LED2/INT to INT mode, low active */
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
+	reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN);
+	reg = (reg & 0x77ff) | 0x0880;
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN, reg);
+
+	/* Set RGMII delay */
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0002);
+	reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_RGMII_CTRL);
+	reg |= 0x0030;
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_RGMII_CTRL, reg);
+
+	/* Ensure to return to page 0 */
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0000);
+
+	genphy_config_aneg(phydev);
+	phy_reset(phydev);
+
+	return 0;
+}
 
 static struct phy_driver M88E1011S_driver = {
 	.name = "Marvell 88E1011S",
@@ -465,8 +502,19 @@  static struct phy_driver M88E1149S_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
+static struct phy_driver M88E1310_driver = {
+	.name = "Marvell 88E1310",
+	.uid = 0x01410e90,
+	.mask = 0xffffff0,
+	.features = PHY_GBIT_FEATURES,
+	.config = &m88e1310_config,
+	.startup = &m88e1011s_startup,
+	.shutdown = &genphy_shutdown,
+};
+
 int phy_marvell_init(void)
 {
+	phy_register(&M88E1310_driver);
 	phy_register(&M88E1149S_driver);
 	phy_register(&M88E1145_driver);
 	phy_register(&M88E1121R_driver);