blob: 21a257f328e9d9472d1b181ae2860d5e4751be4f [file] [log] [blame]
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2013 Vladimir Serbinenko
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <console/console.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <device/pci_ids.h>
26#include "pch.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020027#include <device/pci_ehci.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010028#include <arch/io.h>
29
30static void usb_ehci_init(struct device *dev)
31{
32 u32 reg32;
33
34 /* Disable Wake on Disconnect in RMH */
35 reg32 = RCBA32(0x35b0);
36 reg32 |= 0x22;
37 RCBA32(0x35b0) = reg32;
38
39 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
40
41 pci_write_config32(dev, 0x84, 0x130c8911);
42 pci_write_config32(dev, 0x88, 0xa0);
43 pci_write_config32(dev, 0xf4, 0x80808588);
44 pci_write_config32(dev, 0xf4, 0x00808588);
45 pci_write_config32(dev, 0xf4, 0x00808588);
46 pci_write_config32(dev, 0xfc, 0x301b1728);
47
48 reg32 = pci_read_config32(dev, PCI_COMMAND);
49 reg32 |= PCI_COMMAND_MASTER;
50 //reg32 |= PCI_COMMAND_SERR;
51 pci_write_config32(dev, PCI_COMMAND, reg32);
52
53 printk(BIOS_DEBUG, "done.\n");
54}
55
56static void usb_ehci_set_subsystem(device_t dev, unsigned vendor,
57 unsigned device)
58{
59 u8 access_cntl;
60
61 access_cntl = pci_read_config8(dev, 0x80);
62
63 /* Enable writes to protected registers. */
64 pci_write_config8(dev, 0x80, access_cntl | 1);
65
66 if (!vendor || !device) {
67 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
68 pci_read_config32(dev, PCI_VENDOR_ID));
69 } else {
70 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
71 ((device & 0xffff) << 16) | (vendor &
72 0xffff));
73 }
74
75 /* Restore protection. */
76 pci_write_config8(dev, 0x80, access_cntl);
77}
78
79
80static struct pci_operations lops_pci = {
81 .set_subsystem = &usb_ehci_set_subsystem,
82};
83
84static struct device_operations usb_ehci_ops = {
85 .read_resources = pci_ehci_read_resources,
86 .set_resources = pci_dev_set_resources,
Vladimir Serbinenko83ef7492014-03-03 23:21:12 +010087 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010088 .init = usb_ehci_init,
89 .scan_bus = 0,
90 .ops_pci = &lops_pci,
91};
92
93static const unsigned short pci_device_ids[] = { 0x3b34, 0x3b3c, 0 };
94
95static const struct pci_driver pch_usb_ehci __pci_driver = {
96 .ops = &usb_ehci_ops,
97 .vendor = PCI_VENDOR_ID_INTEL,
98 .devices = pci_device_ids,
99};