Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 27 | static 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 | |
| 47 | static 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 | |
| 65 | static struct pci_operations lops_pci = { |
| 66 | .set_subsystem = &usb_ehci_set_subsystem, |
| 67 | }; |
| 68 | |
| 69 | static 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 | |
| 79 | /* 82801Gx */ |
| 80 | static const struct pci_driver i82801ex_usb_ehci __pci_driver = { |
| 81 | .ops = &usb_ehci_ops, |
| 82 | .vendor = PCI_VENDOR_ID_INTEL, |
| 83 | .device = 0x27cc, |
| 84 | }; |