drivers/usb/typec/rt1719.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/rt1719.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/rt1719.c- Extension
.c- Size
- 24319 bytes
- Lines
- 955
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/completion.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/power_supply.hlinux/regmap.hlinux/usb/pd.hlinux/usb/role.hlinux/usb/typec.h
Detected Declarations
struct rt1719_psel_capstruct rt1719_dataenum rt1719_snkcapfunction rt1719_read16function rt1719_read32function rt1719_write32function rt1719_get_pwr_opmodefunction rt1719_get_data_rolefunction rt1719_set_data_rolefunction rt1719_update_data_rolefunction rt1719_register_partnerfunction rt1719_attachfunction rt1719_detachfunction rt1719_update_operating_statusfunction rt1719_update_pwr_opmodefunction rt1719_update_source_pdosfunction rt1719_dr_setfunction rt1719_usbpd_request_voltagefunction rt1719_psy_set_propertyfunction rt1719_psy_get_propertyfunction rt1719_psy_property_is_writeablefunction devm_rt1719_psy_registerfunction rt1719_irq_handlerfunction rt1719_irq_initfunction rt1719_init_attach_statefunction rt1719_gen_snkcap_by_currentfunction rt1719_gen_snkcap_by_wattfunction rt1719_gen_snkcapfunction rt1719_get_capsfunction rt1719_check_existfunction rt1719_probefunction rt1719_remove
Annotated Snippet
struct rt1719_psel_cap {
u8 lomask;
u8 himask;
u32 milliwatt;
u32 milliamp;
};
struct rt1719_data {
struct device *dev;
struct regmap *regmap;
struct typec_port *port;
struct usb_role_switch *role_sw;
struct power_supply *psy;
struct typec_partner *partner;
struct power_supply_desc psy_desc;
struct usb_pd_identity partner_ident;
struct typec_partner_desc partner_desc;
struct completion req_completion;
enum power_supply_usb_type usb_type;
bool attached;
bool pd_capable;
bool drswap_support;
u32 voltage;
u32 req_voltage;
u32 max_current;
u32 op_current;
u32 spdos[RT1719_MAX_SRCPDO];
u16 snkcaps[RT1719_MAX_SNKCAP];
int spdo_num;
int spdo_sel;
u32 conn_info;
u16 conn_stat;
};
static const enum power_supply_property rt1719_psy_properties[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_MAX,
POWER_SUPPLY_PROP_CURRENT_NOW
};
static int rt1719_read16(struct rt1719_data *data, unsigned int reg, u16 *val)
{
__le16 regval;
int ret;
ret = regmap_raw_read(data->regmap, reg, ®val, sizeof(regval));
if (ret)
return ret;
*val = le16_to_cpu(regval);
return 0;
}
static int rt1719_read32(struct rt1719_data *data, unsigned int reg, u32 *val)
{
__le32 regval;
int ret;
ret = regmap_raw_read(data->regmap, reg, ®val, sizeof(regval));
if (ret)
return ret;
*val = le32_to_cpu(regval);
return 0;
}
static int rt1719_write32(struct rt1719_data *data, unsigned int reg, u32 val)
{
__le32 regval = cpu_to_le32(val);
return regmap_raw_write(data->regmap, reg, ®val, sizeof(regval));
}
static enum typec_pwr_opmode rt1719_get_pwr_opmode(u32 conn, u16 stat)
{
u16 cc1, cc2, cc_stat;
cc1 = FIELD_GET(RT1719_CC1_STAT, stat);
cc2 = FIELD_GET(RT1719_CC2_STAT, stat);
if (conn & RT1719_ATTACH_SNK) {
if (conn & RT1719_POLARITY_MASK)
cc_stat = cc2;
else
cc_stat = cc1;
switch (cc_stat) {
case SNK_PWR_3A:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/completion.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/power_supply.h`, `linux/regmap.h`.
- Detected declarations: `struct rt1719_psel_cap`, `struct rt1719_data`, `enum rt1719_snkcap`, `function rt1719_read16`, `function rt1719_read32`, `function rt1719_write32`, `function rt1719_get_pwr_opmode`, `function rt1719_get_data_role`, `function rt1719_set_data_role`, `function rt1719_update_data_role`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.