drivers/gpu/drm/bridge/tc358762.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/bridge/tc358762.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/bridge/tc358762.c- Extension
.c- Size
- 8486 bytes
- Lines
- 334
- 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/delay.hlinux/gpio/consumer.hlinux/mod_devicetable.hlinux/module.hlinux/of_graph.hlinux/regulator/consumer.hvideo/mipi_display.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_crtc.hdrm/drm_mipi_dsi.hdrm/drm_of.hdrm/drm_print.hdrm/drm_probe_helper.h
Detected Declarations
struct tc358762function tc358762_clear_errorfunction tc358762_writefunction tc358762_initfunction tc358762_post_disablefunction tc358762_pre_enablefunction tc358762_enablefunction tc358762_attachfunction tc358762_bridge_mode_setfunction tc358762_parse_dtfunction tc358762_configure_regulatorsfunction tc358762_probefunction tc358762_remove
Annotated Snippet
struct tc358762 {
struct device *dev;
struct drm_bridge bridge;
struct regulator *regulator;
struct drm_bridge *panel_bridge;
struct gpio_desc *reset_gpio;
struct drm_display_mode mode;
bool pre_enabled;
int error;
};
static int tc358762_clear_error(struct tc358762 *ctx)
{
int ret = ctx->error;
ctx->error = 0;
return ret;
}
static void tc358762_write(struct tc358762 *ctx, u16 addr, u32 val)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
ssize_t ret;
u8 data[6];
if (ctx->error)
return;
data[0] = addr;
data[1] = addr >> 8;
data[2] = val;
data[3] = val >> 8;
data[4] = val >> 16;
data[5] = val >> 24;
ret = mipi_dsi_generic_write(dsi, data, sizeof(data));
if (ret < 0)
ctx->error = ret;
}
static inline struct tc358762 *bridge_to_tc358762(struct drm_bridge *bridge)
{
return container_of(bridge, struct tc358762, bridge);
}
static int tc358762_init(struct tc358762 *ctx)
{
u32 lcdctrl;
tc358762_write(ctx, DSI_LANEENABLE,
LANEENABLE_L0EN | LANEENABLE_CLEN);
tc358762_write(ctx, PPI_D0S_CLRSIPOCOUNT, 5);
tc358762_write(ctx, PPI_D1S_CLRSIPOCOUNT, 5);
tc358762_write(ctx, PPI_D0S_ATMR, 0);
tc358762_write(ctx, PPI_D1S_ATMR, 0);
tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD);
tc358762_write(ctx, SPICMR, 0x00);
lcdctrl = LCDCTRL_VSDELAY(1) | LCDCTRL_RGB888 |
LCDCTRL_UNK6 | LCDCTRL_VTGEN;
if (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC)
lcdctrl |= LCDCTRL_HSPOL;
if (ctx->mode.flags & DRM_MODE_FLAG_NVSYNC)
lcdctrl |= LCDCTRL_VSPOL;
tc358762_write(ctx, LCDCTRL, lcdctrl);
tc358762_write(ctx, SYSCTRL, 0x040f);
msleep(100);
tc358762_write(ctx, PPI_STARTPPI, PPI_START_FUNCTION);
tc358762_write(ctx, DSI_STARTDSI, DSI_RX_START);
msleep(100);
return tc358762_clear_error(ctx);
}
static void tc358762_post_disable(struct drm_bridge *bridge,
struct drm_atomic_commit *state)
{
struct tc358762 *ctx = bridge_to_tc358762(bridge);
int ret;
/*
* The post_disable hook might be called multiple times.
* We want to avoid regulator imbalance below.
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of_graph.h`, `linux/regulator/consumer.h`, `video/mipi_display.h`, `drm/drm_atomic_helper.h`.
- Detected declarations: `struct tc358762`, `function tc358762_clear_error`, `function tc358762_write`, `function tc358762_init`, `function tc358762_post_disable`, `function tc358762_pre_enable`, `function tc358762_enable`, `function tc358762_attach`, `function tc358762_bridge_mode_set`, `function tc358762_parse_dt`.
- 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.