Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 2 | |
Kyösti Mälkki | ef84401 | 2013-06-25 23:17:43 +0300 | [diff] [blame] | 3 | // Use simple device model for this file even in ramstage |
| 4 | #define __SIMPLE_DEVICE__ |
| 5 | |
Uwe Hermann | dc3aa7a | 2010-09-25 23:47:15 +0000 | [diff] [blame] | 6 | #include <stdint.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 8 | #include <device/pci_ehci.h> |
Uwe Hermann | dc3aa7a | 2010-09-25 23:47:15 +0000 | [diff] [blame] | 9 | #include <device/pci_def.h> |
Stefan Reinauer | a8e1168 | 2009-03-11 14:54:18 +0000 | [diff] [blame] | 10 | |
Kyösti Mälkki | 8101aa6 | 2013-08-15 16:27:06 +0300 | [diff] [blame] | 11 | pci_devfn_t pci_ehci_dbg_dev(unsigned int hcd_idx) |
| 12 | { |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 13 | u32 class; |
| 14 | pci_devfn_t dev; |
| 15 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 16 | if (!CONFIG(HAVE_USBDEBUG_OPTIONS)) |
Kyösti Mälkki | 6683e40 | 2017-07-30 13:23:32 +0300 | [diff] [blame] | 17 | return PCI_DEV(0, 0x1d, 7); |
| 18 | |
Elyes HAOUAS | 581fe58 | 2018-04-26 09:57:07 +0200 | [diff] [blame] | 19 | if (hcd_idx == 2) |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 20 | dev = PCI_DEV(0, 0x1a, 0); |
| 21 | else |
| 22 | dev = PCI_DEV(0, 0x1d, 0); |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 23 | |
Kyösti Mälkki | 6683e40 | 2017-07-30 13:23:32 +0300 | [diff] [blame] | 24 | /* If we enter here before RCBA programming, EHCI function may |
| 25 | * appear with the highest function number instead. |
| 26 | */ |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 27 | class = pci_read_config32(dev, PCI_CLASS_REVISION) >> 8; |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 28 | if (class != PCI_EHCI_CLASSCODE) |
Kyösti Mälkki | 6683e40 | 2017-07-30 13:23:32 +0300 | [diff] [blame] | 29 | dev |= PCI_DEV(0, 0, 7); |
Kyösti Mälkki | 545b30d | 2013-06-13 13:51:14 +0300 | [diff] [blame] | 30 | |
| 31 | return dev; |
Kyösti Mälkki | 8101aa6 | 2013-08-15 16:27:06 +0300 | [diff] [blame] | 32 | } |
| 33 | |
Uwe Hermann | 370d979 | 2010-09-25 14:23:31 +0000 | [diff] [blame] | 34 | /* Required for successful build, but currently empty. */ |
Kyösti Mälkki | 8101aa6 | 2013-08-15 16:27:06 +0300 | [diff] [blame] | 35 | void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port) |
Uwe Hermann | 370d979 | 2010-09-25 14:23:31 +0000 | [diff] [blame] | 36 | { |
| 37 | /* Not needed, the ICH* southbridges hardcode physical USB port 1. */ |
| 38 | } |