Thanks
Jinlong Mao
> > +
> > +static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
> > +{
> > + struct device *dev = &adev->dev;
> > + struct coresight_platform_data *pdata;
> > + struct tpdm_drvdata *drvdata;
> > + struct coresight_desc desc = { 0 };
> > +
> > + desc.name = coresight_alloc_device_name(&tpdm_devs, dev);
> > + if (!desc.name)
> > + return -ENOMEM;
> > + pdata = coresight_get_platform_data(dev);
> > + if (IS_ERR(pdata))
> > + return PTR_ERR(pdata);
> > + adev->dev.platform_data = pdata;
> > +
> > + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> > + if (!drvdata)
> > + return -ENOMEM;
> > + drvdata->dev = &adev->dev;
> > + dev_set_drvdata(dev, drvdata);
> > +
> > + drvdata->base = devm_ioremap_resource(dev, &adev->res);
> > + if (!drvdata->base)
> > + return -ENOMEM;
> > +
> > + mutex_init(&drvdata->lock);
> > +
> > + desc.type = CORESIGHT_DEV_TYPE_SOURCE;
> > + desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SYS;
> > + desc.ops = &tpdm_cs_ops;
> > + desc.pdata = adev->dev.platform_data;
> > + desc.dev = &adev->dev;
> > + drvdata->csdev = coresight_register(&desc);
> > + if (IS_ERR(drvdata->csdev))
> > + return PTR_ERR(drvdata->csdev);
> > +
> > + tpdm_init_default_data(drvdata);
> > + pm_runtime_put(&adev->dev);
> > +
> > + return 0;
> > +}
> > +
> > +static void __exit tpdm_remove(struct amba_device *adev)
> > +{
> > + struct tpdm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
> > +
> > + coresight_unregister(drvdata->csdev);
> > +}
> > +
> > +static struct amba_id tpdm_ids[] = {
> > + {
> > + .id = 0x000f0e00,
> > + .mask = 0x000fff00,
> > + },
> > + { 0, 0},
> > +};
> > +
> > +static struct amba_driver tpdm_driver = {
> > + .drv = {
> > + .name = "coresight-tpdm",
> > + .owner = THIS_MODULE,
> > + .suppress_bind_attrs = true,
> > + },
> > + .probe = tpdm_probe,
> > + .id_table = tpdm_ids,
> > +};
> > +
> > +module_amba_driver(tpdm_driver);
> > +
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_DESCRIPTION("Trace, Profiling & Diagnostic Monitor driver");
> > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.h b/drivers/hwtracing/coresight/coresight-tpdm.h
> > new file mode 100644
> > index 000000000000..980ae90ff1c8
> > --- /dev/null
> > +++ b/drivers/hwtracing/coresight/coresight-tpdm.h
> > @@ -0,0 +1,31 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
> > + */
> > +
> > +#ifndef _CORESIGHT_CORESIGHT_TPDM_H
> > +#define _CORESIGHT_CORESIGHT_TPDM_H
> > +
> > +/* Default value of the traceid */
> > +#define TPDM_TRACE_ID_START 128
> > +
> > +/**
> > + * struct tpdm_drvdata - specifics associated to an TPDM component
> > + * @base: memory mapped base address for this component.
> > + * @dev: The device entity associated to this component.
> > + * @csdev: component vitals needed by the framework.
> > + * @lock: lock for the enable value.
> > + * @enable: enable status of the component.
> > + * @traceid: value of the current ID for this component.
> > + */
> > +
> > +struct tpdm_drvdata {
> > + void __iomem *base;
> > + struct device *dev;
> > + struct coresight_device *csdev;
> > + struct mutex lock;
> > + bool enable;
> > + int traceid;
> > +};
> > +
> > +#endif /* _CORESIGHT_CORESIGHT_TPDM_H */
> > diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> > index 93a2922b7653..e48d463be63b 100644
> > --- a/include/linux/coresight.h
> > +++ b/include/linux/coresight.h
> > @@ -65,6 +65,7 @@ enum coresight_dev_subtype_source {
> > CORESIGHT_DEV_SUBTYPE_SOURCE_PROC,
> > CORESIGHT_DEV_SUBTYPE_SOURCE_BUS,
> > CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE,
> > + CORESIGHT_DEV_SUBTYPE_SOURCE_SYS,
> > };
> >
> > enum coresight_dev_subtype_helper {
> > --
> > 2.17.1
> >
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK