drivers/hwtracing/coresight/coresight-etb10.c

Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-etb10.c

File Facts

System
Linux kernel
Corpus path
drivers/hwtracing/coresight/coresight-etb10.c
Extension
.c
Size
21655 bytes
Lines
855
Domain
Driver Families
Bucket
drivers/hwtracing
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations etb_fops = {
	.owner		= THIS_MODULE,
	.open		= etb_open,
	.read		= etb_read,
	.release	= etb_release,
};

static struct attribute *coresight_etb_mgmt_attrs[] = {
	coresight_simple_reg32(rdp, ETB_RAM_DEPTH_REG),
	coresight_simple_reg32(sts, ETB_STATUS_REG),
	coresight_simple_reg32(rrp, ETB_RAM_READ_POINTER),
	coresight_simple_reg32(rwp, ETB_RAM_WRITE_POINTER),
	coresight_simple_reg32(trg, ETB_TRG),
	coresight_simple_reg32(ctl, ETB_CTL_REG),
	coresight_simple_reg32(ffsr, ETB_FFSR),
	coresight_simple_reg32(ffcr, ETB_FFCR),
	NULL,
};

static ssize_t trigger_cntr_show(struct device *dev,
			    struct device_attribute *attr, char *buf)
{
	struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);
	unsigned long val = drvdata->trigger_cntr;

	return sprintf(buf, "%#lx\n", val);
}

static ssize_t trigger_cntr_store(struct device *dev,
			     struct device_attribute *attr,
			     const char *buf, size_t size)
{
	int ret;
	unsigned long val;
	struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent);

	ret = kstrtoul(buf, 16, &val);
	if (ret)
		return ret;

	drvdata->trigger_cntr = val;
	return size;
}
static DEVICE_ATTR_RW(trigger_cntr);

static struct attribute *coresight_etb_attrs[] = {
	&dev_attr_trigger_cntr.attr,
	NULL,
};

static const struct attribute_group coresight_etb_group = {
	.attrs = coresight_etb_attrs,
};

static const struct attribute_group coresight_etb_mgmt_group = {
	.attrs = coresight_etb_mgmt_attrs,
	.name = "mgmt",
};

static const struct attribute_group *coresight_etb_groups[] = {
	&coresight_etb_group,
	&coresight_etb_mgmt_group,
	NULL,
};

static int etb_probe(struct amba_device *adev, const struct amba_id *id)
{
	int ret;
	void __iomem *base;
	struct device *dev = &adev->dev;
	struct coresight_platform_data *pdata = NULL;
	struct etb_drvdata *drvdata;
	struct resource *res = &adev->res;
	struct coresight_desc desc = { 0 };

	desc.name = coresight_alloc_device_name("etb", dev);
	if (!desc.name)
		return -ENOMEM;

	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
	if (!drvdata)
		return -ENOMEM;

	drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
	if (IS_ERR(drvdata->atclk))
		return PTR_ERR(drvdata->atclk);

	dev_set_drvdata(dev, drvdata);

	/* validity for the resource is already checked by the AMBA core */

Annotation

Implementation Notes