Debian Codegraph @

src/southbridge/intel/bd82x6x/usb_ehci.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/mmio.h>
6 #include <device/pci_ehci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9 #include <device/pci.h>
10
11 #include "pch.h"
12
13 static void usb_ehci_init(struct device *dev)
14 {
15 u32 reg32;
16
17 /* Disable Wake on Disconnect in RMH */
18 reg32 = RCBA32(RMHWKCTL);
19 reg32 |= 0x22;
20 RCBA32(RMHWKCTL) = reg32;
21
22 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
23
24 /* For others, done in MRC. */
25 #if CONFIG(USE_NATIVE_RAMINIT)
26 pci_write_config32(dev, 0x84, 0x930c8811);
27 pci_write_config32(dev, 0x88, 0x24000d30);
28 pci_write_config32(dev, 0xf4, 0x80408588);
29 pci_write_config32(dev, 0xf4, 0x80808588);
30 pci_write_config32(dev, 0xf4, 0x00808588);
31 pci_write_config32(dev, 0xfc, 0x205b1708);
32 #endif
33
34 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
35 //pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_SERR);
36
37 /* For others, done in MRC. */
38 #if CONFIG(USE_NATIVE_RAMINIT)
39 struct resource *res;
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
47 res = probe_resource(dev, PCI_BASE_ADDRESS_0);
48 if (res) {
49 /* Number of ports and companion controllers. */
50 reg32 = read32p((uintptr_t)(res->base + 4));
51 write32p((uintptr_t)(res->base + 4),
52 (reg32 & 0xfff00000) | 3);
53 }
54
55 /* Restore protection. */
56 pci_write_config8(dev, 0x80, access_cntl);
57 #endif
58
59 printk(BIOS_DEBUG, "done.\n");
60 }
61
62 static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
63 unsigned int device)
64 {
65 u8 access_cntl;
66
67 access_cntl = pci_read_config8(dev, 0x80);
68
69 /* Enable writes to protected registers. */
70 pci_write_config8(dev, 0x80, access_cntl | 1);
71
72 pci_dev_set_subsystem(dev, vendor, device);
73
74 /* Restore protection. */
75 pci_write_config8(dev, 0x80, access_cntl);
76 }
77
78 static const char *usb_ehci_acpi_name(const struct device *dev)
79 {
80 switch (dev->path.pci.devfn) {
81 case PCI_DEVFN(0x1a, 0):
82 return "EHC2";
83 case PCI_DEVFN(0x1d, 0):
84 return "EHC1";
85 }
86 return NULL;
87 }
88
89 static struct pci_operations lops_pci = {
90 .set_subsystem = &usb_ehci_set_subsystem,
91 };
92
93 struct device_operations bd82x6x_usb_ehci_ops = {
94 .read_resources = pci_ehci_read_resources,
95 .set_resources = pci_dev_set_resources,
96 .enable_resources = pci_dev_enable_resources,
97 .init = usb_ehci_init,
98 .ops_pci = &lops_pci,
99 .acpi_name = usb_ehci_acpi_name,
100 };