phylib: Basic support for the M88E1121R Marvell chip
Subsystems (3)
PATCH 1/3 phylib: Basic support for the M88E1121R Marvell chip
From: Sergei Poselenov <[email protected]>
Add support for the Marvell M88E1121R Dual GigE PHY
--- drivers/net/phy/marvell.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-)
drivers/net/phy/marvell.c +41 -0
@@ -69,6 +69,11 @@#define MII_M1111_COPPER 0#define MII_M1111_FIBER 1 +#define MII_88E1121_PHY_LED_CTRL 16 +#define MII_88E1121_PHY_LED_PAGE 3 +#define MII_88E1121_PHY_LED_DEF 0x0030 +#define MII_88E1121_PHY_PAGE 22 +#define MII_M1011_PHY_STATUS 0x11#define MII_M1011_PHY_STATUS_1000 0x8000#define MII_M1011_PHY_STATUS_100 0x4000
@@ -154,6 +159,30 @@ static int marvell_config_aneg(struct phy_device *phydev)return err; } +static int m88e1121_config_aneg (struct phy_device *phydev) +{ +int err, temp; + + err =phy_write (phydev,MII_BMCR ,BMCR_RESET ); +if (err <0 ) +return err; + + err =phy_write (phydev,MII_M1011_PHY_SCR , +MII_M1011_PHY_SCR_AUTO_CROSS ); +if (err <0 ) +return err; + + temp =phy_read (phydev,MII_88E1121_PHY_PAGE ); + +phy_write (phydev,MII_88E1121_PHY_PAGE ,MII_88E1121_PHY_LED_PAGE ); +phy_write (phydev,MII_88E1121_PHY_LED_CTRL ,MII_88E1121_PHY_LED_DEF ); +phy_write (phydev,MII_88E1121_PHY_PAGE , temp); + + err =genphy_config_aneg (phydev); + +return err; +} +static int m88e1111_config_init (struct phy_device *phydev) {int err;
@@ -482,6 +511,18 @@ static struct phy_driver marvell_drivers[] = { .driver = {.owner = THIS_MODULE,}, }, { + .phy_id = 0x01410cb0, + .phy_id_mask = 0xfffffff0, + .name = "Marvell 88E1121R", + .features = PHY_GBIT_FEATURES, + .flags = PHY_HAS_INTERRUPT, + .config_aneg = &m88e1121_config_aneg, + .read_status = &marvell_read_status, + .ack_interrupt = &marvell_ack_interrupt, + .config_intr = &marvell_config_intr, + .driver = { .owner = THIS_MODULE }, + }, + { .phy_id = 0x01410cd0, .phy_id_mask = 0xfffffff0, .name = "Marvell 88E1145",
Signature · 1 line
1.5.6.3
PATCH 2/3 phylib: Allow early-out in phy_change
Marvell 88E1121R Dual PHY device can be hardware-configured to use shared interrupt pin for both PHY ports. For such PHY configurations using shared PHY interrupt phy_interrupt() handler will also schedule a work for PHY port which didn't cause an interrupt.
This patch adds a possibility for PHY drivers to provide did_interrupt() function which reports if the PHY (or a PHY port in a multi-PHY device) generated an interrupt. This function is called in phy_change() as phy_change() shouldn't proceed if it is invoked for a PHY which didn't cause an interrupt. So check for interrupt originator in phy_change() to allow early-out.
--- drivers/net/phy/phy.c | 9 +++++++++ include/linux/phy.h | 6 ++++++ 2 files changed, 15 insertions(+), 0 deletions(-)
drivers/net/phy/phy.c +9 -0
@@ -655,6 +655,10 @@ static void phy_change(struct work_struct *work)struct phy_device *phydev = container_of(work, struct phy_device, phy_queue); +if (phydev->drv->did_interrupt && + !phydev->drv->did_interrupt (phydev)) + goto ignore; + err =phy_disable_interrupts (phydev);if (err)
@@ -681,6 +685,11 @@ static void phy_change(struct work_struct *work)return ; +ignore: +atomic_dec (&phydev->irq_disable); +enable_irq (phydev->irq); +return ; + irq_enable_err:disable_irq (phydev->irq);atomic_inc (&phydev->irq_disable);
include/linux/phy.h +6 -0
@@ -388,6 +388,12 @@ struct phy_driver {/* Enables or disables interrupts */ int (*config_intr)(struct phy_device *phydev); +/* +* Checks if the PHY generated an interrupt. +* For multy-PHY devices with shared PHY interrupt pin +*/ +int (*did_interrupt)(struct phy_device *phydev); +/* Clears up any memory if needed */ void (*remove)(struct phy_device *phydev);
Signature · 1 line
1.5.6.3
PATCH 3/3 phylib: Add interrupt source check function to M88E1121R driver
Add did_interrupt() function to check if a PHY port really caused an interrupt. This is needed in the case of shared PHY interrupt pin configuration to stop interrupt event processing for PHY ports which didn't cause an interrupt.
--- drivers/net/phy/marvell.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/net/phy/marvell.c +13 -0
@@ -458,6 +458,18 @@ static int marvell_read_status(struct phy_device *phydev)return 0 ; } +static int m88e1121_did_interrupt (struct phy_device *phydev) +{ +int imask; + + imask =phy_read (phydev,MII_M1011_IEVENT ); + +if (imask &MII_M1011_IMASK_INIT ) +return 1 ; + +return 0 ; +} +static struct phy_driver marvell_drivers[] = { { .phy_id =0x01410c60 ,
@@ -520,6 +532,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = &marvell_read_status, .ack_interrupt = &marvell_ack_interrupt, .config_intr = &marvell_config_intr, + .did_interrupt = &m88e1121_did_interrupt, .driver = { .owner = THIS_MODULE }, }, {
Signature · 1 line
1.5.6.3
From: Anatolij Gustschin <[email protected]>
Date: Tue, 7 Apr 2009 14:01:41 +0200
Quoted 7 lines
From: Sergei Poselenov <[email protected]>
Add support for the Marvell M88E1121R Dual GigE PHY
Signed-off-by Yuri Tikhonov <[email protected]>Signed-off-by Sergei Poselenov <[email protected]>Signed-off-by Anatolij Gustschin <[email protected]>
Applied.
Re: [PATCH 3/3] phylib: Add interrupt source check function to M88E1121R driver
In reply to Anatolij GustschinFrom: Anatolij Gustschin <[email protected]>
Date: Tue, 7 Apr 2009 14:01:43 +0200
Quoted 7 lines
Add
did_interrupt()function to check if a PHY port really caused an interrupt. This is needed in the case of shared PHY interrupt pin configuration to stop interrupt event processing for PHY ports which didn't cause an interrupt.Signed-off-by Anatolij Gustschin <[email protected]>
Applied.
Re: [PATCH 2/3] phylib: Allow early-out in phy_change
In reply to Anatolij GustschinFrom: Anatolij Gustschin <[email protected]>
Date: Tue, 7 Apr 2009 14:01:42 +0200
Quoted 14 lines
Marvell 88E1121R Dual PHY device can be hardware-configured to use shared interrupt pin for both PHY ports. For such PHY configurations using shared PHY interrupt
phy_interrupt()handler will also schedule a work for PHY port which didn't cause an interrupt.This patch adds a possibility for PHY drivers to provide
did_interrupt()function which reports if the PHY (or a PHY port in a multi-PHY device) generated an interrupt. This function is called inphy_change()asphy_change()shouldn't proceed if it is invoked for a PHY which didn't cause an interrupt. So check for interrupt originator inphy_change()to allow early-out.
Quoted 1 line
Signed-off-by Anatolij Gustschin <[email protected]>
Applied.
include/linux/phy.h struct phy_driver { · line 393
Quoted 1 line
include/linux/phy.h +1
-0+* For multy-PHY devices with shared PHY interrupt pin
^^^^^
I fixed that typo when commiting this change.