blob: 1a72e0fee84d882a5ba842f7b2b916aad7f9c3da [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banika554b0c2017-02-16 16:08:49 +05302
3#ifndef SOC_INTEL_COMMON_BLOCK_XHCI_H
4#define SOC_INTEL_COMMON_BLOCK_XHCI_H
5
Subrata Banik36ca7b32023-03-23 14:48:53 +05306#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 Normana5215c42023-09-22 15:26:54 +100019/*
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 Banik36ca7b32023-03-23 14:48:53 +053026#if !defined(__ACPI__)
Karthikeyan Ramasubramaniancc7cdb12019-03-20 11:38:01 -060027#include <device/device.h>
Robert Ziebaa23aa1c2022-08-10 16:56:09 -060028#include <device/xhci.h>
Tim Wawrzynczak56fcfb52020-11-10 13:39:37 -070029#include <elog.h>
30#include <stdint.h>
Karthikeyan Ramasubramaniancc7cdb12019-03-20 11:38:01 -060031
Subrata Banik5885ffe2019-11-14 11:08:51 +053032/*
Tim Wawrzynczak56fcfb52020-11-10 13:39:37 -070033 * 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 */
37struct 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 Ramasubramaniancc7cdb12019-03-20 11:38:01 -060046 * @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 Wawrzynczak56fcfb52020-11-10 13:39:37 -070054bool xhci_update_wake_event(const struct xhci_wake_info *wake_info,
55 size_t wake_info_count);
Karthikeyan Ramasubramaniancc7cdb12019-03-20 11:38:01 -060056
Subrata Banike3a4a132022-04-11 17:45:33 +053057/* xhci_host_reset() - Function to reset the host controller */
58void xhci_host_reset(void);
Subrata Banika554b0c2017-02-16 16:08:49 +053059void soc_xhci_init(struct device *dev);
60
Subrata Banik5885ffe2019-11-14 11:08:51 +053061/*
Karthikeyan Ramasubramanian0f718312019-07-03 13:02:37 -060062 * 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 Wawrzynczak56fcfb52020-11-10 13:39:37 -070069const struct xhci_usb_info *soc_get_xhci_usb_info(pci_devfn_t xhci_dev);
Karthikeyan Ramasubramanian0f718312019-07-03 13:02:37 -060070
Subrata Banik5885ffe2019-11-14 11:08:51 +053071/*
Karthikeyan Ramasubramanianef0c2262019-06-06 15:35:11 -060072 * 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 */
85void usb_xhci_disable_unused(bool (*ext_usb_xhci_en_cb)(unsigned int port_type,
86 unsigned int port_id));
Subrata Banik36ca7b32023-03-23 14:48:53 +053087#endif /* if !defined(__ACPI__) */
Subrata Banika554b0c2017-02-16 16:08:49 +053088#endif /* SOC_INTEL_COMMON_BLOCK_XHCI_H */