drivers/media/cec/platform/meson/ao-cec-g12a.c
Source file repositories/reference/linux-study-clean/drivers/media/cec/platform/meson/ao-cec-g12a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/cec/platform/meson/ao-cec-g12a.c- Extension
.c- Size
- 21293 bytes
- Lines
- 793
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- 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/bitfield.hlinux/clk.hlinux/device.hlinux/io.hlinux/delay.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/types.hlinux/interrupt.hlinux/reset.hlinux/slab.hlinux/regmap.hmedia/cec.hmedia/cec-notifier.hlinux/clk-provider.h
Detected Declarations
struct meson_ao_cec_g12a_datastruct meson_ao_cec_g12a_devicestruct meson_ao_cec_g12a_dualdiv_clkfunction meson_ao_cec_g12a_dualdiv_clk_recalc_ratefunction meson_ao_cec_g12a_dualdiv_clk_enablefunction meson_ao_cec_g12a_dualdiv_clk_disablefunction meson_ao_cec_g12a_dualdiv_clk_is_enabledfunction meson_ao_cec_g12a_setup_clkfunction meson_ao_cec_g12a_readfunction meson_ao_cec_g12a_writefunction meson_ao_cec_g12a_irq_setupfunction meson_ao_cec_g12a_irq_rxfunction meson_ao_cec_g12a_irqfunction meson_ao_cec_g12a_irq_threadfunction meson_ao_cec_g12a_set_log_addrfunction meson_ao_cec_g12a_transmitfunction meson_ao_cec_g12a_adap_enablefunction meson_ao_cec_g12a_probefunction meson_ao_cec_g12a_remove
Annotated Snippet
struct meson_ao_cec_g12a_data {
/* Setup the internal CECB_CTRL2 register */
bool ctrl2_setup;
};
struct meson_ao_cec_g12a_device {
struct platform_device *pdev;
struct regmap *regmap;
struct regmap *regmap_cec;
spinlock_t cec_reg_lock;
struct cec_notifier *notify;
struct cec_adapter *adap;
struct cec_msg rx_msg;
struct clk *oscin;
struct clk *core;
const struct meson_ao_cec_g12a_data *data;
};
static const struct regmap_config meson_ao_cec_g12a_regmap_conf = {
.reg_bits = 8,
.val_bits = 32,
.reg_stride = 4,
.max_register = CECB_INTR_STAT_REG,
};
/*
* The AO-CECB embeds a dual/divider to generate a more precise
* 32,768KHz clock for CEC core clock.
* ______ ______
* | | | |
* ______ | Div1 |-| Cnt1 | ______
* | | /|______| |______|\ | |
* Xtal-->| Gate |---| ______ ______ X-X--| Gate |-->
* |______| | \| | | |/ | |______|
* | | Div2 |-| Cnt2 | |
* | |______| |______| |
* |_______________________|
*
* The dividing can be switched to single or dual, with a counter
* for each divider to set when the switching is done.
* The entire dividing mechanism can be also bypassed.
*/
struct meson_ao_cec_g12a_dualdiv_clk {
struct clk_hw hw;
struct regmap *regmap;
};
#define hw_to_meson_ao_cec_g12a_dualdiv_clk(_hw) \
container_of(_hw, struct meson_ao_cec_g12a_dualdiv_clk, hw) \
static unsigned long
meson_ao_cec_g12a_dualdiv_clk_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct meson_ao_cec_g12a_dualdiv_clk *dualdiv_clk =
hw_to_meson_ao_cec_g12a_dualdiv_clk(hw);
unsigned long n1;
u32 reg0, reg1;
regmap_read(dualdiv_clk->regmap, CECB_CLK_CNTL_REG0, ®0);
regmap_read(dualdiv_clk->regmap, CECB_CLK_CNTL_REG0, ®1);
if (reg1 & CECB_CLK_CNTL_BYPASS_EN)
return parent_rate;
if (reg0 & CECB_CLK_CNTL_DUAL_EN) {
unsigned long n2, m1, m2, f1, f2, p1, p2;
n1 = FIELD_GET(CECB_CLK_CNTL_N1, reg0) + 1;
n2 = FIELD_GET(CECB_CLK_CNTL_N2, reg0) + 1;
m1 = FIELD_GET(CECB_CLK_CNTL_M1, reg1) + 1;
m2 = FIELD_GET(CECB_CLK_CNTL_M1, reg1) + 1;
f1 = DIV_ROUND_CLOSEST(parent_rate, n1);
f2 = DIV_ROUND_CLOSEST(parent_rate, n2);
p1 = DIV_ROUND_CLOSEST(100000000 * m1, f1 * (m1 + m2));
p2 = DIV_ROUND_CLOSEST(100000000 * m2, f2 * (m1 + m2));
return DIV_ROUND_UP(100000000, p1 + p2);
}
n1 = FIELD_GET(CECB_CLK_CNTL_N1, reg0) + 1;
return DIV_ROUND_CLOSEST(parent_rate, n1);
}
static int meson_ao_cec_g12a_dualdiv_clk_enable(struct clk_hw *hw)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/device.h`, `linux/io.h`, `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct meson_ao_cec_g12a_data`, `struct meson_ao_cec_g12a_device`, `struct meson_ao_cec_g12a_dualdiv_clk`, `function meson_ao_cec_g12a_dualdiv_clk_recalc_rate`, `function meson_ao_cec_g12a_dualdiv_clk_enable`, `function meson_ao_cec_g12a_dualdiv_clk_disable`, `function meson_ao_cec_g12a_dualdiv_clk_is_enabled`, `function meson_ao_cec_g12a_setup_clk`, `function meson_ao_cec_g12a_read`, `function meson_ao_cec_g12a_write`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.