static void __tpiu_disable_to_sdc_swdtrc(struct tpiu_drvdata *drvdata) { __tpiu_disable(drvdata); __tpiu_disable_to_sdc(drvdata); clk_disable_unprepare(drvdata->clk); }
static void __tpiu_disable_to_sdc_trace(struct tpiu_drvdata *drvdata) { /* sdc mode needs to be disabled only when tracing is enabled */ if (!drvdata->enable) return; __tpiu_disable(drvdata); __tpiu_disable_to_sdc(drvdata); }
static ssize_t tpiu_store_out_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct tpiu_drvdata *drvdata = dev_get_drvdata(dev->parent); char str[10] = ""; int ret; if (strlen(buf) >= 10) return -EINVAL; if (sscanf(buf, "%s", str) != 1) return -EINVAL; mutex_lock(&drvdata->mutex); if (!strcmp(str, "mictor")) { if (drvdata->out_mode == TPIU_OUT_MODE_MICTOR) goto out; if (!drvdata->enable) { drvdata->out_mode = TPIU_OUT_MODE_MICTOR; goto out; } __tpiu_disable_to_sdc(drvdata); ret = __tpiu_enable_to_mictor(drvdata); if (ret) { dev_err(drvdata->dev, "failed to enable mictor\n"); goto err; } drvdata->out_mode = TPIU_OUT_MODE_MICTOR; } else if (!strcmp(str, "sdc")) { if (drvdata->out_mode == TPIU_OUT_MODE_SDC) goto out; if (!drvdata->enable) { drvdata->out_mode = TPIU_OUT_MODE_SDC; goto out; } __tpiu_disable_to_mictor(drvdata); ret = __tpiu_enable_to_sdc(drvdata); if (ret) { dev_err(drvdata->dev, "failed to enable sdc\n"); goto err; } drvdata->out_mode = TPIU_OUT_MODE_SDC; } out: mutex_unlock(&drvdata->mutex); return size; err: mutex_unlock(&drvdata->mutex); return ret; }
static void tpiu_disable(struct coresight_device *csdev) { struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); mutex_lock(&drvdata->mutex); if (drvdata->out_mode == TPIU_OUT_MODE_MICTOR) __tpiu_disable_to_mictor(drvdata); else __tpiu_disable_to_sdc(drvdata); drvdata->enable = false; mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); dev_info(drvdata->dev, "TPIU disabled\n"); }