blob: 4b751aea24dd65174b3cf231e2c98b8907b09430 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banik23ccb0d2017-04-24 11:28:40 +05302
Subrata Banik23ccb0d2017-04-24 11:28:40 +05303#include <device/device.h>
4#include <device/pci.h>
5#include <device/pci_ids.h>
6#include <intelblocks/xdci.h>
Duncan Laurie4df7d2c2018-03-26 02:17:33 -07007#include <security/vboot/vboot_common.h>
Subrata Banik23ccb0d2017-04-24 11:28:40 +05308
Aaron Durbin64031672018-04-21 14:45:32 -06009__weak void soc_xdci_init(struct device *dev) { /* no-op */ }
Subrata Banik23ccb0d2017-04-24 11:28:40 +053010
Angel Ponsc7cfe0b2021-06-23 12:39:22 +020011bool xdci_can_enable(unsigned int xdci_devfn)
Duncan Laurie4df7d2c2018-03-26 02:17:33 -070012{
Angel Ponsc7cfe0b2021-06-23 12:39:22 +020013 /* Enable xDCI controller if enabled in devicetree and allowed */
14 if (!vboot_can_enable_udc()) {
15 devfn_disable(pci_root_bus(), xdci_devfn);
16 return false;
17 }
18 return is_devfn_enabled(xdci_devfn);
Duncan Laurie4df7d2c2018-03-26 02:17:33 -070019}
20
Subrata Banik23ccb0d2017-04-24 11:28:40 +053021static struct device_operations usb_xdci_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010022 .read_resources = pci_dev_read_resources,
23 .set_resources = pci_dev_set_resources,
24 .enable_resources = pci_dev_enable_resources,
Subrata Banik23ccb0d2017-04-24 11:28:40 +053025 .init = soc_xdci_init,
Subrata Banik6bbc91a2017-12-07 14:55:51 +053026 .ops_pci = &pci_dev_ops_pci,
Subrata Banik23ccb0d2017-04-24 11:28:40 +053027};
28
29static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010030 PCI_DID_INTEL_APL_XDCI,
31 PCI_DID_INTEL_CNL_LP_XDCI,
32 PCI_DID_INTEL_GLK_XDCI,
33 PCI_DID_INTEL_SPT_LP_XDCI,
34 PCI_DID_INTEL_CNP_H_XDCI,
35 PCI_DID_INTEL_ICP_LP_XDCI,
36 PCI_DID_INTEL_CMP_LP_XDCI,
37 PCI_DID_INTEL_CMP_H_XDCI,
38 PCI_DID_INTEL_TGP_LP_XDCI,
39 PCI_DID_INTEL_TGP_H_XDCI,
40 PCI_DID_INTEL_MCC_XDCI,
41 PCI_DID_INTEL_JSP_XDCI,
42 PCI_DID_INTEL_ADP_P_XDCI,
43 PCI_DID_INTEL_ADP_S_XDCI,
44 PCI_DID_INTEL_ADP_M_XDCI,
Subrata Banik23ccb0d2017-04-24 11:28:40 +053045 0
46};
47
48static const struct pci_driver pch_usb_xdci __pci_driver = {
49 .ops = &usb_xdci_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010050 .vendor = PCI_VID_INTEL,
Subrata Banik23ccb0d2017-04-24 11:28:40 +053051 .devices = pci_device_ids,
52};