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 <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include "i82801gx.h"
8 #include <device/pci_ehci.h>
9 #include <device/mmio.h>
10 #include <device/pci_def.h>
11 #include <device/pci_ops.h>
12 
13 static void usb_ehci_init(struct device *dev)
14 {
15  struct resource *res;
16  u8 *base;
17  u32 reg32;
18 
19  printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
21 
22  pci_or_config32(dev, 0xdc, (1 << 31) | (1 << 27));
23 
24  pci_update_config32(dev, 0xfc, ~(3 << 2), (2 << 2) | (1 << 29) | (1 << 17));
25 
26  /* Clear any pending port changes */
28  base = res2mmio(res, 0, 0);
29  reg32 = read32(base + 0x24) | (1 << 2);
30  write32(base + 0x24, reg32);
31 
32  /* workaround */
33  pci_or_config8(dev, 0x84, 1 << 4);
34 
35  printk(BIOS_DEBUG, "done.\n");
36 }
37 
38 static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
39 {
40  u8 access_cntl;
41 
42  access_cntl = pci_read_config8(dev, 0x80);
43 
44  /* Enable writes to protected registers. */
45  pci_write_config8(dev, 0x80, access_cntl | 1);
46 
48 
49  /* Restore protection. */
50  pci_write_config8(dev, 0x80, access_cntl);
51 }
52 
53 static struct pci_operations lops_pci = {
54  .set_subsystem = &usb_ehci_set_subsystem,
55 };
56 
57 static struct device_operations usb_ehci_ops = {
59  .set_resources = pci_dev_set_resources,
60  .enable_resources = pci_dev_enable_resources,
61  .init = usb_ehci_init,
62  .enable = i82801gx_enable,
63  .ops_pci = &lops_pci,
64 };
65 
66 /* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
67 static const struct pci_driver i82801gx_usb_ehci __pci_driver = {
68  .ops = &usb_ehci_ops,
69  .vendor = PCI_VID_INTEL,
70  .device = 0x27cc,
71 };
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
int vendor
Definition: cpu.c:91
#define printk(level,...)
Definition: stdlib.h:16
struct resource * find_resource(const struct device *dev, unsigned int index)
Return an existing resource structure for a given index.
Definition: device_util.c:394
void i82801gx_enable(struct device *dev)
Definition: i82801gx.c:54
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_update_config32(const struct device *dev, u16 reg, u32 mask, u32 or)
Definition: pci_ops.h:120
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static __always_inline void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
Definition: pci_ops.h:169
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
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_COMMAND_SERR
Definition: pci_def.h:19
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_BASE_ADDRESS_0
Definition: pci_def.h:63
#define PCI_COMMAND
Definition: pci_def.h:10
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
static void * res2mmio(const struct resource *res, unsigned long offset, unsigned long mask)
Definition: resource.h:87
uintptr_t base
Definition: uart.c:17
static struct pci_operations lops_pci
Definition: usb_ehci.c:53
static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
Definition: usb_ehci.c:38
static const struct pci_driver i82801gx_usb_ehci __pci_driver
Definition: usb_ehci.c:67
static struct device_operations usb_ehci_ops
Definition: usb_ehci.c:57
static void usb_ehci_init(struct device *dev)
Definition: usb_ehci.c:13
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107