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 <stdint.h> |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 30 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 31 | /* |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 32 | * struct xhci_wake_info - Relates an XHCI device to registers and wake types |
| 33 | * @xhci_dev: devfn of the XHCI device |
| 34 | * @elog_wake_type_host: the wake type for the controller device |
| 35 | */ |
| 36 | struct xhci_wake_info { |
| 37 | pci_devfn_t xhci_dev; |
| 38 | uint8_t elog_wake_type_host; |
| 39 | }; |
| 40 | |
| 41 | /* |
| 42 | * xhci_update_wake_event() - Identify and log XHCI wake events. |
| 43 | * @wake_info: A mapping of XHCI devfn to elog wake types |
| 44 | * @wake_info_count: Count of items in wake_info |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 45 | * @info: Information about number of USB ports and their status reg offset. |
| 46 | * |
| 47 | * This function goes through individual USB port status registers within the |
| 48 | * XHCI block and identifies if any of those USB ports triggered a wake-up and |
| 49 | * log information about those ports to the event log. |
| 50 | * |
| 51 | * Return: True if any port is identified as a wake source, false if none. |
| 52 | */ |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 53 | bool xhci_update_wake_event(const struct xhci_wake_info *wake_info, |
| 54 | size_t wake_info_count); |
Karthikeyan Ramasubramanian | cc7cdb1 | 2019-03-20 11:38:01 -0600 | [diff] [blame] | 55 | |
Subrata Banik | e3a4a13 | 2022-04-11 17:45:33 +0530 | [diff] [blame] | 56 | /* xhci_host_reset() - Function to reset the host controller */ |
| 57 | void xhci_host_reset(void); |
Subrata Banik | a554b0c | 2017-02-16 16:08:49 +0530 | [diff] [blame] | 58 | void soc_xhci_init(struct device *dev); |
| 59 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 60 | /* |
Karthikeyan Ramasubramanian | 0f71831 | 2019-07-03 13:02:37 -0600 | [diff] [blame] | 61 | * soc_get_xhci_usb_info() - Get the information about USB2 & USB3 ports. |
| 62 | * |
| 63 | * This function is used to get USB ports and status register offset information |
| 64 | * within a XHCI controller. |
| 65 | * |
| 66 | * Return: USB ports and status register offset info for the SoC. |
| 67 | */ |
Tim Wawrzynczak | 56fcfb5 | 2020-11-10 13:39:37 -0700 | [diff] [blame] | 68 | 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] | 69 | |
Subrata Banik | 5885ffe | 2019-11-14 11:08:51 +0530 | [diff] [blame] | 70 | /* |
Karthikeyan Ramasubramanian | ef0c226 | 2019-06-06 15:35:11 -0600 | [diff] [blame] | 71 | * usb_xhci_disable_unused() - Disable unused USB devices |
| 72 | * @ext_usb_xhci_en_cb: Callback function to be invoked, supplied by mainboard, |
| 73 | * to identify the status of externally visible USB ports. |
| 74 | * (Return true if port is present, false if port is absent) |
| 75 | * |
| 76 | * This function is used to disable unused USB devices/ports that are configured |
| 77 | * in the device tree. For the internal USB ports, the connect status of the port |
| 78 | * is probed from the XHCI controller block and the port is disabled if it is not |
| 79 | * connected. For the external USB ports, the mainboard provides the connect status |
| 80 | * of the concerned port depending on the variants and their SKUs. If the mainboard |
| 81 | * supplied callback function is NULL, then all the externally visible USB devices |
| 82 | * in the device tree are enabled. |
| 83 | */ |
| 84 | void usb_xhci_disable_unused(bool (*ext_usb_xhci_en_cb)(unsigned int port_type, |
| 85 | unsigned int port_id)); |
Subrata Banik | 36ca7b3 | 2023-03-23 14:48:53 +0530 | [diff] [blame] | 86 | #endif /* if !defined(__ACPI__) */ |
Subrata Banik | a554b0c | 2017-02-16 16:08:49 +0530 | [diff] [blame] | 87 | #endif /* SOC_INTEL_COMMON_BLOCK_XHCI_H */ |