blob: f4b975a4a04f41c0857ddd160487924e19f8ff3e [file] [log] [blame]
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01001/*
2 * This file is part of the coreboot project.
3 *
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010014 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pci_ids.h>
20#include "pch.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020021#include <device/pci_ehci.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020022#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020023#include <device/pci_ops.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010024
25static void usb_ehci_init(struct device *dev)
26{
27 u32 reg32;
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020028 struct resource *res;
29 u8 access_cntl;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010030
31 /* Disable Wake on Disconnect in RMH */
32 reg32 = RCBA32(0x35b0);
33 reg32 |= 0x22;
34 RCBA32(0x35b0) = reg32;
35
36 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
37
38 pci_write_config32(dev, 0x84, 0x130c8911);
39 pci_write_config32(dev, 0x88, 0xa0);
40 pci_write_config32(dev, 0xf4, 0x80808588);
41 pci_write_config32(dev, 0xf4, 0x00808588);
42 pci_write_config32(dev, 0xf4, 0x00808588);
43 pci_write_config32(dev, 0xfc, 0x301b1728);
44
45 reg32 = pci_read_config32(dev, PCI_COMMAND);
46 reg32 |= PCI_COMMAND_MASTER;
47 //reg32 |= PCI_COMMAND_SERR;
48 pci_write_config32(dev, PCI_COMMAND, reg32);
49
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020050 access_cntl = pci_read_config8(dev, 0x80);
51
52 /* Enable writes to protected registers. */
53 pci_write_config8(dev, 0x80, access_cntl | 1);
54
55 res = find_resource(dev, PCI_BASE_ADDRESS_0);
56 if (res) {
57 /* Number of ports and companion controllers. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080058 reg32 = read32((u32 *)(uintptr_t)(res->base + 4));
59 write32((u32 *)(uintptr_t)(res->base + 4),
60 (reg32 & 0xfff00000) | 2);
Vladimir Serbinenko61f902d2014-06-07 16:41:14 +020061 }
62
63 /* Restore protection. */
64 pci_write_config8(dev, 0x80, access_cntl);
65
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010066 printk(BIOS_DEBUG, "done.\n");
67}
68
Martin Rothff744bf2019-10-23 21:46:03 -060069static void usb_ehci_set_subsystem(struct device *dev, unsigned int vendor,
70 unsigned int device)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010071{
72 u8 access_cntl;
73
74 access_cntl = pci_read_config8(dev, 0x80);
75
76 /* Enable writes to protected registers. */
77 pci_write_config8(dev, 0x80, access_cntl | 1);
78
Subrata Banik4a0f0712019-03-20 14:29:47 +053079 pci_dev_set_subsystem(dev, vendor, device);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010080
81 /* Restore protection. */
82 pci_write_config8(dev, 0x80, access_cntl);
83}
84
85
86static struct pci_operations lops_pci = {
87 .set_subsystem = &usb_ehci_set_subsystem,
88};
89
90static struct device_operations usb_ehci_ops = {
91 .read_resources = pci_ehci_read_resources,
92 .set_resources = pci_dev_set_resources,
Vladimir Serbinenko83ef7492014-03-03 23:21:12 +010093 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010094 .init = usb_ehci_init,
95 .scan_bus = 0,
96 .ops_pci = &lops_pci,
97};
98
Felix Singer838fbc72019-11-21 21:23:32 +010099static const unsigned short pci_device_ids[] = {
100 PCI_DID_INTEL_IBEXPEAK_EHCI_1,
101 PCI_DID_INTEL_IBEXPEAK_EHCI_2,
102 0
103};
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100104
105static const struct pci_driver pch_usb_ehci __pci_driver = {
106 .ops = &usb_ehci_ops,
107 .vendor = PCI_VENDOR_ID_INTEL,
108 .devices = pci_device_ids,
109};