coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
r8168.c File Reference
#include <cbfs.h>
#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
#include <string.h>
#include <arch/io.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ops.h>
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <delay.h>
#include <fmap.h>
#include <types.h>
#include "chip.h"
Include dependency graph for r8168.c:

Go to the source code of this file.

Macros

#define NIC_TIMEOUT   1000
 
#define CMD_REG   0x37
 
#define CMD_REG_RESET   0x10
 
#define CMD_LED0_LED1   0x18
 
#define CMD_LED_FEATURE   0x94
 
#define CMD_LEDSEL0   0x18
 
#define CMD_LEDSEL2   0x84
 
#define CFG_9346   0x50
 
#define CFG_9346_LOCK   0x00
 
#define CFG_9346_UNLOCK   0xc0
 
#define CMD_REG_ASPM   0xb0
 
#define ASPM_L1_2_MASK   0xe059000f
 
#define DEVICE_INDEX_BYTE   12
 
#define MAX_DEVICE_SUPPORT   10
 
#define MACLEN   17
 

Functions

static size_t search (const char *p, const u8 *a, size_t lengthp, size_t lengtha)
 search: Find first instance of string in a given region More...
 
static u8 get_hex_digit (const u8 c)
 
static enum cb_err fetch_mac_vpd_key (u8 *macstrbuf, const char *vpd_key)
 
static enum cb_err fetch_mac_vpd_dev_idx (u8 *macstrbuf, u8 device_index)
 
static void fetch_mac_string_vpd (struct drivers_net_config *config, u8 *macstrbuf)
 
static enum cb_err fetch_mac_string_cbfs (u8 *macstrbuf)
 
static void get_mac_address (u8 *macaddr, const u8 *strbuf)
 
static void program_mac_address (struct device *dev, u16 io_base)
 
static void enable_aspm_l1_2 (u16 io_base)
 
static void r8168_set_customized_led (struct device *dev, u16 io_base)
 
static void r8168_init (struct device *dev)
 

Variables

static struct device_operations r8168_ops
 
static const unsigned short pci_device_ids []
 
static const struct pci_driver r8168_driver __pci_driver
 
struct chip_operations drivers_net_ops
 

Macro Definition Documentation

◆ ASPM_L1_2_MASK

#define ASPM_L1_2_MASK   0xe059000f

Definition at line 40 of file r8168.c.

◆ CFG_9346

#define CFG_9346   0x50

Definition at line 36 of file r8168.c.

◆ CFG_9346_LOCK

#define CFG_9346_LOCK   0x00

Definition at line 37 of file r8168.c.

◆ CFG_9346_UNLOCK

#define CFG_9346_UNLOCK   0xc0

Definition at line 38 of file r8168.c.

◆ CMD_LED0_LED1

#define CMD_LED0_LED1   0x18

Definition at line 31 of file r8168.c.

◆ CMD_LED_FEATURE

#define CMD_LED_FEATURE   0x94

Definition at line 32 of file r8168.c.

◆ CMD_LEDSEL0

#define CMD_LEDSEL0   0x18

Definition at line 33 of file r8168.c.

◆ CMD_LEDSEL2

#define CMD_LEDSEL2   0x84

Definition at line 34 of file r8168.c.

◆ CMD_REG

#define CMD_REG   0x37

Definition at line 29 of file r8168.c.

◆ CMD_REG_ASPM

#define CMD_REG_ASPM   0xb0

Definition at line 39 of file r8168.c.

◆ CMD_REG_RESET

#define CMD_REG_RESET   0x10

Definition at line 30 of file r8168.c.

◆ DEVICE_INDEX_BYTE

#define DEVICE_INDEX_BYTE   12

Definition at line 42 of file r8168.c.

◆ MACLEN

#define MACLEN   17

Definition at line 88 of file r8168.c.

◆ MAX_DEVICE_SUPPORT

#define MAX_DEVICE_SUPPORT   10

Definition at line 43 of file r8168.c.

◆ NIC_TIMEOUT

#define NIC_TIMEOUT   1000

Definition at line 27 of file r8168.c.

Function Documentation

◆ enable_aspm_l1_2()

static void enable_aspm_l1_2 ( u16  io_base)
static

Definition at line 249 of file r8168.c.

References ASPM_L1_2_MASK, BIOS_INFO, CFG_9346, CFG_9346_LOCK, CFG_9346_UNLOCK, CMD_REG_ASPM, outb(), outl(), and printk.

Referenced by r8168_init().

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

◆ fetch_mac_string_cbfs()

static enum cb_err fetch_mac_string_cbfs ( u8 macstrbuf)
static

Definition at line 146 of file r8168.c.

