Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Subrata Banik | a554b0c | 2017-02-16 16:08:49 +0530 | [diff] [blame] | 2 | |
| 3 | #ifndef SOC_INTEL_COMMON_BLOCK_XHCI_H |
| 4 | #define SOC_INTEL_COMMON_BLOCK_XHCI_H |
| 5 | |
Subrata Banik | 36ca7b3 | 2023-03-23 14:48:53 +0530 | [diff] [blame] | 6 | #define PORTSCN_OFFSET 0x480 |
| 7 | #define PORTSCN_WAKE_ON_DISCONNECT_ENABLE 0x4000000 |
| 8 | #define PORTSCN_WAKE_ON_CONNECT_ENABLE 0x2000000 |
| 9 | /* Set WDE and WCE bits */ |
| 10 | #define PORTSCN_WAKE_ON_BOTH_CONNECT_DISCONNECT_ENABLE 0x6000000 |
| 11 | /* |
| 12 | * And port status/control reg with RO and RWS bits |
| 13 | * RO bits: 0, 2:3, 10:13, 24, 28:30 |
| 14 | * RWS bits: 5:9, 14:16, 25:27 |
| 15 | */ |
| 16 | #define PORTSCN_BITS_OFF_MASK ~0x80FE0012 |
| 17 | #define PORTSCXUSB3_OFFSET 0x540 |
| 18 | |
Reka Norman | a5215c4 | 2023-09-22 15:26:54 +1000 | [diff] [blame^] | 19 | /* |
| 20 | * Set bit corresponding to USB port in wake enable bitmap. Bit 0 corresponds |
| 21 | * to Port 1, Bit n corresponds to Port (n+1). This bitmap is later used to |
| 22 | * decide what ports need to set PORTSCN/PORTSCXUSB3 register bits. |
| 23 | */ |
| 24 | #define USB_PORT_WAKE_ENABLE(x) (1 << ((x) - 1)) |
| 25 | |
Subrata Banik | 36ca7b3 | 2023-03-23 14:48:53 +0530 | [diff] [blame] | 26 | #if !defined(__ACPI__) |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 27 | #include <device/device.h> |
Robert Zieba | a23aa1c | 2022-08-10 16:56:09 -0600 | [diff] [blame] | 28 | #include <device/xhci.h> |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 29 | #include <elog.h> |
| 30 | #include <stdint.h> |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 31 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 32 | /* |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 33 | * struct xhci_wake_info - Relates an XHCI device to registers and wake types |
| 34 | * @xhci_dev: devfn of the XHCI device |
| 35 | * @elog_wake_type_host: the wake type for the controller device |
| 36 | */ |
| 37 | struct xhci_wake_info { |
| 38 | pci_devfn_t xhci_dev; |
| 39 | uint8_t elog_wake_type_host; |
| 40 | }; |
| 41 | |
| 42 | /* |
| 43 | * xhci_update_wake_event() - Identify and log XHCI wake events. |
| 44 | * @wake_info: A mapping of XHCI devfn to elog wake types |
| 45 | * @wake_info_count: Count of items in wake_info |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 46 | * @info: Information about number of USB ports and their status reg offset. |
| 47 | * |
| 48 | * This function goes through individual USB port status registers within the |
| 49 | * XHCI block and identifies if any of those USB ports triggered a wake-up and |
| 50 | * log information about those ports to the event log. |
| 51 | * |
| 52 | * Return: True if any port is identified as a wake source, false if none. |
| 53 | */ |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 54 | bool xhci_update_wake_event(const struct xhci_wake_info *wake_info, |
| 55 | size_t wake_info_count); |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 56 | |
Subrata Banik | e3a4a13 | 2022-04-11 17:45:33 +0530 | [diff] [blame] | 57 | /* xhci_host_reset() - Function to reset the host controller */ |
| 58 | void xhci_host_reset(void); |
Subrata Banik | a554b0c | 2017-02-16 16:08:49 +0530 | [diff] [blame] | 59 | void soc_xhci_init(struct device *dev); |
| 60 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 61 | /* |
Karthikeyan Ramasubramanian | 0f71831 | 2019-07-03 13:02:37 -0600 | [diff] [blame] | 62 | * soc_get_xhci_usb_info() - Get the information about USB2 & USB3 ports. |
| 63 | * |
| 64 | * This function is used to get USB ports and status register offset information |
| 65 | * within a XHCI controller. |
| 66 | * |
| 67 | * Return: USB ports and status register offset info for the SoC. |
| 68 | */ |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 69 | const struct xhci_usb_info *soc_get_xhci_usb_info(pci_devfn_t xhci_dev); |
Karthikeyan Ramasubramanian | 0f71831 | 2019-07-03 13:02:37 -0600 | [diff] [blame] | 70 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 71 | /* |
Karthikeyan Ramasubramanian | ef0c226 | 2019-06-06 15:35:11 -0600 | [diff] [blame] | 72 | * usb_xhci_disable_unused() - Disable unused USB devices |
| 73 | * @ext_usb_xhci_en_cb: Callback function to be invoked, supplied by mainboard, |
| 74 | * to identify the status of externally visible USB ports. |
| 75 | * (Return true if port is present, false if port is absent) |
| 76 | * |
| 77 | * This function is used to disable unused USB devices/ports that are configured |
| 78 | * in the device tree. For the internal USB ports, the connect status of the port |
| 79 | * is probed from the XHCI controller block and the port is disabled if it is not |
| 80 | * connected. For the external USB ports, the mainboard provides the connect status |
| 81 | * of the concerned port depending on the variants and their SKUs. If the mainboard |
| 82 | * supplied callback function is NULL, then all the externally visible USB devices |
| 83 | * in the device tree are enabled. |
| 84 | */ |
| 85 | void usb_xhci_disable_unused(bool (*ext_usb_xhci_en_cb)(unsigned int port_type, |
| 86 | unsigned int port_id)); |
Subrata Banik | 36ca7b3 | 2023-03-23 14:48:53 +0530 | [diff] [blame] | 87 | #endif /* if !defined(__ACPI__) */ |
Subrata Banik | a554b0c | 2017-02-16 16:08:49 +0530 | [diff] [blame] | 88 | #endif /* SOC_INTEL_COMMON_BLOCK_XHCI_H */ |