14 unsigned int this_cap_offset =
offset;
15 unsigned int next_cap_offset, this_cap, cafe;
19 if ((this_cap & 0xffff) == cap) {
20 return this_cap_offset;
21 }
else if ((cafe & 0xffff) == cap) {
22 return this_cap_offset + 4;
24 next_cap_offset = this_cap >> 20;
25 this_cap_offset = next_cap_offset;
27 }
while (next_cap_offset != 0);
47 #define PCIE_TRAIN_RETRY 10000
94 struct device *endp,
unsigned int endp_cap)
96 u16 root_scc, endp_scc, lnkctl;
107 if (root_scc && endp_scc) {
151 struct device *dev,
unsigned int cap)
183 unsigned int parent_cap = 0;
205 dev->
ops->
ops_pci->get_ltr_max_latencies(max_snoop, max_nosnoop);
210 struct device *dev,
unsigned int cap)
219 u16 max_snoop, max_nosnoop;
231 unsigned char mult[4] = {2, 10, 100, 0};
233 unsigned int L1SubStateSupport = *data & 0xf;
234 unsigned int comm_mode_rst_time = (*data >> 8) & 0xff;
235 unsigned int power_on_scale = (*data >> 16) & 0x3;
236 unsigned int power_on_value = (*data >> 19) & 0x1f;
239 unsigned int endp_L1SubStateSupport = endp_data & 0xf;
240 unsigned int endp_comm_mode_restore_time = (endp_data >> 8) & 0xff;
241 unsigned int endp_power_on_scale = (endp_data >> 16) & 0x3;
242 unsigned int endp_power_on_value = (endp_data >> 19) & 0x1f;
244 L1SubStateSupport &= endp_L1SubStateSupport;
246 if (L1SubStateSupport == 0)
249 if (power_on_value * mult[power_on_scale] <
250 endp_power_on_value * mult[endp_power_on_scale]) {
251 power_on_value = endp_power_on_value;
252 power_on_scale = endp_power_on_scale;
254 if (comm_mode_rst_time < endp_comm_mode_restore_time)
255 comm_mode_rst_time = endp_comm_mode_restore_time;
257 *data = (comm_mode_rst_time << 8) | (power_on_scale << 16)
258 | (power_on_value << 19) | L1SubStateSupport;
264 unsigned int root_cap,
unsigned int end_cap)
267 unsigned char L1_ss_ok;
269 unsigned int L1SubStateSupport;
270 unsigned int comm_mode_rst_time;
271 unsigned int power_on_scale;
272 unsigned int endp_power_on_value;
274 for (dev_t = dev; dev_t; dev_t = dev_t->
sibling) {
287 L1SubStateSupport = rp_L1_support & 0xf;
288 comm_mode_rst_time = (rp_L1_support >> 8) & 0xff;
289 power_on_scale = (rp_L1_support >> 16) & 0x3;
290 endp_power_on_value = (rp_L1_support >> 19) & 0x1f;
295 printk(
BIOS_INFO,
"CommonModeRestoreTime = 0x%x\n", comm_mode_rst_time);
297 endp_power_on_value, power_on_scale);
300 (comm_mode_rst_time << 8));
303 (endp_power_on_value << 3) | (power_on_scale));
317 for (dev_t = dev; dev_t; dev_t = dev_t->
sibling) {
319 (endp_power_on_value << 3) | (power_on_scale));
334 unsigned int root_cap, end_cap;
360 struct device *endp,
unsigned int endp_cap,
363 int root_lat = 0, endp_lat = 0;
364 u32 root_lnkcap, endp_lnkcap;
371 if (!(root_lnkcap & (1 << (
type + 9))) ||
372 !(endp_lnkcap & (1 << (
type + 9))))
389 return (endp_lat > root_lat) ? endp_lat : root_lat;
396 struct device *endp,
unsigned int endp_cap)
398 const char *aspm_type_str[] = {
"None",
"L0s",
"L1",
"L0s and L1" };
400 int exit_latency, ok_latency;
414 if (exit_latency >= 0 && exit_latency <= ok_latency)
421 if (exit_latency >= 0 && exit_latency <= ok_latency)
443 struct device *endp,
unsigned int endp_cap)
445 unsigned int endp_max_payload, root_max_payload, max_payload;
446 u16 endp_devctl, root_devctl;
447 u32 endp_devcap, root_devcap;
458 max_payload =
MIN(endp_max_payload, root_max_payload);
459 if (max_payload > 5) {
461 printk(
BIOS_ERR,
"PCIe: Max_Payload_Size field restricted from %d to 5\n",
468 endp_devctl |= max_payload << 5;
473 root_devctl |= max_payload << 5;
476 printk(
BIOS_INFO,
"PCIe: Max_Payload_Size adjusted to %d\n", (1 << (max_payload + 7)));
482 unsigned int root_cap, cap;
493 if (
CONFIG(PCIEXP_COMMON_CLOCK))
497 if (
CONFIG(PCIEXP_CLK_PM))
501 if (
CONFIG(PCIEXP_L1_SUB_STATE))
515 unsigned int max_devfn)
574 if (
CONFIG(PCIEXP_HOTPLUG_PREFETCH_MEM_ABOVE_4G))
#define printk(level,...)
struct device * alloc_dev(struct bus *parent, struct device_path *path)
struct resource * new_resource(struct device *dev, unsigned int index)
See if a resource structure already exists for a given index and if not allocate one.
const char * dev_path(const struct device *dev)
static void noop_set_resources(struct device *dev)
static __always_inline void pci_update_config32(const struct device *dev, u16 reg, u32 mask, u32 or)
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
static __always_inline u16 pci_find_capability(const struct device *dev, u16 cap)
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define PCI_LTR_MAX_NOSNOOP
#define PCIE_EXT_CAP_LTR_ID
#define PCI_EXP_EN_CLK_PM
#define PCI_EXP_DEVCAP_L0S
#define PCI_LTR_MAX_SNOOP
#define PCI_EXP_DEVCAP_PAYLOAD
#define PCI_EXP_LNKCTL_CCC
#define PCI_EXP_LNKCAP_L0SEL
#define PCI_EXP_LNKSTA_SLC
#define PCIE_EXT_CAP_L1SS_ID
#define PCIE_EXT_CAP_OFFSET
#define PCI_EXP_DEVCAP2_LTR
#define PCI_EXP_LNKCAP_L1EL
#define PCI_EXP_LNKCTL_RL
#define PCI_EXP_DEVCAP_L1
#define PCI_EXP_LNKSTA_LT
#define PCI_EXP_DEVCTL_PAYLOAD
void pci_scan_bus(struct bus *bus, unsigned int min_devfn, unsigned int max_devfn)
Scan a PCI bus.
void pci_bus_enable_resources(struct device *dev)
void pci_bus_read_resources(struct device *dev)
void pci_bus_reset(struct bus *bus)
void do_pci_scan_bridge(struct device *dev, void(*do_scan_bus)(struct bus *bus, unsigned int min_devfn, unsigned int max_devfn))
Scan a PCI bridge and the buses behind the bridge.
void pci_dev_set_resources(struct device *dev)
#define ASPM_LTR_L12_THRESHOLD_VALUE_MASK
#define ASPM_LTR_L12_THRESHOLD_VALUE_OFFSET
#define ASPM_LTR_L12_THRESHOLD_SCALE_OFFSET
#define ASPM_LTR_L12_THRESHOLD_SCALE_MASK
static void pciexp_enable_aspm(struct device *root, unsigned int root_cap, struct device *endp, unsigned int endp_cap)
static struct device_operations pciexp_hotplug_dummy_ops
struct device_operations default_pciexp_ops_bus
static bool _pciexp_ltr_enabled(struct device *dev, unsigned int cap)
static void pciexp_config_L1_sub_state(struct device *root, struct device *dev)
static void pciexp_enable_common_clock(struct device *root, unsigned int root_cap, struct device *endp, unsigned int endp_cap)
static void pciexp_enable_clock_power_pm(struct device *endp, unsigned int endp_cap)
static void pciexp_set_max_payload_size(struct device *root, unsigned int root_cap, struct device *endp, unsigned int endp_cap)
unsigned int pciexp_find_extended_cap(const struct device *dev, unsigned int cap)
static void pciexp_enable_ltr(struct device *dev)
void pciexp_scan_bus(struct bus *bus, unsigned int min_devfn, unsigned int max_devfn)
unsigned int pciexp_find_next_extended_cap(const struct device *dev, unsigned int cap, unsigned int pos)
static unsigned int pciexp_get_ext_cap_offset(const struct device *dev, unsigned int cap, unsigned int offset)
static void pciexp_configure_ltr(struct device *parent, unsigned int parent_cap, struct device *dev, unsigned int cap)
static struct pci_operations pciexp_bus_ops_pci
Default device operations for PCI Express bridges.
static void pciexp_hotplug_dummy_read_resources(struct device *dev)
static bool _pciexp_ltr_supported(struct device *dev, unsigned int cap)
struct device_operations default_pciexp_hotplug_ops_bus
static unsigned char pciexp_L1_substate_cal(struct device *dev, unsigned int endp_cap, unsigned int *data)
static void pciexp_tune_dev(struct device *dev)
void pciexp_hotplug_scan_bridge(struct device *dev)
void pciexp_scan_bridge(struct device *dev)
static int pciexp_aspm_latency(struct device *root, unsigned int root_cap, struct device *endp, unsigned int endp_cap, enum aspm_type type)
static int pciexp_retrain_link(struct device *dev, unsigned int cap)
bool pciexp_get_ltr_max_latencies(struct device *dev, u16 *max_snoop, u16 *max_nosnoop)
static void pciexp_L1_substate_commit(struct device *root, struct device *dev, unsigned int root_cap, unsigned int end_cap)
static bool _pciexp_enable_ltr(struct device *parent, unsigned int parent_cap, struct device *dev, unsigned int cap)
#define IORESOURCE_ABOVE_4G
#define IORESOURCE_PREFETCH
DEVTREE_CONST struct device * children
DEVTREE_CONST struct device * dev
void(* read_resources)(struct device *dev)
const struct pci_operations * ops_pci
enum device_path_type type
DEVTREE_CONST struct device * sibling
struct device_operations * ops
DEVTREE_CONST struct bus * bus
DEVTREE_CONST struct bus * link_list
unsigned int disable_pcie_aspm
typedef void(X86APIP X86EMU_intrFuncs)(int num)