Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [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> |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 7 | #include <device/pci_ids.h> |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 8 | #include "i82801jx.h" |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 9 | #include <device/pci_ehci.h> |
| 10 | |
| 11 | static void usb_ehci_init(struct device *dev) |
| 12 | { |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 13 | printk(BIOS_DEBUG, "EHCI: Setting up controller.. "); |
Elyes HAOUAS | ca4ff25 | 2020-04-28 10:29:11 +0200 | [diff] [blame] | 14 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [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) |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [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); |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 30 | |
| 31 | /* Restore protection. */ |
| 32 | pci_write_config8(dev, 0x80, access_cntl); |
| 33 | } |
| 34 | |
| 35 | static const unsigned short pci_device_ids[] = { |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 36 | 0x3a3a, |
| 37 | 0x3a6a, |
| 38 | 0x3a3c, |
| 39 | 0x3a6c, |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 40 | 0 |
| 41 | }; |
| 42 | |
| 43 | static struct pci_operations lops_pci = { |
| 44 | .set_subsystem = &usb_ehci_set_subsystem, |
| 45 | }; |
| 46 | |
| 47 | static 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 Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 52 | .ops_pci = &lops_pci, |
| 53 | }; |
| 54 | |
| 55 | static const struct pci_driver pch_usb_ehci1 __pci_driver = { |
| 56 | .ops = &usb_ehci_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame^] | 57 | .vendor = PCI_VID_INTEL, |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 58 | .devices = pci_device_ids, |
| 59 | }; |