coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
device.h File Reference
#include <device/resource.h>
#include <device/path.h>
#include <device/pci_type.h>
#include <smbios.h>
#include <static.h>
#include <types.h>
Include dependency graph for device.h:

Go to the source code of this file.

Data Structures

struct  chip_operations
 
struct  device_operations
 
struct  bus
 
struct  pci_irq_info
 
struct  device
 

Macros

#define CHIP_NAME(X)   .name = X,
 
#define amd_cpu_topology(cpu, node, core)    set_cpu_topology(cpu, node, 0, core, 0)
 
#define intel_cpu_topology(cpu, package, core, thread)    set_cpu_topology(cpu, 0, package, core, thread)
 
#define LOG_MEM_RESOURCE(type, dev, index, base_kb, size_kb)
 
#define LOG_IO_RESOURCE(type, dev, index, base, size)
 
#define DEV_FUNC_ENTER(dev)
 
#define DEV_FUNC_EXIT(dev)
 
#define DEVICE_IO_ALIGN   16
 
#define DEVICE_MEM_ALIGN   4096
 
#define ram_resource(dev, idx, basek, sizek)    fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_CACHEABLE)
 
#define reserved_ram_resource(dev, idx, basek, sizek)
 
#define bad_ram_resource(dev, idx, basek, sizek)    reserved_ram_resource((dev), (idx), (basek), (sizek))
 
#define uma_resource(dev, idx, basek, sizek)    fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_RESERVE)
 
#define mmio_resource(dev, idx, basek, sizek)    fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_RESERVE)
 
#define io_resource(dev, idx, base, size)    fixed_io_resource(dev, idx, base, size)
 
#define config_of_soc()   __pci_0_00_0_config
 
#define DEV_PTR(_alias)   _dev_##_alias##_ptr
 
#define WEAK_DEV_PTR(_alias)    __weak DEVTREE_CONST struct device *const DEV_PTR(_alias)
 

Functions

static void noop_read_resources (struct device *dev)
 Standard device operations function pointers shims. More...
 
static void noop_set_resources (struct device *dev)
 
struct devicealloc_dev (struct bus *parent, struct device_path *path)
 
void dev_initialize_chips (void)
 Initialize all chips of statically known devices. More...
 
void dev_enumerate (void)
 Determine the existence of devices and extend the device tree. More...
 
void dev_configure (void)
 Configure devices on the devices tree. More...
 
void dev_enable (void)
 Enable devices on the device tree. More...
 
void dev_initialize (void)
 Initialize all devices in the global device tree. More...
 
void dev_finalize (void)
 Finalize all devices in the global device tree. More...
 
void dev_finalize_chips (void)
 Finalize all chips of statically known devices. More...
 
void devfn_disable (const struct bus *bus, unsigned int devfn)
 
int reset_bus (struct bus *bus)
 Reset all of the devices on a bus and clear the bus's reset_needed flag. More...
 
void scan_bridges (struct bus *bus)
 
void assign_resources (struct bus *bus)
 Assign the computed resources to the devices on the bus. More...
 
const char * dev_name (const struct device *dev)
 
const char * dev_path (const struct device *dev)
 
u32 dev_path_encode (const struct device *dev)
 Encode the device path into 3 bytes for logging to CMOS. More...
 
const char * bus_path (struct bus *bus)
 
void dev_set_enabled (struct device *dev, int enable)
 
void disable_children (struct bus *bus)
 
bool dev_is_active_bridge (struct device *dev)
 
void add_more_links (struct device *dev, unsigned int total_links)
 Ensure the device has a minimum number of bus links. More...
 
bool is_dev_enabled (const struct device *const dev)
 
bool is_devfn_enabled (unsigned int devfn)
 
void run_bios (struct device *dev, unsigned long addr)
 
DEVTREE_CONST struct devicefind_dev_path (const struct bus *parent, const struct device_path *path)
 See if a device structure exists for path. More...
 
DEVTREE_CONST struct devicefind_dev_nested_path (const struct bus *parent, const struct device_path nested_path[], size_t nested_path_length)
 Find the device structure given an array of nested device paths,. More...
 
struct devicealloc_find_dev (struct bus *parent, struct device_path *path)
 See if a device structure already exists and if not allocate it. More...
 
struct devicedev_find_device (u16 vendor, u16 device, struct device *from)
 Find a device of a given vendor and type. More...
 
struct devicedev_find_class (unsigned int class, struct device *from)
 Find a device of a given class. More...
 
DEVTREE_CONST struct devicedev_find_path (DEVTREE_CONST struct device *prev_match, enum device_path_type path_type)
 Given a Device Path Type, find the device structure. More...
 
struct devicedev_find_lapic (unsigned int apic_id)
 Given a Local APIC ID, find the device structure. More...
 
int dev_count_cpu (void)
 
struct deviceadd_cpu_device (struct bus *cpu_bus, unsigned int apic_id, int enabled)
 
void set_cpu_topology (struct device *cpu, unsigned int node, unsigned int package, unsigned int core, unsigned int thread)
 
void mp_init_cpus (DEVTREE_CONST struct bus *cpu_bus)
 
static void mp_cpu_bus_init (struct device *dev)
 
void print_resource_tree (const struct device *root, int debug_level, const char *msg)
 
void show_devs_tree (const struct device *dev, int debug_level, int depth)
 
void show_devs_subtree (struct device *root, int debug_level, const char *msg)
 
void show_all_devs (int debug_level, const char *msg)
 
void show_all_devs_tree (int debug_level, const char *msg)
 
void show_one_resource (int debug_level, struct device *dev, struct resource *resource, const char *comment)
 
void show_all_devs_resources (int debug_level, const char *msg)
 
void pci_domain_read_resources (struct device *dev)
 
void pci_domain_set_resources (struct device *dev)
 
void pci_domain_scan_bus (struct device *dev)
 Scan a PCI domain. More...
 
void fixed_io_resource (struct device *dev, unsigned long index, unsigned long base, unsigned long size)
 
