blob: eaa2cf19cd6819aadbf2ce3b842c32817e1b9a53 [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>
20#include <device/pci_ids.h>
21#include "i82801gx.h"
22
23static 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 Reinauerc02b4fc2010-03-22 11:42:32 +000029 printk(BIOS_DEBUG, "UHCI: Setting up controller.. ");
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000030
31 reg32 = pci_read_config32(dev, PCI_COMMAND);
32 pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER);
33
Stefan Reinauer7a3d0952010-01-17 13:49:07 +000034 // Erratum
35 pci_write_config8(dev, 0xca, 0x00);
36
37 // Yes. Another Erratum
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000038 reg8 = pci_read_config8(dev, 0xca);
39 reg8 |= (1 << 0);
40 pci_write_config8(dev, 0xca, reg8);
41
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000042 printk(BIOS_DEBUG, "done.\n");
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000043}
44
Elyes HAOUAS99667032018-05-13 12:47:28 +020045static void usb_set_subsystem(struct device *dev, unsigned int vendor,
46 unsigned int device)
Stefan Reinauera8e11682009-03-11 14:54:18 +000047{
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
57static struct pci_operations usb_pci_ops = {
58 .set_subsystem = usb_set_subsystem,
59};
60
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000061static 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 Reinauera8e11682009-03-11 14:54:18 +000068 .ops_pci = &usb_pci_ops,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000069};
70
71/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
72static const struct pci_driver i82801gb_usb1 __pci_driver = {
73 .ops = &usb_ops,
74 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000075 .device = 0x27c8,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000076};
77
Uwe Hermannbddc6932008-10-29 13:51:31 +000078/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000079static const struct pci_driver i82801gb_usb2 __pci_driver = {
80 .ops = &usb_ops,
81 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000082 .device = 0x27c9,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000083};
84
Uwe Hermannbddc6932008-10-29 13:51:31 +000085/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000086static const struct pci_driver i82801gb_usb3 __pci_driver = {
87 .ops = &usb_ops,
88 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000089 .device = 0x27ca,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000090};
91
Uwe Hermannbddc6932008-10-29 13:51:31 +000092/* 82801GB/GR/GDH/GBM/GHM/GU (ICH7/ICH7R/ICH7DH/ICH7-M/ICH7-M DH/ICH7-U) */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000093static const struct pci_driver i82801gb_usb4 __pci_driver = {
94 .ops = &usb_ops,
95 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000096 .device = 0x27cb,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000097};