Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 2 | |
| 3 | // Use simple device model for this file even in ramstage |
| 4 | #define __SIMPLE_DEVICE__ |
| 5 | |
| 6 | #include <stdint.h> |
Felix Held | 0f5f2ce | 2023-07-14 19:36:20 +0200 | [diff] [blame] | 7 | #include <amdblocks/acpimmio.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 8 | #include <device/mmio.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 9 | #include <device/pci_ehci.h> |
| 10 | #include <device/pci_def.h> |
| 11 | #include "hudson.h" |
| 12 | |
| 13 | #define DEBUGPORT_MISC_CONTROL 0x80 |
| 14 | |
| 15 | pci_devfn_t pci_ehci_dbg_dev(unsigned int hcd_idx) |
| 16 | { |
Kyösti Mälkki | 6683e40 | 2017-07-30 13:23:32 +0300 | [diff] [blame] | 17 | /* Enable all of the USB controllers */ |
Felix Held | 0f5f2ce | 2023-07-14 19:36:20 +0200 | [diff] [blame] | 18 | pm_io_write8(0xef, 0x7f); |
Kyösti Mälkki | 6683e40 | 2017-07-30 13:23:32 +0300 | [diff] [blame] | 19 | |
Elyes HAOUAS | c021ffe | 2016-09-18 19:18:56 +0200 | [diff] [blame] | 20 | if (hcd_idx == 3) |
Kyösti Mälkki | 55ed672 | 2015-06-08 16:39:52 +0300 | [diff] [blame] | 21 | return PCI_DEV(0, 0x16, 0); |
Elyes HAOUAS | c021ffe | 2016-09-18 19:18:56 +0200 | [diff] [blame] | 22 | else if (hcd_idx == 2) |
Kyösti Mälkki | 55ed672 | 2015-06-08 16:39:52 +0300 | [diff] [blame] | 23 | return PCI_DEV(0, 0x13, 0); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 24 | else |
Kyösti Mälkki | 55ed672 | 2015-06-08 16:39:52 +0300 | [diff] [blame] | 25 | return PCI_DEV(0, 0x12, 0); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | void pci_ehci_dbg_set_port(pci_devfn_t dev, unsigned int port) |
| 29 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 30 | u8 *base_regs = pci_ehci_base_regs(dev); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 31 | u32 reg32; |
| 32 | |
| 33 | /* Write the port number to DEBUGPORT_MISC_CONTROL[31:28]. */ |
| 34 | reg32 = read32(base_regs + DEBUGPORT_MISC_CONTROL); |
| 35 | reg32 &= ~(0xf << 28); |
| 36 | reg32 |= (port << 28); |
| 37 | reg32 |= (1 << 27); /* Enable Debug Port port number remapping. */ |
| 38 | write32(base_regs + DEBUGPORT_MISC_CONTROL, reg32); |
| 39 | } |