Lines 5330-5363
em_enable_wakeup(device_t dev)
Link Here
|
5330 |
{ |
5330 |
{ |
5331 |
struct adapter *adapter = device_get_softc(dev); |
5331 |
struct adapter *adapter = device_get_softc(dev); |
5332 |
if_t ifp = adapter->ifp; |
5332 |
if_t ifp = adapter->ifp; |
5333 |
u32 pmc, ctrl, ctrl_ext, rctl, wuc; |
5333 |
int error = 0; |
|
|
5334 |
u32 pmc, ctrl, ctrl_ext, rctl; |
5334 |
u16 status; |
5335 |
u16 status; |
5335 |
|
5336 |
|
5336 |
if ((pci_find_cap(dev, PCIY_PMG, &pmc) != 0)) |
5337 |
if (pci_find_cap(dev, PCIY_PMG, &pmc) != 0) |
5337 |
return; |
5338 |
return; |
5338 |
|
5339 |
|
5339 |
/* Advertise the wakeup capability */ |
|
|
5340 |
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL); |
5341 |
ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3); |
5342 |
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl); |
5343 |
wuc = E1000_READ_REG(&adapter->hw, E1000_WUC); |
5344 |
wuc |= E1000_WUC_PME_EN; |
5345 |
E1000_WRITE_REG(&adapter->hw, E1000_WUC, wuc); |
5346 |
|
5347 |
if ((adapter->hw.mac.type == e1000_ich8lan) || |
5348 |
(adapter->hw.mac.type == e1000_pchlan) || |
5349 |
(adapter->hw.mac.type == e1000_ich9lan) || |
5350 |
(adapter->hw.mac.type == e1000_ich10lan)) |
5351 |
e1000_suspend_workarounds_ich8lan(&adapter->hw); |
5352 |
|
5353 |
/* Keep the laser running on Fiber adapters */ |
5354 |
if (adapter->hw.phy.media_type == e1000_media_type_fiber || |
5355 |
adapter->hw.phy.media_type == e1000_media_type_internal_serdes) { |
5356 |
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); |
5357 |
ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA; |
5358 |
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext); |
5359 |
} |
5360 |
|
5361 |
/* |
5340 |
/* |
5362 |
** Determine type of Wakeup: note that wol |
5341 |
** Determine type of Wakeup: note that wol |
5363 |
** is set with all bits on by default. |
5342 |
** is set with all bits on by default. |
Lines 5373-5385
em_enable_wakeup(device_t dev)
Link Here
|
5373 |
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl); |
5352 |
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl); |
5374 |
} |
5353 |
} |
5375 |
|
5354 |
|
|
|
5355 |
if (!(adapter->wol & (E1000_WUFC_EX | E1000_WUFC_MAG | E1000_WUFC_MC))) |
5356 |
goto pme; |
5357 |
|
5358 |
/* Advertise the wakeup capability */ |
5359 |
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL); |
5360 |
ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3); |
5361 |
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl); |
5362 |
|
5363 |
/* Keep the laser running on Fiber adapters */ |
5364 |
if (adapter->hw.phy.media_type == e1000_media_type_fiber || |
5365 |
adapter->hw.phy.media_type == e1000_media_type_internal_serdes) { |
5366 |
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); |
5367 |
ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA; |
5368 |
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext); |
5369 |
} |
5370 |
|
5371 |
if ((adapter->hw.mac.type == e1000_ich8lan) || |
5372 |
(adapter->hw.mac.type == e1000_pchlan) || |
5373 |
(adapter->hw.mac.type == e1000_ich9lan) || |
5374 |
(adapter->hw.mac.type == e1000_ich10lan)) |
5375 |
e1000_suspend_workarounds_ich8lan(&adapter->hw); |
5376 |
|
5376 |
if ((adapter->hw.mac.type == e1000_pchlan) || |
5377 |
if ((adapter->hw.mac.type == e1000_pchlan) || |
5377 |
(adapter->hw.mac.type == e1000_pch2lan) || |
5378 |
(adapter->hw.mac.type == e1000_pch2lan) || |
5378 |
(adapter->hw.mac.type == e1000_pch_lpt) || |
5379 |
(adapter->hw.mac.type == e1000_pch_lpt) || |
5379 |
(adapter->hw.mac.type == e1000_pch_spt)) { |
5380 |
(adapter->hw.mac.type == e1000_pch_spt)) { |
5380 |
if (em_enable_phy_wakeup(adapter)) |
5381 |
error = em_enable_phy_wakeup(adapter); |
5381 |
return; |
5382 |
if (error) |
|
|
5383 |
goto pme; |
5382 |
} else { |
5384 |
} else { |
|
|
5385 |
/* Enable wakeup by the MAC */ |
5383 |
E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN); |
5386 |
E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN); |
5384 |
E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol); |
5387 |
E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol); |
5385 |
} |
5388 |
} |
Lines 5387-5396
em_enable_wakeup(device_t dev)
Link Here
|
5387 |
if (adapter->hw.phy.type == e1000_phy_igp_3) |
5390 |
if (adapter->hw.phy.type == e1000_phy_igp_3) |
5388 |
e1000_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); |
5391 |
e1000_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); |
5389 |
|
5392 |
|
5390 |
/* Request PME */ |
5393 |
pme: |
5391 |
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2); |
5394 |
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2); |
5392 |
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); |
5395 |
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); |
5393 |
if (if_getcapenable(ifp) & IFCAP_WOL) |
5396 |
if (!error && (if_getcapenable(ifp) & IFCAP_WOL)) |
5394 |
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; |
5397 |
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; |
5395 |
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2); |
5398 |
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2); |
5396 |
|
5399 |
|