drivers/gpu/drm/bridge/samsung-dsim.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/samsung-dsim.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/bridge/samsung-dsim.c- Extension
.c- Size
- 66173 bytes
- Lines
- 2339
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- 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/unaligned.hlinux/clk.hlinux/delay.hlinux/export.hlinux/irq.hlinux/media-bus-format.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/units.hvideo/mipi_display.hdrm/bridge/samsung-dsim.hdrm/drm_panel.hdrm/drm_print.h
Detected Declarations
enum samsung_dsim_transfer_typeenum reg_idxenum reg_value_idxfunction samsung_dsim_writefunction samsung_dsim_readfunction samsung_dsim_wait_for_resetfunction samsung_dsim_resetfunction samsung_dsim_pll_find_pmsfunction samsung_dsim_set_pllfunction samsung_dsim_enable_clockfunction samsung_dsim_set_phy_ctrlfunction samsung_dsim_disable_clockfunction samsung_dsim_enable_lanefunction samsung_dsim_init_linkfunction samsung_dsim_set_display_modefunction samsung_dsim_set_display_enablefunction samsung_dsim_wait_for_hdr_fifofunction samsung_dsim_set_cmd_lpmfunction samsung_dsim_force_btafunction samsung_dsim_send_to_fifofunction samsung_dsim_read_from_fifofunction samsung_dsim_transfer_startfunction samsung_dsim_transfer_finishfunction samsung_dsim_remove_transferfunction samsung_dsim_transferfunction samsung_dsim_irqfunction samsung_dsim_enable_irqfunction samsung_dsim_disable_irqfunction samsung_dsim_initfunction samsung_dsim_atomic_pre_enablefunction samsung_dsim_atomic_enablefunction samsung_dsim_atomic_disablefunction samsung_dsim_atomic_post_disablefunction samsung_dsim_pixel_output_fmt_supportedfunction samsung_dsim_atomic_get_input_bus_fmtsfunction samsung_dsim_atomic_checkfunction samsung_dsim_mode_setfunction samsung_dsim_attachfunction samsung_dsim_te_irq_handlerfunction samsung_dsim_register_te_irqfunction samsung_dsim_unregister_te_irqfunction samsung_dsim_host_attachfunction devicefunction samsung_dsim_host_detachfunction samsung_dsim_host_transferfunction samsung_dsim_of_read_u32function samsung_dsim_parse_dtfunction generic_dsim_register_host
Annotated Snippet
if (delta < min_delta) {
best_p = _p;
best_m = _m;
best_s = _s;
min_delta = delta;
best_freq = tmp;
}
}
}
if (best_freq) {
*p = best_p;
*m = best_m;
*s = best_s;
}
return best_freq;
}
static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi,
unsigned long freq)
{
const struct samsung_dsim_driver_data *driver_data = dsi->driver_data;
unsigned long fin, fout;
int timeout;
u8 p, s;
u16 m;
u32 reg;
if (dsi->pll_clk) {
/*
* Ensure that the reference clock is generated with a power of
* two divider from its parent, but close to the PLLs upper
* limit.
*/
fin = clk_get_rate(clk_get_parent(dsi->pll_clk));
while (fin > driver_data->pll_fin_max * HZ_PER_MHZ)
fin /= 2;
clk_set_rate(dsi->pll_clk, fin);
fin = clk_get_rate(dsi->pll_clk);
} else {
fin = dsi->pll_clk_rate;
}
dev_dbg(dsi->dev, "PLL ref clock freq %lu\n", fin);
fout = samsung_dsim_pll_find_pms(dsi, fin, freq, &p, &m, &s);
if (!fout) {
dev_err(dsi->dev,
"failed to find PLL PMS for requested frequency\n");
return 0;
}
dev_dbg(dsi->dev, "PLL freq %lu, (p %d, m %d, s %d)\n", fout, p, m, s);
writel(driver_data->reg_values[PLL_TIMER],
dsi->reg_base + driver_data->plltmr_reg);
reg = DSIM_PLL_EN | DSIM_PLL(p, driver_data->pll_p_offset)
| DSIM_PLL(m, driver_data->pll_m_offset)
| DSIM_PLL(s, driver_data->pll_s_offset);
if (driver_data->has_freqband) {
static const unsigned long freq_bands[] = {
100 * HZ_PER_MHZ, 120 * HZ_PER_MHZ, 160 * HZ_PER_MHZ,
200 * HZ_PER_MHZ, 270 * HZ_PER_MHZ, 320 * HZ_PER_MHZ,
390 * HZ_PER_MHZ, 450 * HZ_PER_MHZ, 510 * HZ_PER_MHZ,
560 * HZ_PER_MHZ, 640 * HZ_PER_MHZ, 690 * HZ_PER_MHZ,
770 * HZ_PER_MHZ, 870 * HZ_PER_MHZ, 950 * HZ_PER_MHZ,
};
int band;
for (band = 0; band < ARRAY_SIZE(freq_bands); ++band)
if (fout < freq_bands[band])
break;
dev_dbg(dsi->dev, "band %d\n", band);
reg |= DSIM_FREQ_BAND(band);
}
if (dsi->swap_dn_dp_clk)
reg |= DSIM_PLL_DPDNSWAP_CLK;
if (dsi->swap_dn_dp_data)
reg |= DSIM_PLL_DPDNSWAP_DAT;
samsung_dsim_write(dsi, DSIM_PLLCTRL_REG, reg);
timeout = 3000;
do {
if (timeout-- == 0) {
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/clk.h`, `linux/delay.h`, `linux/export.h`, `linux/irq.h`, `linux/media-bus-format.h`, `linux/of.h`, `linux/phy/phy.h`.
- Detected declarations: `enum samsung_dsim_transfer_type`, `enum reg_idx`, `enum reg_value_idx`, `function samsung_dsim_write`, `function samsung_dsim_read`, `function samsung_dsim_wait_for_reset`, `function samsung_dsim_reset`, `function samsung_dsim_pll_find_pms`, `function samsung_dsim_set_pll`, `function samsung_dsim_enable_clock`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.