blob: f5136288023b0b3a6638d6f1242aadcc6c36ea3b [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
8#include "pch.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +02009#include <device/pci_ehci.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020010#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020011#include <device/pci_ops.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010012
13static void usb_ehci_init(struct device *dev)
14{
15 u32 reg32;
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020016 struct resource *res;
17 u8 access_cntl;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010018
19 /* Disable Wake on Disconnect in RMH */
20 reg32 = RCBA32(0x35b0);
21 reg32 |= 0x22;
22 RCBA32(0x35b0) = reg32;
23
24 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
25
26 pci_write_config32(dev, 0x84, 0x130c8911);
27 pci_write_config32(dev, 0x88, 0xa0);
28 pci_write_config32(dev, 0xf4, 0x80808588);
29 pci_write_config32(dev, 0xf4, 0x00808588);
30 pci_write_config32(dev, 0xf4, 0x00808588);
31 pci_write_config32(dev, 0xfc, 0x301b1728);
32
33 reg32 = pci_read_config32(dev, PCI_COMMAND);
34 reg32 |= PCI_COMMAND_MASTER;
35 //reg32 |= PCI_COMMAND_SERR;
36 pci_write_config32(dev, PCI_COMMAND, reg32);
37
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020038 access_cntl = pci_read_config8(dev, 0x80);
39
40 /* Enable writes to protected registers. */
41 pci_write_config8(dev, 0x80, access_cntl | 1);
42
43 res = find_resource(dev, PCI_BASE_ADDRESS_0);
44 if (res) {
45 /* Number of ports and companion controllers. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080046 reg32 = read32((u32 *)(uintptr_t)(res->base + 4));
47 write32((u32 *)(uintptr_t)(res->base + 4),
48 (reg32 & 0xfff00000) | 2);
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020049 }
50
51 /* Restore protection. */
52 pci_write_config8(dev, 0x80, access_cntl);
53
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010054 printk(BIOS_DEBUG, "done.\n");
55}
56
Martin Rothff744bf2019-10-23 21:46:03 -060057static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
58 unsigned int device)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010059{
60 u8 access_cntl;
61
62 access_cntl = pci_read_config8(dev, 0x80);
63
64 /* Enable writes to protected registers. */
65 pci_write_config8(dev, 0x80, access_cntl | 1);
66
Subrata Banik4a0f0712019-03-20 14:29:47 +053067 pci_dev_set_subsystem(dev, vendor, device);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010068
69 /* Restore protection. */
70 pci_write_config8(dev, 0x80, access_cntl);
71}
72
73
74static struct pci_operations lops_pci = {
75 .set_subsystem = &usb_ehci_set_subsystem,
76};
77
78static struct device_operations usb_ehci_ops = {
79 .read_resources = pci_ehci_read_resources,
80 .set_resources = pci_dev_set_resources,
Vladimir Serbinenko83ef7492014-03-03 23:21:12 +010081 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010082 .init = usb_ehci_init,
83 .scan_bus = 0,
84 .ops_pci = &lops_pci,
85};
86
Felix Singer838fbc72019-11-21 21:23:32 +010087static const unsigned short pci_device_ids[] = {
88 PCI_DID_INTEL_IBEXPEAK_EHCI_1,
89 PCI_DID_INTEL_IBEXPEAK_EHCI_2,
90 0
91};
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010092
93static const struct pci_driver pch_usb_ehci __pci_driver = {
94 .ops = &usb_ehci_ops,
95 .vendor = PCI_VENDOR_ID_INTEL,
96 .devices = pci_device_ids,
97};