Rest replicator registers when enabling it first time

Replicator register value could be reset when it's disabled and
clock is off. Reset the register to all ports disabled when enabling
it first time to avoid all ports to be enabled by default.

Change-Id: I29973d38eb7f836fabe22757f98db62afbe6a4c3
Signed-off-by: Mao Jinlong <jinlmao@codeaurora.org>
This commit is contained in:
Mao Jinlong 2020-04-30 12:54:21 +08:00 • committed by Gerrit - the friendly Code Review server
commit 75d0b9f7e9

View file

@ -94,6 +94,18 @@ static int dynamic_replicator_enable(struct replicator_drvdata *drvdata,
return rc;
}
static bool is_replicator_disabled(struct coresight_device *csdev)
{
int i;
for (i = 0; i < csdev->pdata->nr_outport; i++) {
if (atomic_read(&csdev->refcnt[i]) > 0)
return false;
}
return true;
}
static int replicator_enable(struct coresight_device *csdev, int inport,
int outport)
{
@ -103,6 +115,10 @@ static int replicator_enable(struct coresight_device *csdev, int inport,
bool first_enable = false;
spin_lock_irqsave(&drvdata->spinlock, flags);
if (is_replicator_disabled(csdev))
dynamic_replicator_reset(drvdata);
if (atomic_read(&csdev->refcnt[outport]) == 0) {
if (drvdata->base)
rc = dynamic_replicator_enable(drvdata, inport,