void fixed_mem_resource (struct device *dev, unsigned long index, unsigned long basek, unsigned long sizek, unsigned long type)
 
void mmconf_resource (struct device *dev, unsigned long index)
 
void tolm_test (void *gp, struct device *dev, struct resource *new)
 
u32 find_pci_tolm (struct bus *bus)
 
DEVTREE_CONST struct devicedev_find_next_pci_device (DEVTREE_CONST struct device *previous_dev)
 Given a device pointer, find the next PCI device. More...
 
DEVTREE_CONST struct devicedev_find_slot_on_smbus (unsigned int bus, unsigned int addr)
 Given an SMBus bus and a device number, find the device structure. More...
 
DEVTREE_CONST struct devicedev_find_slot_pnp (u16 port, u16 device)
 Given a PnP port and a device number, find the device structure. More...
 
DEVTREE_CONST struct devicedev_bus_each_child (const struct bus *parent, DEVTREE_CONST struct device *prev_child)
 Given a device and previous match iterate through all the children. More...
 
DEVTREE_CONST struct devicepcidev_path_behind (const struct bus *parent, pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_path_on_root (pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_path_on_bus (unsigned int bus, pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_on_root (uint8_t dev, uint8_t fn)
 
DEVTREE_CONST struct buspci_root_bus (void)
 
DEVTREE_CONST struct devicepcidev_path_behind_pci2pci_bridge (const struct device *bridge, pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_path_on_root_debug (pci_devfn_t devfn, const char *func)
 
void devtree_bug (const char *func, pci_devfn_t devfn)
 
void __noreturn devtree_die (void)
 
static DEVTREE_CONST voidconfig_of (const struct device *dev)
 
void enable_static_device (struct device *dev)
 
void enable_static_devices (struct device *bus)
 Enable devices on static buses. More...
 
void scan_smbus (struct device *bus)
 
void scan_generic_bus (struct device *bus)
 
void scan_static_bus (struct device *bus)
 

Variables

DEVTREE_CONST struct device dev_root
 This is the root of the device tree. More...
 
DEVTREE_CONST struct device *DEVTREE_CONST all_devices
 Linked list of ALL devices. More...
 
struct resourcefree_resources
 Linked list of free resources. More...
 
struct busfree_links
 
const char mainboard_name []
 
struct device_operations default_dev_ops_root
 Default device operation for root device. More...
 

Macro Definition Documentation

◆ amd_cpu_topology

#define amd_cpu_topology (   cpu,
  node,
  core 
)     set_cpu_topology(cpu, node, 0, core, 0)

Definition at line 233 of file device.h.

◆ bad_ram_resource

#define bad_ram_resource (   dev,
  idx,
  basek,
  sizek 
)     reserved_ram_resource((dev), (idx), (basek), (sizek))

Definition at line 328 of file device.h.

◆ CHIP_NAME

#define CHIP_NAME (   X)    .name = X,

Definition at line 32 of file device.h.

◆ config_of_soc

#define config_of_soc ( )    __pci_0_00_0_config

Definition at line 394 of file device.h.

◆ DEV_FUNC_ENTER

#define DEV_FUNC_ENTER (   dev)

Definition at line 295 of file device.h.

◆ DEV_FUNC_EXIT

#define DEV_FUNC_EXIT (   dev)

Definition at line 296 of file device.h.

◆ DEV_PTR

#define DEV_PTR (   _alias)    _dev_##_alias##_ptr

Definition at line 403 of file device.h.

◆ DEVICE_IO_ALIGN

#define DEVICE_IO_ALIGN   16

Definition at line 302 of file device.h.

◆ DEVICE_MEM_ALIGN

#define DEVICE_MEM_ALIGN   4096

Definition at line 303 of file device.h.

◆ intel_cpu_topology

#define intel_cpu_topology (   cpu,
  package,
  core,
  thread 
)     set_cpu_topology(cpu, 0, package, core, thread)

Definition at line 236 of file device.h.

◆ io_resource

#define io_resource (   dev,
  idx,
  base,
  size 
)     fixed_io_resource(dev, idx, base, size)

Definition at line 337 of file device.h.

◆ LOG_IO_RESOURCE

#define LOG_IO_RESOURCE (   type,
  dev,
  index,
  base,
  size 
)

Definition at line 282 of file device.h.

◆ LOG_MEM_RESOURCE

#define LOG_MEM_RESOURCE (   type,
  dev,
  index,
  base_kb,
  size_kb 
)

Definition at line 281 of file device.h.

◆ mmio_resource

#define mmio_resource (   dev,
  idx,
  basek,
  sizek 
)     fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_RESERVE)

Definition at line 334 of file device.h.

◆ ram_resource

#define ram_resource (   dev,
  idx,
  basek,
  sizek 
)     fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_CACHEABLE)

Definition at line 321 of file device.h.

◆ reserved_ram_resource

#define reserved_ram_resource (   dev,
  idx,
  basek,
  sizek 
)
Value:
fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_CACHEABLE \
void fixed_mem_resource(struct device *dev, unsigned long index, unsigned long basek, unsigned long sizek, unsigned long type)
Definition: device_util.c:825
#define IORESOURCE_RESERVE
Definition: resource.h:30
#define IORESOURCE_CACHEABLE
Definition: resource.h:19

Definition at line 324 of file device.h.

◆ uma_resource

#define uma_resource (   dev,
  idx,
  basek,
  sizek 
)     fixed_mem_resource(dev, idx, basek, sizek, IORESOURCE_RESERVE)

Definition at line 331 of file device.h.

◆ WEAK_DEV_PTR

#define WEAK_DEV_PTR (   _alias)     __weak DEVTREE_CONST struct device *const DEV_PTR(_alias)

Definition at line 407 of file device.h.

Function Documentation

◆ add_cpu_device()

struct device* add_cpu_device ( struct bus cpu_bus,
unsigned int  apic_id,
int  enabled 
)

