drivers/gpu/drm/adp/adp-mipi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/adp/adp-mipi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/adp/adp-mipi.c- Extension
.c- Size
- 6825 bytes
- Lines
- 278
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/component.hlinux/iopoll.hlinux/of.hlinux/platform_device.hdrm/drm_bridge.hdrm/drm_mipi_dsi.h
Detected Declarations
struct adp_mipi_drv_privatefunction adp_dsi_gen_pkt_hdr_writefunction adp_dsi_writefunction adp_dsi_readfunction adp_dsi_host_transferfunction adp_dsi_bindfunction adp_dsi_unbindfunction adp_dsi_host_attachfunction adp_dsi_host_detachfunction adp_dsi_bridge_attachfunction adp_mipi_probefunction adp_mipi_remove
Annotated Snippet
struct adp_mipi_drv_private {
struct mipi_dsi_host dsi;
struct drm_bridge bridge;
struct drm_bridge *next_bridge;
void __iomem *mipi;
};
#define mipi_to_adp(x) container_of(x, struct adp_mipi_drv_private, dsi)
static int adp_dsi_gen_pkt_hdr_write(struct adp_mipi_drv_private *adp, u32 hdr_val)
{
int ret;
u32 val, mask;
ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS,
val, !(val & GEN_CMD_FULL), 1000,
CMD_PKT_STATUS_TIMEOUT_US);
if (ret) {
dev_err(adp->dsi.dev, "failed to get available command FIFO\n");
return ret;
}
writel(hdr_val, adp->mipi + DSI_GEN_HDR);
mask = GEN_CMD_EMPTY | GEN_PLD_W_EMPTY;
ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS,
val, (val & mask) == mask,
1000, CMD_PKT_STATUS_TIMEOUT_US);
if (ret) {
dev_err(adp->dsi.dev, "failed to write command FIFO\n");
return ret;
}
return 0;
}
static int adp_dsi_write(struct adp_mipi_drv_private *adp,
const struct mipi_dsi_packet *packet)
{
const u8 *tx_buf = packet->payload;
int len = packet->payload_length, pld_data_bytes = sizeof(u32), ret;
__le32 word;
u32 val;
while (len) {
if (len < pld_data_bytes) {
word = 0;
memcpy(&word, tx_buf, len);
writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA);
len = 0;
} else {
memcpy(&word, tx_buf, pld_data_bytes);
writel(le32_to_cpu(word), adp->mipi + DSI_GEN_PLD_DATA);
tx_buf += pld_data_bytes;
len -= pld_data_bytes;
}
ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS,
val, !(val & GEN_PLD_W_FULL), 1000,
CMD_PKT_STATUS_TIMEOUT_US);
if (ret) {
dev_err(adp->dsi.dev,
"failed to get available write payload FIFO\n");
return ret;
}
}
word = 0;
memcpy(&word, packet->header, sizeof(packet->header));
return adp_dsi_gen_pkt_hdr_write(adp, le32_to_cpu(word));
}
static int adp_dsi_read(struct adp_mipi_drv_private *adp,
const struct mipi_dsi_msg *msg)
{
int i, j, ret, len = msg->rx_len;
u8 *buf = msg->rx_buf;
u32 val;
/* Wait end of the read operation */
ret = readl_poll_timeout(adp->mipi + DSI_CMD_PKT_STATUS,
val, !(val & GEN_RD_CMD_BUSY),
1000, CMD_PKT_STATUS_TIMEOUT_US);
if (ret) {
dev_err(adp->dsi.dev, "Timeout during read operation\n");
return ret;
}
for (i = 0; i < len; i += 4) {
/* Read fifo must not be empty before all bytes are read */
Annotation
- Immediate include surface: `linux/component.h`, `linux/iopoll.h`, `linux/of.h`, `linux/platform_device.h`, `drm/drm_bridge.h`, `drm/drm_mipi_dsi.h`.
- Detected declarations: `struct adp_mipi_drv_private`, `function adp_dsi_gen_pkt_hdr_write`, `function adp_dsi_write`, `function adp_dsi_read`, `function adp_dsi_host_transfer`, `function adp_dsi_bind`, `function adp_dsi_unbind`, `function adp_dsi_host_attach`, `function adp_dsi_host_detach`, `function adp_dsi_bridge_attach`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.