blob: 4e6327a8cd423bf1fb351fae3359df26ef0e9b6a [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgie72a8a32012-11-06 11:05:09 +01002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01007#include <device/pci_ids.h>
8#include "i82801ix.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +02009#include <device/pci_ehci.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010010
11static void usb_ehci_init(struct device *dev)
12{
Patrick Georgie72a8a32012-11-06 11:05:09 +010013 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
Elyes HAOUASb9d2e222020-04-28 10:25:12 +020014 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Patrick Georgie72a8a32012-11-06 11:05:09 +010015
16 printk(BIOS_DEBUG, "done.\n");
17}
18
Martin Rothff744bf2019-10-23 21:46:03 -060019static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
20 unsigned int device)
Patrick Georgie72a8a32012-11-06 11:05:09 +010021{
22 u8 access_cntl;
23
24 access_cntl = pci_read_config8(dev, 0x80);
25
26 /* Enable writes to protected registers. */
27 pci_write_config8(dev, 0x80, access_cntl | 1);
28
Subrata Banik4a0f0712019-03-20 14:29:47 +053029 pci_dev_set_subsystem(dev, vendor, device);
Patrick Georgie72a8a32012-11-06 11:05:09 +010030
31 /* Restore protection. */
32 pci_write_config8(dev, 0x80, access_cntl);
33}
34
Patrick Georgie72a8a32012-11-06 11:05:09 +010035static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010036 PCI_DID_INTEL_82801IB_EHCI1,
37 PCI_DID_INTEL_82801IB_EHCI2,
Patrick Georgie72a8a32012-11-06 11:05:09 +010038 0
39};
40
41static struct pci_operations lops_pci = {
42 .set_subsystem = &usb_ehci_set_subsystem,
43};
44
45static struct device_operations usb_ehci_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +030046 .read_resources = pci_ehci_read_resources,
47 .set_resources = pci_dev_set_resources,
Patrick Georgie72a8a32012-11-06 11:05:09 +010048 .enable_resources = pci_dev_enable_resources,
49 .init = usb_ehci_init,
Patrick Georgie72a8a32012-11-06 11:05:09 +010050 .ops_pci = &lops_pci,
51};
52
53static const struct pci_driver pch_usb_ehci1 __pci_driver = {
54 .ops = &usb_ehci_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010055 .vendor = PCI_VID_INTEL,
Patrick Georgie72a8a32012-11-06 11:05:09 +010056 .devices = pci_device_ids,
57};