blob: 4c875ad0358b211bc1e9ea36d3753f9ae7caee91 [file] [log] [blame]
Patrick Georgie72a8a32012-11-06 11:05:09 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * 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.
Patrick Georgie72a8a32012-11-06 11:05:09 +010015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010021#include <device/pci_ids.h>
22#include "i82801ix.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020023#include <device/pci_ehci.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010024
25static void usb_ehci_init(struct device *dev)
26{
27 u32 reg32;
28
29 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
30 reg32 = pci_read_config32(dev, PCI_COMMAND);
31 reg32 |= PCI_COMMAND_MASTER;
32 pci_write_config32(dev, PCI_COMMAND, reg32);
33
34 printk(BIOS_DEBUG, "done.\n");
35}
36
Martin Rothff744bf2019-10-23 21:46:03 -060037static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
38 unsigned int device)
Patrick Georgie72a8a32012-11-06 11:05:09 +010039{
40 u8 access_cntl;
41
42 access_cntl = pci_read_config8(dev, 0x80);
43
44 /* Enable writes to protected registers. */
45 pci_write_config8(dev, 0x80, access_cntl | 1);
46
Subrata Banik4a0f0712019-03-20 14:29:47 +053047 pci_dev_set_subsystem(dev, vendor, device);
Patrick Georgie72a8a32012-11-06 11:05:09 +010048
49 /* Restore protection. */
50 pci_write_config8(dev, 0x80, access_cntl);
51}
52
Patrick Georgie72a8a32012-11-06 11:05:09 +010053static const unsigned short pci_device_ids[] = {
Felix Singer7f8b0cd82019-11-10 11:04:08 +010054 PCI_DEVICE_ID_INTEL_82801IB_EHCI1,
55 PCI_DEVICE_ID_INTEL_82801IB_EHCI2,
Patrick Georgie72a8a32012-11-06 11:05:09 +010056 0
57};
58
59static struct pci_operations lops_pci = {
60 .set_subsystem = &usb_ehci_set_subsystem,
61};
62
63static struct device_operations usb_ehci_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +030064 .read_resources = pci_ehci_read_resources,
65 .set_resources = pci_dev_set_resources,
Patrick Georgie72a8a32012-11-06 11:05:09 +010066 .enable_resources = pci_dev_enable_resources,
67 .init = usb_ehci_init,
68 .scan_bus = 0,
69 .ops_pci = &lops_pci,
70};
71
72static const struct pci_driver pch_usb_ehci1 __pci_driver = {
73 .ops = &usb_ehci_ops,
74 .vendor = PCI_VENDOR_ID_INTEL,
75 .devices = pci_device_ids,
76};