From nobody Tue Apr 7 15:28:03 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAFB0377556 for ; Thu, 26 Feb 2026 02:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772071526; cv=none; b=bG5MUx2ZxRBBPryeZdXRrTw5jA5ANKcAhpEAF6Zn9aCroR3ynEtAlyEyR4BKkFJTi6ZFqVyalZCQLxCLnVBsH2nzFKd5Dcyg1ZwAiQ7TXzmDBlPXJP9EhqHUdWtCyTAeazqOZXumdPBIJ7YvKC3qvuOZMIglncyQTaWI8gZzWe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772071526; c=relaxed/simple; bh=TNFz3rWf70CPHIUu5tr3uOicC0j05DttTIe/9zMOmVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pB3k05i1IH4/DyC22ndMlxzz3JwaDn/52XDms6ZRiVQJBjqRmN30cBD33eOvdbxOQbim2tpCWfrl1Z9DoUjyR5JcTU7buk5+ohkXehAreK/p0P2Iaum2U/sUWsBWTVCE3Veb/gFiuygoQ4dRJOvvTfCcRg5/zL8rNcFIusZYdFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ZiE8ZwDq; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=OB6o9sn0; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ZiE8ZwDq"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="OB6o9sn0" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61Q0pMw72974762 for ; Thu, 26 Feb 2026 02:05:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=D93wpyNGQT2 /lKSYk4tEdicwazQlUCt3v5pJwWaeHr0=; b=ZiE8ZwDqn5jZVcSkryVDfOFNTFg IBfqavxvMJp3w7n97wnamLf2GD9A4ADmhmKweb8oSb/OTCpMlhM02un/lk1XJkv4 SiJYROfbZchyPUE4yaZ8H/a1aufFYhoz5w8na2iZPcRQvo0RgaWpDmptkzPxVrxw XFAfvSqC5VUuSCJtJ6qcHNHuU9JmcLOv//n929RxFlhs3m0GjpqAWUXCYMXvK/JM rWlBNDwf+EshXoafbQ/8gqBgF5eN9ZMnOiAqksspq8yN6jJmWKlR+PgX0GieSjoh txRJomMEaLm+XMS9Z+/xQJNmitYvpEMan3VwtMqDDp5J/qythavjlzW/56A== Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cjc0g85vw-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 26 Feb 2026 02:05:23 +0000 (GMT) Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-679c5fde4c7so10023837eaf.0 for ; Wed, 25 Feb 2026 18:05:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772071523; x=1772676323; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D93wpyNGQT2/lKSYk4tEdicwazQlUCt3v5pJwWaeHr0=; b=OB6o9sn0PA7Jee58bfYvydnTdl210Y9eDEaWWfisk4rti3xEZxZxb9k6QUBefgGGwd 5q7hfrXaDlRHLzg2ip3WoBdLbwsTkxGa1/i5j4xXgX6zePBG7klyU4AxFg0lDDhxPJfW DFb7ZLf0SQBiFWfzlg3gI9uMG6YH+NtanFi3Cp8FXvDe+zoNUKMyCWa7jifHRjmft5r0 AJzxz0DmnCBh2y9ejAKmHR3thRjF/Vej4n/PLBAyLSJCSVOUi+P8dQYFV5CGgPZKT6Ax i95lToic2oG2/IG5F3IwK3K+Ji8iysbIJ8OJKXPtfl8a37n+t5KDSaBBUwxHHw/oDe/T mKcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772071523; x=1772676323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D93wpyNGQT2/lKSYk4tEdicwazQlUCt3v5pJwWaeHr0=; b=Fe8xiqEZk5apqyEh7bu3QWq78By+S/mqReT+mmqL2aVXh+RLWT7GiHnl8cUU9vbv23 a0tVu+X34ytfuL7gGtLgn1GwYiQSz/Ic0owIuHEcTBZ8zqQWA/Bk8+D8c1CdVL462RBo Y2z34viZn2/JTjTG+e1Rsg/Tjoo87Gpf/HP25HolEfIDj+tzAyuD0vFD7YnvEK7Bf54e qP2Ehws3F8WaSpMrEjikR+sLW+BmRHro/Vh6DksqBqAHbzdnFReSYREflR6HC76yJDvF FiYeismkYVG00tnzDLWDEEJudqIS4ur/8YneE42TwLJEyRZVQBvdztzo72bQDYTU1N9V AGqA== X-Forwarded-Encrypted: i=1; AJvYcCXSs8BOYVKXfP46IXkl9Ud3XEs4xhikmGlOWqCbG9l77YePDiK49tdYfxqCtnKgecjyr5QbcDLTSA/5YEc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7Itz9piw9b8zmvfeeJE6hlO57qgAGR/Lw658GAappaAcf85En CrApnfjLHCiqbbr+LH/DyV+OKk0ql+QLefkIeChiLCrH+UYtZI1Cl1LkXAQbaDCiHih+SUxJyB2 C0QlT+zk2IaXrgDkqbHubEfH1n5AyNpLVAidZfgJ6xuKR4iSUA768w93sO9sFesTrnwU= X-Gm-Gg: ATEYQzx0JwOVVSImrxLo9VaPgNwCcrg9pYosO5S3hDyZ7I1+263wcvYbEtNBUQzqowh 1TUbIX2rQBVLTC0ToLnk39n4qKA3QhpvpSzwih49TWSvJsW1lyjfnFzj/wiA/q60HwO0jMRMv5R 9lr6ap66P1FxSxRyDZHmkrvx8tOrFP/NCxN+xKRivQwzstZF00Q3HxlvNjN3DW/UOQvfqRU4C2L cDtLfhPd/UM64rkAg/FZjnrfIAMql4TQ9n9mgMiQZTlHEkt6BvH3XOWCWaD0YOG94k2oj3+Ixuv SrAgr8bXoOjuFCo5iiwZUCNC2l/Ac1O+47SIBt6nAp7Gt+6n214PPdRL6zb6wYLaslllGgwk2Go dEygL099B2thPGnL74/wROPr7qF9i1R2kfZudwN7jUY+WP8lfT0eSaUQpHkZRGba02b7WcZ6rNc UL X-Received: by 2002:a05:6820:821:b0:679:a41d:2d2f with SMTP id 006d021491bc7-679ef823bf5mr1206438eaf.30.1772071523046; Wed, 25 Feb 2026 18:05:23 -0800 (PST) X-Received: by 2002:a05:6820:821:b0:679:a41d:2d2f with SMTP id 006d021491bc7-679ef823bf5mr1206427eaf.30.1772071522626; Wed, 25 Feb 2026 18:05:22 -0800 (PST) Received: from hu-songchai-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-679f2d9e8d6sm549939eaf.13.2026.02.25.18.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 18:05:21 -0800 (PST) From: Songwei Chai To: andersson@kernel.org, alexander.shishkin@linux.intel.com, mike.leach@linaro.org, konrad.dybcio@oss.qualcomm.com, suzuki.poulose@arm.com, james.clark@arm.com, krzk+dt@kernel.org, conor+dt@kernel.org Cc: Songwei Chai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, coresight@lists.linaro.org, devicetree@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v11 4/7] qcom-tgu: Add TGU decode support Date: Wed, 25 Feb 2026 18:04:51 -0800 Message-Id: <20260226020454.3210149-5-songwei.chai@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260226020454.3210149-1-songwei.chai@oss.qualcomm.com> References: <20260226020454.3210149-1-songwei.chai@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=XI49iAhE c=1 sm=1 tr=0 ts=699faa63 cx=c_pps a=lVi5GcDxkcJcfCmEjVJoaw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=DXd_79bSlwW_W-LZS_AA:9 a=rBiNkAWo9uy_4UTK5NWh:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI2MDAxNiBTYWx0ZWRfX0gQn1DNedydh gsYdA3q/da00ign0KBdudp7duCGvcMJYq2lu61BH7I4PSYgPfI6Jb3WXAZMGWFs84tK7rijRBfX PfLxTtNCLDiTUZBCuV2yauch9G4yUTbATMIJ199knnUJ72S3w5S46SwtGTt395CUHJcZmQKWoEb GC4lZLvs5ow7rz17ZHaBklw0Z75pNaU2Y4qkcw05/G48W+/bdXHIy/ZUe2nNe9Z5OoZE5Lu35vB hT6GjeEi5j+zSEIUxUAaGwCKtmYNZ0FP6r+H6cQdFSGyNMeo5/kNAr2lVNWc33a99vo3ElbOCkN omblSaojU2WOE/3h7cfb+yObQ4ivhVoZAnHt1QV4gcQcXCNNwtKc1FdOHJId6ZTNkSFEo2opptz KRPvyzopN2NMdX98uGB5I+4LdQPFjqiiJR5b/dXectNnKRhIHZcjjuNa6ERmaEfnRqE/vn+jBjz yP4GPVFlQUIcDWIhCBA== X-Proofpoint-ORIG-GUID: 2fWh8ExqiL2QtPfSw1kR_y1fyV8EaAOG X-Proofpoint-GUID: 2fWh8ExqiL2QtPfSw1kR_y1fyV8EaAOG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-25_04,2026-02-25_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602260016 Content-Type: text/plain; charset="utf-8" Decoding is when all the potential pieces for creating a trigger are brought together for a given step. Example - there may be a counter keeping track of some occurrences and a priority-group that is being used to detect a pattern on the sense inputs. These 2 inputs to condition_decode must be programmed, for a given step, to establish the condition for the trigger, or movement to another steps. Signed-off-by: Songwei Chai --- .../ABI/testing/sysfs-bus-amba-devices-tgu | 7 + drivers/hwtracing/qcom/tgu.c | 157 +++++++++++++++--- drivers/hwtracing/qcom/tgu.h | 28 ++++ 3 files changed, 171 insertions(+), 21 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu b/Documen= tation/ABI/testing/sysfs-bus-amba-devices-tgu index 23ba73c4db0e..a18f6e4c797d 100644 --- a/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu +++ b/Documentation/ABI/testing/sysfs-bus-amba-devices-tgu @@ -14,3 +14,10 @@ KernelVersion 6.20 Contact: Jinlong Mao , Songwei Chai Description: (RW) Set/Get the sensed signal with specific step and priority for TGU. + +What: /sys/bus/amba/devices//step[0:7]_condition_decode/reg[0:3] +Date: February 2026 +KernelVersion 6.20 +Contact: Jinlong Mao , Songwei Chai +Description: + (RW) Set/Get the decode mode with specific step for TGU. diff --git a/drivers/hwtracing/qcom/tgu.c b/drivers/hwtracing/qcom/tgu.c index 14d6ad410d89..85fe1140eab5 100644 --- a/drivers/hwtracing/qcom/tgu.c +++ b/drivers/hwtracing/qcom/tgu.c @@ -18,8 +18,33 @@ static int calculate_array_location(struct tgu_drvdata *= drvdata, int step_index, int operation_index, int reg_index) { - return operation_index * (drvdata->num_step) * (drvdata->num_reg) + - step_index * (drvdata->num_reg) + reg_index; + switch (operation_index) { + case TGU_PRIORITY0: + case TGU_PRIORITY1: + case TGU_PRIORITY2: + case TGU_PRIORITY3: + return operation_index * (drvdata->num_step) * + (drvdata->num_reg) + + step_index * (drvdata->num_reg) + reg_index; + case TGU_CONDITION_DECODE: + return step_index * (drvdata->num_condition_decode) + + reg_index; + default: + break; + } + + return -EINVAL; +} + +static int check_array_location(struct tgu_drvdata *drvdata, int step, + int ops, int reg) +{ + int result =3D calculate_array_location(drvdata, step, ops, reg); + + if (result =3D=3D -EINVAL) + dev_err(drvdata->dev, "check arrary location - Fail\n"); + + return result; } =20 static ssize_t tgu_dataset_show(struct device *dev, @@ -30,12 +55,26 @@ static ssize_t tgu_dataset_show(struct device *dev, container_of(attr, struct tgu_attribute, attr); int index; =20 - index =3D calculate_array_location(drvdata, tgu_attr->step_index, - tgu_attr->operation_index, - tgu_attr->reg_num); - - return sysfs_emit(buf, "0x%x\n", - drvdata->value_table->priority[index]); + index =3D check_array_location(drvdata, tgu_attr->step_index, + tgu_attr->operation_index, tgu_attr->reg_num); + + if (index =3D=3D -EINVAL) + return index; + + switch (tgu_attr->operation_index) { + case TGU_PRIORITY0: + case TGU_PRIORITY1: + case TGU_PRIORITY2: + case TGU_PRIORITY3: + return sysfs_emit(buf, "0x%x\n", + drvdata->value_table->priority[index]); + case TGU_CONDITION_DECODE: + return sysfs_emit(buf, "0x%x\n", + drvdata->value_table->condition_decode[index]); + default: + break; + } + return -EINVAL; } =20 static ssize_t tgu_dataset_store(struct device *dev, @@ -54,13 +93,31 @@ static ssize_t tgu_dataset_store(struct device *dev, return ret; =20 guard(spinlock)(&tgu_drvdata->lock); - index =3D calculate_array_location(tgu_drvdata, tgu_attr->step_index, + index =3D check_array_location(tgu_drvdata, tgu_attr->step_index, tgu_attr->operation_index, tgu_attr->reg_num); =20 - tgu_drvdata->value_table->priority[index] =3D val; + if (index =3D=3D -EINVAL) + return index; + + switch (tgu_attr->operation_index) { + case TGU_PRIORITY0: + case TGU_PRIORITY1: + case TGU_PRIORITY2: + case TGU_PRIORITY3: + tgu_drvdata->value_table->priority[index] =3D val; + ret =3D size; + break; + case TGU_CONDITION_DECODE: + tgu_drvdata->value_table->condition_decode[index] =3D val; + ret =3D size; + break; + default: + ret =3D -EINVAL; + break; + } =20 - return size; + return ret; } =20 static umode_t tgu_node_visible(struct kobject *kobject, @@ -77,13 +134,26 @@ static umode_t tgu_node_visible(struct kobject *kobjec= t, if (tgu_attr->step_index >=3D drvdata->num_step) return SYSFS_GROUP_INVISIBLE; =20 - if (tgu_attr->reg_num >=3D drvdata->num_reg) - return 0; + switch (tgu_attr->operation_index) { + case TGU_PRIORITY0: + case TGU_PRIORITY1: + case TGU_PRIORITY2: + case TGU_PRIORITY3: + if (tgu_attr->reg_num < drvdata->num_reg) + return attr->mode; + break; + case TGU_CONDITION_DECODE: + if (tgu_attr->reg_num < drvdata->num_condition_decode) + return attr->mode; + break; + default: + break; + } =20 - return attr->mode; + return 0; } =20 -static void tgu_write_all_hw_regs(struct tgu_drvdata *drvdata) +static ssize_t tgu_write_all_hw_regs(struct tgu_drvdata *drvdata) { int i, j, k, index; =20 @@ -91,8 +161,10 @@ static void tgu_write_all_hw_regs(struct tgu_drvdata *d= rvdata) for (i =3D 0; i < drvdata->num_step; i++) { for (j =3D 0; j < MAX_PRIORITY; j++) { for (k =3D 0; k < drvdata->num_reg; k++) { - index =3D calculate_array_location( + index =3D check_array_location( drvdata, i, j, k); + if (index =3D=3D -EINVAL) + goto exit; =20 writel(drvdata->value_table->priority[index], drvdata->base + @@ -100,9 +172,23 @@ static void tgu_write_all_hw_regs(struct tgu_drvdata *= drvdata) } } } + + for (i =3D 0; i < drvdata->num_step; i++) { + for (j =3D 0; j < drvdata->num_condition_decode; j++) { + index =3D check_array_location(drvdata, i, + TGU_CONDITION_DECODE, j); + if (index =3D=3D -EINVAL) + goto exit; + + writel(drvdata->value_table->condition_decode[index], + drvdata->base + CONDITION_DECODE_STEP(i, j)); + } + } /* Enable TGU to program the triggers */ writel(1, drvdata->base + TGU_CONTROL); +exit: TGU_LOCK(drvdata->base); + return index >=3D 0 ? 0 : -EINVAL; } =20 static void tgu_set_reg_number(struct tgu_drvdata *drvdata) @@ -131,18 +217,28 @@ static void tgu_set_steps(struct tgu_drvdata *drvdata) drvdata->num_step =3D TGU_DEVID_STEPS(devid); } =20 +static void tgu_set_conditions(struct tgu_drvdata *drvdata) +{ + u32 devid; + + devid =3D readl(drvdata->base + TGU_DEVID); + drvdata->num_condition_decode =3D TGU_DEVID_CONDITIONS(devid); +} + static int tgu_enable(struct device *dev) { struct tgu_drvdata *drvdata =3D dev_get_drvdata(dev); + int ret; =20 guard(spinlock)(&drvdata->lock); if (drvdata->enabled) return -EBUSY; =20 - tgu_write_all_hw_regs(drvdata); - drvdata->enabled =3D true; + ret =3D tgu_write_all_hw_regs(drvdata); + if (!ret) + drvdata->enabled =3D true; =20 - return 0; + return ret; } =20 static void tgu_do_disable(struct tgu_drvdata *drvdata) @@ -252,6 +348,14 @@ static const struct attribute_group *tgu_attr_groups[]= =3D { PRIORITY_ATTRIBUTE_GROUP_INIT(7, 1), PRIORITY_ATTRIBUTE_GROUP_INIT(7, 2), PRIORITY_ATTRIBUTE_GROUP_INIT(7, 3), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(0), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(1), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(2), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(3), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(4), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(5), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(6), + CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(7), NULL, }; =20 @@ -259,8 +363,8 @@ static int tgu_probe(struct amba_device *adev, const st= ruct amba_id *id) { struct device *dev =3D &adev->dev; struct tgu_drvdata *drvdata; - unsigned int *priority; - size_t priority_size; + unsigned int *priority, *condition; + size_t priority_size, condition_size; int ret; =20 drvdata =3D devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); @@ -278,6 +382,7 @@ static int tgu_probe(struct amba_device *adev, const st= ruct amba_id *id) =20 tgu_set_reg_number(drvdata); tgu_set_steps(drvdata); + tgu_set_conditions(drvdata); =20 ret =3D sysfs_create_groups(&dev->kobj, tgu_attr_groups); if (ret) { @@ -300,6 +405,16 @@ static int tgu_probe(struct amba_device *adev, const s= truct amba_id *id) =20 drvdata->value_table->priority =3D priority; =20 + condition_size =3D drvdata->num_condition_decode * drvdata->num_step; + + condition =3D devm_kcalloc(dev, condition_size, + sizeof(*(drvdata->value_table->condition_decode)), + GFP_KERNEL); + if (!condition) + return -ENOMEM; + + drvdata->value_table->condition_decode =3D condition; + drvdata->enabled =3D false; =20 pm_runtime_put(&adev->dev); diff --git a/drivers/hwtracing/qcom/tgu.h b/drivers/hwtracing/qcom/tgu.h index 970292f91b02..ca8dfbef0cd2 100644 --- a/drivers/hwtracing/qcom/tgu.h +++ b/drivers/hwtracing/qcom/tgu.h @@ -16,6 +16,9 @@ ((int)FIELD_GET(GENMASK(17, 10), devid_val)) #define TGU_DEVID_STEPS(devid_val) \ ((int)FIELD_GET(GENMASK(6, 3), devid_val)) +#define TGU_DEVID_CONDITIONS(devid_val) \ + ((int)FIELD_GET(GENMASK(2, 0), devid_val)) + #define TGU_BITS_PER_SIGNAL 4 #define LENGTH_REGISTER 32 =20 @@ -49,6 +52,7 @@ */ #define STEP_OFFSET 0x1D8 #define PRIORITY_START_OFFSET 0x0074 +#define CONDITION_DECODE_OFFSET 0x0050 #define PRIORITY_OFFSET 0x60 #define REG_OFFSET 0x4 =20 @@ -57,6 +61,9 @@ (PRIORITY_START_OFFSET + PRIORITY_OFFSET * priority +\ REG_OFFSET * reg + STEP_OFFSET * step) =20 +#define CONDITION_DECODE_STEP(step, decode) \ + (CONDITION_DECODE_OFFSET + REG_OFFSET * decode + STEP_OFFSET * step) + #define tgu_dataset_rw(name, step_index, type, reg_num) \ (&((struct tgu_attribute[]){ { \ __ATTR(name, 0644, tgu_dataset_show, tgu_dataset_store), \ @@ -68,6 +75,8 @@ #define STEP_PRIORITY(step_index, reg_num, priority) \ tgu_dataset_rw(reg##reg_num, step_index, TGU_PRIORITY##priority, \ reg_num) +#define STEP_DECODE(step_index, reg_num) \ + tgu_dataset_rw(reg##reg_num, step_index, TGU_CONDITION_DECODE, reg_num) =20 #define STEP_PRIORITY_LIST(step_index, priority) \ {STEP_PRIORITY(step_index, 0, priority), \ @@ -91,6 +100,14 @@ NULL \ } =20 +#define STEP_DECODE_LIST(n) \ + {STEP_DECODE(n, 0), \ + STEP_DECODE(n, 1), \ + STEP_DECODE(n, 2), \ + STEP_DECODE(n, 3), \ + NULL \ + } + #define PRIORITY_ATTRIBUTE_GROUP_INIT(step, priority)\ (&(const struct attribute_group){\ .attrs =3D (struct attribute*[])STEP_PRIORITY_LIST(step, priority),\ @@ -98,11 +115,19 @@ .name =3D "step" #step "_priority" #priority \ }) =20 +#define CONDITION_DECODE_ATTRIBUTE_GROUP_INIT(step)\ + (&(const struct attribute_group){\ + .attrs =3D (struct attribute*[])STEP_DECODE_LIST(step),\ + .is_visible =3D tgu_node_visible,\ + .name =3D "step" #step "_condition_decode" \ + }) + enum operation_index { TGU_PRIORITY0, TGU_PRIORITY1, TGU_PRIORITY2, TGU_PRIORITY3, + TGU_CONDITION_DECODE, }; =20 /* Maximum priority that TGU supports */ @@ -117,6 +142,7 @@ struct tgu_attribute { =20 struct value_table { unsigned int *priority; + unsigned int *condition_decode; }; =20 static inline void TGU_LOCK(void __iomem *addr) @@ -146,6 +172,7 @@ static inline void TGU_UNLOCK(void __iomem *addr) * @value_table: Store given value based on relevant parameters * @num_reg: Maximum number of registers * @num_step: Maximum step size + * @num_condition_decode: Maximum number of condition_decode * * This structure defines the data associated with a TGU device, * including its base address, device pointers, clock, spinlock for @@ -160,6 +187,7 @@ struct tgu_drvdata { struct value_table *value_table; int num_reg; int num_step; + int num_condition_decode; }; =20 #endif --=20 2.34.1