Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/pci/pci_host_generic_acpi.c
/*- | /*- | ||||
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com> | * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com> | ||||
* Copyright (c) 2014 The FreeBSD Foundation | * Copyright (c) 2014 The FreeBSD Foundation | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* This software was developed by Semihalf under | * This software was developed by Semihalf under | ||||
* the sponsorship of the FreeBSD Foundation. | * the sponsorship of the FreeBSD Foundation. | ||||
* | * | ||||
emaste: The previous statement is the standard one for Foundation-sponsored work, however I am not… | |||||
Not Done Inline ActionsYou are right. I should have kept this. Fixed. pdk_semihalf.com: You are right. I should have kept this. Fixed. | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
* documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. | ||||
Show All 34 Lines | |||||
#include <dev/acpica/acpivar.h> | #include <dev/acpica/acpivar.h> | ||||
#include <dev/acpica/acpi_pcibvar.h> | #include <dev/acpica/acpi_pcibvar.h> | ||||
#include <dev/pci/pcivar.h> | #include <dev/pci/pcivar.h> | ||||
#include <dev/pci/pcireg.h> | #include <dev/pci/pcireg.h> | ||||
#include <dev/pci/pcib_private.h> | #include <dev/pci/pcib_private.h> | ||||
#include <dev/pci/pci_host_generic.h> | #include <dev/pci/pci_host_generic.h> | ||||
#include <dev/pci/pci_host_generic_acpi.h> | |||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <machine/intr.h> | #include <machine/intr.h> | ||||
#include "pcib_if.h" | #include "pcib_if.h" | ||||
int pci_host_generic_acpi_attach(device_t); | int pci_host_generic_acpi_attach(device_t); | ||||
Show All 16 Lines | |||||
#define PCI_IO_WINDOW_OFFSET 0x1000 | #define PCI_IO_WINDOW_OFFSET 0x1000 | ||||
#define SPACE_CODE_SHIFT 24 | #define SPACE_CODE_SHIFT 24 | ||||
#define SPACE_CODE_MASK 0x3 | #define SPACE_CODE_MASK 0x3 | ||||
#define SPACE_CODE_IO_SPACE 0x1 | #define SPACE_CODE_IO_SPACE 0x1 | ||||
#define PROPS_CELL_SIZE 1 | #define PROPS_CELL_SIZE 1 | ||||
#define PCI_ADDR_CELL_SIZE 2 | #define PCI_ADDR_CELL_SIZE 2 | ||||
struct generic_pcie_acpi_softc { | |||||
struct generic_pcie_core_softc base; | |||||
ACPI_BUFFER ap_prt; /* interrupt routing table */ | |||||
}; | |||||
/* Forward prototypes */ | /* Forward prototypes */ | ||||
static int generic_pcie_acpi_probe(device_t dev); | static int generic_pcie_acpi_probe(device_t dev); | ||||
static uint32_t generic_pcie_read_config(device_t dev, u_int bus, u_int slot, | |||||
u_int func, u_int reg, int bytes); | |||||
static void generic_pcie_write_config(device_t dev, u_int bus, u_int slot, | static void generic_pcie_write_config(device_t dev, u_int bus, u_int slot, | ||||
u_int func, u_int reg, uint32_t val, int bytes); | u_int func, u_int reg, uint32_t val, int bytes); | ||||
static int generic_pcie_release_resource(device_t dev, device_t child, | static int generic_pcie_release_resource(device_t dev, device_t child, | ||||
int type, int rid, struct resource *res); | int type, int rid, struct resource *res); | ||||
static int | static int | ||||
generic_pcie_acpi_probe(device_t dev) | generic_pcie_acpi_probe(device_t dev) | ||||
{ | { | ||||
ACPI_DEVICE_INFO *devinfo; | ACPI_DEVICE_INFO *devinfo; | ||||
ACPI_HANDLE h; | ACPI_HANDLE h; | ||||
int root; | int root; | ||||
if (acpi_disabled("pcib") || (h = acpi_get_handle(dev)) == NULL || | if (acpi_disabled("pcib") || (h = acpi_get_handle(dev)) == NULL || | ||||
ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) | ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) | ||||
Not Done Inline ActionsCan you split the quirks out into a new review? It is mostly separate from the other changes. andrew: Can you split the quirks out into a new review? It is mostly separate from the other changes. | |||||
return (ENXIO); | return (ENXIO); | ||||
root = (devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0; | root = (devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0; | ||||
AcpiOsFree(devinfo); | AcpiOsFree(devinfo); | ||||
if (!root) | if (!root) | ||||
return (ENXIO); | return (ENXIO); | ||||
device_set_desc(dev, "Generic PCI host controller"); | device_set_desc(dev, "Generic PCI host controller"); | ||||
return (BUS_PROBE_GENERIC); | return (BUS_PROBE_GENERIC); | ||||
Show All 17 Lines | pci_host_generic_acpi_attach(device_t dev) | ||||
acpi_pcib_fetch_prt(dev, &sc->ap_prt); | acpi_pcib_fetch_prt(dev, &sc->ap_prt); | ||||
error = pci_host_generic_core_attach(dev); | error = pci_host_generic_core_attach(dev); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
device_add_child(dev, "pci", -1); | device_add_child(dev, "pci", -1); | ||||
return (bus_generic_attach(dev)); | return (bus_generic_attach(dev)); | ||||
Not Done Inline ActionsAre these encoded as Producer resources instead of Consumer resources? jhb: Are these encoded as Producer resources instead of Consumer resources? | |||||
Not Done Inline ActionsThey are encoded as Producer resources. pdk_semihalf.com: They are encoded as Producer resources. | |||||
} | } | ||||
static int | static int | ||||
generic_pcie_acpi_route_interrupt(device_t bus, device_t dev, int pin) | generic_pcie_acpi_route_interrupt(device_t bus, device_t dev, int pin) | ||||
{ | { | ||||
struct generic_pcie_acpi_softc *sc; | struct generic_pcie_acpi_softc *sc; | ||||
sc = device_get_softc(bus); | sc = device_get_softc(bus); | ||||
Show All 27 Lines | #if defined(NEW_PCIB) && defined(PCI_RES_BUS) | ||||
if (type == PCI_RES_BUS) { | if (type == PCI_RES_BUS) { | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
return (pci_domain_alloc_bus(sc->base.ecam, child, rid, start, | return (pci_domain_alloc_bus(sc->base.ecam, child, rid, start, | ||||
end, count, flags)); | end, count, flags)); | ||||
} | } | ||||
#endif | #endif | ||||
return (bus_generic_alloc_resource(dev, child, type, rid, start, end, | return (bus_generic_alloc_resource(dev, child, type, rid, start, end, | ||||
count, flags)); | count, flags)); | ||||
Not Done Inline ActionsWhy is this only needed for memory? andrew: Why is this only needed for memory? | |||||
Not Done Inline ActionsIn pci_host_generic_acpi_parse_resource we add memory regions to rman. Here we are allocating memory from it. pdk_semihalf.com: In `pci_host_generic_acpi_parse_resource` we add memory regions to rman. Here we are… | |||||
} | } | ||||
static int | static int | ||||
generic_pcie_acpi_activate_resource(device_t dev, device_t child, int type, | generic_pcie_acpi_activate_resource(device_t dev, device_t child, int type, | ||||
int rid, struct resource *r) | int rid, struct resource *r) | ||||
{ | { | ||||
struct generic_pcie_acpi_softc *sc; | struct generic_pcie_acpi_softc *sc; | ||||
int res; | int res; | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
DEFINE_CLASS_1(pcib, generic_pcie_acpi_driver, generic_pcie_acpi_methods, | DEFINE_CLASS_1(pcib, generic_pcie_acpi_driver, generic_pcie_acpi_methods, | ||||
sizeof(struct generic_pcie_acpi_softc), generic_pcie_core_driver); | sizeof(struct generic_pcie_acpi_softc), generic_pcie_core_driver); | ||||
static devclass_t generic_pcie_acpi_devclass; | static devclass_t generic_pcie_acpi_devclass; | ||||
DRIVER_MODULE(pcib, acpi, generic_pcie_acpi_driver, generic_pcie_acpi_devclass, | DRIVER_MODULE(pcib, acpi, generic_pcie_acpi_driver, generic_pcie_acpi_devclass, | ||||
0, 0); | 0, 0); | ||||
Not Done Inline Actionsdo you know if these are temporary quirks for pre-prod systems only? emaste: do you know if these are temporary quirks for pre-prod systems only? | |||||
Not Done Inline ActionsThese quirks are necessary for current ThunderX2 revision. I have no information if there will be some future revisions with these things fixed. pdk_semihalf.com: These quirks are necessary for current ThunderX2 revision. I have no information if there will… | |||||
Not Done Inline ActionsIs there an erratum for this? I don't see anything in Linux, or my copy of the ThunderX2 known issues document. andrew: Is there an erratum for this? I don't see anything in Linux, or my copy of the ThunderX2 known… |
The previous statement is the standard one for Foundation-sponsored work, however I am not aware of the history of this file off hand.