drivers/gpu/drm/imx/dc/dc-cf.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imx/dc/dc-cf.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/imx/dc/dc-cf.c
Extension
.c
Size
3879 bytes
Lines
173
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2024 NXP
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/component.h>
#include <linux/ioport.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#include "dc-drv.h"
#include "dc-pe.h"

#define STATICCONTROL		0x8

#define FRAMEDIMENSIONS		0xc
#define  HEIGHT(x)		FIELD_PREP(GENMASK(29, 16), ((x) - 1))
#define  WIDTH(x)		FIELD_PREP(GENMASK(13, 0), ((x) - 1))

#define CONSTANTCOLOR		0x10
#define  BLUE(x)		FIELD_PREP(GENMASK(15, 8), (x))

static const struct dc_subdev_info dc_cf_info[] = {
	{ .reg_start = 0x56180960, .id = 0, },
	{ .reg_start = 0x561809e0, .id = 1, },
	{ .reg_start = 0x561809a0, .id = 4, },
	{ .reg_start = 0x56180a20, .id = 5, },
};

static const struct regmap_range dc_cf_regmap_ranges[] = {
	regmap_reg_range(STATICCONTROL, CONSTANTCOLOR),
};

static const struct regmap_access_table dc_cf_regmap_access_table = {
	.yes_ranges = dc_cf_regmap_ranges,
	.n_yes_ranges = ARRAY_SIZE(dc_cf_regmap_ranges),
};

static const struct regmap_config dc_cf_cfg_regmap_config = {
	.name = "cfg",
	.reg_bits = 32,
	.reg_stride = 4,
	.val_bits = 32,
	.fast_io = true,
	.wr_table = &dc_cf_regmap_access_table,
	.rd_table = &dc_cf_regmap_access_table,
	.max_register = CONSTANTCOLOR,
};

static inline void dc_cf_enable_shden(struct dc_cf *cf)
{
	regmap_write(cf->reg_cfg, STATICCONTROL, SHDEN);
}

enum dc_link_id dc_cf_get_link_id(struct dc_cf *cf)
{
	return cf->link;
}

void dc_cf_framedimensions(struct dc_cf *cf, unsigned int w,
			   unsigned int h)
{
	regmap_write(cf->reg_cfg, FRAMEDIMENSIONS, WIDTH(w) | HEIGHT(h));
}

void dc_cf_constantcolor_black(struct dc_cf *cf)
{
	regmap_write(cf->reg_cfg, CONSTANTCOLOR, 0);
}

void dc_cf_constantcolor_blue(struct dc_cf *cf)
{
	regmap_write(cf->reg_cfg, CONSTANTCOLOR, BLUE(0xff));
}

void dc_cf_init(struct dc_cf *cf)
{
	dc_cf_enable_shden(cf);
}

static int dc_cf_bind(struct device *dev, struct device *master, void *data)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct dc_drm_device *dc_drm = data;
	struct resource *res_pec;
	void __iomem *base_cfg;

Annotation

Implementation Notes