drivers/usb/typec/mux/wcd939x-usbss.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/mux/wcd939x-usbss.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/mux/wcd939x-usbss.c- Extension
.c- Size
- 23394 bytes
- Lines
- 780
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/regmap.hlinux/bitfield.hlinux/gpio/consumer.hlinux/usb/typec_dp.hlinux/usb/typec_mux.h
Detected Declarations
struct wcd939x_usbssfunction wcd939x_usbss_setfunction wcd939x_usbss_switch_setfunction wcd939x_usbss_mux_setfunction wcd939x_usbss_probefunction wcd939x_usbss_remove
Annotated Snippet
struct wcd939x_usbss {
struct i2c_client *client;
struct gpio_desc *reset_gpio;
struct regulator *vdd_supply;
/* used to serialize concurrent change requests */
struct mutex lock;
struct typec_switch_dev *sw;
struct typec_mux_dev *mux;
struct regmap *regmap;
struct typec_mux *codec;
struct typec_switch *codec_switch;
enum typec_orientation orientation;
unsigned long mode;
unsigned int svid;
};
static const struct regmap_range_cfg wcd939x_usbss_ranges[] = {
{
.range_min = 0,
.range_max = WCD_USBSS_MAX_REGISTER,
.selector_reg = 0x0,
.selector_mask = 0xff,
.selector_shift = 0,
.window_start = 0,
.window_len = 0x100,
},
};
static const struct regmap_config wcd939x_usbss_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = WCD_USBSS_MAX_REGISTER,
.ranges = wcd939x_usbss_ranges,
.num_ranges = ARRAY_SIZE(wcd939x_usbss_ranges),
};
/* Linearlizer coefficients for 32ohm load */
static const struct {
unsigned int offset;
unsigned int mask;
unsigned int value;
} wcd939x_usbss_coeff_init[] = {
{ WCD_USBSS_AUD_COEF_L_K5_0, GENMASK(7, 0), 0x39 },
{ WCD_USBSS_AUD_COEF_R_K5_0, GENMASK(7, 0), 0x39 },
{ WCD_USBSS_GND_COEF_L_K2_0, GENMASK(7, 0), 0xe8 },
{ WCD_USBSS_GND_COEF_L_K4_0, GENMASK(7, 0), 0x73 },
{ WCD_USBSS_GND_COEF_R_K2_0, GENMASK(7, 0), 0xe8 },
{ WCD_USBSS_GND_COEF_R_K4_0, GENMASK(7, 0), 0x73 },
{ WCD_USBSS_RATIO_SPKR_REXT_L_LSB, GENMASK(7, 0), 0x00 },
{ WCD_USBSS_RATIO_SPKR_REXT_L_MSB, GENMASK(6, 0), 0x04 },
{ WCD_USBSS_RATIO_SPKR_REXT_R_LSB, GENMASK(7, 0), 0x00 },
{ WCD_USBSS_RATIO_SPKR_REXT_R_MSB, GENMASK(6, 0), 0x04 },
};
static int wcd939x_usbss_set(struct wcd939x_usbss *usbss)
{
bool reverse = (usbss->orientation == TYPEC_ORIENTATION_REVERSE);
bool enable_audio = false;
bool enable_usb = false;
bool enable_dp = false;
int ret;
/* USB Mode */
if (usbss->mode < TYPEC_STATE_MODAL ||
(!usbss->svid && (usbss->mode == TYPEC_MODE_USB2 ||
usbss->mode == TYPEC_MODE_USB3))) {
enable_usb = true;
} else if (usbss->svid) {
switch (usbss->mode) {
/* DP Only */
case TYPEC_DP_STATE_C:
case TYPEC_DP_STATE_E:
enable_dp = true;
break;
/* DP + USB */
case TYPEC_DP_STATE_D:
case TYPEC_DP_STATE_F:
enable_usb = true;
enable_dp = true;
break;
default:
return -EOPNOTSUPP;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/regmap.h`, `linux/bitfield.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct wcd939x_usbss`, `function wcd939x_usbss_set`, `function wcd939x_usbss_switch_set`, `function wcd939x_usbss_mux_set`, `function wcd939x_usbss_probe`, `function wcd939x_usbss_remove`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.