drivers/mfd/ti_am335x_tscadc.c
Source file repositories/reference/linux-study-clean/drivers/mfd/ti_am335x_tscadc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/ti_am335x_tscadc.c- Extension
.c- Size
- 10384 bytes
- Lines
- 389
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/slab.hlinux/err.hlinux/io.hlinux/clk.hlinux/regmap.hlinux/mfd/core.hlinux/pm_runtime.hlinux/of.hlinux/platform_device.hlinux/sched.hlinux/mfd/ti_am335x_tscadc.h
Detected Declarations
function am335x_tsc_se_set_cachefunction am335x_tscadc_need_adcfunction am335x_tsc_se_set_oncefunction am335x_tsc_se_adc_donefunction am335x_tsc_se_clrfunction tscadc_idle_configfunction ti_tscadc_probefunction ti_tscadc_removefunction ti_tscadc_can_wakeupfunction tscadc_suspendfunction tscadc_resumeexport am335x_tsc_se_set_cacheexport am335x_tsc_se_set_onceexport am335x_tsc_se_adc_doneexport am335x_tsc_se_clr
Annotated Snippet
if (val > 7) {
dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
val);
of_node_put(node);
return -EINVAL;
}
}
of_node_put(node);
total_channels = tscmag_wires + adc_channels;
if (total_channels > 8) {
dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
return -EINVAL;
}
if (total_channels == 0) {
dev_err(&pdev->dev, "Need at least one channel.\n");
return -EINVAL;
}
if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {
dev_err(&pdev->dev, "Too many step configurations requested\n");
return -EINVAL;
}
err = platform_get_irq(pdev, 0);
if (err < 0)
return err;
else
tscadc->irq = err;
tscadc->tscadc_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(tscadc->tscadc_base))
return PTR_ERR(tscadc->tscadc_base);
tscadc->tscadc_phys_base = res->start;
tscadc->regmap = devm_regmap_init_mmio(&pdev->dev,
tscadc->tscadc_base,
&tscadc_regmap_config);
if (IS_ERR(tscadc->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n");
return PTR_ERR(tscadc->regmap);
}
spin_lock_init(&tscadc->reg_lock);
init_waitqueue_head(&tscadc->reg_se_wait);
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);
/*
* The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
* ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
* am33xx ADCs expect to capture 200ksps.
* am47xx ADCs expect to capture 867ksps.
* We need ADC clocks respectively running at 3MHz and 13MHz.
* These frequencies are valid since TSC_ADC_SS controller design
* assumes the OCP clock is at least 6x faster than the ADC clock.
*/
clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get fck\n");
err = PTR_ERR(clk);
goto err_disable_clk;
}
tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
/*
* Set the control register bits. tscadc->ctrl stores the configuration
* of the CTRL register but not the subsystem enable bit which must be
* added manually when timely.
*/
tscadc->ctrl = CNTRLREG_STEPID;
if (ti_adc_with_touchscreen(tscadc)) {
tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
if (use_tsc) {
tscadc->ctrl |= CNTRLREG_TSC_ENB;
if (tscmag_wires == 5)
tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
else
tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
}
} else {
tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN |
CNTRLREG_MAG_PREAMP_BYPASS;
}
regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/err.h`, `linux/io.h`, `linux/clk.h`, `linux/regmap.h`, `linux/mfd/core.h`, `linux/pm_runtime.h`.
- Detected declarations: `function am335x_tsc_se_set_cache`, `function am335x_tscadc_need_adc`, `function am335x_tsc_se_set_once`, `function am335x_tsc_se_adc_done`, `function am335x_tsc_se_clr`, `function tscadc_idle_config`, `function ti_tscadc_probe`, `function ti_tscadc_remove`, `function ti_tscadc_can_wakeup`, `function tscadc_suspend`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: integration 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.