blob: f29c4269b15ca6035f551ec8aa7d6140d0a1c3ba [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Duncan Lauriec88c54c2014-04-30 16:36:13 -070015 */
16
Duncan Lauriec88c54c2014-04-30 16:36:13 -070017#include <delay.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
Georg Wicherski49ee5ef2015-10-13 16:27:15 +020021#include <device/pci_ehci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020022#include <device/pci_ops.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070023#include <soc/ehci.h>
24#include <soc/pch.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070025
Elyes HAOUAS040aff22018-05-27 16:30:36 +020026static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
Lee Leahy23602df2017-03-16 19:00:37 -070027 unsigned int device)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070028{
29 u8 access_cntl;
30
31 access_cntl = pci_read_config8(dev, 0x80);
32
33 /* Enable writes to protected registers. */
34 pci_write_config8(dev, 0x80, access_cntl | 1);
35
Subrata Banik4a0f0712019-03-20 14:29:47 +053036 pci_dev_set_subsystem(dev, vendor, device);
Duncan Lauriec88c54c2014-04-30 16:36:13 -070037
38 /* Restore protection. */
39 pci_write_config8(dev, 0x80, access_cntl);
40}
41
Duncan Laurie61680272014-05-05 12:42:35 -050042static void ehci_enable(struct device *dev)
43{
44 if (CONFIG_USBDEBUG)
45 dev->enabled = 1;
46 else
47 pch_disable_devfn(dev);
48}
49
Duncan Lauriec88c54c2014-04-30 16:36:13 -070050static struct pci_operations ehci_ops_pci = {
51 .set_subsystem = &usb_ehci_set_subsystem,
52};
53
54static struct device_operations usb_ehci_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010055 .read_resources = pci_ehci_read_resources,
56 .set_resources = pci_dev_set_resources,
57 .enable_resources = pci_dev_enable_resources,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070058 .ops_pci = &ehci_ops_pci,
Elyes HAOUAS1d191272018-11-27 12:23:48 +010059 .enable = ehci_enable,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070060};
61
62static const unsigned short pci_device_ids[] = {
63 0x9c26, /* LynxPoint-LP */
64 0x9ca6, /* WildcatPoint */
65 0
66};
67
68static const struct pci_driver pch_usb_ehci __pci_driver = {
69 .ops = &usb_ehci_ops,
70 .vendor = PCI_VENDOR_ID_INTEL,
71 .devices = pci_device_ids,
72};