static ssize_t stm_store_stm_en(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent);
	uint32_t val;
	int ret = 0;

	if (sscanf(buf, "%x", &val) != 1)
		return -EINVAL;

	if (val) {
		exynos_etb_stm();
		spin_lock(&drvdata->spinlock);
		__stm_enable(drvdata);
		drvdata->enable = true;
		spin_unlock(&drvdata->spinlock);
	} else {
		spin_lock(&drvdata->spinlock);
		__stm_disable(drvdata);
		drvdata->enable = false;
		spin_unlock(&drvdata->spinlock);

		/* Wait for 100ms so that pending data has been written to HW */
		msleep(100);
	}

	if (ret)
		return ret;
	return size;
}
static void stm_disable(struct coresight_device *csdev)
{
	struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);

	spin_lock(&drvdata->spinlock);
	__stm_disable(drvdata);
	drvdata->enable = false;
	spin_unlock(&drvdata->spinlock);

	/* Wait for 100ms so that pending data has been written to HW */
	msleep(100);

	dev_info(drvdata->dev, "STM tracing disabled\n");
}
static void stm_disable(struct coresight_device *csdev)
{
	struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);

	spin_lock(&drvdata->spinlock);
	__stm_disable(drvdata);
	drvdata->enable = false;
	spin_unlock(&drvdata->spinlock);

	/*                                                            */
	msleep(100);

	clk_disable_unprepare(drvdata->clk);

	dev_info(drvdata->dev, "STM tracing disabled\n");
}