Definition at line 6 of file cpu_device.c.

References alloc_find_dev(), BIOS_DEBUG, dev_path(), DEVICE_PATH_APIC, device::enabled, find_dev_path(), NULL, and printk.

Referenced by cpu_bus_scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_more_links()

void add_more_links ( struct device dev,
unsigned int  total_links 
)

Ensure the device has a minimum number of bus links.

Parameters
devThe device to add links to.
total_linksThe minimum number of links to have.

Definition at line 652 of file device_util.c.

References bus::dev, die(), device::link_list, bus::link_num, malloc(), memset(), bus::next, and NULL.

Referenced by cpu_bus_scan(), init_cpus(), and mp_cpu_bus_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc_dev()

struct device* alloc_dev ( struct bus parent,
struct device_path path 
)

Definition at line 122 of file device.c.

References __alloc_dev(), device::path, spin_lock, and spin_unlock.

Referenced by pci_probe_dev().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alloc_find_dev()

struct device* alloc_find_dev ( struct bus parent,
struct device_path path 
)

See if a device structure already exists and if not allocate it.

Parameters
parentThe bus to find the device on.
pathThe relative path from the bus to the appropriate device.
Returns
Pointer to a device structure for the device on bus at path.

Definition at line 138 of file device.c.

References __alloc_dev(), find_dev_path(), device::path, spin_lock, and spin_unlock.

Referenced by add_cpu_device(), allocate_cpu_devices(), google_chromeec_fill_ssdt_generator(), init_bsp(), initialize_cpus(), intel_sibling_init(), and pnp_enable_devices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign_resources()

void assign_resources ( struct bus bus)

Assign the computed resources to the devices on the bus.

Use the device specific set_resources() method to store the computed resources to hardware. For bridge devices, the set_resources() method has to recurse into every down stream buses.

Mutual recursion: assign_resources() -> device_operation::set_resources() device_operation::set_resources() -> assign_resources()

Parameters
busPointer to the structure for this bus.

Definition at line 268 of file device.c.

References BIOS_ERR, BIOS_SPEW, bus::children, bus::dev, dev_path(), device::enabled, bus::link_num, device::ops, post_log_clear(), post_log_path(), printk, device::resource_list, bus::secondary, device_operations::set_resources, and device::sibling.

Referenced by cpu_pci_domain_set_resources(), dev_configure(), domain_set_resources(), generic_set_resources(), mch_domain_set_resources(), nb_set_resources(), pci_dev_set_resources(), pci_domain_set_resources(), set_resources(), and xeonsp_pci_domain_set_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_path()

const char* bus_path ( struct bus bus)

Definition at line 243 of file device_util.c.

References buffer, BUS_PATH_MAX, bus::dev, dev_path(), bus::link_num, and snprintf().

Here is the call graph for this function:

◆ config_of()

◆ dev_bus_each_child()

DEVTREE_CONST struct device* dev_bus_each_child ( const struct bus parent,
DEVTREE_CONST struct device prev_child 
)

Given a device and previous match iterate through all the children.

Parameters
busparent device's bus holding all the children
prev_childprevious child already traversed, if NULL start at children of parent bus.
Returns
pointer to child or NULL when no more children

Definition at line 353 of file device_const.c.

References bus::children, DEVTREE_CONST, NULL, and device::sibling.

Referenced by audio_codec_device_update(), variant_devtree_update(), and variant_touchscreen_update().

Here is the caller graph for this function:

◆ dev_configure()

void dev_configure ( void  )

Configure devices on the devices tree.

Starting at the root of the device tree, travel it recursively in two passes. In the first pass, we compute and allocate resources (ranges) required by each device. In the second pass, the resources ranges are relocated to their final position and stored to the hardware.

I/O resources grow upward. MEM resources grow downward.

Since the assignment is hierarchical we set the values into the dev_root struct.

Definition at line 453 of file device.c.

References allocate_resources(), assign_resources(), BIOS_INFO, BIOS_SPEW, dev_root, device::link_list, print_resource_tree(), printk, read_resources(), and set_vga_bridge_bits().

Referenced by bs_dev_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_count_cpu()

int dev_count_cpu ( void  )

◆ dev_enable()

void dev_enable ( void  )

Enable devices on the device tree.

Starting at the root, walk the tree and enable all devices/bridges by calling the device's enable_resources() method.

Definition at line 492 of file device.c.

References BIOS_INFO, dev_root, enable_resources(), device::link_list, bus::next, and printk.

Referenced by bs_dev_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_enumerate()

void dev_enumerate ( void  )

Determine the existence of devices and extend the device tree.

Most of the devices in the system are listed in the mainboard devicetree.cb file. The device structures for these devices are generated at compile time by the config tool and are organized into the device tree. This function determines if the devices created at compile time actually exist in the physical system.

For devices in the physical system but not listed in devicetree.cb, the device structures have to be created at run time and attached to the device tree.

This function starts from the root device 'dev_root', scans the buses in the system recursively, and modifies the device tree according to the result of the probe.

This function has no idea how to scan and probe buses and devices at all. It depends on the bus/device specific scan_bus() method to do it. The scan_bus() method also has to create the device structure and attach it to the device tree.

Definition at line 416 of file device.c.

References BIOS_ERR, BIOS_INFO, BIOS_SPEW, device::chip_ops, dev_root, chip_operations::enable_dev, device::ops, post_log_clear(), printk, scan_bus(), device_operations::scan_bus, show_all_devs(), and show_devs_tree().

Referenced by bs_dev_enumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_finalize()

void dev_finalize ( void  )

Finalize all devices in the global device tree.

Starting at the root device, call the device's final() method to do device-specific cleanup, then call each child's final() method.

Definition at line 625 of file device.c.

References BIOS_INFO, dev_root, final_dev(), final_link(), device::link_list, bus::next, and printk.

Referenced by bs_post_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_finalize_chips()

void dev_finalize_chips ( void  )

Finalize all chips of statically known devices.

