drivers/gpu/drm/meson/meson_dw_mipi_dsi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/meson/meson_dw_mipi_dsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/meson/meson_dw_mipi_dsi.c- Extension
.c- Size
- 9816 bytes
- Lines
- 357
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/of_graph.hlinux/platform_device.hlinux/reset.hlinux/phy/phy.hlinux/bitfield.hvideo/mipi_display.hdrm/bridge/dw_mipi_dsi.hdrm/drm_mipi_dsi.hdrm/drm_atomic_helper.hdrm/drm_device.hdrm/drm_probe_helper.hdrm/drm_print.hmeson_drv.hmeson_dw_mipi_dsi.hmeson_registers.hmeson_venc.h
Detected Declarations
struct meson_dw_mipi_dsifunction meson_dw_mipi_dsi_hw_initfunction dw_mipi_dsi_phy_initfunction dw_mipi_dsi_phy_power_onfunction dw_mipi_dsi_phy_power_offfunction dw_mipi_dsi_get_lane_mbpsfunction dw_mipi_dsi_phy_get_timingfunction dw_mipi_dsi_get_esc_clk_ratefunction meson_dw_mipi_dsi_host_attachfunction meson_dw_mipi_dsi_host_detachfunction meson_dw_mipi_dsi_probefunction meson_dw_mipi_dsi_remove
Annotated Snippet
struct meson_dw_mipi_dsi {
struct meson_drm *priv;
struct device *dev;
void __iomem *base;
struct phy *phy;
union phy_configure_opts phy_opts;
struct dw_mipi_dsi *dmd;
struct dw_mipi_dsi_plat_data pdata;
struct mipi_dsi_device *dsi_device;
const struct drm_display_mode *mode;
struct clk *bit_clk;
struct clk *px_clk;
struct reset_control *top_rst;
};
#define encoder_to_meson_dw_mipi_dsi(x) \
container_of(x, struct meson_dw_mipi_dsi, encoder)
static void meson_dw_mipi_dsi_hw_init(struct meson_dw_mipi_dsi *mipi_dsi)
{
/* Software reset */
writel_bits_relaxed(MIPI_DSI_TOP_SW_RESET_DWC | MIPI_DSI_TOP_SW_RESET_INTR |
MIPI_DSI_TOP_SW_RESET_DPI | MIPI_DSI_TOP_SW_RESET_TIMING,
MIPI_DSI_TOP_SW_RESET_DWC | MIPI_DSI_TOP_SW_RESET_INTR |
MIPI_DSI_TOP_SW_RESET_DPI | MIPI_DSI_TOP_SW_RESET_TIMING,
mipi_dsi->base + MIPI_DSI_TOP_SW_RESET);
writel_bits_relaxed(MIPI_DSI_TOP_SW_RESET_DWC | MIPI_DSI_TOP_SW_RESET_INTR |
MIPI_DSI_TOP_SW_RESET_DPI | MIPI_DSI_TOP_SW_RESET_TIMING,
0, mipi_dsi->base + MIPI_DSI_TOP_SW_RESET);
/* Enable clocks */
writel_bits_relaxed(MIPI_DSI_TOP_CLK_SYSCLK_EN | MIPI_DSI_TOP_CLK_PIXCLK_EN,
MIPI_DSI_TOP_CLK_SYSCLK_EN | MIPI_DSI_TOP_CLK_PIXCLK_EN,
mipi_dsi->base + MIPI_DSI_TOP_CLK_CNTL);
/* Take memory out of power down */
writel_relaxed(0, mipi_dsi->base + MIPI_DSI_TOP_MEM_PD);
}
static int dw_mipi_dsi_phy_init(void *priv_data)
{
struct meson_dw_mipi_dsi *mipi_dsi = priv_data;
unsigned int dpi_data_format, venc_data_width;
int ret;
/* Set the bit clock rate to hs_clk_rate */
ret = clk_set_rate(mipi_dsi->bit_clk,
mipi_dsi->phy_opts.mipi_dphy.hs_clk_rate);
if (ret) {
dev_err(mipi_dsi->dev, "Failed to set DSI Bit clock rate %lu (ret %d)\n",
mipi_dsi->phy_opts.mipi_dphy.hs_clk_rate, ret);
return ret;
}
/* Make sure the rate of the bit clock is not modified by someone else */
ret = clk_rate_exclusive_get(mipi_dsi->bit_clk);
if (ret) {
dev_err(mipi_dsi->dev,
"Failed to set the exclusivity on the bit clock rate (ret %d)\n", ret);
return ret;
}
clk_disable_unprepare(mipi_dsi->px_clk);
ret = clk_set_rate(mipi_dsi->px_clk, mipi_dsi->mode->clock * 1000);
if (ret) {
dev_err(mipi_dsi->dev, "Failed to set DSI Pixel clock rate %u (%d)\n",
mipi_dsi->mode->clock * 1000, ret);
return ret;
}
ret = clk_prepare_enable(mipi_dsi->px_clk);
if (ret) {
dev_err(mipi_dsi->dev, "Failed to enable DSI Pixel clock (ret %d)\n", ret);
return ret;
}
switch (mipi_dsi->dsi_device->format) {
case MIPI_DSI_FMT_RGB888:
dpi_data_format = DPI_COLOR_24BIT;
venc_data_width = VENC_IN_COLOR_24B;
break;
case MIPI_DSI_FMT_RGB666:
dpi_data_format = DPI_COLOR_18BIT_CFG_2;
venc_data_width = VENC_IN_COLOR_18B;
break;
default:
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of_graph.h`, `linux/platform_device.h`, `linux/reset.h`, `linux/phy/phy.h`.
- Detected declarations: `struct meson_dw_mipi_dsi`, `function meson_dw_mipi_dsi_hw_init`, `function dw_mipi_dsi_phy_init`, `function dw_mipi_dsi_phy_power_on`, `function dw_mipi_dsi_phy_power_off`, `function dw_mipi_dsi_get_lane_mbps`, `function dw_mipi_dsi_phy_get_timing`, `function dw_mipi_dsi_get_esc_clk_rate`, `function meson_dw_mipi_dsi_host_attach`, `function meson_dw_mipi_dsi_host_detach`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.