Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277965
b: refs/heads/master
c: 32f160d
h: refs/heads/master
i:
  277963: 1856fd3
v: v3
  • Loading branch information
Tristram Ha authored and David S. Miller committed Nov 26, 2011
1 parent 41829bf commit e3c7651
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9a8de214c91eecf596b3e79c7986b74ef17f4ec
refs/heads/master: 32f160d96514a15cc52b708d8a8b9742bc3acd5d
47 changes: 27 additions & 20 deletions trunk/drivers/net/ethernet/micrel/ks8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op)
mdelay(1); /* wait for condition to clear */
}

/**
* ks8851_set_powermode - set power mode of the device
* @ks: The device state
* @pwrmode: The power mode value to write to KS_PMECR.
*
* Change the power mode of the chip.
*/
static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode)
{
unsigned pmecr;

netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);

pmecr = ks8851_rdreg16(ks, KS_PMECR);
pmecr &= ~PMECR_PM_MASK;
pmecr |= pwrmode;

ks8851_wrreg16(ks, KS_PMECR, pmecr);
}

/**
* ks8851_write_mac_addr - write mac address to device registers
* @dev: The network device
Expand All @@ -358,8 +378,15 @@ static int ks8851_write_mac_addr(struct net_device *dev)

mutex_lock(&ks->lock);

/*
* Wake up chip in case it was powered off when stopped; otherwise,
* the first write to the MAC address does not take effect.
*/
ks8851_set_powermode(ks, PMECR_PM_NORMAL);
for (i = 0; i < ETH_ALEN; i++)
ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]);
if (!netif_running(dev))
ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);

mutex_unlock(&ks->lock);

Expand Down Expand Up @@ -764,26 +791,6 @@ static void ks8851_tx_work(struct work_struct *work)
mutex_unlock(&ks->lock);
}

/**
* ks8851_set_powermode - set power mode of the device
* @ks: The device state
* @pwrmode: The power mode value to write to KS_PMECR.
*
* Change the power mode of the chip.
*/
static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode)
{
unsigned pmecr;

netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);

pmecr = ks8851_rdreg16(ks, KS_PMECR);
pmecr &= ~PMECR_PM_MASK;
pmecr |= pwrmode;

ks8851_wrreg16(ks, KS_PMECR, pmecr);
}

/**
* ks8851_net_open - open network device
* @dev: The network device being opened.
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ethernet/micrel/ks8851.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define CCR_32PIN (1 << 0)

/* MAC address registers */
#define KS_MAR(_m) 0x15 - (_m)
#define KS_MAR(_m) (0x15 - (_m))
#define KS_MARL 0x10
#define KS_MARM 0x12
#define KS_MARH 0x14
Expand Down

0 comments on commit e3c7651

Please sign in to comment.