Skip to content

Commit 7f82299

Browse files
Yinghai Lujbarnes993
authored andcommitted
PCI: pciehp: Add Disable/enable link functions
Will use it during power off/on of slots Signed-off-by: Yinghai Lu <[email protected]> Signed-off-by: Jesse Barnes <[email protected]>
1 parent bffe4f7 commit 7f82299

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,42 @@ int pciehp_check_link_status(struct controller *ctrl)
352352
return retval;
353353
}
354354

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+
355391
int pciehp_get_attention_status(struct slot *slot, u8 *status)
356392
{
357393
struct controller *ctrl = slot->ctrl;

0 commit comments

Comments
 (0)