According to the Arm ARM (DDI 0487 L.b), ASICCTL is implemented only
when CTIDEVID.EXTMUXNUM is non-zero.
Based on CTIDEVID.EXTMUXNUM, add a flag 'asicctl_impl' to indicate
whether the register is implemented, and access ASICCTL conditionally
based on the flag.
Allow the sysfs node to be visible only when the register is
implemented.
Reviewed-by: Mike Leach <mike.leach@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260226-arm_coresight_cti_refactor_v1-v2-3-b30fada3cfec@arm.com
/* other regs */
writel_relaxed(config->ctigate, drvdata->base + CTIGATE);
- writel_relaxed(config->asicctl, drvdata->base + ASICCTL);
+ if (config->asicctl_impl)
+ writel_relaxed(config->asicctl, drvdata->base + ASICCTL);
writel_relaxed(config->ctiappset, drvdata->base + CTIAPPSET);
/* re-enable CTI */
config->trig_filter_enable = true;
config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0);
config->enable_req_count = 0;
+
+ config->asicctl_impl = !!FIELD_GET(GENMASK(4, 0), devid);
}
/*
NULL,
};
+static umode_t coresight_cti_regs_is_visible(struct kobject *kobj,
+ struct attribute *attr, int idx)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+
+ if (attr == &dev_attr_asicctl.attr && !drvdata->config.asicctl_impl)
+ return 0;
+
+ return attr->mode;
+}
+
/* CTI channel x-trigger programming */
static int
cti_trig_op_parse(struct device *dev, enum cti_chan_op op,
static const struct attribute_group coresight_cti_regs_group = {
.attrs = coresight_cti_regs_attrs,
+ .is_visible = coresight_cti_regs_is_visible,
.name = "regs",
};
* @nr_trig_max: Max number of trigger signals implemented on device.
* (max of trig_in or trig_out) - from ID register.
* @nr_ctm_channels: number of available CTM channels - from ID register.
+ * @asicctl_impl: true if asicctl is implemented.
* @enable_req_count: CTI is enabled alongside >=1 associated devices.
* @hw_enabled: true if hw is currently enabled.
* @hw_powered: true if associated cpu powered on, or no cpu.
/* hardware description */
int nr_ctm_channels;
int nr_trig_max;
+ bool asicctl_impl;
/* cti enable control */
int enable_req_count;