blob: 8191d0aba72bb804e80df9b0d8dd02a37e39a9b0 [file] [log] [blame]
Patrick Georgibe61a172010-12-18 07:48:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2010 coresystems GmbH
5 * Copyright (C) 2009-2010 iWave Systems
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Patrick Georgibe61a172010-12-18 07:48:43 +000016 */
17
18#include <console/console.h>
19#include <device/device.h>
20#include <device/pci.h>
21#include <device/pci_ids.h>
22#include <arch/io.h>
23
24static void usb_ehci_init(struct device *dev)
25{
26 u32 reg32;
27
28 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
29 reg32 = pci_read_config32(dev, PCI_COMMAND);
30 reg32 |= PCI_COMMAND_MASTER;
31 pci_write_config32(dev, PCI_COMMAND, reg32);
Stefan Reinauer4bab6e72016-05-03 15:53:33 -070032 /* Disable clock gating */
33#if 0
Patrick Georgibe61a172010-12-18 07:48:43 +000034 reg32 = pci_read_config32(dev, 0xc0);
35 reg32 |= (1 << 2);
Stefan Reinauer4bab6e72016-05-03 15:53:33 -070036 pci_write_config32(dev, 0xc0, reg32);
37#endif
38 // pci_write_config32(dev, 0x3c, 0x17);
Patrick Georgibe61a172010-12-18 07:48:43 +000039 reg32 = pci_read_config32(dev, 0xFC);
40 reg32 |= (1 << 28);
41 pci_write_config32(dev, 0xFC, reg32);
42
43 reg32 = pci_read_config32(dev, 0x4);
Stefan Reinauer4bab6e72016-05-03 15:53:33 -070044 printk(BIOS_DEBUG, "PCI_COMMAND %x.\n", reg32);
Patrick Georgibe61a172010-12-18 07:48:43 +000045 reg32 = pci_read_config32(dev, 0x20);
Stefan Reinauer4bab6e72016-05-03 15:53:33 -070046 printk(BIOS_DEBUG, "PCI_BASE %x.\n", reg32);
Patrick Georgibe61a172010-12-18 07:48:43 +000047 reg32 = pci_read_config32(dev, 0xC0);
Stefan Reinauer4bab6e72016-05-03 15:53:33 -070048 printk(BIOS_DEBUG, "PCI_FD %x.\n", reg32);
Patrick Georgibe61a172010-12-18 07:48:43 +000049 printk(BIOS_DEBUG, "done.\n");
50}
51
Uwe Hermann405721d2010-12-18 13:22:37 +000052static void usb_ehci_set_subsystem(device_t dev, unsigned vendor,
53 unsigned device)
Patrick Georgibe61a172010-12-18 07:48:43 +000054{
55 u8 access_cntl;
56
57 access_cntl = pci_read_config8(dev, 0x80);
58
59 /* Enable writes to protected registers. */
60 pci_write_config8(dev, 0x80, access_cntl | 1);
61
62 if (!vendor || !device) {
63 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
64 pci_read_config32(dev, PCI_VENDOR_ID));
65 } else {
66 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
67 ((device & 0xffff) << 16) | (vendor & 0xffff));
68 }
69
70 /* Restore protection. */
71 pci_write_config8(dev, 0x80, access_cntl);
72}
73
74static struct pci_operations lops_pci = {
Uwe Hermann405721d2010-12-18 13:22:37 +000075 .set_subsystem = &usb_ehci_set_subsystem,
Patrick Georgibe61a172010-12-18 07:48:43 +000076};
77
78static struct device_operations usb_ehci_ops = {
79 .read_resources = pci_dev_read_resources,
80 .set_resources = pci_dev_set_resources,
81 .enable_resources = pci_dev_enable_resources,
82 .init = usb_ehci_init,
83 .scan_bus = 0,
84 .ops_pci = &lops_pci,
85};
86
Patrick Georgibe61a172010-12-18 07:48:43 +000087static const struct pci_driver sch_usb_ehci __pci_driver = {
88 .ops = &usb_ehci_ops,
89 .vendor = PCI_VENDOR_ID_INTEL,
90 .device = 0x8117,
91};