coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
usb_ehci.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ehci.h>
7 #include <device/pci_ops.h>
8 #include <soc/ehci.h>
9 #include <soc/pch.h>
10 
11 static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
12  unsigned int device)
13 {
14  u8 access_cntl;
15 
16  access_cntl = pci_read_config8(dev, 0x80);
17 
18  /* Enable writes to protected registers. */
19  pci_write_config8(dev, 0x80, access_cntl | 1);
20 
22 
23  /* Restore protection. */
24  pci_write_config8(dev, 0x80, access_cntl);
25 }
26 
27 static void ehci_enable(struct device *dev)
28 {
29  if (CONFIG(USBDEBUG))
30  dev->enabled = 1;
31  else
32  pch_disable_devfn(dev);
33 }
34 
35 static struct pci_operations ehci_ops_pci = {
36  .set_subsystem = &usb_ehci_set_subsystem,
37 };
38 
39 static struct device_operations usb_ehci_ops = {
41  .set_resources = pci_dev_set_resources,
42  .enable_resources = pci_dev_enable_resources,
43  .ops_pci = &ehci_ops_pci,
44  .enable = ehci_enable,
45 };
46 
47 static const unsigned short pci_device_ids[] = {
48  0x9c26, /* LynxPoint-LP */
49  0x9ca6, /* WildcatPoint */
50  0
51 };
52 
53 static const struct pci_driver pch_usb_ehci __pci_driver = {
54  .ops = &usb_ehci_ops,
55  .vendor = PCI_VID_INTEL,
56  .devices = pci_device_ids,
57 };
int vendor
Definition: cpu.c:91
@ CONFIG
Definition: dsi_common.h:201
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
void pci_dev_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
Definition: pci_device.c:791
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define pci_ehci_read_resources
Definition: pci_ehci.h:22
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
void pch_disable_devfn(struct device *dev)
Definition: pch.c:77
static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
Definition: usb_ehci.c:11
static void ehci_enable(struct device *dev)
Definition: usb_ehci.c:27
static const struct pci_driver pch_usb_ehci __pci_driver
Definition: usb_ehci.c:53
static const unsigned short pci_device_ids[]
Definition: usb_ehci.c:47
static struct pci_operations ehci_ops_pci
Definition: usb_ehci.c:35
static struct device_operations usb_ehci_ops
Definition: usb_ehci.c:39
uint8_t u8
Definition: stdint.h:45
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
unsigned int enabled
Definition: device.h:122