Commit a3bf5fa7 authored by Mark Einon's avatar Mark Einon Committed by Greg Kroah-Hartman

staging: et131x: Introduce et1310_in_phy_coma() call

In several places in the code, the pm_csr register is read and the PHY_SW_COMA bit checked.

Move this check into its own small function to make the code more readable.
Signed-off-by: default avatarMark Einon <mark.einon@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 53c3ee0d
...@@ -612,7 +612,7 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *adapter) ...@@ -612,7 +612,7 @@ void et1310_setup_device_for_multicast(struct et131x_adapter *adapter)
/* Write out the new hash to the device */ /* Write out the new hash to the device */
pm_csr = readl(&adapter->regs->global.pm_csr); pm_csr = readl(&adapter->regs->global.pm_csr);
if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { if (!et1310_in_phy_coma(adapter)) {
writel(hash1, &rxmac->multi_hash1); writel(hash1, &rxmac->multi_hash1);
writel(hash2, &rxmac->multi_hash2); writel(hash2, &rxmac->multi_hash2);
writel(hash3, &rxmac->multi_hash3); writel(hash3, &rxmac->multi_hash3);
...@@ -653,7 +653,7 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter) ...@@ -653,7 +653,7 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter)
adapter->addr[5]; adapter->addr[5];
pm_csr = readl(&adapter->regs->global.pm_csr); pm_csr = readl(&adapter->regs->global.pm_csr);
if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { if (!et1310_in_phy_coma(adapter)) {
writel(uni_pf1, &rxmac->uni_pf_addr1); writel(uni_pf1, &rxmac->uni_pf_addr1);
writel(uni_pf2, &rxmac->uni_pf_addr2); writel(uni_pf2, &rxmac->uni_pf_addr2);
writel(uni_pf3, &rxmac->uni_pf_addr3); writel(uni_pf3, &rxmac->uni_pf_addr3);
......
...@@ -86,6 +86,21 @@ ...@@ -86,6 +86,21 @@
#include "et131x_adapter.h" #include "et131x_adapter.h"
#include "et131x.h" #include "et131x.h"
/**
* et1310_in_phy_coma - check if the device is in phy coma
* @adapter: pointer to our adapter structure
*
* Returns 0 if the device is not in phy coma, 1 if it is in phy coma
*/
int et1310_in_phy_coma(struct et131x_adapter *adapter)
{
u32 pmcsr;
pmcsr = readl(&adapter->regs->global.pm_csr);
return ET_PM_PHY_SW_COMA & pmcsr ? 1 : 0;
}
/** /**
* et1310_enable_phy_coma - called when network cable is unplugged * et1310_enable_phy_coma - called when network cable is unplugged
* @adapter: pointer to our adapter structure * @adapter: pointer to our adapter structure
......
...@@ -87,6 +87,7 @@ void et131x_enable_txrx(struct net_device *netdev); ...@@ -87,6 +87,7 @@ void et131x_enable_txrx(struct net_device *netdev);
void et131x_disable_txrx(struct net_device *netdev); void et131x_disable_txrx(struct net_device *netdev);
/* et1310_pm.c */ /* et1310_pm.c */
int et1310_in_phy_coma(struct et131x_adapter *adapter);
void et1310_enable_phy_coma(struct et131x_adapter *adapter); void et1310_enable_phy_coma(struct et131x_adapter *adapter);
void et1310_disable_phy_coma(struct et131x_adapter *adapter); void et1310_disable_phy_coma(struct et131x_adapter *adapter);
......
...@@ -239,15 +239,11 @@ static int et131x_pci_init(struct et131x_adapter *adapter, ...@@ -239,15 +239,11 @@ static int et131x_pci_init(struct et131x_adapter *adapter,
void et131x_error_timer_handler(unsigned long data) void et131x_error_timer_handler(unsigned long data)
{ {
struct et131x_adapter *adapter = (struct et131x_adapter *) data; struct et131x_adapter *adapter = (struct et131x_adapter *) data;
u32 pm_csr;
pm_csr = readl(&adapter->regs->global.pm_csr); if (!et1310_in_phy_coma(adapter))
if ((pm_csr & ET_PM_PHY_SW_COMA) == 0)
et1310_update_macstat_host_counters(adapter); et1310_update_macstat_host_counters(adapter);
else else
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev, "No interrupts, in PHY coma\n");
"No interrupts, in PHY coma, pm_csr = 0x%x\n", pm_csr);
if (!(adapter->bmsr & BMSR_LSTATUS) && if (!(adapter->bmsr & BMSR_LSTATUS) &&
adapter->boot_coma < 11) { adapter->boot_coma < 11) {
...@@ -256,7 +252,7 @@ void et131x_error_timer_handler(unsigned long data) ...@@ -256,7 +252,7 @@ void et131x_error_timer_handler(unsigned long data)
if (adapter->boot_coma == 10) { if (adapter->boot_coma == 10) {
if (!(adapter->bmsr & BMSR_LSTATUS)) { if (!(adapter->bmsr & BMSR_LSTATUS)) {
if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) { if (!et1310_in_phy_coma(adapter)) {
/* NOTE - This was originally a 'sync with /* NOTE - This was originally a 'sync with
* interrupt'. How to do that under Linux? * interrupt'. How to do that under Linux?
*/ */
...@@ -443,9 +439,6 @@ static void et131x_adjust_link(struct net_device *netdev) ...@@ -443,9 +439,6 @@ static void et131x_adjust_link(struct net_device *netdev)
{ {
struct et131x_adapter *adapter = netdev_priv(netdev); struct et131x_adapter *adapter = netdev_priv(netdev);
struct phy_device *phydev = adapter->phydev; struct phy_device *phydev = adapter->phydev;
struct address_map __iomem *iomem = adapter->regs;
u32 pm_csr;
if (netif_carrier_ok(netdev)) { if (netif_carrier_ok(netdev)) {
adapter->boot_coma = 20; adapter->boot_coma = 20;
...@@ -488,16 +481,13 @@ static void et131x_adjust_link(struct net_device *netdev) ...@@ -488,16 +481,13 @@ static void et131x_adjust_link(struct net_device *netdev)
} }
if (phydev->link != adapter->link) { if (phydev->link != adapter->link) {
/* If we are in coma mode, we need to disable it. */ /*
pm_csr = readl(&iomem->global.pm_csr); * Check to see if we are in coma mode and if
if (pm_csr & ET_PM_PHY_SW_COMA) { * so, disable it because we will not be able
/* * to read PHY values until we are out.
* Check to see if we are in coma mode and if */
* so, disable it because we will not be able if (et1310_in_phy_coma(adapter))
* to read PHY values until we are out.
*/
et1310_disable_phy_coma(adapter); et1310_disable_phy_coma(adapter);
}
if (phydev->link) { if (phydev->link) {
adapter->boot_coma = 20; adapter->boot_coma = 20;
......
...@@ -304,7 +304,7 @@ void et131x_isr_handler(struct work_struct *work) ...@@ -304,7 +304,7 @@ void et131x_isr_handler(struct work_struct *work)
* bp xon/xoff) * bp xon/xoff)
*/ */
pm_csr = readl(&iomem->global.pm_csr); pm_csr = readl(&iomem->global.pm_csr);
if ((pm_csr & ET_PM_PHY_SW_COMA) == 0) if (!et1310_in_phy_coma(adapter))
writel(3, &iomem->txmac.bp_ctrl); writel(3, &iomem->txmac.bp_ctrl);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment