blob: 1a59d376ae02182de79fdbaabd0311a5f0a7863e [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Arthur Heymans7b9c1392017-04-09 20:40:39 +02002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Arthur Heymans7b9c1392017-04-09 20:40:39 +02007#include <device/pci_ids.h>
Arthur Heymans349e0852017-04-09 20:48:37 +02008#include "i82801jx.h"
Arthur Heymans7b9c1392017-04-09 20:40:39 +02009#include <device/pci_ehci.h>
10
11static void usb_ehci_init(struct device *dev)
12{
Arthur Heymans7b9c1392017-04-09 20:40:39 +020013 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
Elyes HAOUASca4ff252020-04-28 10:29:11 +020014 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Arthur Heymans7b9c1392017-04-09 20:40:39 +020015
16 printk(BIOS_DEBUG, "done.\n");
17}
18
Martin Rothff744bf2019-10-23 21:46:03 -060019static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
20 unsigned int device)
Arthur Heymans7b9c1392017-04-09 20:40:39 +020021{
22 u8 access_cntl;
23
24 access_cntl = pci_read_config8(dev, 0x80);
25
26 /* Enable writes to protected registers. */
27 pci_write_config8(dev, 0x80, access_cntl | 1);
28
Subrata Banik4a0f0712019-03-20 14:29:47 +053029 pci_dev_set_subsystem(dev, vendor, device);
Arthur Heymans7b9c1392017-04-09 20:40:39 +020030
31 /* Restore protection. */
32 pci_write_config8(dev, 0x80, access_cntl);
33}
34
35static const unsigned short pci_device_ids[] = {
Arthur Heymans349e0852017-04-09 20:48:37 +020036 0x3a3a,
37 0x3a6a,
38 0x3a3c,
39 0x3a6c,
Arthur Heymans7b9c1392017-04-09 20:40:39 +020040 0
41};
42
43static struct pci_operations lops_pci = {
44 .set_subsystem = &usb_ehci_set_subsystem,
45};
46
47static struct device_operations usb_ehci_ops = {
48 .read_resources = pci_ehci_read_resources,
49 .set_resources = pci_dev_set_resources,
50 .enable_resources = pci_dev_enable_resources,
51 .init = usb_ehci_init,
Arthur Heymans7b9c1392017-04-09 20:40:39 +020052 .ops_pci = &lops_pci,
53};
54
55static const struct pci_driver pch_usb_ehci1 __pci_driver = {
56 .ops = &usb_ehci_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010057 .vendor = PCI_VID_INTEL,
Arthur Heymans7b9c1392017-04-09 20:40:39 +020058 .devices = pci_device_ids,
59};