Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 7 | #include <device/pci_ids.h> |
| 8 | #include "i82801ix.h" |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 9 | #include <device/pci_ehci.h> |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 10 | |
| 11 | static void usb_ehci_init(struct device *dev) |
| 12 | { |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 13 | printk(BIOS_DEBUG, "EHCI: Setting up controller.. "); |
Elyes HAOUAS | b9d2e22 | 2020-04-28 10:25:12 +0200 | [diff] [blame] | 14 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 15 | |
| 16 | printk(BIOS_DEBUG, "done.\n"); |
| 17 | } |
| 18 | |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 19 | static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, |
| 20 | unsigned int device) |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 21 | { |
| 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 Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 29 | pci_dev_set_subsystem(dev, vendor, device); |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 30 | |
| 31 | /* Restore protection. */ |
| 32 | pci_write_config8(dev, 0x80, access_cntl); |
| 33 | } |
| 34 | |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 35 | static const unsigned short pci_device_ids[] = { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame^] | 36 | PCI_DID_INTEL_82801IB_EHCI1, |
| 37 | PCI_DID_INTEL_82801IB_EHCI2, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 38 | 0 |
| 39 | }; |
| 40 | |
| 41 | static struct pci_operations lops_pci = { |
| 42 | .set_subsystem = &usb_ehci_set_subsystem, |
| 43 | }; |
| 44 | |
| 45 | static struct device_operations usb_ehci_ops = { |
Kyösti Mälkki | fb387df | 2013-06-07 22:16:52 +0300 | [diff] [blame] | 46 | .read_resources = pci_ehci_read_resources, |
| 47 | .set_resources = pci_dev_set_resources, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 48 | .enable_resources = pci_dev_enable_resources, |
| 49 | .init = usb_ehci_init, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 50 | .ops_pci = &lops_pci, |
| 51 | }; |
| 52 | |
| 53 | static const struct pci_driver pch_usb_ehci1 __pci_driver = { |
| 54 | .ops = &usb_ehci_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame^] | 55 | .vendor = PCI_VID_INTEL, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 56 | .devices = pci_device_ids, |
| 57 | }; |