This is the last call before calling the payload. This is a good place to lock registers or other final cleanup.

Definition at line 60 of file device.c.

References all_devices, device::chip_info, device::chip_ops, chip_operations::final, chip_operations::finalized, and device::next.

Referenced by bs_write_tables().

Here is the caller graph for this function:

◆ dev_find_class()

struct device* dev_find_class ( unsigned int  class,
struct device from 
)

Find a device of a given class.

Parameters
classClass of the device.
fromPointer to the device structure, used as a starting point in the linked list of all_devices, which can be 0 to start at the head of the list (i.e. all_devices).
Returns
Pointer to the device struct.

Definition at line 64 of file device_util.c.

References all_devices, device::class, and device::next.

Referenced by set_vga_bridge_bits().

Here is the caller graph for this function:

◆ dev_find_device()

struct device* dev_find_device ( u16  vendor,
u16  device,
struct device from 
)

Find a device of a given vendor and type.

Parameters
vendorA PCI vendor ID (e.g. 0x8086 for Intel).
deviceA PCI device ID.
fromPointer to the device structure, used as a starting point in the linked list of all_devices, which can be 0 to start at the head of the list (i.e. all_devices).
Returns
Pointer to the device struct.

Definition at line 42 of file device_util.c.

References all_devices, device::device, device::next, vendor, and device::vendor.

Referenced by handleInt1a(), int1a_handler(), lan_init(), mainboard_final(), mainboard_init(), set_imc_locks(), set_upi_locks(), smp_write_config_table(), spi_init(), and variant_mainboard_final().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_find_lapic()

struct device* dev_find_lapic ( unsigned int  apic_id)

Given a Local APIC ID, find the device structure.

Parameters
apic_idThe Local APIC ID number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 17 of file device_util.c.

References all_devices, device_path::apic, apic_path::apic_id, DEVICE_PATH_APIC, device::next, NULL, device::path, and device_path::type.

Referenced by configure_c_states(), configure_p_states(), configure_thermal_target(), generate_C_state_entries(), get_cpu_index(), initialize_vr_config(), and is_s0ix_enabled().

Here is the caller graph for this function:

◆ dev_find_next_pci_device()

DEVTREE_CONST struct device* dev_find_next_pci_device ( DEVTREE_CONST struct device previous_dev)

Given a device pointer, find the next PCI device.

Parameters
previous_devA pointer to a PCI device structure.
Returns
Pointer to the next device structure (if found), 0 otherwise.

Definition at line 79 of file device_const.c.

References dev_find_path(), and DEVICE_PATH_PCI.

Here is the call graph for this function:

◆ dev_find_path()

DEVTREE_CONST struct device* dev_find_path ( DEVTREE_CONST struct device prev_match,
enum device_path_type  path_type 
)

Given a Device Path Type, find the device structure.

Parameters
prev_matchThe previously matched device instance.
path_typeThe Device Path Type.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 53 of file device_const.c.

References all_devices, DEVTREE_CONST, device::next, NULL, device::path, and device_path::type.

Referenced by dev_find_next_pci_device(), get_usb_port_references(), init_cpus(), pci_root_bus(), and variant_devtree_update().

Here is the caller graph for this function:

◆ dev_find_slot_on_smbus()

DEVTREE_CONST struct device* dev_find_slot_on_smbus ( unsigned int  bus,
unsigned int  addr 
)

Given an SMBus bus and a device number, find the device structure.

Parameters
busThe bus number.
addrA device number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 307 of file device_const.c.

References addr, all_devices, device::bus, i2c_path::device, DEVICE_PATH_I2C, DEVTREE_CONST, device_path::i2c, device::next, device::path, bus::secondary, and device_path::type.

Referenced by at24rf08c_find_bank(), and smbios_system_set_uuid().

Here is the caller graph for this function:

◆ dev_find_slot_pnp()

DEVTREE_CONST struct device* dev_find_slot_pnp ( u16  port,
u16  device 
)

Given a PnP port and a device number, find the device structure.

Parameters
portThe I/O port.
deviceLogical device number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 331 of file device_const.c.

References all_devices, pnp_path::device, DEVICE_PATH_PNP, DEVTREE_CONST, device::next, device::path, device_path::pnp, pnp_path::port, and device_path::type.

Referenced by config_addon_uart(), config_gpio_mux(), disable_gpio_io_port(), drivers_lenovo_is_wacom_present(), early_hybrid_graphics(), reset_gpio_default_od(), sch5545_get_gpio(), sch5545_read_emi_bar(), sch5545_set_drq(), sch5545_set_iobase(), and sch5545_set_irq().

Here is the caller graph for this function:

◆ dev_initialize()

void dev_initialize ( void  )

Initialize all devices in the global device tree.

Starting at the root device, call the device's init() method to do device-specific setup, then call each child's init() method.

Definition at line 563 of file device.c.

References BIOS_INFO, BIOS_SPEW, dev_root, init_dev(), init_link(), device::link_list, bus::next, post_log_clear(), printk, setup_default_ebda(), and show_all_devs().

Referenced by bs_dev_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_initialize_chips()

void dev_initialize_chips ( void  )

Initialize all chips of statically known devices.

Will be called before bus enumeration to initialize chips stated in the device tree.

Definition at line 38 of file device.c.

References all_devices, device::chip_info, device::chip_ops, chip_operations::init, chip_operations::initialized, device::next, post_log_clear(), and post_log_path().

Referenced by bs_dev_init_chips().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dev_is_active_bridge()

bool dev_is_active_bridge ( struct device dev)

Definition at line 622 of file device_util.c.

References bus::children, DEVICE_PATH_NONE, device::enabled, device::link_list, bus::next, device::path, device::sibling, and device_path::type.

Referenced by smbios_generate_type9_from_devtree().

Here is the caller graph for this function:

◆ dev_name()

const char* dev_name ( const struct device dev)

Definition at line 233 of file device_util.c.

