diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-01-27 13:55:14 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2012-02-14 11:45:01 -0500 |
commit | 7f822999e12a144e68c915194267108f8051cf9b (patch) | |
tree | 8836b3dcde3fa8c8847a045e638089c97542fd0e /drivers/pci | |
parent | bffe4f72fcdd92bfb24909d586d1636e5cec500d (diff) |
PCI: pciehp: Add Disable/enable link functions
Will use it during power off/on of slots
Signed-off-by: Yinghai Lu <yinghai.lu@oracle.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/pciehp_hpc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 4ebdc1de2cb4..db33688af588 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -352,6 +352,42 @@ int pciehp_check_link_status(struct controller *ctrl) | |||
352 | return retval; | 352 | return retval; |
353 | } | 353 | } |
354 | 354 | ||
355 | static int __pciehp_link_set(struct controller *ctrl, bool enable) | ||
356 | { | ||
357 | u16 lnk_ctrl; | ||
358 | int retval = 0; | ||
359 | |||
360 | retval = pciehp_readw(ctrl, PCI_EXP_LNKCTL, &lnk_ctrl); | ||
361 | if (retval) { | ||
362 | ctrl_err(ctrl, "Cannot read LNKCTRL register\n"); | ||
363 | return retval; | ||
364 | } | ||
365 | |||
366 | if (enable) | ||
367 | lnk_ctrl &= ~PCI_EXP_LNKCTL_LD; | ||
368 | else | ||
369 | lnk_ctrl |= PCI_EXP_LNKCTL_LD; | ||
370 | |||
371 | retval = pciehp_writew(ctrl, PCI_EXP_LNKCTL, lnk_ctrl); | ||
372 | if (retval) { | ||
373 | ctrl_err(ctrl, "Cannot write LNKCTRL register\n"); | ||
374 | return retval; | ||
375 | } | ||
376 | ctrl_dbg(ctrl, "%s: lnk_ctrl = %x\n", __func__, lnk_ctrl); | ||
377 | |||
378 | return retval; | ||
379 | } | ||
380 | |||
381 | static int pciehp_link_enable(struct controller *ctrl) | ||
382 | { | ||
383 | return __pciehp_link_set(ctrl, true); | ||
384 | } | ||
385 | |||
386 | static int pciehp_link_disable(struct controller *ctrl) | ||
387 | { | ||
388 | return __pciehp_link_set(ctrl, false); | ||
389 | } | ||
390 | |||
355 | int pciehp_get_attention_status(struct slot *slot, u8 *status) | 391 | int pciehp_get_attention_status(struct slot *slot, u8 *status) |
356 | { | 392 | { |
357 | struct controller *ctrl = slot->ctrl; | 393 | struct controller *ctrl = slot->ctrl; |