drivers/usb/typec/tcpm/tcpci_mt6370.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/tcpci_mt6370.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/tcpci_mt6370.c- Extension
.c- Size
- 4883 bytes
- Lines
- 205
- 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/bits.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm_wakeirq.hlinux/regmap.hlinux/regulator/consumer.hlinux/usb/tcpci.hlinux/usb/tcpm.h
Detected Declarations
struct mt6370_privfunction mt6370_tcpc_initfunction mt6370_tcpc_set_vconnfunction mt6370_tcpc_set_vbusfunction mt6370_irq_handlerfunction mt6370_check_vendor_infofunction mt6370_unregister_tcpci_portfunction mt6370_tcpc_probefunction mt6370_tcpc_remove
Annotated Snippet
struct mt6370_priv {
struct device *dev;
struct regulator *vbus;
struct tcpci *tcpci;
struct tcpci_data tcpci_data;
};
static const struct reg_sequence mt6370_reg_init[] = {
REG_SEQ(0xA0, 0x1, 1000),
REG_SEQ(0x81, 0x38, 0),
REG_SEQ(0x82, 0x82, 0),
REG_SEQ(0xBA, 0xFC, 0),
REG_SEQ(0xBB, 0x50, 0),
REG_SEQ(0x9E, 0x8F, 0),
REG_SEQ(0xA1, 0x5, 0),
REG_SEQ(0xA2, 0x4, 0),
REG_SEQ(0xA3, 0x4A, 0),
REG_SEQ(0xA4, 0x01, 0),
REG_SEQ(0x95, 0x01, 0),
REG_SEQ(0x80, 0x71, 0),
REG_SEQ(0x9B, 0x3A, 1000),
};
static int mt6370_tcpc_init(struct tcpci *tcpci, struct tcpci_data *data)
{
u16 did;
int ret;
ret = regmap_register_patch(data->regmap, mt6370_reg_init,
ARRAY_SIZE(mt6370_reg_init));
if (ret)
return ret;
ret = regmap_raw_read(data->regmap, TCPC_BCD_DEV, &did, sizeof(u16));
if (ret)
return ret;
if (did == MT6370_TCPC_DID_A)
return regmap_write(data->regmap, TCPC_FAULT_CTRL, 0x80);
return 0;
}
static int mt6370_tcpc_set_vconn(struct tcpci *tcpci, struct tcpci_data *data,
bool enable)
{
return regmap_update_bits(data->regmap, MT6370_REG_SYSCTRL8,
MT6370_AUTOIDLE_MASK,
enable ? 0 : MT6370_AUTOIDLE_MASK);
}
static int mt6370_tcpc_set_vbus(struct tcpci *tcpci, struct tcpci_data *data,
bool source, bool sink)
{
struct mt6370_priv *priv = container_of(data, struct mt6370_priv,
tcpci_data);
int ret;
ret = regulator_is_enabled(priv->vbus);
if (ret < 0)
return ret;
if (ret && !source)
return regulator_disable(priv->vbus);
if (!ret && source)
return regulator_enable(priv->vbus);
return 0;
}
static irqreturn_t mt6370_irq_handler(int irq, void *dev_id)
{
struct mt6370_priv *priv = dev_id;
return tcpci_irq(priv->tcpci);
}
static int mt6370_check_vendor_info(struct mt6370_priv *priv)
{
struct regmap *regmap = priv->tcpci_data.regmap;
u16 vid;
int ret;
ret = regmap_raw_read(regmap, TCPC_VENDOR_ID, &vid, sizeof(u16));
if (ret)
return ret;
if (vid != MT6370_VENDOR_ID)
return dev_err_probe(priv->dev, -ENODEV,
Annotation
- Immediate include surface: `linux/bits.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_wakeirq.h`, `linux/regmap.h`.
- Detected declarations: `struct mt6370_priv`, `function mt6370_tcpc_init`, `function mt6370_tcpc_set_vconn`, `function mt6370_tcpc_set_vbus`, `function mt6370_irq_handler`, `function mt6370_check_vendor_info`, `function mt6370_unregister_tcpci_port`, `function mt6370_tcpc_probe`, `function mt6370_tcpc_remove`.
- 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.