Loading drivers/coresight/coresight-cti.c +98 −45 Original line number Original line Diff line number Diff line /* Copyright (c) 2013, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -96,32 +96,21 @@ static int cti_verify_channel_bound(int ch) return 0; return 0; } } static int cti_enable(struct cti_drvdata *drvdata) static void cti_enable(struct cti_drvdata *drvdata) { { int ret; ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); cti_writel(drvdata, 0x1, CTICONTROL); cti_writel(drvdata, 0x1, CTICONTROL); CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } static int __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) { { uint32_t ctien; uint32_t ctien; int ret; if (drvdata->refcnt == 0) { if (drvdata->refcnt == 0) ret = cti_enable(drvdata); cti_enable(drvdata); if (ret) return ret; } CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); Loading @@ -133,10 +122,8 @@ static int __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) CTI_LOCK(drvdata); CTI_LOCK(drvdata); drvdata->refcnt++; drvdata->refcnt++; return 0; out: out: CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) Loading @@ -155,23 +142,25 @@ int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_map_trigin(drvdata, trig, ch); __cti_map_trigin(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); return ret; clk_disable_unprepare(drvdata->clk); return 0; } } EXPORT_SYMBOL(coresight_cti_map_trigin); EXPORT_SYMBOL(coresight_cti_map_trigin); static int __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) { { uint32_t ctien; uint32_t ctien; int ret; if (drvdata->refcnt == 0) { if (drvdata->refcnt == 0) ret = cti_enable(drvdata); cti_enable(drvdata); if (ret) return ret; } CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); Loading @@ -183,10 +172,8 @@ static int __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) CTI_LOCK(drvdata); CTI_LOCK(drvdata); drvdata->refcnt++; drvdata->refcnt++; return 0; out: out: CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) Loading @@ -205,10 +192,16 @@ int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_map_trigout(drvdata, trig, ch); __cti_map_trigout(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); return ret; clk_disable_unprepare(drvdata->clk); return 0; } } EXPORT_SYMBOL(coresight_cti_map_trigout); EXPORT_SYMBOL(coresight_cti_map_trigout); Loading @@ -223,8 +216,6 @@ static void cti_disable(struct cti_drvdata *drvdata) cti_writel(drvdata, 0x0, CTICONTROL); cti_writel(drvdata, 0x0, CTICONTROL); CTI_LOCK(drvdata); CTI_LOCK(drvdata); clk_disable_unprepare(drvdata->clk); } } static void __cti_unmap_trigin(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_unmap_trigin(struct cti_drvdata *drvdata, int trig, int ch) Loading Loading @@ -262,10 +253,14 @@ void coresight_cti_unmap_trigin(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_unmap_trigin(drvdata, trig, ch); __cti_unmap_trigin(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_unmap_trigin); EXPORT_SYMBOL(coresight_cti_unmap_trigin); Loading Loading @@ -304,9 +299,14 @@ void coresight_cti_unmap_trigout(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_unmap_trigout(drvdata, trig, ch); __cti_unmap_trigout(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_unmap_trigout); EXPORT_SYMBOL(coresight_cti_unmap_trigout); Loading Loading @@ -339,9 +339,14 @@ void coresight_cti_reset(struct coresight_cti *cti) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_reset(drvdata); __cti_reset(drvdata); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_reset); EXPORT_SYMBOL(coresight_cti_reset); Loading Loading @@ -372,9 +377,15 @@ int coresight_cti_set_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_set_trig(drvdata, ch); ret = __cti_set_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_set_trig); EXPORT_SYMBOL(coresight_cti_set_trig); Loading Loading @@ -402,9 +413,14 @@ void coresight_cti_clear_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_clear_trig(drvdata, ch); __cti_clear_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_clear_trig); EXPORT_SYMBOL(coresight_cti_clear_trig); Loading Loading @@ -435,9 +451,15 @@ int coresight_cti_pulse_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_pulse_trig(drvdata, ch); ret = __cti_pulse_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_pulse_trig); EXPORT_SYMBOL(coresight_cti_pulse_trig); Loading Loading @@ -472,9 +494,15 @@ int coresight_cti_enable_gate(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_enable_gate(drvdata, ch); ret = __cti_enable_gate(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_enable_gate); EXPORT_SYMBOL(coresight_cti_enable_gate); Loading Loading @@ -505,9 +533,14 @@ void coresight_cti_disable_gate(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_disable_gate(drvdata, ch); __cti_disable_gate(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_disable_gate); EXPORT_SYMBOL(coresight_cti_disable_gate); Loading Loading @@ -543,7 +576,10 @@ static ssize_t cti_show_trigin(struct device *dev, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { ctien = cti_readl(drvdata, CTIINEN(trig)); ctien = cti_readl(drvdata, CTIINEN(trig)); Loading @@ -557,13 +593,15 @@ static ssize_t cti_show_trigin(struct device *dev, 1, " %#lx %#lx,", trig, ch); 1, " %#lx %#lx,", trig, ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading @@ -580,7 +618,10 @@ static ssize_t cti_show_trigout(struct device *dev, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { ctien = cti_readl(drvdata, CTIOUTEN(trig)); ctien = cti_readl(drvdata, CTIOUTEN(trig)); Loading @@ -594,13 +635,15 @@ static ssize_t cti_show_trigout(struct device *dev, 1, " %#lx %#lx,", trig, ch); 1, " %#lx %#lx,", trig, ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading Loading @@ -705,7 +748,10 @@ static ssize_t cti_show_trig(struct device *dev, struct device_attribute *attr, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; ctiset = cti_readl(drvdata, CTIAPPSET); ctiset = cti_readl(drvdata, CTIAPPSET); for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { Loading @@ -718,12 +764,14 @@ static ssize_t cti_show_trig(struct device *dev, struct device_attribute *attr, 1, " %#lx,", ch); 1, " %#lx,", ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading Loading @@ -794,7 +842,10 @@ static ssize_t cti_show_gate(struct device *dev, struct device_attribute *attr, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; ctigate = cti_readl(drvdata, CTIGATE); ctigate = cti_readl(drvdata, CTIGATE); for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { Loading @@ -807,12 +858,14 @@ static ssize_t cti_show_gate(struct device *dev, struct device_attribute *attr, 1, " %#lx,", ch); 1, " %#lx,", ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading Loading
drivers/coresight/coresight-cti.c +98 −45 Original line number Original line Diff line number Diff line /* Copyright (c) 2013, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -96,32 +96,21 @@ static int cti_verify_channel_bound(int ch) return 0; return 0; } } static int cti_enable(struct cti_drvdata *drvdata) static void cti_enable(struct cti_drvdata *drvdata) { { int ret; ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); cti_writel(drvdata, 0x1, CTICONTROL); cti_writel(drvdata, 0x1, CTICONTROL); CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } static int __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) { { uint32_t ctien; uint32_t ctien; int ret; if (drvdata->refcnt == 0) { if (drvdata->refcnt == 0) ret = cti_enable(drvdata); cti_enable(drvdata); if (ret) return ret; } CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); Loading @@ -133,10 +122,8 @@ static int __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) CTI_LOCK(drvdata); CTI_LOCK(drvdata); drvdata->refcnt++; drvdata->refcnt++; return 0; out: out: CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) Loading @@ -155,23 +142,25 @@ int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_map_trigin(drvdata, trig, ch); __cti_map_trigin(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); return ret; clk_disable_unprepare(drvdata->clk); return 0; } } EXPORT_SYMBOL(coresight_cti_map_trigin); EXPORT_SYMBOL(coresight_cti_map_trigin); static int __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) { { uint32_t ctien; uint32_t ctien; int ret; if (drvdata->refcnt == 0) { if (drvdata->refcnt == 0) ret = cti_enable(drvdata); cti_enable(drvdata); if (ret) return ret; } CTI_UNLOCK(drvdata); CTI_UNLOCK(drvdata); Loading @@ -183,10 +172,8 @@ static int __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) CTI_LOCK(drvdata); CTI_LOCK(drvdata); drvdata->refcnt++; drvdata->refcnt++; return 0; out: out: CTI_LOCK(drvdata); CTI_LOCK(drvdata); return 0; } } int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) Loading @@ -205,10 +192,16 @@ int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_map_trigout(drvdata, trig, ch); __cti_map_trigout(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); return ret; clk_disable_unprepare(drvdata->clk); return 0; } } EXPORT_SYMBOL(coresight_cti_map_trigout); EXPORT_SYMBOL(coresight_cti_map_trigout); Loading @@ -223,8 +216,6 @@ static void cti_disable(struct cti_drvdata *drvdata) cti_writel(drvdata, 0x0, CTICONTROL); cti_writel(drvdata, 0x0, CTICONTROL); CTI_LOCK(drvdata); CTI_LOCK(drvdata); clk_disable_unprepare(drvdata->clk); } } static void __cti_unmap_trigin(struct cti_drvdata *drvdata, int trig, int ch) static void __cti_unmap_trigin(struct cti_drvdata *drvdata, int trig, int ch) Loading Loading @@ -262,10 +253,14 @@ void coresight_cti_unmap_trigin(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_unmap_trigin(drvdata, trig, ch); __cti_unmap_trigin(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_unmap_trigin); EXPORT_SYMBOL(coresight_cti_unmap_trigin); Loading Loading @@ -304,9 +299,14 @@ void coresight_cti_unmap_trigout(struct coresight_cti *cti, int trig, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_unmap_trigout(drvdata, trig, ch); __cti_unmap_trigout(drvdata, trig, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_unmap_trigout); EXPORT_SYMBOL(coresight_cti_unmap_trigout); Loading Loading @@ -339,9 +339,14 @@ void coresight_cti_reset(struct coresight_cti *cti) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_reset(drvdata); __cti_reset(drvdata); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_reset); EXPORT_SYMBOL(coresight_cti_reset); Loading Loading @@ -372,9 +377,15 @@ int coresight_cti_set_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_set_trig(drvdata, ch); ret = __cti_set_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_set_trig); EXPORT_SYMBOL(coresight_cti_set_trig); Loading Loading @@ -402,9 +413,14 @@ void coresight_cti_clear_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_clear_trig(drvdata, ch); __cti_clear_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_clear_trig); EXPORT_SYMBOL(coresight_cti_clear_trig); Loading Loading @@ -435,9 +451,15 @@ int coresight_cti_pulse_trig(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_pulse_trig(drvdata, ch); ret = __cti_pulse_trig(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_pulse_trig); EXPORT_SYMBOL(coresight_cti_pulse_trig); Loading Loading @@ -472,9 +494,15 @@ int coresight_cti_enable_gate(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); ret = clk_prepare_enable(drvdata->clk); if (ret) return ret; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); ret = __cti_enable_gate(drvdata, ch); ret = __cti_enable_gate(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); return ret; return ret; } } EXPORT_SYMBOL(coresight_cti_enable_gate); EXPORT_SYMBOL(coresight_cti_enable_gate); Loading Loading @@ -505,9 +533,14 @@ void coresight_cti_disable_gate(struct coresight_cti *cti, int ch) drvdata = to_cti_drvdata(cti); drvdata = to_cti_drvdata(cti); if (clk_prepare_enable(drvdata->clk)) return; mutex_lock(&drvdata->mutex); mutex_lock(&drvdata->mutex); __cti_disable_gate(drvdata, ch); __cti_disable_gate(drvdata, ch); mutex_unlock(&drvdata->mutex); mutex_unlock(&drvdata->mutex); clk_disable_unprepare(drvdata->clk); } } EXPORT_SYMBOL(coresight_cti_disable_gate); EXPORT_SYMBOL(coresight_cti_disable_gate); Loading Loading @@ -543,7 +576,10 @@ static ssize_t cti_show_trigin(struct device *dev, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { ctien = cti_readl(drvdata, CTIINEN(trig)); ctien = cti_readl(drvdata, CTIINEN(trig)); Loading @@ -557,13 +593,15 @@ static ssize_t cti_show_trigin(struct device *dev, 1, " %#lx %#lx,", trig, ch); 1, " %#lx %#lx,", trig, ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading @@ -580,7 +618,10 @@ static ssize_t cti_show_trigout(struct device *dev, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { for (trig = 0; trig < CTI_MAX_TRIGGERS; trig++) { ctien = cti_readl(drvdata, CTIOUTEN(trig)); ctien = cti_readl(drvdata, CTIOUTEN(trig)); Loading @@ -594,13 +635,15 @@ static ssize_t cti_show_trigout(struct device *dev, 1, " %#lx %#lx,", trig, ch); 1, " %#lx %#lx,", trig, ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading Loading @@ -705,7 +748,10 @@ static ssize_t cti_show_trig(struct device *dev, struct device_attribute *attr, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; ctiset = cti_readl(drvdata, CTIAPPSET); ctiset = cti_readl(drvdata, CTIAPPSET); for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { Loading @@ -718,12 +764,14 @@ static ssize_t cti_show_trig(struct device *dev, struct device_attribute *attr, 1, " %#lx,", ch); 1, " %#lx,", ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading Loading @@ -794,7 +842,10 @@ static ssize_t cti_show_gate(struct device *dev, struct device_attribute *attr, mutex_lock(&cti_lock); mutex_lock(&cti_lock); if (!drvdata->refcnt) if (!drvdata->refcnt) goto err; goto err0; if (clk_prepare_enable(drvdata->clk)) goto err0; ctigate = cti_readl(drvdata, CTIGATE); ctigate = cti_readl(drvdata, CTIGATE); for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { for (ch = 0; ch < CTI_MAX_CHANNELS; ch++) { Loading @@ -807,12 +858,14 @@ static ssize_t cti_show_gate(struct device *dev, struct device_attribute *attr, 1, " %#lx,", ch); 1, " %#lx,", ch); if (size >= PAGE_SIZE - 2) { if (size >= PAGE_SIZE - 2) { dev_err(dev, "show buffer full\n"); dev_err(dev, "show buffer full\n"); goto err; goto err1; } } } } } } err: err1: clk_disable_unprepare(drvdata->clk); err0: size += scnprintf(&buf[size], 2, "\n"); size += scnprintf(&buf[size], 2, "\n"); mutex_unlock(&cti_lock); mutex_unlock(&cti_lock); return size; return size; Loading