blob: 09a134b74df24f71ab926c581bc550d724355aee [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 <stdint.h>
Karthikeyan Ramasubramaniancc7cdb12019-03-20 11:38:01 -060030
Subrata Banik5885ffe2019-11-14 11:08:51 +053031/*
Tim Wawrzynczak56fcfb52020-11-10 13:39:37 -070032 * 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 */
36struct 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 Ramasubramaniancc7cdb12019-03-20 11:38:01 -060045 * @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 Wawrzynczak56fcfb52020-11-10 13:39:37 -070053bool xhci_update_wake_event(const struct xhci_wake_info *wake_info,
54 size_t wake_info_count);
Karthikeyan Ramasubramaniancc7cdb12019-03-20 11:38:01 -060055
Subrata Banike3a4a132022-04-11 17:45:33 +053056/* xhci_host_reset() - Function to reset the host controller */
57void xhci_host_reset(void);
Subrata Banika554b0c2017-02-16 16:08:49 +053058void soc_xhci_init(struct device *dev);
59
Subrata Banik5885ffe2019-11-14 11:08:51 +053060/*
Karthikeyan Ramasubramanian0f718312019-07-03 13:02:37 -060061 * 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 Wawrzynczak56fcfb52020-11-10 13:39:37 -070068const struct xhci_usb_info *soc_get_xhci_usb_info(pci_devfn_t xhci_dev);
Karthikeyan Ramasubramanian0f718312019-07-03 13:02:37 -060069
Subrata Banik5885ffe2019-11-14 11:08:51 +053070/*
Karthikeyan Ramasubramanianef0c2262019-06-06 15:35:11 -060071 * 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 */
84void usb_xhci_disable_unused(bool (*ext_usb_xhci_en_cb)(unsigned int port_type,
85 unsigned int port_id));
Subrata Banik36ca7b32023-03-23 14:48:53 +053086#endif /* if !defined(__ACPI__) */
Subrata Banika554b0c2017-02-16 16:08:49 +053087#endif /* SOC_INTEL_COMMON_BLOCK_XHCI_H */