Nico Huber | b0f8326 | 2014-01-01 20:47:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of uio_usbdebug |
| 3 | * |
| 4 | * Copyright (C) 2013 Nico Huber <nico.h@gmx.de> |
| 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; version 2 of 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. |
Nico Huber | b0f8326 | 2014-01-01 20:47:55 +0100 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/io.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci_ehci.h> |
| 19 | #include <console/usb.h> |
| 20 | |
| 21 | extern void *ehci_bar; |
| 22 | |
| 23 | pci_devfn_t pci_ehci_dbg_dev(unsigned hcd_idx) |
| 24 | { |
| 25 | u32 class; |
| 26 | pci_devfn_t dev; |
| 27 | |
| 28 | #if CONFIG_HAVE_USBDEBUG_OPTIONS |
| 29 | if (hcd_idx==2) |
| 30 | dev = PCI_DEV(0, 0x1a, 0); |
| 31 | else |
| 32 | dev = PCI_DEV(0, 0x1d, 0); |
| 33 | #else |
| 34 | dev = PCI_DEV(0, 0x1d, 7); |
| 35 | #endif |
| 36 | |
| 37 | class = pci_read_config32(dev, PCI_CLASS_REVISION) >> 8; |
| 38 | #if CONFIG_HAVE_USBDEBUG_OPTIONS |
| 39 | if (class != PCI_EHCI_CLASSCODE) { |
| 40 | /* If we enter here before RCBA programming, EHCI function may |
| 41 | * appear with the highest function number instead. |
| 42 | */ |
| 43 | dev |= PCI_DEV(0, 0, 7); |
| 44 | class = pci_read_config32(dev, PCI_CLASS_REVISION) >> 8; |
| 45 | } |
| 46 | #endif |
| 47 | if (class != PCI_EHCI_CLASSCODE) |
| 48 | return 0; |
| 49 | |
| 50 | return dev; |
| 51 | } |
| 52 | |
| 53 | void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port) |
| 54 | { |
| 55 | /* claim usb debug port */ |
| 56 | const unsigned long dbgctl_addr = |
| 57 | ((unsigned long)ehci_bar) + CONFIG_EHCI_DEBUG_OFFSET; |
| 58 | write32(dbgctl_addr, read32(dbgctl_addr) | (1 << 30)); |
| 59 | } |
| 60 | |
| 61 | void pci_ehci_dbg_enable(pci_devfn_t dev, unsigned long base) |
| 62 | { |
| 63 | } |