drivers/usb/typec/mux/pi3usb30532.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/mux/pi3usb30532.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/mux/pi3usb30532.c- Extension
.c- Size
- 4302 bytes
- Lines
- 191
- 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/i2c.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/usb/typec_dp.hlinux/usb/typec_mux.h
Detected Declarations
struct pi3usb30532function pi3usb30532_set_conffunction pi3usb30532_sw_setfunction pi3usb30532_mux_setfunction pi3usb30532_probefunction pi3usb30532_remove
Annotated Snippet
struct pi3usb30532 {
struct i2c_client *client;
struct mutex lock; /* protects the cached conf register */
struct typec_switch_dev *sw;
struct typec_mux_dev *mux;
u8 conf;
};
static int pi3usb30532_set_conf(struct pi3usb30532 *pi, u8 new_conf)
{
int ret = 0;
if (pi->conf == new_conf)
return 0;
ret = i2c_smbus_write_byte_data(pi->client, PI3USB30532_CONF, new_conf);
if (ret) {
dev_err(&pi->client->dev, "Error writing conf: %d\n", ret);
return ret;
}
pi->conf = new_conf;
return 0;
}
static int pi3usb30532_sw_set(struct typec_switch_dev *sw,
enum typec_orientation orientation)
{
struct pi3usb30532 *pi = typec_switch_get_drvdata(sw);
u8 new_conf;
int ret;
mutex_lock(&pi->lock);
new_conf = pi->conf;
switch (orientation) {
case TYPEC_ORIENTATION_NONE:
new_conf = PI3USB30532_CONF_OPEN;
break;
case TYPEC_ORIENTATION_NORMAL:
new_conf &= ~PI3USB30532_CONF_SWAP;
break;
case TYPEC_ORIENTATION_REVERSE:
new_conf |= PI3USB30532_CONF_SWAP;
break;
}
ret = pi3usb30532_set_conf(pi, new_conf);
mutex_unlock(&pi->lock);
return ret;
}
static int
pi3usb30532_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state)
{
struct pi3usb30532 *pi = typec_mux_get_drvdata(mux);
u8 new_conf;
int ret;
mutex_lock(&pi->lock);
new_conf = pi->conf;
switch (state->mode) {
case TYPEC_STATE_SAFE:
new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
PI3USB30532_CONF_OPEN;
break;
case TYPEC_STATE_USB:
new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
PI3USB30532_CONF_USB3;
break;
case TYPEC_DP_STATE_C:
case TYPEC_DP_STATE_E:
new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
PI3USB30532_CONF_4LANE_DP;
break;
case TYPEC_DP_STATE_D:
new_conf = (new_conf & PI3USB30532_CONF_SWAP) |
PI3USB30532_CONF_USB3_AND_2LANE_DP;
break;
default:
break;
}
ret = pi3usb30532_set_conf(pi, new_conf);
mutex_unlock(&pi->lock);
return ret;
}
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/usb/typec_dp.h`, `linux/usb/typec_mux.h`.
- Detected declarations: `struct pi3usb30532`, `function pi3usb30532_set_conf`, `function pi3usb30532_sw_set`, `function pi3usb30532_mux_set`, `function pi3usb30532_probe`, `function pi3usb30532_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.