Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 3 | |
| 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 8 | #include <device/pci_ids.h> |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 9 | #include "i82801jx.h" |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 10 | #include <device/pci_ehci.h> |
| 11 | |
| 12 | static void usb_ehci_init(struct device *dev) |
| 13 | { |
| 14 | u32 reg32; |
| 15 | |
| 16 | printk(BIOS_DEBUG, "EHCI: Setting up controller.. "); |
| 17 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 18 | reg32 |= PCI_COMMAND_MASTER; |
| 19 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 20 | |
| 21 | printk(BIOS_DEBUG, "done.\n"); |
| 22 | } |
| 23 | |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 24 | static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, |
| 25 | unsigned int device) |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 26 | { |
| 27 | u8 access_cntl; |
| 28 | |
| 29 | access_cntl = pci_read_config8(dev, 0x80); |
| 30 | |
| 31 | /* Enable writes to protected registers. */ |
| 32 | pci_write_config8(dev, 0x80, access_cntl | 1); |
| 33 | |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 34 | pci_dev_set_subsystem(dev, vendor, device); |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 35 | |
| 36 | /* Restore protection. */ |
| 37 | pci_write_config8(dev, 0x80, access_cntl); |
| 38 | } |
| 39 | |
| 40 | static const unsigned short pci_device_ids[] = { |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 41 | 0x3a3a, |
| 42 | 0x3a6a, |
| 43 | 0x3a3c, |
| 44 | 0x3a6c, |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 45 | 0 |
| 46 | }; |
| 47 | |
| 48 | static struct pci_operations lops_pci = { |
| 49 | .set_subsystem = &usb_ehci_set_subsystem, |
| 50 | }; |
| 51 | |
| 52 | static struct device_operations usb_ehci_ops = { |
| 53 | .read_resources = pci_ehci_read_resources, |
| 54 | .set_resources = pci_dev_set_resources, |
| 55 | .enable_resources = pci_dev_enable_resources, |
| 56 | .init = usb_ehci_init, |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 57 | .ops_pci = &lops_pci, |
| 58 | }; |
| 59 | |
| 60 | static const struct pci_driver pch_usb_ehci1 __pci_driver = { |
| 61 | .ops = &usb_ehci_ops, |
| 62 | .vendor = PCI_VENDOR_ID_INTEL, |
| 63 | .devices = pci_device_ids, |
| 64 | }; |