coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
usb_xhci.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include "pch.h"
8 #include <device/pci_ehci.h>
9 #include <device/pci_ops.h>
10 #include "chip.h"
11 
12 static void usb_xhci_init(struct device *dev)
13 {
14  u32 reg32;
16 
17  printk(BIOS_DEBUG, "XHCI: Setting up controller.. ");
18 
19  if (config->xhci_overcurrent_mapping)
20  pci_write_config32(dev, XOCM, config->xhci_overcurrent_mapping);
21 
22  /* lock overcurrent map */
23  pci_or_config32(dev, 0x44, 1);
24 
25  pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports);
26  pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports);
27 
28  /* Enable clock gating */
29  reg32 = pci_read_config32(dev, 0x40);
30  reg32 &= ~((1 << 20) | (1 << 21));
31  reg32 |= (1 << 19) | (1 << 18) | (1 << 17);
32  reg32 |= (1 << 10) | (1 << 9) | (1 << 8);
33  reg32 |= (1 << 31); /* lock */
34  pci_write_config32(dev, 0x40, reg32);
35 
36  printk(BIOS_DEBUG, "done.\n");
37 }
38 
39 static const char *xhci_acpi_name(const struct device *dev)
40 {
41  return "XHC";
42 }
43 
44 static struct device_operations usb_xhci_ops = {
46  .set_resources = pci_dev_set_resources,
47  .enable_resources = pci_dev_enable_resources,
48  .init = usb_xhci_init,
49  .ops_pci = &pci_dev_ops_pci,
50  .acpi_name = xhci_acpi_name,
51 };
52 
53 static const unsigned short pci_device_ids[] = { 0x1e31, 0 };
54 
55 static const struct pci_driver pch_usb_xhci __pci_driver = {
56  .ops = &usb_xhci_ops,
57  .vendor = PCI_VID_INTEL,
58  .devices = pci_device_ids,
59 };
#define printk(level,...)
Definition: stdlib.h:16
static __always_inline void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
Definition: pci_ops.h:191
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
enum board_config config
Definition: memory.c:448
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
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
#define XUSB2PRM
Definition: pch.h:403
#define USB3PRM
Definition: pch.h:404
#define XOCM
Definition: pch.h:402
static const char * xhci_acpi_name(const struct device *dev)
Definition: usb_xhci.c:39
static struct device_operations usb_xhci_ops
Definition: usb_xhci.c:44
static const struct pci_driver pch_usb_xhci __pci_driver
Definition: usb_xhci.c:55
static const unsigned short pci_device_ids[]
Definition: usb_xhci.c:53
static void usb_xhci_init(struct device *dev)
Definition: usb_xhci.c:12
uint32_t u32
Definition: stdint.h:51
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164