guard(raw_spinlock_irqsave)(&drvdata->spinlock);
/* no need to do anything if enabled */
- if (config->hw_enabled)
+ if (cti_is_active(config))
goto cti_state_unchanged;
/* claim the device */
cti_write_all_hw_regs(drvdata);
- config->hw_enabled = true;
-
cti_state_unchanged:
drvdata->config.enable_req_count++;
return 0;
guard(raw_spinlock_irqsave)(&drvdata->spinlock);
/* don't allow negative refcounts, return an error */
- if (!drvdata->config.enable_req_count)
+ if (!cti_is_active(config))
return -EINVAL;
/* check refcount - disable on 0 */
if (--drvdata->config.enable_req_count > 0)
return 0;
- /* no need to do anything if disabled */
- if (!config->hw_enabled)
- return 0;
-
CS_UNLOCK(drvdata->base);
/* disable CTI */
writel_relaxed(0, drvdata->base + CTICONTROL);
- config->hw_enabled = false;
coresight_disclaim_device_unlocked(csdev);
CS_LOCK(drvdata->base);
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock)
- enable_req = drvdata->config.enable_req_count;
+ enable_req = cti_is_active(&drvdata->config);
return sprintf(buf, "%d\n", !!enable_req);
}
* @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.
* @trig_in_use: bitfield of in triggers registered as in use.
* @trig_out_use: bitfield of out triggers registered as in use.
* @trig_out_filter: bitfield of out triggers that are blocked if filter
/* cti enable control */
int enable_req_count;
- bool hw_enabled;
/* registered triggers and filtering */
u32 trig_in_use;
/* Check if a cti device is enabled */
static inline bool cti_is_active(struct cti_config *cfg)
{
- return cfg->hw_enabled;
+ return !!cfg->enable_req_count;
}
#endif /* _CORESIGHT_CORESIGHT_CTI_H */