blob: 3ada5b26b14773154032314bc07b817c9f45a419 [file] [log] [blame]
Angel Ponsf94ac9a2020-04-05 15:46:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Lauriec88c54c2014-04-30 16:36:13 -07002
Duncan Lauriec88c54c2014-04-30 16:36:13 -07003#include <device/device.h>
4#include <device/pci.h>
5#include <device/pci_ids.h>
Georg Wicherski49ee5ef2015-10-13 16:27:15 +02006#include <device/pci_ehci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -07008#include <soc/ehci.h>
9#include <soc/pch.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070010
Elyes HAOUAS040aff22018-05-27 16:30:36 +020011static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
Lee Leahy23602df2017-03-16 19:00:37 -070012 unsigned int device)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070013{
14 u8 access_cntl;
15
16 access_cntl = pci_read_config8(dev, 0x80);
17
18 /* Enable writes to protected registers. */
19 pci_write_config8(dev, 0x80, access_cntl | 1);
20
Subrata Banik4a0f0712019-03-20 14:29:47 +053021 pci_dev_set_subsystem(dev, vendor, device);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070022
23 /* Restore protection. */
24 pci_write_config8(dev, 0x80, access_cntl);
25}
26
Duncan Laurie61680272014-05-05 12:42:35 -050027static void ehci_enable(struct device *dev)
28{
Kyösti Mälkkifd159552019-03-20 18:46:30 +020029 if (CONFIG(USBDEBUG))
Duncan Laurie61680272014-05-05 12:42:35 -050030 dev->enabled = 1;
31 else
32 pch_disable_devfn(dev);
33}
34
Duncan Lauriec88c54c2014-04-30 16:36:13 -070035static struct pci_operations ehci_ops_pci = {
36 .set_subsystem = &usb_ehci_set_subsystem,
37};
38
39static struct device_operations usb_ehci_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010040 .read_resources = pci_ehci_read_resources,
41 .set_resources = pci_dev_set_resources,
42 .enable_resources = pci_dev_enable_resources,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070043 .ops_pci = &ehci_ops_pci,
Elyes HAOUAS1d191272018-11-27 12:23:48 +010044 .enable = ehci_enable,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070045};
46
47static const unsigned short pci_device_ids[] = {
48 0x9c26, /* LynxPoint-LP */
49 0x9ca6, /* WildcatPoint */
50 0
51};
52
53static const struct pci_driver pch_usb_ehci __pci_driver = {
54 .ops = &usb_ehci_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010055 .vendor = PCI_VID_INTEL,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070056 .devices = pci_device_ids,
57};