blob: 9eb66cc7b6076c24d90f4bf9138f4c18e84f1ab8 [file] [log] [blame]
Angel Ponsf94ac9a2020-04-05 15:46:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Duncan Lauriec88c54c2014-04-30 16:36:13 -07003
Duncan Lauriec88c54c2014-04-30 16:36:13 -07004#include <device/device.h>
5#include <device/pci.h>
6#include <device/pci_ids.h>
Georg Wicherski49ee5ef2015-10-13 16:27:15 +02007#include <device/pci_ehci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02008#include <device/pci_ops.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -07009#include <soc/ehci.h>
10#include <soc/pch.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070011
Elyes HAOUAS040aff22018-05-27 16:30:36 +020012static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
Lee Leahy23602df2017-03-16 19:00:37 -070013 unsigned int device)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070014{
15 u8 access_cntl;
16
17 access_cntl = pci_read_config8(dev, 0x80);
18
19 /* Enable writes to protected registers. */
20 pci_write_config8(dev, 0x80, access_cntl | 1);
21
Subrata Banik4a0f0712019-03-20 14:29:47 +053022 pci_dev_set_subsystem(dev, vendor, device);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070023
24 /* Restore protection. */
25 pci_write_config8(dev, 0x80, access_cntl);
26}
27
Duncan Laurie61680272014-05-05 12:42:35 -050028static void ehci_enable(struct device *dev)
29{
Kyösti Mälkkifd159552019-03-20 18:46:30 +020030 if (CONFIG(USBDEBUG))
Duncan Laurie61680272014-05-05 12:42:35 -050031 dev->enabled = 1;
32 else
33 pch_disable_devfn(dev);
34}
35
Duncan Lauriec88c54c2014-04-30 16:36:13 -070036static struct pci_operations ehci_ops_pci = {
37 .set_subsystem = &usb_ehci_set_subsystem,
38};
39
40static struct device_operations usb_ehci_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010041 .read_resources = pci_ehci_read_resources,
42 .set_resources = pci_dev_set_resources,
43 .enable_resources = pci_dev_enable_resources,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070044 .ops_pci = &ehci_ops_pci,
Elyes HAOUAS1d191272018-11-27 12:23:48 +010045 .enable = ehci_enable,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070046};
47
48static const unsigned short pci_device_ids[] = {
49 0x9c26, /* LynxPoint-LP */
50 0x9ca6, /* WildcatPoint */
51 0
52};
53
54static const struct pci_driver pch_usb_ehci __pci_driver = {
55 .ops = &usb_ehci_ops,
56 .vendor = PCI_VENDOR_ID_INTEL,
57 .devices = pci_device_ids,
58};