blob: 46c151cbb939850ac7ccaa4c5d43156ec71a6b9c [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauera8e11682009-03-11 14:54:18 +00002
Kyösti Mälkkief844012013-06-25 23:17:43 +03003// Use simple device model for this file even in ramstage
4#define __SIMPLE_DEVICE__
5
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +00006#include <stdint.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02007#include <device/pci_ops.h>
Kyösti Mälkkie2227a22014-02-05 13:02:55 +02008#include <device/pci_ehci.h>
Uwe Hermanndc3aa7a2010-09-25 23:47:15 +00009#include <device/pci_def.h>
Stefan Reinauera8e11682009-03-11 14:54:18 +000010
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030011pci_devfn_t pci_ehci_dbg_dev(unsigned int hcd_idx)
12{
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030013 u32 class;
14 pci_devfn_t dev;
15
Julius Wernercd49cce2019-03-05 16:53:33 -080016 if (!CONFIG(HAVE_USBDEBUG_OPTIONS))
Kyösti Mälkki6683e402017-07-30 13:23:32 +030017 return PCI_DEV(0, 0x1d, 7);
18
Elyes HAOUAS581fe582018-04-26 09:57:07 +020019 if (hcd_idx == 2)
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030020 dev = PCI_DEV(0, 0x1a, 0);
21 else
22 dev = PCI_DEV(0, 0x1d, 0);
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030023
Kyösti Mälkki6683e402017-07-30 13:23:32 +030024 /* If we enter here before RCBA programming, EHCI function may
25 * appear with the highest function number instead.
26 */
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030027 class = pci_read_config32(dev, PCI_CLASS_REVISION) >> 8;
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030028 if (class != PCI_EHCI_CLASSCODE)
Kyösti Mälkki6683e402017-07-30 13:23:32 +030029 dev |= PCI_DEV(0, 0, 7);
Kyösti Mälkki545b30d2013-06-13 13:51:14 +030030
31 return dev;
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030032}
33
Uwe Hermann370d9792010-09-25 14:23:31 +000034/* Required for successful build, but currently empty. */
Kyösti Mälkki8101aa62013-08-15 16:27:06 +030035void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port)
Uwe Hermann370d9792010-09-25 14:23:31 +000036{
37 /* Not needed, the ICH* southbridges hardcode physical USB port 1. */
38}