References BIOS_ERR, CB_SUCCESS, config, CONFIG, fetch_mac_vpd_dev_idx(), fetch_mac_vpd_key(), MAX_DEVICE_SUPPORT, and printk.

Referenced by program_mac_address().

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

◆ fetch_mac_string_vpd()

static void fetch_mac_string_vpd ( struct drivers_net_config config,
u8 macstrbuf 
)
static

Definition at line 146 of file r8168.c.

Referenced by program_mac_address().

Here is the caller graph for this function:

◆ fetch_mac_vpd_dev_idx()

static enum cb_err fetch_mac_vpd_dev_idx ( u8 macstrbuf,
u8  device_index 
)
static

Definition at line 70 of file r8168.c.

References BIOS_ERR, c, and printk.

Referenced by fetch_mac_string_cbfs().

Here is the caller graph for this function:

◆ fetch_mac_vpd_key()

static enum cb_err fetch_mac_vpd_key ( u8 macstrbuf,
const char *  vpd_key 
)
static

Definition at line 70 of file r8168.c.

Referenced by fetch_mac_string_cbfs().

Here is the caller graph for this function:

◆ get_hex_digit()

static u8 get_hex_digit ( const u8  c)
static

Definition at line 70 of file r8168.c.

Referenced by get_mac_address().

Here is the caller graph for this function:

◆ get_mac_address()

static void get_mac_address ( u8 macaddr,
const u8 strbuf 
)
static

Definition at line 181 of file r8168.c.

References BIOS_ERR, get_hex_digit(), offset, and printk.

Referenced by program_mac_address().

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

◆ program_mac_address()

static void program_mac_address ( struct device dev,
u16  io_base 
)
static

Definition at line 201 of file r8168.c.

References BIOS_DEBUG, BIOS_ERR, CB_SUCCESS, CFG_9346, CFG_9346_LOCK, CFG_9346_UNLOCK, device::chip_info, CMD_REG, CMD_REG_RESET, config, CONFIG, fetch_mac_string_cbfs(), fetch_mac_string_vpd(), get_mac_address(), inb(), inl(), MACLEN, NIC_TIMEOUT, outb(), outl(), printk, and udelay().

Referenced by r8168_init().

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

◆ r8168_init()

static void r8168_init ( struct device dev)
static

◆ r8168_set_customized_led()

static void r8168_set_customized_led ( struct device dev,
u16  io_base 
)
static

Definition at line 263 of file r8168.c.

References BIOS_DEBUG, device::chip_info, CMD_LED0_LED1, CMD_LED_FEATURE, CMD_LEDSEL0, CMD_LEDSEL2, config, device::device, inb(), inw(), outb(), outw(), PCI_DID_REALTEK_8125, and printk.

Referenced by r8168_init().

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

◆ search()

static size_t search ( const char *  p,
const u8 a,
size_t  lengthp,
size_t  lengtha 
)
static

search: Find first instance of string in a given region

Parameters
pstring to find
astart address of region to search
lengthplength of string to search for
lengthalength of region to search in
Returns
offset offset from start address a where string was found. If string not found, return lengtha.

Definition at line 53 of file r8168.c.

Referenced by search_bus_resources(), and search_global_resources().

Here is the caller graph for this function:

Variable Documentation

◆ __pci_driver

const struct pci_driver r8168_driver __pci_driver
static
Initial value:
= {
.ops = &r8168_ops,
.vendor = PCI_VID_REALTEK,
.devices = pci_device_ids,
}
#define PCI_VID_REALTEK
Definition: pci_ids.h:1298
static const unsigned short pci_device_ids[]
Definition: r8168.c:427
static struct device_operations r8168_ops
Definition: r8168.c:416

Definition at line 427 of file r8168.c.

◆ drivers_net_ops

struct chip_operations drivers_net_ops
Initial value:
= {
}

Definition at line 427 of file r8168.c.

◆ pci_device_ids

const unsigned short pci_device_ids[]
static
Initial value:
= {
0
}
#define PCI_DID_REALTEK_8111
Definition: pci_ids.h:1301
#define PCI_DID_REALTEK_8125
Definition: pci_ids.h:1302
#define PCI_DID_REALTEK_8168
Definition: pci_ids.h:1305

Definition at line 427 of file r8168.c.

◆ r8168_ops

struct device_operations r8168_ops
static
Initial value:
= {
.read_resources = pci_dev_read_resources,
.set_resources = pci_dev_set_resources,
.enable_resources = pci_dev_enable_resources,
.init = r8168_init,
}
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
static void r8168_init(struct device *dev)
Definition: r8168.c:335

Definition at line 335 of file r8168.c.