Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2009 coresystems GmbH |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 5 | * |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 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. |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 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. |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_ids.h> |
| 21 | #include "i82801gx.h" |
| 22 | |
| 23 | static void usb_init(struct device *dev) |
| 24 | { |
| 25 | u32 reg32; |
| 26 | u8 reg8; |
| 27 | |
| 28 | /* USB Specification says the device must be Bus Master */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 29 | printk(BIOS_DEBUG, "UHCI: Setting up controller.. "); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 30 | |
| 31 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 32 | pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER); |
| 33 | |
Stefan Reinauer | 7a3d095 | 2010-01-17 13:49:07 +0000 | [diff] [blame] | 34 | // Erratum |
| 35 | pci_write_config8(dev, 0xca, 0x00); |
| 36 | |
| 37 | // Yes. Another Erratum |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 38 | reg8 = pci_read_config8(dev, 0xca); |
| 39 | reg8 |= (1 << 0); |
| 40 | pci_write_config8(dev, 0xca, reg8); |
| 41 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 42 | printk(BIOS_DEBUG, "done.\n"); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Elyes HAOUAS | 9966703 | 2018-05-13 12:47:28 +0200 | [diff] [blame] | 45 | static void usb_set_subsystem(struct device *dev, unsigned int vendor, |
| 46 | unsigned int device) |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 47 | { |
| 48 | if (!vendor || !device) { |
| 49 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 50 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 51 | } else { |
| 52 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 53 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | static struct pci_operations usb_pci_ops = { |
| 58 | .set_subsystem = usb_set_subsystem, |
| 59 | }; |
| 60 | |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 61 | static struct device_operations usb_ops = { |
| 62 | .read_resources = pci_dev_read_resources, |
| 63 | .set_resources = pci_dev_set_resources, |
| 64 | .enable_resources = pci_dev_enable_resources, |
| 65 | .init = usb_init, |
| 66 | .scan_bus = 0, |
| 67 | .enable = i82801gx_enable, |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 68 | .ops_pci = &usb_pci_ops, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */ |
| 72 | static const struct pci_driver i82801gb_usb1 __pci_driver = { |
| 73 | .ops = &usb_ops, |
| 74 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 75 | .device = 0x27c8, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 78 | /* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 79 | static const struct pci_driver i82801gb_usb2 __pci_driver = { |
| 80 | .ops = &usb_ops, |
| 81 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 82 | .device = 0x27c9, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 85 | /* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 86 | static const struct pci_driver i82801gb_usb3 __pci_driver = { |
| 87 | .ops = &usb_ops, |
| 88 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 89 | .device = 0x27ca, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 92 | /* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 93 | static const struct pci_driver i82801gb_usb4 __pci_driver = { |
| 94 | .ops = &usb_ops, |
| 95 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 96 | .device = 0x27cb, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 97 | }; |