summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-04-16 16:33:03 -0500
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-12-06 02:47:18 +0100
commitd2e5f6815e72ca1e52f5f08aa97dfabbd0ecbf67 (patch)
tree51396dcef88b727a3aeec7bf957e542aa54cc1b5
parent59bff09f301fe3544cc70aafaf666cae40fa3257 (diff)
southbridge/hudson: Disable USB controllers if devicetree says so
Change-Id: I009a01d3324d48d2eeda87d74c8e3e7c27958ee2 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/5525 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
-rw-r--r--src/southbridge/amd/agesa/hudson/hudson.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/southbridge/amd/agesa/hudson/hudson.c b/src/southbridge/amd/agesa/hudson/hudson.c
index 3b57221d65..d5f11dcc53 100644
--- a/src/southbridge/amd/agesa/hudson/hudson.c
+++ b/src/southbridge/amd/agesa/hudson/hudson.c
@@ -82,11 +82,34 @@ u16 pm_read16(u16 reg)
return read16(PM_MMIO_BASE + reg);
}
+#define PM_REG_USB_ENABLE 0xef
+
+enum usb_enable {
+ USB_EN_DEVFN_12_0 = (1 << 0),
+ USB_EN_DEVFN_12_2 = (1 << 1),
+ USB_EN_DEVFN_13_0 = (1 << 2),
+ USB_EN_DEVFN_13_2 = (1 << 3),
+ USB_EN_DEVFN_16_0 = (1 << 4),
+ USB_EN_DEVFN_16_2 = (1 << 5),
+};
+
+static void hudson_disable_usb(u8 disable)
+{
+ u8 reg8;
+
+ /* Bit 7 handles routing, 6 is reserved. we don't mess with those */
+ disable &= 0x3f;
+
+ reg8 = pm_read8(PM_REG_USB_ENABLE);
+ reg8 &= ~disable;
+ pm_write8(PM_REG_USB_ENABLE, reg8);
+}
+
void hudson_enable(device_t dev)
{
printk(BIOS_DEBUG, "hudson_enable()\n");
switch (dev->path.pci.devfn) {
- case (0x14 << 3) | 7: /* 0:14.7 SD */
+ case PCI_DEVFN(0x14, 7):
if (dev->enabled == 0) {
// read the VENDEV ID
device_t sd_dev = dev_find_slot( 0, PCI_DEVFN( 0x14, 7));
@@ -109,6 +132,29 @@ void hudson_enable(device_t dev)
pm_write8(0xd3, reg8);
}
break;
+
+ /* Make sure to disable other functions if function 0 is disabled */
+ case PCI_DEVFN(0x12, 0):
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_12_0);
+ case PCI_DEVFN(0x12, 2): /* Fall through */
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_12_2);
+ break;
+ case PCI_DEVFN(0x13, 0):
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_13_0);
+ case PCI_DEVFN(0x13, 2): /* Fall through */
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_13_2);
+ break;
+ case PCI_DEVFN(0x16, 0):
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_16_0);
+ case PCI_DEVFN(0x16, 2): /* Fall through */
+ if (dev->enabled == 0)
+ hudson_disable_usb(USB_EN_DEVFN_16_2);
+ break;
default:
break;
}