Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 1 | /* |
| 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. |
| 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 20 | #include <device/pci_ops.h> |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 21 | #include <device/pci_ids.h> |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 22 | #include "i82801jx.h" |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 23 | #include <device/pci_ehci.h> |
| 24 | |
| 25 | static 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 Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame^] | 37 | static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor, |
| 38 | unsigned int device) |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 39 | { |
| 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 Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 47 | pci_dev_set_subsystem(dev, vendor, device); |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 48 | |
| 49 | /* Restore protection. */ |
| 50 | pci_write_config8(dev, 0x80, access_cntl); |
| 51 | } |
| 52 | |
| 53 | static const unsigned short pci_device_ids[] = { |
Arthur Heymans | 349e085 | 2017-04-09 20:48:37 +0200 | [diff] [blame] | 54 | 0x3a3a, |
| 55 | 0x3a6a, |
| 56 | 0x3a3c, |
| 57 | 0x3a6c, |
Arthur Heymans | 7b9c139 | 2017-04-09 20:40:39 +0200 | [diff] [blame] | 58 | 0 |
| 59 | }; |
| 60 | |
| 61 | static struct pci_operations lops_pci = { |
| 62 | .set_subsystem = &usb_ehci_set_subsystem, |
| 63 | }; |
| 64 | |
| 65 | static struct device_operations usb_ehci_ops = { |
| 66 | .read_resources = pci_ehci_read_resources, |
| 67 | .set_resources = pci_dev_set_resources, |
| 68 | .enable_resources = pci_dev_enable_resources, |
| 69 | .init = usb_ehci_init, |
| 70 | .scan_bus = 0, |
| 71 | .ops_pci = &lops_pci, |
| 72 | }; |
| 73 | |
| 74 | static const struct pci_driver pch_usb_ehci1 __pci_driver = { |
| 75 | .ops = &usb_ehci_ops, |
| 76 | .vendor = PCI_VENDOR_ID_INTEL, |
| 77 | .devices = pci_device_ids, |
| 78 | }; |