drivers/media/platform/ti/cal/cal-camerarx.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/ti/cal/cal-camerarx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/ti/cal/cal-camerarx.c- Extension
.c- Size
- 29323 bytes
- Lines
- 1047
- 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.
- 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/clk.hlinux/delay.hlinux/mfd/syscon.hlinux/module.hlinux/of_graph.hlinux/platform_device.hlinux/regmap.hlinux/slab.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.hcal.hcal_regs.h
Detected Declarations
function Layerfunction camerarx_writefunction cal_camerarx_get_ext_link_freqfunction cal_camerarx_lane_configfunction cal_camerarx_enablefunction cal_camerarx_disablefunction cal_camerarx_configfunction cal_camerarx_powerfunction cal_camerarx_wait_resetfunction cal_camerarx_wait_stop_statefunction cal_camerarx_enable_irqsfunction cal_camerarx_disable_irqsfunction cal_camerarx_ppi_enablefunction cal_camerarx_ppi_disablefunction cal_camerarx_startfunction cal_camerarx_stopfunction cal_camerarx_i913_erratafunction cal_camerarx_regmap_initfunction cal_camerarx_parse_dtfunction cal_camerarx_get_phy_from_entityfunction cal_camerarx_sd_enable_streamsfunction cal_camerarx_sd_disable_streamsfunction cal_camerarx_sd_enum_mbus_codefunction cal_camerarx_sd_enum_frame_sizefunction cal_camerarx_sd_set_fmtfunction cal_camerarx_set_routingfunction cal_camerarx_sd_set_routingfunction cal_camerarx_sd_init_statefunction cal_camerarx_get_frame_descfunction cal_camerarx_destroy
Annotated Snippet
if (ret) {
phy_err(phy, "enable streams failed in source: %d\n", ret);
return ret;
}
phy->enable_count++;
return 0;
}
link_freq = cal_camerarx_get_ext_link_freq(phy);
if (link_freq < 0)
return link_freq;
ret = v4l2_subdev_call(phy->source, core, s_power, 1);
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) {
phy_err(phy, "power on failed in subdev\n");
return ret;
}
cal_camerarx_enable_irqs(phy);
/*
* CSI-2 PHY Link Initialization Sequence, according to the DRA74xP /
* DRA75xP / DRA76xP / DRA77xP TRM. The DRA71x / DRA72x and the AM65x /
* DRA80xM TRMs have a slightly simplified sequence.
*/
/*
* 1. Configure all CSI-2 low level protocol registers to be ready to
* receive signals/data from the CSI-2 PHY.
*
* i.-v. Configure the lanes position and polarity.
*/
cal_camerarx_lane_config(phy);
/*
* vi.-vii. Configure D-PHY mode, enable the required lanes and
* enable the CAMERARX clock.
*/
cal_camerarx_enable(phy);
/*
* 2. CSI PHY and link initialization sequence.
*
* a. Deassert the CSI-2 PHY reset. Do not wait for reset completion
* at this point, as it requires the external source to send the
* CSI-2 HS clock.
*/
cal_write_field(phy->cal, CAL_CSI2_COMPLEXIO_CFG(phy->instance),
CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_OPERATIONAL,
CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_MASK);
phy_dbg(3, phy, "CAL_CSI2_COMPLEXIO_CFG(%d) = 0x%08x De-assert Complex IO Reset\n",
phy->instance,
cal_read(phy->cal, CAL_CSI2_COMPLEXIO_CFG(phy->instance)));
/* Dummy read to allow SCP reset to complete. */
camerarx_read(phy, CAL_CSI2_PHY_REG0);
/* Program the PHY timing parameters. */
cal_camerarx_config(phy, link_freq);
/*
* b. Assert the FORCERXMODE signal.
*
* The stop-state-counter is based on fclk cycles, and we always use
* the x16 and x4 settings, so stop-state-timeout =
* fclk-cycle * 16 * 4 * counter.
*
* Stop-state-timeout must be more than 100us as per CSI-2 spec, so we
* calculate a timeout that's 100us (rounding up).
*/
sscounter = DIV_ROUND_UP(clk_get_rate(phy->cal->fclk), 10000 * 16 * 4);
val = cal_read(phy->cal, CAL_CSI2_TIMING(phy->instance));
cal_set_field(&val, 1, CAL_CSI2_TIMING_STOP_STATE_X16_IO1_MASK);
cal_set_field(&val, 1, CAL_CSI2_TIMING_STOP_STATE_X4_IO1_MASK);
cal_set_field(&val, sscounter,
CAL_CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK);
cal_write(phy->cal, CAL_CSI2_TIMING(phy->instance), val);
phy_dbg(3, phy, "CAL_CSI2_TIMING(%d) = 0x%08x Stop States\n",
phy->instance,
cal_read(phy->cal, CAL_CSI2_TIMING(phy->instance)));
/* Assert the FORCERXMODE signal. */
cal_write_field(phy->cal, CAL_CSI2_TIMING(phy->instance),
1, CAL_CSI2_TIMING_FORCE_RX_MODE_IO1_MASK);
phy_dbg(3, phy, "CAL_CSI2_TIMING(%d) = 0x%08x Force RXMODE\n",
phy->instance,
cal_read(phy->cal, CAL_CSI2_TIMING(phy->instance)));
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of_graph.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/slab.h`.
- Detected declarations: `function Layer`, `function camerarx_write`, `function cal_camerarx_get_ext_link_freq`, `function cal_camerarx_lane_config`, `function cal_camerarx_enable`, `function cal_camerarx_disable`, `function cal_camerarx_config`, `function cal_camerarx_power`, `function cal_camerarx_wait_reset`, `function cal_camerarx_wait_stop_state`.
- 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.
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.