drivers/usb/typec/mux/fsa4480.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/mux/fsa4480.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/mux/fsa4480.c- Extension
.c- Size
- 9124 bytes
- Lines
- 363
- 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/usb/typec_dp.hlinux/usb/typec_mux.hlinux/regulator/consumer.h
Detected Declarations
struct fsa4480function fsa4480_setfunction fsa4480_switch_setfunction fsa4480_mux_setfunction fsa4480_parse_data_lanes_mappingfunction fsa4480_probefunction fsa4480_remove
Annotated Snippet
struct fsa4480 {
struct i2c_client *client;
/* used to serialize concurrent change requests */
struct mutex lock;
struct typec_switch_dev *sw;
struct typec_mux_dev *mux;
struct regmap *regmap;
enum typec_orientation orientation;
unsigned long mode;
unsigned int svid;
u8 cur_enable;
bool swap_sbu_lanes;
};
static const struct regmap_config fsa4480_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = FSA4480_MAX_REGISTER,
/* Accesses only done under fsa4480->lock */
.disable_locking = true,
};
static int fsa4480_set(struct fsa4480 *fsa)
{
bool reverse = (fsa->orientation == TYPEC_ORIENTATION_REVERSE);
u8 enable = FSA4480_ENABLE_DEVICE;
u8 sel = 0;
if (fsa->swap_sbu_lanes)
reverse = !reverse;
/* USB Mode */
if (fsa->mode < TYPEC_STATE_MODAL ||
(!fsa->svid && (fsa->mode == TYPEC_MODE_USB2 ||
fsa->mode == TYPEC_MODE_USB3))) {
enable |= FSA4480_ENABLE_USB;
sel = FSA4480_SEL_USB;
} else if (fsa->svid) {
switch (fsa->mode) {
/* DP Only */
case TYPEC_DP_STATE_C:
case TYPEC_DP_STATE_E:
enable |= FSA4480_ENABLE_SBU;
if (reverse)
sel = FSA4480_SEL_SBU_REVERSE;
break;
/* DP + USB */
case TYPEC_DP_STATE_D:
case TYPEC_DP_STATE_F:
enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_SBU;
sel = FSA4480_SEL_USB;
if (reverse)
sel |= FSA4480_SEL_SBU_REVERSE;
break;
default:
return -EOPNOTSUPP;
}
} else if (fsa->mode == TYPEC_MODE_AUDIO) {
/* Audio Accessory Mode, setup to auto Jack Detection */
enable |= FSA4480_ENABLE_USB | FSA4480_ENABLE_AGND;
} else
return -EOPNOTSUPP;
if (fsa->cur_enable & FSA4480_ENABLE_SBU) {
/* Disable SBU output while re-configuring the switch */
regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE,
fsa->cur_enable & ~FSA4480_ENABLE_SBU);
/* 35us to allow the SBU switch to turn off */
usleep_range(35, 1000);
}
regmap_write(fsa->regmap, FSA4480_SWITCH_SELECT, sel);
regmap_write(fsa->regmap, FSA4480_SWITCH_ENABLE, enable);
/* Start AUDIO JACK DETECTION to setup MIC, AGND & Sense muxes */
if (enable & FSA4480_ENABLE_AGND)
regmap_write(fsa->regmap, FSA4480_FUNCTION_ENABLE,
FSA4480_ENABLE_AUTO_JACK_DETECT);
if (enable & FSA4480_ENABLE_SBU) {
/* 15us to allow the SBU switch to turn on again */
usleep_range(15, 1000);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/regmap.h`, `linux/usb/typec_dp.h`, `linux/usb/typec_mux.h`.
- Detected declarations: `struct fsa4480`, `function fsa4480_set`, `function fsa4480_switch_set`, `function fsa4480_mux_set`, `function fsa4480_parse_data_lanes_mapping`, `function fsa4480_probe`, `function fsa4480_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.