coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_usb.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/mmio.h>
4 #include <device/pci_ops.h>
5 #include <device/pci_def.h>
8 
9 #include "pch.h"
10 
11 void early_usb_init(const struct southbridge_usb_port *portmap)
12 {
13  u32 reg32;
14  const u32 rcba_dump[8] = {
15  /* 3560 */ 0x024c8001, 0x000024a3, 0x00040002, 0x01000050,
16  /* 3570 */ 0x02000772, 0x16000f9f, 0x1800ff4f, 0x0001d630,
17  };
18  const u32 currents[] = { 0x20000153, 0x20000f57, 0x2000055b, 0x20000f51,
19  0x2000094a, 0x2000035f, 0x20000f53, 0x20000357,
20  0x20000353 };
21  int i;
22 
23  /* Unlock registers. */
25 
26  for (i = 0; i < 14; i++)
27  RCBA32(USBIR0 + 4 * i) = currents[portmap[i].current];
28  for (i = 0; i < 10; i++)
29  RCBA32(0x3538 + 4 * i) = 0;
30 
31  for (i = 0; i < 8; i++)
32  RCBA32(0x3560 + 4 * i) = rcba_dump[i];
33  for (i = 0; i < 8; i++)
34  RCBA32(0x3580 + 4 * i) = 0;
35  reg32 = 0;
36  for (i = 0; i < 14; i++)
37  if (!portmap[i].enabled)
38  reg32 |= (1 << i);
39  RCBA32(USBPDO) = reg32;
40  reg32 = 0;
41  for (i = 0; i < 8; i++)
42  if (portmap[i].enabled && portmap[i].oc_pin >= 0)
43  reg32 |= (1 << (i + 8 * portmap[i].oc_pin));
44  RCBA32(USBOCM1) = reg32;
45  reg32 = 0;
46  for (i = 8; i < 14; i++)
47  if (portmap[i].enabled && portmap[i].oc_pin >= 4)
48  reg32 |= (1 << (i - 8 + 8 * (portmap[i].oc_pin - 4)));
49  RCBA32(USBOCM2) = reg32;
50  for (i = 0; i < 22; i++)
51  RCBA32(0x35a8 + 4 * i) = 0;
52 
53  pci_write_config32(PCH_XHCI_DEV, 0xe4, 0x00000000);
54 
55  /* Relock registers. */
57 }
#define UPRWC_WR_EN
Definition: pm.h:222
#define UPRWC
Definition: pm.h:221
void early_usb_init(const struct southbridge_usb_port *portmap)
Definition: early_usb.c:11
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
void write_pmbase16(const u8 addr, const u16 val)
Definition: pmbase.c:43
u16 read_pmbase16(const u8 addr)
Definition: pmbase.c:64
#define USBOCM1
Definition: pch.h:389
#define USBPDO
Definition: pch.h:387
#define PCH_XHCI_DEV
Definition: pch.h:88
#define USBOCM2
Definition: pch.h:390
#define USBIR0
Definition: pch.h:369
#define RCBA32(x)
Definition: rcba.h:14
uint32_t u32
Definition: stdint.h:51