References device::chip_ops, chip_operations::name, and device::name.

◆ dev_path()

const char* dev_path ( const struct device dev)

Definition at line 149 of file device_util.c.

References mmio_path::addr, device_path::apic, apic_path::apic_id, BIOS_ERR, buffer, device::bus, cpu_cluster_path::cluster, device_path::cpu, device_path::cpu_bus, device_path::cpu_cluster, spi_path::cs, pci_path::devfn, pnp_path::device, i2c_path::device, DEVICE_PATH_APIC, DEVICE_PATH_CPU, DEVICE_PATH_CPU_BUS, DEVICE_PATH_CPU_CLUSTER, DEVICE_PATH_DOMAIN, DEVICE_PATH_GENERIC, DEVICE_PATH_GPIO, DEVICE_PATH_I2C, DEVICE_PATH_IOAPIC, DEVICE_PATH_MAX, DEVICE_PATH_MMIO, DEVICE_PATH_NONE, DEVICE_PATH_PCI, DEVICE_PATH_PNP, DEVICE_PATH_ROOT, DEVICE_PATH_SPI, DEVICE_PATH_USB, domain_path::domain, device_path::domain, device_path::generic, device_path::gpio, device_path::i2c, cpu_path::id, cpu_bus_path::id, generic_path::id, gpio_path::id, device_path::ioapic, ioapic_path::ioapic_id, device_path::mmio, device::path, device_path::pci, PCI_FUNC, PCI_SLOT, device_path::pnp, pnp_path::port, usb_path::port_id, usb_path::port_type, printk, bus::secondary, snprintf(), device_path::spi, strcpy(), generic_path::subid, device_path::type, and device_path::usb.

Referenced by __allocate_resources(), _pciexp_enable_ltr(), acpi_write_dbg2_pci_uart(), add_cpu_device(), allocate_child_resources(), allocate_resources(), assign_resources(), assign_stack_resources(), attach_iio_stacks(), avoid_fixed_resources(), broadwell_pch_enable_dev(), bus_path(), cardbus_enable_resources(), cleanup_resource_ranges(), compute_resources(), configure_adjustable_base(), configure_child_lpc_windows(), constrain_resources(), cpu_bus_scan(), create_vga_resource(), crosec_audio_codec_fill_ssdt(), crosec_i2c_tunnel_fill_ssdt(), dnv_get_int_line(), do_pci_scan_bridge(), dptf_fill_ssdt(), ecam0_pci_enable_msix(), enable_dev(), enable_static_device(), final_dev(), find_resource(), get_pbus_smbus(), get_pci_bridge_ops(), graphics_dev_init(), handleInt1a(), hudson_lpc_enable_childrens_resources(), i2c_dev_read_at16(), i2c_dev_readb(), i2c_dev_readb_at(), i2c_dev_writeb(), i2c_dev_writeb_at(), i2c_gpiomux_bus_fill_ssdt(), i2c_gpiomux_mux_fill_ssdt(), i2c_link(), i2c_sx9310_fill_ssdt(), i2c_sx9324_fill_ssdt(), i2c_sx9360_fill_ssdt(), i2c_tpm_fill_ssdt(), i2s_machine_dev_fill_ssdt(), i82801gx_enable(), init_dev(), intel_acpi_gen_def_acpi_pirq(), lpc47n217_pnp_set_resource(), lpc47n227_pnp_set_resource(), lv2_enable_ltr(), max98357a_fill_ssdt(), pch_enable(), pch_pcie_check_set_enabled(), pch_pcie_enable(), pci_bus_enable_resources(), pci_cfg_read(), pci_dev_enable_resources(), pci_get_resource(), pci_get_rom_resource(), pci_probe_dev(), pci_rom_probe(), pci_scan_bus(), pci_scan_hidden_device(), pci_set_resource(), pcie_generic_fill_ssdt(), pcie_rp_update_dev(), pcie_rtd3_acpi_fill_ssdt(), pcie_rtd3_device_acpi_fill_ssdt(), pciexp_configure_ltr(), pciexp_retrain_link(), pcix_tune_dev(), pnp_get_ioresource(), pnp_set_resource(), print_resource_ranges(), print_resource_tree(), read_resources(), report_resource_stored(), resource_tree(), rl5c476_set_resources(), root_port_commit_config(), scan_bus(), scan_generic_bus(), scan_static_bus(), sch5545_set_drq(), sch5545_set_iobase(), sch5545_set_irq(), sch5545_set_resource(), set_pci_ops(), set_vga_bridge_bits(), setup_resource_ranges(), show_all_devs(), show_all_devs_resources(), show_devs_subtree(), show_devs_tree(), show_one_resource(), smbios_walk_device_tree(), smp_write_intsrc_pci_bridge(), soc_pmc_fill_ssdt(), soc_silicon_init_params(), spi_acpi_fill_ssdt_generator(), superio_common_fill_ssdt_generator(), tas5825m_init(), thermal_zone_fill_ssdt(), uart_acpi_fill_ssdt(), uart_enable(), update_bridge_resource(), update_constraints(), usb_acpi_fill_ssdt_generator(), wifi_ssdt_write_properties(), write_smp_table(), wwan_fm350gl_acpi_fill_ssdt(), xeonsp_pci_dev_iterator(), xeonsp_pci_domain_scan_bus(), xhci_acpi_name(), and xhci_fill_ssdt().

Here is the call graph for this function:

◆ dev_path_encode()

◆ dev_set_enabled()

void dev_set_enabled ( struct device dev,
int  enable 
)

Definition at line 594 of file device_util.c.

References device::chip_ops, device_operations::enable, chip_operations::enable_dev, device::enabled, and device::ops.

Referenced by disable_children().

Here is the caller graph for this function:

◆ devfn_disable()

void devfn_disable ( const struct bus bus,
unsigned int  devfn 
)

Definition at line 25 of file device.c.

References device::enabled, and pcidev_path_behind().

Referenced by fill_fsps_tsn_params().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ devtree_bug()

