Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 1 | /* |
| 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" |
| 27 | #include <usbdebug.h> |
| 28 | #include <arch/io.h> |
| 29 | |
| 30 | static 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 | |
| 56 | static 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 | |
| 80 | static struct pci_operations lops_pci = { |
| 81 | .set_subsystem = &usb_ehci_set_subsystem, |
| 82 | }; |
| 83 | |
| 84 | static struct device_operations usb_ehci_ops = { |
| 85 | .read_resources = pci_ehci_read_resources, |
| 86 | .set_resources = pci_dev_set_resources, |
| 87 | .init = usb_ehci_init, |
| 88 | .scan_bus = 0, |
| 89 | .ops_pci = &lops_pci, |
| 90 | }; |
| 91 | |
| 92 | static const unsigned short pci_device_ids[] = { 0x3b34, 0x3b3c, 0 }; |
| 93 | |
| 94 | static const struct pci_driver pch_usb_ehci __pci_driver = { |
| 95 | .ops = &usb_ehci_ops, |
| 96 | .vendor = PCI_VENDOR_ID_INTEL, |
| 97 | .devices = pci_device_ids, |
| 98 | }; |