Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04dbc4c3 authored by Mao Jinlong's avatar Mao Jinlong Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarMao Jinlong <jinlmao@codeaurora.org>
parent 17d718ca
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011-2015, 2020 The Linux Foundation. All rights reserved.
 */

#include <linux/amba/bus.h>
@@ -84,6 +84,18 @@ static int dynamic_replicator_enable(struct replicator_state *drvdata,
	return rc;
}

static bool is_replicator_disabled(struct coresight_device *csdev)
{
	int i;

	for (i = 0; i < csdev->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)
{
@@ -93,6 +105,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))
		replicator_reset(drvdata);

	if (atomic_read(&csdev->refcnt[outport]) == 0) {
		rc = dynamic_replicator_enable(drvdata, inport, outport);
		if (!rc)