summaryrefslogtreecommitdiff
path: root/src/soc/intel/apollolake/p2sb.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-07-01 16:36:03 -0500
committerAaron Durbin <adurbin@chromium.org>2016-07-02 03:22:32 +0200
commitfadfc2e2f6abbcaea7bbc92c13716c5382443993 (patch)
treed4c5ba325a8aa0a33c1fe17fd8be8d854d726d41 /src/soc/intel/apollolake/p2sb.c
parent4025e26fc585d372a39087c67b6efd4b410a89bd (diff)
soc/intel/apollolake: handle p2sb quirks
The P2SB device is device 0xd and function 0. If hidden that causes the latter pci devices on function >= 1 to not be probed in the kernel. This is also a problem for coreboot if the P2SB device is hidden by FSP. That means the coreboot driver won't be ran. Therefore, provide hide and unhide functions for the P2SB device. The other quirk is to allow the GPIO devices to work correctly. Those devices are ACPI devices. However, their resources are sub-regions within the P2SB BAR. Sadly, linux doesn't handle ACPI devices being children of PCI devices. This leads to resource conflict errors when the P2SB device is visible. For the time being keep the P2SB device hidden, but also ensure the resources it is using are accounted for and reserved. The fallout of that is the PMC and SPI device are no longer probed by the kernel. BUG=chrome-os-partner:53017 TEST=Ensured P2SB device is visible and pci resources are allocated correctly for the devices. Change-Id: I24e59bbde74310e1ce8425b344a3ad0b88702153 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/15530 Tested-by: build bot (Jenkins) Reviewed-by: Andrey Petrov <andrey.petrov@intel.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/soc/intel/apollolake/p2sb.c')
-rw-r--r--src/soc/intel/apollolake/p2sb.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/soc/intel/apollolake/p2sb.c b/src/soc/intel/apollolake/p2sb.c
new file mode 100644
index 0000000000..7834e3866e
--- /dev/null
+++ b/src/soc/intel/apollolake/p2sb.c
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/io.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <rules.h>
+#include <soc/iomap.h>
+#include <soc/pci_devs.h>
+#include <soc/pci_ids.h>
+#include <soc/p2sb.h>
+
+#define P2SB_E0 0xe0
+#define HIDE_BIT (1 << 0)
+
+static void p2sb_set_hide_bit(int hide)
+{
+ struct device *dev;
+ const uint16_t reg = P2SB_E0 + 1;
+ const uint8_t mask = HIDE_BIT;
+ uint8_t val;
+
+ dev = P2SB_DEV;
+
+ val = pci_read_config8(dev, reg);
+ val &= ~mask;
+ if (hide)
+ val |= mask;
+ pci_write_config8(dev, reg, val);
+}
+
+void p2sb_unhide(void)
+{
+ p2sb_set_hide_bit(0);
+}
+
+void p2sb_hide(void)
+{
+ p2sb_set_hide_bit(HIDE_BIT);
+}
+
+static void read_resources(struct device *dev)
+{
+ /*
+ * There's only one resource on the P2SB device. It's also already
+ * manually set to a fixed address in earlier boot stages.
+ */
+ mmio_resource(dev, PCI_BASE_ADDRESS_0, P2SB_BAR / KiB, P2SB_SIZE / KiB);
+}
+
+static const struct device_operations device_ops = {
+ .read_resources = read_resources,
+ .set_resources = DEVICE_NOOP,
+};
+
+static const struct pci_driver pmc __pci_driver = {
+ .ops = &device_ops,
+ .vendor = PCI_VENDOR_ID_INTEL,
+ .device = PCI_DEVICE_ID_APOLLOLAKE_P2SB,
+};