drivers/usb/typec/tcpm/tcpci_rt1711h.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/tcpci_rt1711h.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/tcpci_rt1711h.c- Extension
.c- Size
- 10448 bytes
- Lines
- 405
- 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/bits.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/i2c.hlinux/interrupt.hlinux/gpio/consumer.hlinux/usb/tcpci.hlinux/usb/tcpm.hlinux/regmap.hlinux/regulator/consumer.h
Detected Declarations
struct rt1711h_chip_infostruct rt1711h_chipfunction rt1711h_read16function rt1711h_write16function rt1711h_read8function rt1711h_write8function rt1711h_initfunction rt1711h_set_vbusfunction rt1711h_set_vconnfunction rt1711h_init_cc_paramsfunction rt1711h_start_drp_togglingfunction rt1711h_irqfunction rt1711h_sw_resetfunction rt1711h_probefunction rt1711h_remove
Annotated Snippet
struct rt1711h_chip_info {
u32 rxdz_sel;
bool enable_pd30_extended_message;
};
struct rt1711h_chip {
struct tcpci_data data;
struct tcpci *tcpci;
struct device *dev;
struct regulator *vbus;
const struct rt1711h_chip_info *info;
bool src_en;
};
static int rt1711h_read16(struct rt1711h_chip *chip, unsigned int reg, u16 *val)
{
return regmap_raw_read(chip->data.regmap, reg, val, sizeof(u16));
}
static int rt1711h_write16(struct rt1711h_chip *chip, unsigned int reg, u16 val)
{
return regmap_raw_write(chip->data.regmap, reg, &val, sizeof(u16));
}
static int rt1711h_read8(struct rt1711h_chip *chip, unsigned int reg, u8 *val)
{
return regmap_raw_read(chip->data.regmap, reg, val, sizeof(u8));
}
static int rt1711h_write8(struct rt1711h_chip *chip, unsigned int reg, u8 val)
{
return regmap_raw_write(chip->data.regmap, reg, &val, sizeof(u8));
}
static const struct regmap_config rt1711h_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0xFF, /* 0x80 .. 0xFF are vendor defined */
};
static struct rt1711h_chip *tdata_to_rt1711h(struct tcpci_data *tdata)
{
return container_of(tdata, struct rt1711h_chip, data);
}
static int rt1711h_init(struct tcpci *tcpci, struct tcpci_data *tdata)
{
struct rt1711h_chip *chip = tdata_to_rt1711h(tdata);
struct regmap *regmap = chip->data.regmap;
int ret;
/* CK 300K from 320K, shipping off, auto_idle enable, tout = 32ms */
ret = rt1711h_write8(chip, RT1711H_RTCTRL8,
RT1711H_RTCTRL8_SET(0, 1, 1, 2));
if (ret < 0)
return ret;
/* Enable PD30 extended message for RT1715 */
if (chip->info->enable_pd30_extended_message) {
ret = regmap_update_bits(regmap, RT1711H_RTCTRL8,
RT1711H_ENEXTMSG, RT1711H_ENEXTMSG);
if (ret < 0)
return ret;
}
/* I2C reset : (val + 1) * 12.5ms */
ret = rt1711h_write8(chip, RT1711H_RTCTRL11,
RT1711H_RTCTRL11_SET(1, 0x0F));
if (ret < 0)
return ret;
/* tTCPCfilter : (26.7 * val) us */
ret = rt1711h_write8(chip, RT1711H_RTCTRL14, 0x0F);
if (ret < 0)
return ret;
/* tDRP : (51.2 + 6.4 * val) ms */
ret = rt1711h_write8(chip, RT1711H_RTCTRL15, 0x04);
if (ret < 0)
return ret;
/* dcSRC.DRP : 33% */
ret = rt1711h_write16(chip, RT1711H_RTCTRL16, 330);
if (ret < 0)
return ret;
/* Enable phy discard retry, retry count 7, rx filter deglitch 100 us */
ret = rt1711h_write8(chip, RT1711H_PHYCTRL1, 0xF1);
if (ret < 0)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct rt1711h_chip_info`, `struct rt1711h_chip`, `function rt1711h_read16`, `function rt1711h_write16`, `function rt1711h_read8`, `function rt1711h_write8`, `function rt1711h_init`, `function rt1711h_set_vbus`, `function rt1711h_set_vconn`, `function rt1711h_init_cc_params`.
- 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.