void devtree_bug ( const char *  func,
pci_devfn_t  devfn 
)

Definition at line 290 of file device_const.c.

References BIOS_ERR, and printk.

Referenced by pcidev_path_on_root_debug().

Here is the caller graph for this function:

◆ devtree_die()

void __noreturn devtree_die ( void  )

Definition at line 295 of file device_const.c.

References die().

Referenced by config_of().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disable_children()

void disable_children ( struct bus bus)

Definition at line 606 of file device_util.c.

References bus::children, dev_set_enabled(), device::link_list, bus::next, and device::sibling.

Here is the call graph for this function:

◆ enable_static_device()

void enable_static_device ( struct device dev)

Definition at line 10 of file root_device.c.

References BIOS_DEBUG, device::chip_ops, dev_path(), device_operations::enable, chip_operations::enable_dev, device::enabled, device::ops, and printk.

Referenced by enable_static_devices(), pci_scan_bus(), and scan_generic_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable_static_devices()

void enable_static_devices ( struct device bus)

Enable devices on static buses.

The enumeration of certain buses is purely static. The existence of devices on those buses can be completely determined at compile time and is specified in the config file. Typical examples are the 'PNP' devices on a legacy ISA/LPC bus. There is no need of probing of any kind, the only thing we have to do is to walk through the bus and enable or disable devices as indicated in the config file.

On the other hand, some devices are virtual and their existence is artificial. They can not be probed at run time. One example is the debug device. Those virtual devices have to be listed in the config file under some static bus in order to be enumerated at run time.

Parameters
busPointer to the device to which the static buses are attached to.

Definition at line 40 of file root_device.c.

References bus::children, enable_static_device(), bus::next, and device::sibling.

Referenced by scan_static_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_dev_nested_path()

DEVTREE_CONST struct device* find_dev_nested_path ( const struct bus parent,
const struct device_path  nested_path[],
size_t  nested_path_length 
)

Find the device structure given an array of nested device paths,.

Parameters
parentThe parent bus to start the search on.
nested_pathAn array of relative paths from the parent bus to the target device.
nested_path_lengthNumber of path elements in nested_path array.
Returns
Pointer to a device structure for the device at nested path or 0/NULL if no device is found.

Definition at line 193 of file device_const.c.

References DEVTREE_CONST, find_dev_path(), device::link_list, and NULL.

Referenced by fill_fspm_misc_params(), and tcss_get_port_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_dev_path()

DEVTREE_CONST struct device* find_dev_path ( const struct bus parent,
const struct device_path path 
)

See if a device structure exists for path.

Parameters
parentThe bus to find the device on.
pathThe relative path from the bus to the appropriate device.
Returns
Pointer to a device structure for the device on bus at path or 0/NULL if no device is found.

Definition at line 166 of file device_const.c.

References BUG, bus::children, DEVTREE_CONST, NULL, device::path, path_eq(), and device::sibling.

Referenced by add_cpu_device(), alloc_find_dev(), camera_fill_sensor(), ecam0_fix_missing_devices(), find_dev_nested_path(), and pcidev_path_behind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_pci_tolm()

u32 find_pci_tolm ( struct bus bus)

Definition at line 890 of file device_util.c.

References resource::base, IORESOURCE_ASSIGNED, IORESOURCE_MEM, NULL, search_bus_resources(), and tolm_test().

Referenced by domain_set_resources(), i440bx_domain_read_resources(), and mch_domain_read_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fixed_io_resource()

void fixed_io_resource ( struct device dev,
unsigned long  index,
unsigned long  base,
unsigned long  size 
)

◆ fixed_mem_resource()

void fixed_mem_resource ( struct device dev,
unsigned long  index,
unsigned long  basek,
unsigned long  sizek,
unsigned long  type 
)

Definition at line 825 of file device_util.c.

References resource::base, resource::flags, resource::index, IORESOURCE_ASSIGNED, IORESOURCE_FIXED, IORESOURCE_MEM, IORESOURCE_STORED, new_resource(), resource::size, and type.

Referenced by hudson_lpc_read_resources(), lpc_read_resources(), and mch_domain_read_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_dev_enabled()

◆ is_devfn_enabled()

◆ mmconf_resource()

void mmconf_resource ( struct device dev,
unsigned long  index 
)

◆ mp_cpu_bus_init()

static void mp_cpu_bus_init ( struct device dev)
inlinestatic

Definition at line 240 of file device.h.

References add_more_links(), device::link_list, and mp_init_cpus().

Referenced by cpu_bus_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mp_init_cpus()

void mp_init_cpus ( DEVTREE_CONST struct bus cpu_bus)

Referenced by mp_cpu_bus_init().

Here is the caller graph for this function:

◆ noop_read_resources()

static void noop_read_resources ( struct device dev)
inlinestatic

Standard device operations function pointers shims.

Definition at line 73 of file device.h.

◆ noop_set_resources()

static void noop_set_resources ( struct device dev)
inlinestatic

Definition at line 74 of file device.h.

◆ pci_domain_read_resources()

void pci_domain_read_resources ( struct device dev)

◆ pci_domain_scan_bus()

void pci_domain_scan_bus ( struct device dev)

Scan a PCI domain.

This function is the default scan_bus() method for PCI domains.

Parameters
devPointer to the domain.

Definition at line 1610 of file pci_device.c.

References bus::dev, device::link_list, PCI_DEVFN, and pci_scan_bus().

Here is the call graph for this function:

◆ pci_domain_set_resources()

void pci_domain_set_resources ( struct device dev)

Definition at line 564 of file pci_device.c.

References assign_resources(), and device::link_list.

Referenced by mtk_pcie_domain_set_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pci_root_bus()

DEVTREE_CONST struct bus* pci_root_bus ( void  )

Definition at line 239 of file device_const.c.

References dev_find_path(), DEVICE_PATH_DOMAIN, DEVTREE_CONST, device::link_list, and NULL.

