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

Commit 05152ac7 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "coresight: handle error on failure to enable nidnt modes"

parents 644165e9 1127d14e
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/interrupt.h>
#include "coresight-priv.h"
#include "coresight-nidnt.h"

@@ -143,6 +144,8 @@ int coresight_nidnt_config_swoverride(enum nidnt_debug_mode mode)
		return -EPERM;

	ret = coresight_nidnt_setup_pinctrl(nidnt_drvdata, mode);
	if (ret < 0)
		return ret;

	spin_lock(&nidnt_drvdata->spinlock);

@@ -160,7 +163,7 @@ int coresight_nidnt_config_swoverride(enum nidnt_debug_mode mode)

	spin_unlock(&nidnt_drvdata->spinlock);

	return ret;
	return 0;
}
EXPORT_SYMBOL(coresight_nidnt_config_swoverride);

@@ -191,7 +194,7 @@ void coresight_nidnt_set_hwdetect_param(bool val)
}
EXPORT_SYMBOL(coresight_nidnt_set_hwdetect_param);

static int __coresight_nidnt_enable_hwdetect(struct nidnt_drvdata
static void __coresight_nidnt_enable_hwdetect(struct nidnt_drvdata
					     *nidnt_drvdata)
{
	unsigned int regval;
@@ -209,22 +212,18 @@ static int __coresight_nidnt_enable_hwdetect(struct nidnt_drvdata
	nidnt_writel(nidnt_drvdata, regval, TLMM_QDSD_TIMEOUT_VALUE_CTL);

	spin_unlock(&nidnt_drvdata->spinlock);

	return 0;
}

int coresight_nidnt_enable_hwdetect(void)
{
	int ret = 0;

	if (!nidnt_drvdata->nidnt_hwdetect_enable)
		return -EPERM;

	coresight_nidnt_config_hwdetect(nidnt_drvdata);
	/* Enable the TLMM debug mode for nidnt detect.*/
	ret = __coresight_nidnt_enable_hwdetect(nidnt_drvdata);
	__coresight_nidnt_enable_hwdetect(nidnt_drvdata);

	return ret;
	return 0;
}
EXPORT_SYMBOL(coresight_nidnt_enable_hwdetect);

+37 −9
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ static int nidnt_boot_hw_detect = 1;
module_param_named(nidnt_boot_hw_detect,
	nidnt_boot_hw_detect, int, S_IRUGO | S_IWUSR | S_IWGRP);

static void __tpiu_disable(struct tpiu_drvdata *drvdata);
static void __tpiu_disable_to_sdc(struct tpiu_drvdata *drvdata);

static void tpiu_flush_and_stop(struct tpiu_drvdata *drvdata)
{
	int count;
@@ -306,6 +309,8 @@ static int __tpiu_enable_to_sdc_trace(struct tpiu_drvdata *drvdata)

	if (drvdata->nidnthw) {
		ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_TRACE);
		if (ret)
			goto err;
	} else if (drvdata->nidnt) {
		coresight_nidnt_writel(0x16D, TLMM_SDC2_HDRV_PULL_CTL);
		coresight_nidnt_writel(1, TLMM_ETM_MODE);
@@ -314,6 +319,10 @@ static int __tpiu_enable_to_sdc_trace(struct tpiu_drvdata *drvdata)
		msm_tlmm_misc_reg_write(TLMM_ETM_MODE_REG, 1);
	}
	return 0;
err:
	__tpiu_disable(drvdata);
	__tpiu_disable_to_sdc(drvdata);
	return ret;
}

static int __tpiu_enable_to_sdc_swduart(struct tpiu_drvdata *drvdata)
@@ -330,7 +339,7 @@ static int __tpiu_enable_to_sdc_swduart(struct tpiu_drvdata *drvdata)

	ret = __tpiu_enable_to_sdc(drvdata);
	if (ret)
		goto err;
		goto err0;

	/*
	 * Required sequence to prevent SRST asserstion: set trace to
@@ -341,6 +350,8 @@ static int __tpiu_enable_to_sdc_swduart(struct tpiu_drvdata *drvdata)

	if (drvdata->nidnthw) {
		ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_SWDUART);
		if (ret)
			goto err1;
	} else if (drvdata->nidnt) {
		coresight_nidnt_writel(1, TLMM_ETM_MODE);
		/* Pull down sdc cmd line */
@@ -351,7 +362,12 @@ static int __tpiu_enable_to_sdc_swduart(struct tpiu_drvdata *drvdata)
		msm_tlmm_misc_reg_write(TLMM_SDC2_HDRV_PULL_CTL, 0x96D);
		msm_tlmm_misc_reg_write(TLMM_ETM_MODE_REG, 2);
	}
err:
	return 0;
err1:
	__tpiu_disable(drvdata);
	__tpiu_disable_to_sdc(drvdata);
err0:
	clk_disable_unprepare(drvdata->clk);
	return ret;
}

@@ -369,7 +385,7 @@ static int __tpiu_enable_to_sdc_swdtrc(struct tpiu_drvdata *drvdata)

	ret = __tpiu_enable_to_sdc(drvdata);
	if (ret)
		goto err;
		goto err0;

	/*
	 * Required sequence to prevent SRST asserstion: set trace to
@@ -380,6 +396,8 @@ static int __tpiu_enable_to_sdc_swdtrc(struct tpiu_drvdata *drvdata)

	if (drvdata->nidnthw) {
		ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_SWDTRC);
		if (ret)
			goto err1;
	} else if (drvdata->nidnt) {
		coresight_nidnt_writel(1, TLMM_ETM_MODE);
		/* Pull down sdc cmd line */
@@ -390,18 +408,25 @@ static int __tpiu_enable_to_sdc_swdtrc(struct tpiu_drvdata *drvdata)
		msm_tlmm_misc_reg_write(TLMM_SDC2_HDRV_PULL_CTL, 0x96D);
		msm_tlmm_misc_reg_write(TLMM_ETM_MODE_REG, 3);
	}
err:
err1:
	__tpiu_disable(drvdata);
	__tpiu_disable_to_sdc(drvdata);
err0:
	clk_disable_unprepare(drvdata->clk);
	return ret;
}

static int __tpiu_enable_to_sdc_jtag(struct tpiu_drvdata *drvdata)
{
	int ret = 0;

	ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_JTAG);
	int ret;

	ret = __tpiu_enable_to_sdc(drvdata);
	if (ret)
		return ret;

	ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_JTAG);
	if (ret)
		__tpiu_disable_to_sdc(drvdata);
	return ret;
}

@@ -409,10 +434,13 @@ static int __tpiu_enable_to_sdc_spmi(struct tpiu_drvdata *drvdata)
{
	int ret;

	ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_SPMI);

	ret = __tpiu_enable_to_sdc(drvdata);
	if (ret)
		return ret;

	ret = coresight_nidnt_config_swoverride(NIDNT_MODE_SDC_SPMI);
	if (ret)
		__tpiu_disable_to_sdc(drvdata);
	return ret;
}