blob: 9759186ca3a5c6821889b962e69b8d65dae2eea2 [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. */
Patrick Georgie72a8a32012-11-06 11:05:09 +01003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01008#include <device/pci_ids.h>
9#include "i82801ix.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020010#include <device/pci_ehci.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010011
12static void usb_ehci_init(struct device *dev)
13{
Patrick Georgie72a8a32012-11-06 11:05:09 +010014 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
Elyes HAOUASb9d2e222020-04-28 10:25:12 +020015 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Patrick Georgie72a8a32012-11-06 11:05:09 +010016
17 printk(BIOS_DEBUG, "done.\n");
18}
19
Martin Rothff744bf2019-10-23 21:46:03 -060020static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
21 unsigned int device)
Patrick Georgie72a8a32012-11-06 11:05:09 +010022{
23 u8 access_cntl;
24
25 access_cntl = pci_read_config8(dev, 0x80);
26
27 /* Enable writes to protected registers. */
28 pci_write_config8(dev, 0x80, access_cntl | 1);
29
Subrata Banik4a0f0712019-03-20 14:29:47 +053030 pci_dev_set_subsystem(dev, vendor, device);
Patrick Georgie72a8a32012-11-06 11:05:09 +010031
32 /* Restore protection. */
33 pci_write_config8(dev, 0x80, access_cntl);
34}
35
Patrick Georgie72a8a32012-11-06 11:05:09 +010036static const unsigned short pci_device_ids[] = {
Felix Singer7f8b0cd2019-11-10 11:04:08 +010037 PCI_DEVICE_ID_INTEL_82801IB_EHCI1,
38 PCI_DEVICE_ID_INTEL_82801IB_EHCI2,
Patrick Georgie72a8a32012-11-06 11:05:09 +010039 0
40};
41
42static struct pci_operations lops_pci = {
43 .set_subsystem = &usb_ehci_set_subsystem,
44};
45
46static struct device_operations usb_ehci_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +030047 .read_resources = pci_ehci_read_resources,
48 .set_resources = pci_dev_set_resources,
Patrick Georgie72a8a32012-11-06 11:05:09 +010049 .enable_resources = pci_dev_enable_resources,
50 .init = usb_ehci_init,
Patrick Georgie72a8a32012-11-06 11:05:09 +010051 .ops_pci = &lops_pci,
52};
53
54static const struct pci_driver pch_usb_ehci1 __pci_driver = {
55 .ops = &usb_ehci_ops,
56 .vendor = PCI_VENDOR_ID_INTEL,
57 .devices = pci_device_ids,
58};