Referenced by fill_fspm_misc_params(), fill_fsps_tsn_params(), pcidev_path_on_bus(), pcidev_path_on_root(), pcie_rp_update_devicetree(), and tcss_get_port_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcidev_on_root()

DEVTREE_CONST struct device* pcidev_on_root ( uint8_t  dev,
uint8_t  fn 
)

Definition at line 260 of file device_const.c.

References PCI_DEVFN, and pcidev_path_on_root().

Referenced by acpi_create_igfx_rmrr(), acpi_fill_dmar(), acpi_fill_fadt(), acpi_fill_ivrs(), acpi_fill_ivrs11(), acpi_fill_ivrs40(), acpi_fill_madt(), AmdMemoryReadSPD(), aseg_smm_install(), aseg_smm_lock(), aseg_smm_relocate(), baytrail_run_reference_code(), bridge_silicon_revision(), camera_fill_sensor(), camera_fill_ssdb_defaults(), configure_dmi_pm(), cpu_bus_scan(), cpu_pci_domain_read_resources(), devicetree_fill_pei_data(), devtree_update(), disable_devices(), disable_p2p(), disable_peg(), early_graphics_setup(), early_lpc_init(), ecam0_init(), enable_lp_clock_gating(), fam16_finalize(), fill_in_pattrs(), find_vbt_location(), get_gpio_base(), get_hostbridge_dev(), get_ich7_sata_ports(), get_lpc_dev(), get_mc_dev(), get_node_pci(), get_num_ports(), get_pmbase(), get_pmc_dev(), get_smbus_dev(), gm45_init(), gma_func0_disable(), gtt_setup(), hide_ast2400(), hide_hsuarts(), hide_pci_dev(), hide_pci_fn(), i82801gx_lpc_setup(), i82801ix_ehci_init(), i82801ix_lpc_setup(), i82801ix_pcie_init(), i82801jx_ehci_init(), i82801jx_lpc_setup(), i82801jx_pcie_init(), init(), intel_acpi_gen_def_acpi_pirq(), intel_gma_init_lvds(), intel_gma_init_vga(), ironlake_init(), is_sandybridge(), lpc_get_pmbase(), lpc_init(), lpt_pm_init(), mainboard_enable(), mainboard_final(), mainboard_init(), mainboard_romstage_entry(), mc_read_resources(), mch_domain_init(), mch_domain_read_resources(), northbridge_fill_pei_data(), northbridge_topology_init(), northbridge_write_smram(), pch_enable_gbe(), pch_enable_lpc(), pch_enable_lpc_decode(), pch_get_lpc_device(), pch_log_state(), pch_silicon_revision(), pch_silicon_type(), pcie_slot_enable_mask(), perform_raminit(), platform_BeforeInitLate(), platform_BeforeInitReset(), platform_fsp_silicon_init_params_cb(), qemu_nb_init(), sata_enable(), sata_init(), sdram_program_row_boundaries(), smbios_mainboard_serial_number(), smm_lock(), smp_write_config_table(), soc_memory_init_params(), soc_silicon_init_params(), SocStepping(), southbridge_fill_pei_data(), southbridge_fill_ssdt(), spi_init(), systemagent_vtd_init(), usb_oc_setup(), and watchdog_off().

Here is the call graph for this function:

◆ pcidev_path_behind()

DEVTREE_CONST struct device* pcidev_path_behind ( const struct bus parent,
pci_devfn_t  devfn 
)

Definition at line 211 of file device_const.c.

References DEVICE_PATH_PCI, find_dev_path(), and device_path::type.

Referenced by acpi_fill_madt(), devfn_disable(), ecam0_init(), pci_scan_bus(), pcidev_path_behind_pci2pci_bridge(), pcidev_path_on_bus(), pcidev_path_on_root(), and smbios_mainboard_serial_number().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcidev_path_behind_pci2pci_bridge()

DEVTREE_CONST struct device* pcidev_path_behind_pci2pci_bridge ( const struct device bridge,
pci_devfn_t  devfn 
)

Definition at line 265 of file device_const.c.

References bridge, BUG, DEVICE_PATH_PCI, NULL, and pcidev_path_behind().

Here is the call graph for this function:

◆ pcidev_path_on_bus()

DEVTREE_CONST struct device* pcidev_path_on_bus ( unsigned int  bus,
pci_devfn_t  devfn 
)

Definition at line 221 of file device_const.c.

References device::bus, bus::children, DEVICE_PATH_PCI, DEVTREE_CONST, device::next, NULL, device::path, pci_root_bus(), pcidev_path_behind(), bus::secondary, and device_path::type.

Referenced by handleInt1a(), int1a_handler(), lock_pam0123(), pci_cfg_read(), and pirq_route_irqs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcidev_path_on_root()

DEVTREE_CONST struct device* pcidev_path_on_root ( pci_devfn_t  devfn)

Definition at line 255 of file device_const.c.

References pci_root_bus(), and pcidev_path_behind().

Referenced by acpi_fill_dmar(), agesa_fch_initenv(), agesa_ReadSpd(), amd_init_late(), audio_codec_device_update(), broadwell_systemagent_finalize(), check_xdci_enable(), chip_final(), disable_devices(), fill_vr_domain_config(), get_mmio_size(), get_pl2(), get_pmc_ipcs_method(), get_sku_ac_dc_loadline(), get_sku_icc_max(), get_vccin_aux_imon_iccmax(), gpp_dxio_update_clk_req_config(), graphics_get_framebuffer_address(), graphics_get_gtt_base(), gspi_calc_base_addr(), i82801dx_enable(), i82801ix_function_disabled(), i82801jx_function_disabled(), igd_disable(), is_cnvi_held_in_reset(), is_devfn_enabled(), mainboard_final(), mainboard_set_power_limits(), mtk_pcie_get_controller_base(), parse_devicetree(), pch_cg_init(), pch_thermal_configuration(), pcidev_on_root(), pcidev_path_on_root_debug(), pcie_update_device_tree(), platform_fsp_memory_init_params_cb(), platform_fsp_silicon_init_params_cb(), platform_is_up3(), pmc_ipc_acpi_set_pci_clock(), sa_fill_gnvs(), sa_lock_pam(), set_board_env_params(), set_sb_aoac(), SetFchEnvParams(), SetFchResetParams(), SetMemParams(), smm_lock(), soc_customize_init_early(), soc_fill_dmar(), soc_irq_settings(), soc_systemagent_init(), soc_vtd_enabled(), system_agent_region_base(), systemagent_revision(), tbt_finalize(), uart_get_device(), variant_devtree_update(), variant_sku_gpio_table(), variant_update_devtree(), wa_init_display_signal(), and wifi_device_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcidev_path_on_root_debug()

