drivers/gpu/drm/bridge/microchip-lvds.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/microchip-lvds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/bridge/microchip-lvds.c- Extension
.c- Size
- 6317 bytes
- Lines
- 241
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/component.hlinux/delay.hlinux/jiffies.hlinux/media-bus-format.hlinux/mfd/syscon.hlinux/of_graph.hlinux/pinctrl/devinfo.hlinux/phy/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_of.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.h
Detected Declarations
struct mchp_lvdsfunction lvds_readlfunction lvds_writelfunction lvds_serialiser_onfunction mchp_lvds_attachfunction mchp_lvds_atomic_enablefunction mchp_lvds_atomic_disablefunction mchp_lvds_probe
Annotated Snippet
struct mchp_lvds {
struct device *dev;
void __iomem *regs;
struct clk *pclk;
struct drm_bridge bridge;
struct drm_bridge *panel_bridge;
};
static inline struct mchp_lvds *bridge_to_lvds(struct drm_bridge *bridge)
{
return container_of(bridge, struct mchp_lvds, bridge);
}
static inline u32 lvds_readl(struct mchp_lvds *lvds, u32 offset)
{
return readl_relaxed(lvds->regs + offset);
}
static inline void lvds_writel(struct mchp_lvds *lvds, u32 offset, u32 val)
{
writel_relaxed(val, lvds->regs + offset);
}
static void lvds_serialiser_on(struct mchp_lvds *lvds, u32 bus_format)
{
unsigned long timeout = jiffies + msecs_to_jiffies(LVDS_POLL_TIMEOUT_MS);
u8 map, pix_size;
/* The LVDSC registers can only be written if WPEN is cleared */
lvds_writel(lvds, LVDSC_WPMR, (LVDSC_WPMR_WPKEY_PSSWD &
LVDSC_WPMR_WPKEY_MASK));
/* Wait for the status of configuration registers to be changed */
while (lvds_readl(lvds, LVDSC_SR) & LVDSC_SR_CS) {
if (time_after(jiffies, timeout)) {
dev_err(lvds->dev, "%s: timeout error\n", __func__);
return;
}
usleep_range(1000, 2000);
}
switch (bus_format) {
case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
map = LVDSC_CFGR_MAPPING_JEIDA;
pix_size = LVDSC_CFGR_PIXSIZE_18BITS;
break;
case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
map = LVDSC_CFGR_MAPPING_VESA;
pix_size = LVDSC_CFGR_PIXSIZE_24BITS;
break;
default:
map = LVDSC_CFGR_MAPPING_JEIDA;
pix_size = LVDSC_CFGR_PIXSIZE_24BITS;
break;
}
/* Configure the LVDSC */
lvds_writel(lvds, LVDSC_CFGR, map | LVDSC_CFGR_DC_UNBALANCED |
LVDSC_CFGR_DEN_POL_HIGH | pix_size);
/* Enable the LVDS serializer */
lvds_writel(lvds, LVDSC_CR, LVDSC_CR_SER_EN);
}
static int mchp_lvds_attach(struct drm_bridge *bridge,
struct drm_encoder *encoder,
enum drm_bridge_attach_flags flags)
{
struct mchp_lvds *lvds = bridge_to_lvds(bridge);
return drm_bridge_attach(encoder, lvds->panel_bridge,
bridge, flags);
}
static void mchp_lvds_atomic_enable(struct drm_bridge *bridge,
struct drm_atomic_commit *state)
{
struct mchp_lvds *lvds = bridge_to_lvds(bridge);
struct drm_connector *connector;
int ret;
ret = clk_prepare_enable(lvds->pclk);
if (ret < 0) {
dev_err(lvds->dev, "failed to enable lvds pclk %d\n", ret);
return;
}
ret = pm_runtime_get_sync(lvds->dev);
if (ret < 0) {
dev_err(lvds->dev, "failed to get pm runtime: %d\n", ret);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/delay.h`, `linux/jiffies.h`, `linux/media-bus-format.h`, `linux/mfd/syscon.h`, `linux/of_graph.h`, `linux/pinctrl/devinfo.h`.
- Detected declarations: `struct mchp_lvds`, `function lvds_readl`, `function lvds_writel`, `function lvds_serialiser_on`, `function mchp_lvds_attach`, `function mchp_lvds_atomic_enable`, `function mchp_lvds_atomic_disable`, `function mchp_lvds_probe`.
- 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.