blob: 307b5ac622bc84c55f7383ad288898329e28071d [file] [log] [blame]
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00001/*
2 * This file is part of the coreboot project.
3 *
Stefan Reinauera8e11682009-03-11 14:54:18 +00004 * Copyright (C) 2008-2009 coresystems GmbH
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00005 *
Stefan Reinauera8e11682009-03-11 14:54:18 +00006 * 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 Reinauerdebb11f2008-10-29 04:46:52 +000010 *
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 Reinauerdebb11f2008-10-29 04:46:52 +000015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000021#include <device/pci_ids.h>
22#include "i82801gx.h"
23
24static void usb_init(struct device *dev)
25{
26 u32 reg32;
27 u8 reg8;
28
29 /* USB Specification says the device must be Bus Master */
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000030 printk(BIOS_DEBUG, "UHCI: Setting up controller.. ");
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000031
32 reg32 = pci_read_config32(dev, PCI_COMMAND);
33 pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER);
34
Stefan Reinauer7a3d0952010-01-17 13:49:07 +000035 // Erratum
36 pci_write_config8(dev, 0xca, 0x00);
37
38 // Yes. Another Erratum
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000039 reg8 = pci_read_config8(dev, 0xca);
40 reg8 |= (1 << 0);
41 pci_write_config8(dev, 0xca, reg8);
42
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000043 printk(BIOS_DEBUG, "done.\n");
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000044}
45
Elyes HAOUAS99667032018-05-13 12:47:28 +020046static void usb_set_subsystem(struct device *dev, unsigned int vendor,
47 unsigned int device)
Stefan Reinauera8e11682009-03-11 14:54:18 +000048{
49 if (!vendor || !device) {
50 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
51 pci_read_config32(dev, PCI_VENDOR_ID));
52 } else {
53 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
54 ((device & 0xffff) << 16) | (vendor & 0xffff));
55 }
56}
57
58static struct pci_operations usb_pci_ops = {
59 .set_subsystem = usb_set_subsystem,
60};
61
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000062static struct device_operations usb_ops = {
63 .read_resources = pci_dev_read_resources,
64 .set_resources = pci_dev_set_resources,
65 .enable_resources = pci_dev_enable_resources,
66 .init = usb_init,
67 .scan_bus = 0,
68 .enable = i82801gx_enable,
Stefan Reinauera8e11682009-03-11 14:54:18 +000069 .ops_pci = &usb_pci_ops,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000070};
71
72/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
73static const struct pci_driver i82801gb_usb1 __pci_driver = {
74 .ops = &usb_ops,
75 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000076 .device = 0x27c8,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000077};
78
Uwe Hermannbddc6932008-10-29 13:51:31 +000079/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000080static const struct pci_driver i82801gb_usb2 __pci_driver = {
81 .ops = &usb_ops,
82 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000083 .device = 0x27c9,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000084};
85
Uwe Hermannbddc6932008-10-29 13:51:31 +000086/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000087static const struct pci_driver i82801gb_usb3 __pci_driver = {
88 .ops = &usb_ops,
89 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000090 .device = 0x27ca,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000091};
92
Uwe Hermannbddc6932008-10-29 13:51:31 +000093/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000094static const struct pci_driver i82801gb_usb4 __pci_driver = {
95 .ops = &usb_ops,
96 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000097 .device = 0x27cb,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000098};