blob: 5ac7a1a97c4211123aebea298b51f1e30b2e8fa3 [file] [log] [blame]
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <console/console.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include "i82801gx.h"
26
27static void usb_ehci_init(struct device *dev)
28{
29 u32 reg32;
30
31 printk_debug("EHCI: Setting up controller.. ");
32 reg32 = pci_read_config32(dev, PCI_COMMAND);
33 pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER);
34
35 reg32 = pci_read_config32(dev, 0xdc);
36 reg32 |= (1 << 31) | (1 << 27);
37 pci_write_config32(dev, 0xdc, reg32);
38
39 reg32 = pci_read_config32(dev, 0xfc);
40 reg32 &= ~(3 << 2);
41 reg32 |= (2 << 2) | (1 << 29) | (1 << 17);
42 pci_write_config32(dev, 0xfc, reg32);
43
44 printk_debug("done.\n");
45}
46
47static void usb_ehci_set_subsystem(device_t dev, unsigned vendor,
48 unsigned device)
49{
50 u8 access_cntl;
51
52 access_cntl = pci_read_config8(dev, 0x80);
53
54 /* Enable writes to protected registers. */
55 pci_write_config8(dev, 0x80, access_cntl | 1);
56
57 /* Write the subsystem vendor and device ID. */
58 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
59 ((device & 0xffff) << 16) | (vendor & 0xffff));
60
61 /* Restore protection. */
62 pci_write_config8(dev, 0x80, access_cntl);
63}
64
65static struct pci_operations lops_pci = {
66 .set_subsystem = &usb_ehci_set_subsystem,
67};
68
69static struct device_operations usb_ehci_ops = {
70 .read_resources = pci_dev_read_resources,
71 .set_resources = pci_dev_set_resources,
72 .enable_resources = pci_dev_enable_resources,
73 .init = usb_ehci_init,
74 .scan_bus = 0,
75 .enable = i82801gx_enable,
76 .ops_pci = &lops_pci,
77};
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) */
80static const struct pci_driver i82801gx_usb_ehci __pci_driver = {
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000081 .ops = &usb_ehci_ops,
82 .vendor = PCI_VENDOR_ID_INTEL,
Uwe Hermann5d7a1c82008-10-31 18:41:09 +000083 .device = 0x27cc,
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000084};