DEVTREE_CONST struct device* pcidev_path_on_root_debug ( pci_devfn_t  devfn,
const char *  func 
)

Definition at line 278 of file device_const.c.

References dev_find_slot(), devtree_bug(), DEVTREE_CONST, and pcidev_path_on_root().

Here is the call graph for this function:

◆ print_resource_tree()

void print_resource_tree ( const struct device root,
int  debug_level,
const char *  msg 
)

Definition at line 725 of file device_util.c.

References dev_path(), printk, and resource_tree().

Referenced by dev_configure(), and xeonsp_pci_domain_set_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_bus()

int reset_bus ( struct bus bus)

Reset all of the devices on a bus and clear the bus's reset_needed flag.

Parameters
busPointer to the bus structure.
Returns
1 if the bus was successfully reset, 0 otherwise.

Definition at line 329 of file device.c.

References bus::dev, device::ops, device_operations::reset_bus, and bus::reset_needed.

Referenced by scan_bus().

Here is the caller graph for this function:

◆ run_bios()

◆ scan_bridges()

void scan_bridges ( struct bus bus)

Definition at line 383 of file device.c.

References bus::children, device::ops, scan_bus(), device_operations::scan_bus, and device::sibling.

Referenced by pci_scan_bus(), scan_static_bus(), and xeonsp_pci_domain_scan_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_generic_bus()

void scan_generic_bus ( struct device bus)

Definition at line 52 of file root_device.c.

References BIOS_DEBUG, BIOS_SPEW, device::bus, bus::children, bus::dev, dev_path(), enable_static_device(), bus::link_num, bus::next, printk, bus::secondary, and device::sibling.

Referenced by scan_smbus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_smbus()

void scan_smbus ( struct device bus)

Definition at line 74 of file root_device.c.

References scan_generic_bus().

Here is the call graph for this function:

◆ scan_static_bus()

void scan_static_bus ( struct device bus)

Definition at line 89 of file root_device.c.

References BIOS_SPEW, dev_path(), enable_static_devices(), bus::next, printk, and scan_bridges().

Here is the call graph for this function:

◆ set_cpu_topology()

void set_cpu_topology ( struct device cpu,
unsigned int  node,
unsigned int  package,
unsigned int  core,
unsigned int  thread 
)

◆ show_all_devs()

void show_all_devs ( int  debug_level,
const char *  msg 
)

Definition at line 781 of file device_util.c.

References all_devices, dev_path(), device::enabled, device::next, and printk.

Referenced by dev_enumerate(), and dev_initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_all_devs_resources()

void show_all_devs_resources ( int  debug_level,
const char *  msg 
)

Definition at line 809 of file device_util.c.

References all_devices, dev_path(), device::enabled, device::next, resource::next, printk, device::resource_list, and show_one_resource().

Here is the call graph for this function:

◆ show_all_devs_tree()

void show_all_devs_tree ( int  debug_level,
const char *  msg 
)

Definition at line 763 of file device_util.c.

References all_devices, printk, and show_devs_tree().

Here is the call graph for this function:

◆ show_devs_subtree()

void show_devs_subtree ( struct device root,
int  debug_level,
const char *  msg 
)

Definition at line 771 of file device_util.c.

References dev_path(), printk, and show_devs_tree().

Here is the call graph for this function:

◆ show_devs_tree()

void show_devs_tree ( const struct device dev,
int  debug_level,
int  depth 
)

Definition at line 742 of file device_util.c.

References bus::children, bus::dev, dev_path(), device::enabled, device::link_list, bus::next, printk, and device::sibling.

Referenced by dev_enumerate(), show_all_devs_tree(), and show_devs_subtree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_one_resource()

void show_one_resource ( int  debug_level,
struct device dev,
struct resource resource,
const char *  comment 
)

Definition at line 794 of file device_util.c.

References resource::base, base, buf, dev_path(), resource::gran, resource::index, printk, resource_end(), resource_type(), and resource::size.

Referenced by show_all_devs_resources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tolm_test()

void tolm_test ( void gp,
struct device dev,
struct resource new 
)

Definition at line 870 of file device_util.c.

References resource::base.

Referenced by find_pci_tolm(), and my_find_pci_tolm().

Here is the caller graph for this function:

Variable Documentation

◆ all_devices

◆ default_dev_ops_root

struct device_operations default_dev_ops_root
extern

Default device operation for root device.

This is the default device operation for root devices. These operations should be fully usable as is. However the chip_operations::enable_dev() of a motherboard can override this if you want non-default behavior.

Definition at line 103 of file root_device.c.

Referenced by soc_init().

◆ dev_root

DEVTREE_CONST struct device dev_root
extern

This is the root of the device tree.

The device tree is defined in the static.c file and is generated by the config tool at compile time.

Referenced by dev_configure(), dev_enable(), dev_enumerate(), dev_finalize(), and dev_initialize().

◆ free_links

struct bus* free_links
extern

◆ free_resources

struct resource* free_resources
extern

Linked list of free resources.

Definition at line 23 of file device.c.

Referenced by allocate_more_resources(), free_resource(), and new_resource().

◆ mainboard_name

const char mainboard_name[]
extern

Definition at line 8 of file root_device.c.