drivers/thunderbolt/clx.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/clx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/clx.c- Extension
.c- Size
- 9543 bytes
- Lines
- 429
- Domain
- Driver Families
- Bucket
- drivers/thunderbolt
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.htb.h
Detected Declarations
function tb_port_pm_secondary_setfunction tb_port_pm_secondary_enablefunction tb_port_pm_secondary_disablefunction tb_port_clx_supportedfunction tb_port_clx_setfunction tb_port_clx_disablefunction tb_port_clx_enablefunction tb_port_clxfunction tb_port_clx_is_enabledfunction tb_switch_clx_is_supportedfunction tb_switch_clx_initfunction tb_switch_pm_secondary_resolvefunction tb_switch_mask_clx_objectionsfunction Bfunction validate_maskfunction tb_switch_clx_enablefunction tb_switch_clx_disable
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* CLx support
*
* Copyright (C) 2020 - 2023, Intel Corporation
* Authors: Gil Fine <gil.fine@intel.com>
* Mika Westerberg <mika.westerberg@linux.intel.com>
*/
#include <linux/module.h>
#include "tb.h"
static bool clx_enabled = true;
module_param_named(clx, clx_enabled, bool, 0444);
MODULE_PARM_DESC(clx, "allow low power states on the high-speed lanes (default: true)");
static const char *clx_name(unsigned int clx)
{
switch (clx) {
case TB_CL0S | TB_CL1 | TB_CL2:
return "CL0s/CL1/CL2";
case TB_CL1 | TB_CL2:
return "CL1/CL2";
case TB_CL0S | TB_CL2:
return "CL0s/CL2";
case TB_CL0S | TB_CL1:
return "CL0s/CL1";
case TB_CL0S:
return "CL0s";
case 0:
return "disabled";
default:
return "unknown";
}
}
static int tb_port_pm_secondary_set(struct tb_port *port, bool secondary)
{
u32 phy;
int ret;
ret = tb_port_read(port, &phy, TB_CFG_PORT,
port->cap_phy + LANE_ADP_CS_1, 1);
if (ret)
return ret;
if (secondary)
phy |= LANE_ADP_CS_1_PMS;
else
phy &= ~LANE_ADP_CS_1_PMS;
return tb_port_write(port, &phy, TB_CFG_PORT,
port->cap_phy + LANE_ADP_CS_1, 1);
}
static int tb_port_pm_secondary_enable(struct tb_port *port)
{
return tb_port_pm_secondary_set(port, true);
}
static int tb_port_pm_secondary_disable(struct tb_port *port)
{
return tb_port_pm_secondary_set(port, false);
}
/* Called for USB4 or Titan Ridge routers only */
static bool tb_port_clx_supported(struct tb_port *port, unsigned int clx)
{
u32 val, mask = 0;
bool ret;
/* Don't enable CLx in case of two single-lane links */
if (!port->bonded && port->dual_link_port)
return false;
/* Don't enable CLx in case of inter-domain link */
if (port->xdomain)
return false;
if (tb_switch_is_usb4(port->sw)) {
if (!usb4_port_clx_supported(port))
return false;
} else if (!tb_lc_is_clx_supported(port)) {
return false;
}
if (clx & TB_CL0S)
mask |= LANE_ADP_CS_0_CL0S_SUPPORT;
if (clx & TB_CL1)
Annotation
- Immediate include surface: `linux/module.h`, `tb.h`.
- Detected declarations: `function tb_port_pm_secondary_set`, `function tb_port_pm_secondary_enable`, `function tb_port_pm_secondary_disable`, `function tb_port_clx_supported`, `function tb_port_clx_set`, `function tb_port_clx_disable`, `function tb_port_clx_enable`, `function tb_port_clx`, `function tb_port_clx_is_enabled`, `function tb_switch_clx_is_supported`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.