drivers/extcon/extcon-rtk-type-c.c
Source file repositories/reference/linux-study-clean/drivers/extcon/extcon-rtk-type-c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/extcon/extcon-rtk-type-c.c- Extension
.c- Size
- 53042 bytes
- Lines
- 1796
- Domain
- Driver Families
- Bucket
- drivers/extcon
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/kernel.hlinux/slab.hlinux/platform_device.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/io.hlinux/interrupt.hlinux/syscalls.hlinux/suspend.hlinux/debugfs.hlinux/extcon.hlinux/extcon-provider.hlinux/sys_soc.hlinux/nvmem-consumer.hlinux/gpio/consumer.hlinux/usb/otg.hlinux/usb/typec.h
Detected Declarations
struct cc_paramstruct type_c_cfgstruct type_c_dataenum parameter_versionenum usb_data_rolesfunction rtd129x_switch_type_c_plug_configfunction switch_type_c_plug_configfunction switch_type_c_dr_modefunction connector_attachedfunction connector_detachedfunction __detect_host_devicefunction detect_devicefunction detect_hostfunction host_device_switch_detectionfunction detect_type_c_statefunction host_device_switchfunction type_c_detect_irqfunction type_c_port_dr_setfunction type_c_parameter_showfunction type_c_parameter_openfunction type_c_status_showfunction type_c_status_openfunction create_debug_filesfunction remove_debug_filesfunction create_debug_filesfunction __updated_type_c_parameter_by_efusefunction __updated_type_c_parameter_by_efuse_v2function get_default_type_c_parameterfunction setup_type_c_parameterfunction extcon_rtk_type_c_initfunction extcon_rtk_type_c_edev_registerfunction extcon_rtk_type_c_probefunction extcon_rtk_type_c_removefunction extcon_rtk_type_c_preparefunction extcon_rtk_type_c_completefunction extcon_rtk_type_c_resume
Annotated Snippet
static const struct file_operations type_c_parameter_fops = {
.open = type_c_parameter_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int type_c_status_show(struct seq_file *s, void *unused)
{
struct type_c_data *type_c = s->private;
unsigned long flags;
spin_lock_irqsave(&type_c->lock, flags);
seq_printf(s, "In %s mode %s at %s (cc_status=0x%x)\n",
type_c->cc_mode == IN_HOST_MODE ? "host" : "device",
type_c->is_attach ? "attach" : "detach",
type_c->at_cc1 ? "cc1" : "cc2", type_c->cc_status);
seq_printf(s, "Read Register (type_c_ctrl_cc1_0=0x%x)\n",
readl(type_c->reg_base + 0x0));
seq_printf(s, "Read Register (type_c_ctrl_cc1_1=0x%x)\n",
readl(type_c->reg_base + 0x4));
seq_printf(s, "Read Register (type_c_ctrl_cc2_0=0x%x)\n",
readl(type_c->reg_base + 0x8));
seq_printf(s, "Read Register (type_c_ctrl_cc2_1=0x%x)\n",
readl(type_c->reg_base + 0xc));
seq_printf(s, "Read Register (type_c_status=0x%x)\n",
readl(type_c->reg_base + 0x10));
seq_printf(s, "Read Register (type_c_ctrl=0x%x)\n",
readl(type_c->reg_base + 0x14));
spin_unlock_irqrestore(&type_c->lock, flags);
return 0;
}
static int type_c_status_open(struct inode *inode, struct file *file)
{
return single_open(file, type_c_status_show, inode->i_private);
}
static const struct file_operations type_c_status_fops = {
.open = type_c_status_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static inline void create_debug_files(struct type_c_data *type_c)
{
type_c->debug_dir = debugfs_create_dir("type_c", usb_debug_root);
debugfs_create_file("parameter", 0444, type_c->debug_dir, type_c,
&type_c_parameter_fops);
debugfs_create_file("status", 0444, type_c->debug_dir, type_c,
&type_c_status_fops);
}
static inline void remove_debug_files(struct type_c_data *type_c)
{
debugfs_remove_recursive(type_c->debug_dir);
}
#else
static inline void create_debug_files(struct type_c_data *type_c) { }
static inline void remove_debug_files(struct type_c_data *type_c) { }
#endif /* CONFIG_DEBUG_FS */
/* Init and probe */
static inline s8 get_value(s8 value)
{
return (((s8)value & 0x8) ? (-(s8)(0x7 & value)) : ((s8)(value)));
}
static int __updated_type_c_parameter_by_efuse(struct type_c_data *type_c)
{
struct type_c_cfg *type_c_cfg = type_c->type_c_cfg;
struct cc_param *cc_param;
struct nvmem_cell *cell;
s8 cc1_4p7k = 0;
s8 cc1_12k = 0;
s8 cc1_0p2v = 0;
s8 cc1_0p8v = 0;
s8 cc1_2p6v = 0;
s8 cc1_0p66v = 0;
s8 cc1_1p23v = 0;
s8 cc2_4p7k = 0;
s8 cc2_12k = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/platform_device.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/io.h`.
- Detected declarations: `struct cc_param`, `struct type_c_cfg`, `struct type_c_data`, `enum parameter_version`, `enum usb_data_roles`, `function rtd129x_switch_type_c_plug_config`, `function switch_type_c_plug_config`, `function switch_type_c_dr_mode`, `function connector_attached`, `function connector_detached`.
- Atlas domain: Driver Families / drivers/extcon.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.