Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/acpi More Amazon Graviton quirks:
details: https://anonhg.NetBSD.org/src/rev/1df796ebd241
branches: trunk
changeset: 464626:1df796ebd241
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Oct 14 22:59:15 2019 +0000
description:
More Amazon Graviton quirks:
- Ignore devno > 0 on the PCIe root port.
- Fixup PCIe bridge bus number register on the root port.
- Move quirk handling to acpipchb so it can be applied before the bus
is configured.
diffstat:
sys/arch/arm/acpi/acpi_pci_machdep.c | 128 +-----------------------
sys/arch/arm/acpi/acpi_pci_machdep.h | 4 +-
sys/arch/arm/acpi/acpipchb.c | 178 ++++++++++++++++++++++++++++++++++-
3 files changed, 186 insertions(+), 124 deletions(-)
diffs (truncated from 408 to 300 lines):
diff -r fd510e45d8c0 -r 1df796ebd241 sys/arch/arm/acpi/acpi_pci_machdep.c
--- a/sys/arch/arm/acpi/acpi_pci_machdep.c Mon Oct 14 22:53:05 2019 +0000
+++ b/sys/arch/arm/acpi/acpi_pci_machdep.c Mon Oct 14 22:59:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -60,120 +60,6 @@
#include <arm/pci/pci_msi_machdep.h>
-static int
-acpi_pci_amazon_graviton_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t *data)
-{
- struct acpi_pci_context *ap = pc->pc_conf_v;
- bus_size_t off;
- int b, d, f;
-
- pci_decompose_tag(pc, tag, &b, &d, &f);
-
- if (ap->ap_bus == b) {
- if (d > 0) {
- *data = -1;
- return EINVAL;
- }
- off = f * PCI_EXTCONF_SIZE + reg;
- *data = bus_space_read_4(ap->ap_bst, ap->ap_conf_bsh, off);
- return 0;
- }
-
- return acpimcfg_conf_read(pc, tag, reg, data);
-}
-
-static int
-acpi_pci_amazon_graviton_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
-{
- struct acpi_pci_context *ap = pc->pc_conf_v;
- bus_size_t off;
- int b, d, f;
-
- pci_decompose_tag(pc, tag, &b, &d, &f);
-
- if (ap->ap_bus == b) {
- if (d > 0) {
- return EINVAL;
- }
- off = f * PCI_EXTCONF_SIZE + reg;
- bus_space_write_4(ap->ap_bst, ap->ap_conf_bsh, off, data);
- return 0;
- }
-
- return acpimcfg_conf_write(pc, tag, reg, data);
-}
-
-static ACPI_STATUS
-acpi_pci_amazon_graviton_map(ACPI_HANDLE handle, UINT32 level, void *ctx, void **retval)
-{
- struct acpi_pci_context *ap = ctx;
- struct acpi_resources res;
- struct acpi_mem *mem;
- ACPI_STATUS rv;
- int error;
-
- rv = acpi_resource_parse(ap->ap_dev, handle, "_CRS", &res, &acpi_resource_parse_ops_quiet);
- if (ACPI_FAILURE(rv))
- return rv;
-
- mem = acpi_res_mem(&res, 0);
- if (mem == NULL) {
- acpi_resource_cleanup(&res);
- return AE_NOT_FOUND;
- }
-
- error = bus_space_map(ap->ap_bst, mem->ar_base, mem->ar_length, 0, &ap->ap_conf_bsh);
- if (error != 0)
- return AE_NO_MEMORY;
-
- return AE_CTRL_TERMINATE;
-}
-
-static void
-acpi_pci_amazon_graviton_init(struct pcibus_attach_args *pba)
-{
- struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
- ACPI_STATUS rv;
-
- rv = AcpiGetDevices(__UNCONST("AMZN0001"), acpi_pci_amazon_graviton_map, ap, NULL);
- if (ACPI_FAILURE(rv))
- return;
-
- ap->ap_conf_read = acpi_pci_amazon_graviton_conf_read;
- ap->ap_conf_write = acpi_pci_amazon_graviton_conf_write;
-}
-
-static const struct acpi_pci_quirk {
- const char q_oemid[ACPI_OEM_ID_SIZE+1];
- const char q_oemtableid[ACPI_OEM_TABLE_ID_SIZE+1];
- uint32_t q_oemrevision;
- void (*q_init)(struct pcibus_attach_args *);
-} acpi_pci_quirks[] = {
- { "AMAZON", "GRAVITON", 0, acpi_pci_amazon_graviton_init },
-};
-
-static const struct acpi_pci_quirk *
-acpi_pci_find_quirk(void)
-{
- ACPI_STATUS rv;
- ACPI_TABLE_MCFG *mcfg;
- u_int n;
-
- rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **)&mcfg);
- if (ACPI_FAILURE(rv))
- return NULL;
-
- for (n = 0; n < __arraycount(acpi_pci_quirks); n++) {
- const struct acpi_pci_quirk *q = &acpi_pci_quirks[n];
- if (memcmp(q->q_oemid, mcfg->Header.OemId, ACPI_OEM_ID_SIZE) == 0 &&
- memcmp(q->q_oemtableid, mcfg->Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE) == 0 &&
- q->q_oemrevision == mcfg->Header.OemRevision)
- return q;
- }
-
- return NULL;
-}
-
struct acpi_pci_prt {
u_int prt_segment;
u_int prt_bus;
@@ -274,7 +160,6 @@
{
struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
struct acpi_pci_prt *prt, *prtp;
- const struct acpi_pci_quirk *q;
struct acpi_devnode *ad;
ACPI_HANDLE handle;
int seg, bus, dev, func;
@@ -317,10 +202,6 @@
TAILQ_INSERT_TAIL(&acpi_pci_irq_routes, prt, prt_list);
}
- q = acpi_pci_find_quirk();
- if (q != NULL)
- q->q_init(pba);
-
acpimcfg_map_bus(self, pba->pba_pc, pba->pba_bus);
if (ad != NULL) {
@@ -334,6 +215,11 @@
static int
acpi_pci_md_bus_maxdevs(void *v, int busno)
{
+ struct acpi_pci_context * const ap = v;
+
+ if (ap->ap_bus_maxdevs != NULL)
+ return ap->ap_bus_maxdevs(ap, busno);
+
return 32;
}
diff -r fd510e45d8c0 -r 1df796ebd241 sys/arch/arm/acpi/acpi_pci_machdep.h
--- a/sys/arch/arm/acpi/acpi_pci_machdep.h Mon Oct 14 22:53:05 2019 +0000
+++ b/sys/arch/arm/acpi/acpi_pci_machdep.h Mon Oct 14 22:59:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.h,v 1.3 2019/10/14 00:16:29 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.h,v 1.4 2019/10/14 22:59:15 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,10 +39,12 @@
device_t ap_dev;
u_int ap_seg;
int ap_bus;
+ ACPI_HANDLE ap_handle;
bus_space_tag_t ap_bst;
bus_space_handle_t ap_conf_bsh;
int (*ap_conf_read)(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
int (*ap_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
+ int (*ap_bus_maxdevs)(struct acpi_pci_context *, int);
};
#endif /* !_ARM_ACPI_PCI_MACHDEP_H */
diff -r fd510e45d8c0 -r 1df796ebd241 sys/arch/arm/acpi/acpipchb.c
--- a/sys/arch/arm/acpi/acpipchb.c Mon Oct 14 22:53:05 2019 +0000
+++ b/sys/arch/arm/acpi/acpipchb.c Mon Oct 14 22:59:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -92,6 +92,174 @@
struct acpipchb_bus_space sc_pciio_bst;
};
+static int
+acpipchb_amazon_graviton_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t *data)
+{
+ struct acpi_pci_context *ap = pc->pc_conf_v;
+ int b, d, f;
+
+ pci_decompose_tag(pc, tag, &b, &d, &f);
+
+ if (ap->ap_bus == b) {
+ if (d > 0 || f > 0) {
+ *data = -1;
+ return EINVAL;
+ }
+ *data = bus_space_read_4(ap->ap_bst, ap->ap_conf_bsh, reg);
+ return 0;
+ }
+
+ return acpimcfg_conf_read(pc, tag, reg, data);
+}
+
+static int
+acpipchb_amazon_graviton_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
+{
+ struct acpi_pci_context *ap = pc->pc_conf_v;
+ int b, d, f;
+
+ pci_decompose_tag(pc, tag, &b, &d, &f);
+
+ if (ap->ap_bus == b) {
+ if (d > 0 || f > 0) {
+ return EINVAL;
+ }
+ bus_space_write_4(ap->ap_bst, ap->ap_conf_bsh, reg, data);
+ return 0;
+ }
+
+ return acpimcfg_conf_write(pc, tag, reg, data);
+}
+
+static int
+acpipchb_amazon_graviton_bus_maxdevs(struct acpi_pci_context *ap, int busno)
+{
+ if (busno == ap->ap_bus + 1)
+ return 1;
+
+ return 32;
+}
+
+static ACPI_STATUS
+acpipchb_amazon_graviton_map(ACPI_HANDLE handle, UINT32 level, void *ctx, void **retval)
+{
+ struct acpi_pci_context *ap = ctx;
+ struct acpi_resources res;
+ struct acpi_mem *mem;
+ ACPI_STATUS rv;
+ int error;
+
+ rv = acpi_resource_parse(ap->ap_dev, handle, "_CRS", &res, &acpi_resource_parse_ops_quiet);
+ if (ACPI_FAILURE(rv))
+ return rv;
+
+ mem = acpi_res_mem(&res, 0);
+ if (mem == NULL) {
+ acpi_resource_cleanup(&res);
+ return AE_NOT_FOUND;
+ }
+
+ error = bus_space_map(ap->ap_bst, mem->ar_base, mem->ar_length, 0, &ap->ap_conf_bsh);
+ if (error != 0)
+ return AE_NO_MEMORY;
+
+ return AE_CTRL_TERMINATE;
+}
+
+static ACPI_STATUS
+acpipchb_amazon_graviton_busres(ACPI_RESOURCE *res, void *context)
+{
+ if (res->Type != ACPI_RESOURCE_TYPE_ADDRESS16)
+ return AE_OK;
+ if (res->Data.Address16.ResourceType != ACPI_BUS_NUMBER_RANGE)
+ return AE_OK;
+
+ *(ACPI_RESOURCE *)context = *res;
+ return AE_CTRL_TERMINATE;
+}
+
Home |
Main Index |
Thread Index |
Old Index