From nobody Mon Nov 25 03:04:08 2024 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 EF73E13FEE; Wed, 30 Oct 2024 19:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730314822; cv=none; b=LztwVy4UlcaTzbsj4BZWA+yQN1S6dhI9tO6FhDWphJeQtoRSvTgTyJkZEJz3EfaFtVq9rUaNzpElnh/Z4WvgD9a+B7IrkJ6MuklmxOHTrOn1JzkEOfxzfAglE20xlsi1NJcxE3+gnRpDz82hJj+eH3YEvOOba/hJeCzMHAUwV+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730314822; c=relaxed/simple; bh=GBRBhm33iFUKjUJJYu/hArZWFn9LFaUNhL8mNdnHBMo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XgRcriqV8qZsMGscoPKZ5y2x175pE/fdW7wvODkuq1U9npg5NDmCWfF1wBRn4lR/52HDQkIZOE1cnuCKNASFuQKDJeEmCoynMoDKTNPV4PSXKCa4yRePS0esTu5w4ddQDQqMl2z5i5ob7eaKva7xNlnTsaNNcvCQMiDSVcl4TQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=VaYMI/Ec; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="VaYMI/Ec" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U8vE6B020425; Wed, 30 Oct 2024 18:59:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= MA40Kiv4C89ntoSSPuvZqmiuHlF3RDjxsYk/i06dn5E=; b=VaYMI/EcNCjOZ2Sy wezgaTyZWUgshtyP/FjbSh22glCJXJnsM+b3jDazqew11PqUX9UkXRwoj3dZj4Cx MuDaHu/q8yifC/X/8hV1YPfFFvpJc5bsmmRtJEkMTuqoR/Cmjh+R+AxPjxddANml bLBnvICAh2uejBgudKauiLBBk9QRlm7OBegEdPzbQoAU6mmPmFUn828itVdNrCFR u5uS2EQtdTSF0VWiJDHPe07di7eGWQ6/7FmACNP6mWqj/jokN/EOUwLLyC41OU/U yGwwFr5iDkK5PzWblDRKAPgwgNUPE3qZIUR/YOoEAVtzhFXN+KJnj0yCDKvORmhr 2g1wNA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42grgun3v7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 18:59:56 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49UIxsJb002693 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 18:59:54 GMT Received: from hu-jprakash-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 30 Oct 2024 11:59:45 -0700 From: Jishnu Prakash To: , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Jishnu Prakash , Rob Herring Subject: [PATCH V4 1/4] dt-bindings: iio/adc: Move QCOM ADC bindings to iio/adc folder Date: Thu, 31 Oct 2024 00:28:51 +0530 Message-ID: <20241030185854.4015348-2-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241030185854.4015348-1-quic_jprakash@quicinc.com> References: <20241030185854.4015348-1-quic_jprakash@quicinc.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-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: f0Nb3Goo0Gq6mP2H1w7wb4gjK7NssAwm X-Proofpoint-GUID: f0Nb3Goo0Gq6mP2H1w7wb4gjK7NssAwm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410300150 Content-Type: text/plain; charset="utf-8" There are several files containing QCOM ADC macros for channel names right now in the include/dt-bindings/iio folder. Since all of these are specifically for adc, move the files to the include/dt-bindings/iio/adc folder. Also update all affected devicetree and driver files to fix compilation errors seen with this move and update documentation files to fix dtbinding check errors for the same. Acked-by: Lee Jones Acked-by: Rob Herring Signed-off-by: Jishnu Prakash --- Changes since v3: - Updated files affected by adc file path change in /arch/arm, which were missed earlier. Updated some more new devicetree files requiring this change in /arch/arm64. Changes since v2: - Updated some more new devicetree files requiring this change. .../devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml | 8 ++++---- Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 2 +- .../devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml | 2 +- .../devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml | 6 +++--- arch/arm/boot/dts/qcom/pm8226.dtsi | 2 +- arch/arm/boot/dts/qcom/pm8941.dtsi | 2 +- arch/arm/boot/dts/qcom/pma8084.dtsi | 2 +- arch/arm/boot/dts/qcom/pmx55.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm4125.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm6125.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm6150.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm6150l.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm660.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm660l.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm7250b.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8150.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8150b.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8150l.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8916.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8950.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8953.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8994.dtsi | 2 +- arch/arm64/boot/dts/qcom/pm8998.dtsi | 2 +- arch/arm64/boot/dts/qcom/pmi632.dtsi | 2 +- arch/arm64/boot/dts/qcom/pmi8950.dtsi | 2 +- arch/arm64/boot/dts/qcom/pmm8155au_1.dtsi | 2 +- arch/arm64/boot/dts/qcom/pmp8074.dtsi | 2 +- arch/arm64/boot/dts/qcom/pms405.dtsi | 2 +- arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 4 ++-- arch/arm64/boot/dts/qcom/qcm6490-shift-otter.dts | 4 ++-- arch/arm64/boot/dts/qcom/sc7280-idp.dts | 2 +- arch/arm64/boot/dts/qcom/sc7280-idp.dtsi | 2 +- arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi | 4 ++-- arch/arm64/boot/dts/qcom/sc8180x-pmics.dtsi | 2 +- .../arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 +- arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi | 6 +++--- arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 2 +- arch/arm64/boot/dts/qcom/sm7325-nothing-spacewar.dts | 6 +++--- arch/arm64/boot/dts/qcom/sm8450-hdk.dts | 8 ++++---- drivers/iio/adc/qcom-spmi-adc5.c | 2 +- drivers/iio/adc/qcom-spmi-vadc.c | 2 +- include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm7325.h | 2 +- include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm8350.h | 2 +- .../dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm8350b.h | 2 +- .../dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmk8350.h | 2 +- .../dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmr735a.h | 2 +- .../dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmr735b.h | 2 +- .../dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-smb139x.h | 2 +- include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-vadc.h | 0 49 files changed, 63 insertions(+), 63 deletions(-) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm7325.h (98%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm8350.h (98%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pm8350b.h (99%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmk8350.h (97%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmr735a.h (95%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-pmr735b.h (95%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-adc7-smb139x.h (93%) rename include/dt-bindings/iio/{ =3D> adc}/qcom,spmi-vadc.h (100%) diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml = b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml index c28db0d635a0..a4f72c0c1ec6 100644 --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml @@ -70,9 +70,9 @@ patternProperties: maxItems: 1 description: | ADC channel number. - See include/dt-bindings/iio/qcom,spmi-vadc.h + See include/dt-bindings/iio/adc/qcom,spmi-vadc.h For PMIC7 ADC, the channel numbers are specified separately per = PMIC - in the PMIC-specific files in include/dt-bindings/iio/. + in the PMIC-specific files in include/dt-bindings/iio/adc. =20 label: description: | @@ -276,8 +276,8 @@ examples: }; =20 - | - #include - #include + #include + #include #include =20 pmic { diff --git a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml b/Do= cumentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml index a2b2fbf77d5c..eed4f6d3c889 100644 --- a/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +++ b/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml @@ -274,7 +274,7 @@ examples: #include #include #include - #include + #include #include =20 pmic@0 { diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.= yaml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml index bfad8130a042..65b8c8cf802f 100644 --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm-hc.yaml @@ -110,7 +110,7 @@ unevaluatedProperties: false =20 examples: - | - #include + #include #include =20 pmic { diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.ya= ml b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml index 4470a5942fb2..5d19a82b0319 100644 --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml @@ -163,7 +163,7 @@ unevaluatedProperties: false =20 examples: - | - #include + #include #include =20 pmic { @@ -204,8 +204,8 @@ examples: }; =20 - | - #include - #include + #include + #include #include =20 pmic { diff --git a/arch/arm/boot/dts/qcom/pm8226.dtsi b/arch/arm/boot/dts/qcom/pm= 8226.dtsi index 2fd4f135ed84..774120aa50bc 100644 --- a/arch/arm/boot/dts/qcom/pm8226.dtsi +++ b/arch/arm/boot/dts/qcom/pm8226.dtsi @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -#include +#include #include #include #include diff --git a/arch/arm/boot/dts/qcom/pm8941.dtsi b/arch/arm/boot/dts/qcom/pm= 8941.dtsi index aca0052a02b7..d995cc6eaebf 100644 --- a/arch/arm/boot/dts/qcom/pm8941.dtsi +++ b/arch/arm/boot/dts/qcom/pm8941.dtsi @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include =20 diff --git a/arch/arm/boot/dts/qcom/pma8084.dtsi b/arch/arm/boot/dts/qcom/p= ma8084.dtsi index 309f5256754b..f8790bbc225e 100644 --- a/arch/arm/boot/dts/qcom/pma8084.dtsi +++ b/arch/arm/boot/dts/qcom/pma8084.dtsi @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include #include diff --git a/arch/arm/boot/dts/qcom/pmx55.dtsi b/arch/arm/boot/dts/qcom/pmx= 55.dtsi index da0851173c69..af05ec5a009c 100644 --- a/arch/arm/boot/dts/qcom/pmx55.dtsi +++ b/arch/arm/boot/dts/qcom/pmx55.dtsi @@ -5,7 +5,7 @@ * Copyright (c) 2020, Linaro Limited */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pm4125.dtsi b/arch/arm64/boot/dts/qco= m/pm4125.dtsi index cf8c822e80ce..db175a55035c 100644 --- a/arch/arm64/boot/dts/qcom/pm4125.dtsi +++ b/arch/arm64/boot/dts/qcom/pm4125.dtsi @@ -3,7 +3,7 @@ * Copyright (c) 2023, Linaro Ltd */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm6125.dtsi b/arch/arm64/boot/dts/qco= m/pm6125.dtsi index d0db28336fa9..2bc669e8763b 100644 --- a/arch/arm64/boot/dts/qcom/pm6125.dtsi +++ b/arch/arm64/boot/dts/qcom/pm6125.dtsi @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm6150.dtsi b/arch/arm64/boot/dts/qco= m/pm6150.dtsi index 59524609fb1e..24fbfee8de79 100644 --- a/arch/arm64/boot/dts/qcom/pm6150.dtsi +++ b/arch/arm64/boot/dts/qcom/pm6150.dtsi @@ -3,7 +3,7 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm6150l.dtsi b/arch/arm64/boot/dts/qc= om/pm6150l.dtsi index 334f976f1154..5c0ae7a06bd0 100644 --- a/arch/arm64/boot/dts/qcom/pm6150l.dtsi +++ b/arch/arm64/boot/dts/qcom/pm6150l.dtsi @@ -3,7 +3,7 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pm660.dtsi b/arch/arm64/boot/dts/qcom= /pm660.dtsi index 156b2ddff0dc..0ae38647ec49 100644 --- a/arch/arm64/boot/dts/qcom/pm660.dtsi +++ b/arch/arm64/boot/dts/qcom/pm660.dtsi @@ -3,7 +3,7 @@ * Copyright (c) 2020, Konrad Dybcio */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm660l.dtsi b/arch/arm64/boot/dts/qco= m/pm660l.dtsi index 0094e0ef058b..38f329712079 100644 --- a/arch/arm64/boot/dts/qcom/pm660l.dtsi +++ b/arch/arm64/boot/dts/qcom/pm660l.dtsi @@ -3,7 +3,7 @@ * Copyright (c) 2020, Konrad Dybcio */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm7250b.dtsi b/arch/arm64/boot/dts/qc= om/pm7250b.dtsi index 0761e6b5fd8d..6ad46722ae38 100644 --- a/arch/arm64/boot/dts/qcom/pm7250b.dtsi +++ b/arch/arm64/boot/dts/qcom/pm7250b.dtsi @@ -3,7 +3,7 @@ * Copyright (C) 2022 Luca Weiss */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pm8150.dtsi b/arch/arm64/boot/dts/qco= m/pm8150.dtsi index a74a7ff660d2..206077d09d48 100644 --- a/arch/arm64/boot/dts/qcom/pm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150.dtsi @@ -7,7 +7,7 @@ #include #include #include -#include +#include =20 / { thermal-zones { diff --git a/arch/arm64/boot/dts/qcom/pm8150b.dtsi b/arch/arm64/boot/dts/qc= om/pm8150b.dtsi index 3f7b0b6a1d10..5192ab94e75e 100644 --- a/arch/arm64/boot/dts/qcom/pm8150b.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150b.dtsi @@ -4,7 +4,7 @@ * Copyright (c) 2019, Linaro Limited */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pm8150l.dtsi b/arch/arm64/boot/dts/qc= om/pm8150l.dtsi index 3911d6d0d2e2..7822214f07b0 100644 --- a/arch/arm64/boot/dts/qcom/pm8150l.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150l.dtsi @@ -4,7 +4,7 @@ * Copyright (c) 2019, Linaro Limited */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qco= m/pm8916.dtsi index f8e4829ff7f7..3a709095cda7 100644 --- a/arch/arm64/boot/dts/qcom/pm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm8950.dtsi b/arch/arm64/boot/dts/qco= m/pm8950.dtsi index ed72c6101813..c1462d659ff2 100644 --- a/arch/arm64/boot/dts/qcom/pm8950.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8950.dtsi @@ -5,7 +5,7 @@ * Copyright (c) 2022, Marijn Suijten */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm8953.dtsi b/arch/arm64/boot/dts/qco= m/pm8953.dtsi index 64258505f9ba..9427062b8af5 100644 --- a/arch/arm64/boot/dts/qcom/pm8953.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8953.dtsi @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause /* Copyright (c) 2022, The Linux Foundation. All rights reserved. */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm8994.dtsi b/arch/arm64/boot/dts/qco= m/pm8994.dtsi index 353e4a6bd088..26cbcfd06d05 100644 --- a/arch/arm64/boot/dts/qcom/pm8994.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8994.dtsi @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pm8998.dtsi b/arch/arm64/boot/dts/qco= m/pm8998.dtsi index 3ecb330590e5..b948b98835a9 100644 --- a/arch/arm64/boot/dts/qcom/pm8998.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8998.dtsi @@ -1,7 +1,7 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* Copyright 2018 Google LLC. */ =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/pmi632.dtsi b/arch/arm64/boot/dts/qco= m/pmi632.dtsi index 8c899d148e46..eff176851b83 100644 --- a/arch/arm64/boot/dts/qcom/pmi632.dtsi +++ b/arch/arm64/boot/dts/qcom/pmi632.dtsi @@ -3,7 +3,7 @@ * Copyright (C) 2023 Luca Weiss */ =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pmi8950.dtsi b/arch/arm64/boot/dts/qc= om/pmi8950.dtsi index 4aff437263a2..051c995e9f2e 100644 --- a/arch/arm64/boot/dts/qcom/pmi8950.dtsi +++ b/arch/arm64/boot/dts/qcom/pmi8950.dtsi @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019, AngeloGioacchino Del Regno =20 -#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/pmm8155au_1.dtsi b/arch/arm64/boot/dt= s/qcom/pmm8155au_1.dtsi index 5084de66fc46..3dd3adfa096b 100644 --- a/arch/arm64/boot/dts/qcom/pmm8155au_1.dtsi +++ b/arch/arm64/boot/dts/qcom/pmm8155au_1.dtsi @@ -6,7 +6,7 @@ #include #include #include -#include +#include =20 / { thermal-zones { diff --git a/arch/arm64/boot/dts/qcom/pmp8074.dtsi b/arch/arm64/boot/dts/qc= om/pmp8074.dtsi index 0d0a846ac8d9..9f3e4121d834 100644 --- a/arch/arm64/boot/dts/qcom/pmp8074.dtsi +++ b/arch/arm64/boot/dts/qcom/pmp8074.dtsi @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause =20 #include -#include +#include =20 &spmi_bus { pmic@0 { diff --git a/arch/arm64/boot/dts/qcom/pms405.dtsi b/arch/arm64/boot/dts/qco= m/pms405.dtsi index 3f9100c7eff4..86c17094a92a 100644 --- a/arch/arm64/boot/dts/qcom/pms405.dtsi +++ b/arch/arm64/boot/dts/qcom/pms405.dtsi @@ -5,7 +5,7 @@ =20 #include #include -#include +#include #include =20 / { diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm6= 4/boot/dts/qcom/qcm6490-fairphone-fp5.dts index fdc62f1b1c5a..b34c900439b9 100644 --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts @@ -9,8 +9,8 @@ #define PM7250B_SID 8 #define PM7250B_SID1 9 =20 -#include -#include +#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/qcm6490-shift-otter.dts b/arch/arm64/= boot/dts/qcom/qcm6490-shift-otter.dts index 4667e47a74bc..f376dbaeed2d 100644 --- a/arch/arm64/boot/dts/qcom/qcm6490-shift-otter.dts +++ b/arch/arm64/boot/dts/qcom/qcm6490-shift-otter.dts @@ -9,8 +9,8 @@ #define PM7250B_SID 8 #define PM7250B_SID1 9 =20 -#include -#include +#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dts b/arch/arm64/boot/dts/= qcom/sc7280-idp.dts index b5fe7356be48..1dd4aa300f7f 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dts +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dts @@ -7,7 +7,7 @@ =20 /dts-v1/; =20 -#include +#include #include "sc7280-idp.dtsi" #include "pmr735a.dtsi" =20 diff --git a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi b/arch/arm64/boot/dts= /qcom/sc7280-idp.dtsi index 7370aa0dbf0e..00d68a9588d3 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280-idp.dtsi @@ -5,7 +5,7 @@ * Copyright (c) 2021, The Linux Foundation. All rights reserved. */ =20 -#include +#include #include #include "sc7280.dtsi" #include "pm7325.dtsi" diff --git a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi b/arch/arm64/boot/d= ts/qcom/sc7280-qcard.dtsi index 7d1d5bbbbbd9..8fcd3e1bb815 100644 --- a/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7280-qcard.dtsi @@ -11,8 +11,8 @@ * Copyright 2022 Google LLC. */ =20 -#include -#include +#include +#include #include #include =20 diff --git a/arch/arm64/boot/dts/qcom/sc8180x-pmics.dtsi b/arch/arm64/boot/= dts/qcom/sc8180x-pmics.dtsi index 451c9b984f1f..ed1fcfdc3584 100644 --- a/arch/arm64/boot/dts/qcom/sc8180x-pmics.dtsi +++ b/arch/arm64/boot/dts/qcom/sc8180x-pmics.dtsi @@ -7,7 +7,7 @@ #include #include #include -#include +#include =20 / { thermal-zones { diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/a= rch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts index 83208b10f994..839204918fd4 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts @@ -6,7 +6,7 @@ =20 /dts-v1/; =20 -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot= /dts/qcom/sc8280xp-pmics.dtsi index 1e3babf2e40d..080ae9e037a2 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi +++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi @@ -3,9 +3,9 @@ * Copyright (c) 2022, Linaro Limited */ =20 -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts b/arch/arm64= /boot/dts/qcom/sm7225-fairphone-fp4.dts index 2ee2561b57b1..b8609ad1bd86 100644 --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts @@ -14,7 +14,7 @@ =20 #include #include -#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/sm7325-nothing-spacewar.dts b/arch/ar= m64/boot/dts/qcom/sm7325-nothing-spacewar.dts index a5cda478bd78..5308b1ef85b6 100644 --- a/arch/arm64/boot/dts/qcom/sm7325-nothing-spacewar.dts +++ b/arch/arm64/boot/dts/qcom/sm7325-nothing-spacewar.dts @@ -8,9 +8,9 @@ =20 #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/arch/arm64/boot/dts/qcom/sm8450-hdk.dts b/arch/arm64/boot/dts/= qcom/sm8450-hdk.dts index 67443822653d..88f394dc4867 100644 --- a/arch/arm64/boot/dts/qcom/sm8450-hdk.dts +++ b/arch/arm64/boot/dts/qcom/sm8450-hdk.dts @@ -6,10 +6,10 @@ /dts-v1/; =20 #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include "sm8450.dtsi" #include "pm8350.dtsi" diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-a= dc5.c index af3c2f659f5e..389454edbf75 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -20,7 +20,7 @@ #include #include =20 -#include +#include =20 #define ADC5_USR_REVISION1 0x0 #define ADC5_USR_STATUS1 0x8 diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-v= adc.c index 00a7f0982025..e4878770f88c 100644 --- a/drivers/iio/adc/qcom-spmi-vadc.c +++ b/drivers/iio/adc/qcom-spmi-vadc.c @@ -20,7 +20,7 @@ #include #include =20 -#include +#include =20 /* VADC register and bit definitions */ #define VADC_REVISION2 0x1 diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h b/include/dt-b= indings/iio/adc/qcom,spmi-adc7-pm7325.h similarity index 98% rename from include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pm7325.h index 96908014e09e..f0ab57078ca4 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pm7325.h @@ -10,7 +10,7 @@ #define PM7325_SID 1 #endif =20 -#include +#include =20 /* ADC channels for PM7325_ADC for PMIC7 */ #define PM7325_ADC7_REF_GND (PM7325_SID << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h b/include/dt-b= indings/iio/adc/qcom,spmi-adc7-pm8350.h similarity index 98% rename from include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pm8350.h index 5d98f7d48a1e..ef818248ec8c 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pm8350.h @@ -6,7 +6,7 @@ #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H #define _DT_BINDINGS_QCOM_SPMI_VADC_PM8350_H =20 -#include +#include =20 /* ADC channels for PM8350_ADC for PMIC7 */ #define PM8350_ADC7_REF_GND(sid) ((sid) << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h b/include/dt-= bindings/iio/adc/qcom,spmi-adc7-pm8350b.h similarity index 99% rename from include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pm8350b.h index 57c7977666d3..d841bf00b7b0 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pm8350b.h @@ -10,7 +10,7 @@ #define PM8350B_SID 3 #endif =20 -#include +#include =20 /* ADC channels for PM8350B_ADC for PMIC7 */ #define PM8350B_ADC7_REF_GND (PM8350B_SID << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h b/include/dt-= bindings/iio/adc/qcom,spmi-adc7-pmk8350.h similarity index 97% rename from include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pmk8350.h index 3d1a41a22cef..161b211ec126 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pmk8350.h @@ -10,7 +10,7 @@ #define PMK8350_SID 0 #endif =20 -#include +#include =20 /* ADC channels for PMK8350_ADC for PMIC7 */ #define PMK8350_ADC7_REF_GND (PMK8350_SID << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h b/include/dt-= bindings/iio/adc/qcom,spmi-adc7-pmr735a.h similarity index 95% rename from include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pmr735a.h index c5adfa82b20d..fedc9e3882b8 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pmr735a.h @@ -10,7 +10,7 @@ #define PMR735A_SID 4 #endif =20 -#include +#include =20 /* ADC channels for PMR735A_ADC for PMIC7 */ #define PMR735A_ADC7_REF_GND (PMR735A_SID << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h b/include/dt-= bindings/iio/adc/qcom,spmi-adc7-pmr735b.h similarity index 95% rename from include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-pmr735b.h index fdb8dd9ae541..812f33872e5e 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-pmr735b.h @@ -10,7 +10,7 @@ #define PMR735B_SID 5 #endif =20 -#include +#include =20 /* ADC channels for PMR735B_ADC for PMIC7 */ #define PMR735B_ADC7_REF_GND (PMR735B_SID << 8 | ADC7_REF_GND) diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-smb139x.h b/include/dt-= bindings/iio/adc/qcom,spmi-adc7-smb139x.h similarity index 93% rename from include/dt-bindings/iio/qcom,spmi-adc7-smb139x.h rename to include/dt-bindings/iio/adc/qcom,spmi-adc7-smb139x.h index c0680d1285cf..750a526af2c1 100644 --- a/include/dt-bindings/iio/qcom,spmi-adc7-smb139x.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc7-smb139x.h @@ -6,7 +6,7 @@ #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_SMB139X_H #define _DT_BINDINGS_QCOM_SPMI_VADC_SMB139X_H =20 -#include +#include =20 #define SMB139x_1_ADC7_SMB_TEMP (SMB139x_1_SID << 8 | ADC7_SMB_TEMP) #define SMB139x_1_ADC7_ICHG_SMB (SMB139x_1_SID << 8 | ADC7_ICHG_SMB) diff --git a/include/dt-bindings/iio/qcom,spmi-vadc.h b/include/dt-bindings= /iio/adc/qcom,spmi-vadc.h similarity index 100% rename from include/dt-bindings/iio/qcom,spmi-vadc.h rename to include/dt-bindings/iio/adc/qcom,spmi-vadc.h --=20 2.25.1 From nobody Mon Nov 25 03:04:08 2024 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 40F9B1D0DEC; Wed, 30 Oct 2024 19:00:23 +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=1730314828; cv=none; b=Fmxyo3vScKHhLli720BdPSPZ823BnrXfUnTUSXmI0son80YPqNQk/LvX4SHTtBqLWUSX+nSaQMh73b/P7gBgN4cVGwMls9f0vrW3SJSKe6uICN1Cxltrs9oHq4tICE0eBTTEKlmjOL97mIL+ApMyNAGb4IrqoE9z4aTIvRkGfdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730314828; c=relaxed/simple; bh=B+md4mQW5LEGS+BNC+T0B4RiiRucGXgZK3sHH+glRe0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i2/HV8FlkVvdNwhlc21zAlmMh64InxAQb/ZfJJSOGpcIBHHPVfCAUrg0nejyaLi/Wjzf9bbUUFQjWGgZx4dXA/3xAmWi5aieR0dPUJFRM+M9bcffBNkFQgNf3r5jy6r/b9OI1+Mm1hC+/26CjS/K50eeT4ckOlNDEZmhXLRkYM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mAgW7BoU; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mAgW7BoU" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UIl9aB012768; Wed, 30 Oct 2024 19:00:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= KCxd83/o6rNEW1x6H97RGxR6lisVgryRHz6eepxIwGg=; b=mAgW7BoU2RQPp99i b5S9JY04tDbzh1T05Fos3Retfk0V7yKrzqQfNHm4D6YC1Jps9lVZUwNiFVpEo2po qGLWG9qvEYFx3XtHbQoKsZX4NXMT4U4puAoJzcj3PoB9CwHznmb1anLIpoaJ/QtH +aNeefCA4DtAR00dRw/fTXWPW51iuixZMZ628jiG7tAdU0bb/r1/S33wuDw8Lrnt 1DGOB+Z6gArtuqaHftlMsXI9e3ufP17/QBgEesXGz99SoD32Nz6nOcMkMRuliDI9 BLuzxpp+JI7PYOWMDIULwzQpBymI6qZNNYcDzsz/H/AFjgMlL10QUo/gbA2ABFRv Gf+nPw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42k6rpkbkr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:03 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49UJ02GA023090 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:02 GMT Received: from hu-jprakash-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 30 Oct 2024 11:59:54 -0700 From: Jishnu Prakash To: , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Jishnu Prakash Subject: [PATCH V4 2/4] dt-bindings: iio: adc: Add support for QCOM PMIC5 Gen3 ADC Date: Thu, 31 Oct 2024 00:28:52 +0530 Message-ID: <20241030185854.4015348-3-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241030185854.4015348-1-quic_jprakash@quicinc.com> References: <20241030185854.4015348-1-quic_jprakash@quicinc.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-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: YkpDQZTk-WntG0zZLci_L9wzsEz1E6wr X-Proofpoint-GUID: YkpDQZTk-WntG0zZLci_L9wzsEz1E6wr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410300150 Content-Type: text/plain; charset="utf-8" For the PMIC5-Gen3 type PMICs, ADC peripheral is present in HW for the following PMICs: PMK8550, PM8550, PM8550B and PM8550VX PMICs. It is similar to PMIC5-Gen2, with SW communication to ADCs on all PMICs going through PBS(Programmable Boot Sequence) firmware through a single register interface. This interface is implemented on an SDAM (Shared Direct Access Memory) peripheral on the master PMIC PMK8550 rather than a dedicated ADC peripheral. Add documentation for PMIC5 Gen3 ADC and macro definitions for ADC channels and virtual channels (combination of ADC channel number and PMIC SID number) per PMIC, to be used by clients of this device. Co-developed-by: Anjelique Melendez Signed-off-by: Anjelique Melendez Signed-off-by: Jishnu Prakash --- Changes since v3: - Added ADC5 Gen3 documentation changes in existing qcom,spmi-vadc.yaml file instead of adding separate file and updated top-level constraints in docu= mentation file based on discussion with reviewers. - Dropped default SID definitions. - Addressed other reviewer comments. Changes since v2: - Moved ADC5 Gen3 documentation into a separate new file. Changes since v1: - Updated properties separately for all compatibles to clarify usage of new properties and updates in usage of old properties for ADC5 Gen3. - Avoided updating 'adc7' name to 'adc5 gen2' and just left a comment mentioning this convention. - Used predefined channel IDs in individual PMIC channel definitions instead of numeric IDs. - Addressed other comments from reviewers. .../bindings/iio/adc/qcom,spmi-vadc.yaml | 220 ++++++++++++++++-- .../iio/adc/qcom,spmi-adc5-gen3-pm8550.h | 46 ++++ .../iio/adc/qcom,spmi-adc5-gen3-pm8550b.h | 85 +++++++ .../iio/adc/qcom,spmi-adc5-gen3-pm8550vx.h | 22 ++ .../iio/adc/qcom,spmi-adc5-gen3-pmk8550.h | 52 +++++ include/dt-bindings/iio/adc/qcom,spmi-vadc.h | 81 +++++++ 6 files changed, 486 insertions(+), 20 deletions(-) create mode 100644 include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550.h create mode 100644 include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550b= .h create mode 100644 include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550v= x.h create mode 100644 include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pmk8550= .h diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml = b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml index a4f72c0c1ec6..e6e1795af886 100644 --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml @@ -13,8 +13,12 @@ maintainers: description: | SPMI PMIC voltage ADC (VADC) provides interface to clients to read voltage. The VADC is a 15-bit sigma-delta ADC. - SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read - voltage. The VADC is a 16-bit sigma-delta ADC. + SPMI PMIC5/PMIC7/PMIC5 Gen3 voltage ADC voltage ADC (ADC) provides + interface to clients to read voltage. The VADC is a 16-bit sigma-delta A= DC. + Note that PMIC7 ADC is the generation between PMIC5 and PMIC5 Gen3 ADC, + it can be considered like PMIC5 Gen2. + In addition, PMIC5 Gen3 ADC also performs the same thermal monitoring fu= nction + as the existing ADC_TM devices. =20 properties: compatible: @@ -23,14 +27,20 @@ properties: - const: qcom,pms405-adc - const: qcom,spmi-adc-rev2 - enum: - - qcom,spmi-vadc - - qcom,spmi-adc5 - qcom,spmi-adc-rev2 + - qcom,spmi-adc5 + - qcom,spmi-adc5-gen3 - qcom,spmi-adc7 + - qcom,spmi-vadc =20 reg: - description: VADC base address in the SPMI PMIC register map - maxItems: 1 + description: + For compatible properties "qcom,spmi-vadc", "qcom,spmi-adc5", "qcom,= spmi-adc-rev2" + and "qcom,spmi-adc7", reg is the VADC base address in the SPMI PMIC = register map. + For compatible property "qcom,spmi-adc5-gen3", each reg corresponds = to an SDAM + peripheral base address that is being used for ADC functionality. + minItems: 1 + maxItems: 2 =20 '#address-cells': const: 1 @@ -38,20 +48,28 @@ properties: '#size-cells': const: 0 =20 + "#thermal-sensor-cells": + const: 1 + description: + Number of cells required to uniquely identify the thermal sensors. + For compatible property "qcom,spmi-adc5-gen3", this property is + required for if any channels under it are used for ADC_TM. + Since we have multiple sensors this is set to 1. + '#io-channel-cells': const: 1 =20 interrupts: - maxItems: 1 description: End of conversion interrupt. + For compatible property "qcom,spmi-adc5-gen3", interrupts are defined + for each SDAM being used. + minItems: 1 + maxItems: 2 =20 -required: - - compatible - - reg - - '#address-cells' - - '#size-cells' - - '#io-channel-cells' + interrupt-names: + minItems: 1 + maxItems: 2 =20 patternProperties: "^channel@[0-9a-f]+$": @@ -71,8 +89,8 @@ patternProperties: description: | ADC channel number. See include/dt-bindings/iio/adc/qcom,spmi-vadc.h - For PMIC7 ADC, the channel numbers are specified separately per = PMIC - in the PMIC-specific files in include/dt-bindings/iio/adc. + For PMIC7 and PMIC5 Gen3 ADC, the channel numbers are specified = separately + per PMIC in the PMIC-specific files in include/dt-bindings/iio/a= dc. =20 label: description: | @@ -113,11 +131,11 @@ patternProperties: channel calibration. If property is not found, channel will = be calibrated with 0.625V and 1.25V reference channels, also known as absolute calibration. - - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" a= nd - "qcom,spmi-adc-rev2", if this property is specified VADC wil= l use - the VDD reference (1.875V) and GND for channel calibration. = If - property is not found, channel will be calibrated with 0V an= d 1.25V - reference channels, also known as absolute calibration. + - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7", + "qcom,spmi-adc-rev2" and "qcom,spmi-adc5-gen3", if this prop= erty is + specified VADC will use the VDD reference (1.875V) and GND f= or channel + calibration. If property is not found, channel will be calib= rated with + 0V and 1.25V reference channels, also known as absolute cali= bration. type: boolean =20 qcom,hw-settle-time: @@ -135,9 +153,24 @@ patternProperties: from the ADC that is an average of multiple samples. The value selected is 2^(value). =20 + qcom,adc-tm: + description: + Indicates if ADC_TM monitoring is done on this channel. + Defined for compatible property "qcom,spmi-adc5-gen3". + This is the same functionality as in the existing QCOM ADC_TM + device, documented at devicetree/bindings/thermal/qcom-spmi-adc-= tm5.yaml. + type: boolean + required: - reg =20 +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - '#io-channel-cells' + allOf: - if: properties: @@ -146,6 +179,15 @@ allOf: const: qcom,spmi-vadc =20 then: + properties: + reg: + minItems: 1 + maxItems: 1 + interrupts: + minItems: 1 + maxItems: 1 + "#thermal-sensor-cells": false + interrupt-names: false patternProperties: "^channel@[0-9a-f]+$": properties: @@ -162,6 +204,8 @@ allOf: enum: [ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ] default: 1 =20 + qcom,adc-tm: false + - if: properties: compatible: @@ -169,6 +213,15 @@ allOf: const: qcom,spmi-adc-rev2 =20 then: + properties: + reg: + minItems: 1 + maxItems: 1 + interrupts: + minItems: 1 + maxItems: 1 + "#thermal-sensor-cells": false + interrupt-names: false patternProperties: "^channel@[0-9a-f]+$": properties: @@ -185,6 +238,8 @@ allOf: enum: [ 1, 2, 4, 8, 16 ] default: 1 =20 + qcom,adc-tm: false + - if: properties: compatible: @@ -192,6 +247,15 @@ allOf: const: qcom,spmi-adc5 =20 then: + properties: + reg: + minItems: 1 + maxItems: 1 + interrupts: + minItems: 1 + maxItems: 1 + "#thermal-sensor-cells": false + interrupt-names: false patternProperties: "^channel@[0-9a-f]+$": properties: @@ -208,6 +272,8 @@ allOf: enum: [ 1, 2, 4, 8, 16 ] default: 1 =20 + qcom,adc-tm: false + - if: properties: compatible: @@ -215,6 +281,59 @@ allOf: const: qcom,spmi-adc7 =20 then: + properties: + reg: + minItems: 1 + maxItems: 1 + interrupts: + minItems: 1 + maxItems: 1 + "#thermal-sensor-cells": false + interrupt-names: false + patternProperties: + "^channel@[0-9a-f]+$": + properties: + qcom,decimation: + enum: [ 85, 340, 1360 ] + default: 1360 + + qcom,hw-settle-time: + enum: [ 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000, 4= 000, + 8000, 16000, 32000, 64000, 128000 ] + default: 15 + + qcom,avg-samples: + enum: [ 1, 2, 4, 8, 16 ] + default: 1 + + qcom,adc-tm: false + + - if: + properties: + compatible: + contains: + const: qcom,spmi-adc5-gen3 + + then: + properties: + reg: + minItems: 1 + items: + - description: SDAM0 base address in the SPMI PMIC register map + - description: SDAM1 base address + interrupts: + minItems: 1 + items: + - description: SDAM0 end of conversion (EOC) interrupt + - description: SDAM1 EOC interrupt + interrupt-names: + minItems: 1 + items: + - const: adc-sdam0 + - const: adc-sdam1 + required: + - interrupts + - interrupt-names patternProperties: "^channel@[0-9a-f]+$": properties: @@ -307,3 +426,64 @@ examples: }; }; }; + + - | + #include + #include + #include + #include + #include + + pmic { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@9000 { + compatible =3D "qcom,spmi-adc5-gen3"; + reg =3D <0x9000>, <0x9100>; + interrupts =3D <0x0 0x90 0x1 IRQ_TYPE_EDGE_RISING>, + <0x0 0x91 0x1 IRQ_TYPE_EDGE_RISING>; + interrupt-names =3D "adc-sdam0", "adc-sdam1"; + #address-cells =3D <1>; + #size-cells =3D <0>; + #io-channel-cells =3D <1>; + #thermal-sensor-cells =3D <1>; + + /* PMK8550 Channel nodes */ + channel@3 { + reg =3D ; + label =3D "pmk8550_die_temp"; + qcom,pre-scaling =3D <1 1>; + }; + + channel@44 { + reg =3D ; + label =3D "pmk8550_xo_therm"; + qcom,pre-scaling =3D <1 1>; + qcom,ratiometric; + qcom,hw-settle-time =3D <200>; + qcom,adc-tm; + }; + + /* PM8550 Channel nodes */ + channel@103 { + reg =3D ; + label =3D "pm8550_die_temp"; + qcom,pre-scaling =3D <1 1>; + }; + + /* PM8550B Channel nodes */ + channel@78f { + reg =3D ; + label =3D "pm8550b_vbat_sns_qbg"; + qcom,pre-scaling =3D <1 3>; + }; + + /* PM8550VS_C Channel nodes */ + channel@203 { + reg =3D ; + label =3D "pm8550vs_c_die_temp"; + qcom,pre-scaling =3D <1 1>; + }; + }; + }; diff --git a/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550.h b/inc= lude/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550.h new file mode 100644 index 000000000000..21cc607ce40e --- /dev/null +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. + */ + +#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8550_H +#define _DT_BINDINGS_QCOM_SPMI_VADC_PM8550_H + +#include + +/* ADC channels for PM8550_ADC for PMIC5 Gen3 */ +#define PM8550_ADC5_GEN3_REF_GND(sid) ((sid) << 8 | ADC5_GEN3_REF_GND) +#define PM8550_ADC5_GEN3_1P25VREF(sid) ((sid) << 8 | ADC5_GEN3_1P25VREF) +#define PM8550_ADC5_GEN3_VREF_VADC(sid) ((sid) << 8 | ADC5_GEN3_VREF_VAD= C) +#define PM8550_ADC5_GEN3_DIE_TEMP(sid) ((sid) << 8 | ADC5_GEN3_DIE_TEMP) + +#define PM8550_ADC5_GEN3_AMUX_THM1(sid) ((sid) << 8 | ADC5_GEN3_AMUX1_TH= M) +#define PM8550_ADC5_GEN3_AMUX_THM2(sid) ((sid) << 8 | ADC5_GEN3_AMUX2_TH= M) +#define PM8550_ADC5_GEN3_AMUX_THM3(sid) ((sid) << 8 | ADC5_GEN3_AMUX3_TH= M) +#define PM8550_ADC5_GEN3_AMUX_THM4(sid) ((sid) << 8 | ADC5_GEN3_AMUX4_TH= M) +#define PM8550_ADC5_GEN3_AMUX_THM5(sid) ((sid) << 8 | ADC5_GEN3_AMUX5_TH= M) +#define PM8550_ADC5_GEN3_AMUX_THM6_GPIO2(sid) ((sid) << 8 | ADC5_GEN3_AMU= X6_THM) +#define PM8550_ADC5_GEN3_AMUX1_GPIO3(sid) ((sid) << 8 | ADC5_GEN3_AMUX1_G= PIO) +#define PM8550_ADC5_GEN3_AMUX2_GPIO4(sid) ((sid) << 8 | ADC5_GEN3_AMUX2_G= PIO) +#define PM8550_ADC5_GEN3_AMUX3_GPIO7(sid) ((sid) << 8 | ADC5_GEN3_AMUX3_G= PIO) +#define PM8550_ADC5_GEN3_AMUX4_GPIO12(sid) ((sid) << 8 | ADC5_GEN3_AMUX4_= GPIO) + +/* 100k pull-up */ +#define PM8550_ADC5_GEN3_AMUX_THM1_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_A= MUX1_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX_THM2_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_A= MUX2_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX_THM3_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_A= MUX3_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX_THM4_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_A= MUX4_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX_THM5_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_A= MUX5_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX_THM6_GPIO2_100K_PU(sid) ((sid) << 8 | ADC5_G= EN3_AMUX6_THM_100K_PU) +#define PM8550_ADC5_GEN3_AMUX1_GPIO3_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_= AMUX1_GPIO_100K_PU) +#define PM8550_ADC5_GEN3_AMUX2_GPIO4_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_= AMUX2_GPIO_100K_PU) +#define PM8550_ADC5_GEN3_AMUX3_GPIO7_100K_PU(sid) ((sid) << 8 | ADC5_GEN3_= AMUX3_GPIO_100K_PU) +#define PM8550_ADC5_GEN3_AMUX4_GPIO12_100K_PU(sid) ((sid) << 8 | ADC5_GEN3= _AMUX4_GPIO_100K_PU) + +/* 1/3 Divider */ +#define PM8550_ADC5_GEN3_AMUX3_GPIO7_DIV3(sid) ((sid) << 8 | ADC5_GEN3_AM= UX3_GPIO_DIV3) +#define PM8550_ADC5_GEN3_AMUX4_GPIO12_DIV3(sid) ((sid) << 8 | ADC5_GEN3_A= MUX4_GPIO_DIV3) + +#define PM8550_ADC5_GEN3_VPH_PWR(sid) ((sid) << 8 | ADC5_GEN3_VPH_PWR) + +#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM8550_H */ diff --git a/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550b.h b/in= clude/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550b.h new file mode 100644 index 000000000000..ae5677a26434 --- /dev/null +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550b.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. + */ + +#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8550B_H +#define _DT_BINDINGS_QCOM_SPMI_VADC_PM8550B_H + +#include + +/* ADC channels for PM8550B_ADC for PMIC5 Gen3 */ +#define PM8550B_ADC5_GEN3_REF_GND(sid) ((sid) << 8 | ADC5_GEN3_REF_GND) +#define PM8550B_ADC5_GEN3_1P25VREF(sid) ((sid) << 8 | ADC5_GEN3_1P25VREF) +#define PM8550B_ADC5_GEN3_VREF_VADC(sid) ((sid) << 8 | ADC5_GEN3_VREF_VAD= C) +#define PM8550B_ADC5_GEN3_DIE_TEMP(sid) ((sid) << 8 | ADC5_GEN3_DIE_TEMP) + +#define PM8550B_ADC5_GEN3_AMUX_THM1_BATT_THERM(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX1_THM) +#define PM8550B_ADC5_GEN3_AMUX_THM2_BATT_ID(sid) ((sid) << 8 | ADC5_GEN3_A= MUX2_THM) +#define PM8550B_ADC5_GEN3_AMUX_THM3_SMB_TEMP_V(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX3_THM) +#define PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM(sid) ((sid) << 8 | ADC5_GEN3= _AMUX4_THM) +#define PM8550B_ADC5_GEN3_AMUX_THM5_OPTION(sid) ((sid) << 8 | ADC5_GEN3_A= MUX5_THM) +#define PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10(sid) ((sid) << 8 | ADC5_GEN3_A= MUX6_THM) +#define PM8550B_ADC5_GEN3_AMUX1_GPIO1(sid) ((sid) << 8 | ADC5_GEN3_AMUX1_= GPIO) +#define PM8550B_ADC5_GEN3_AMUX2_GPIO5(sid) ((sid) << 8 | ADC5_GEN3_AMUX2_= GPIO) +#define PM8550B_ADC5_GEN3_AMUX3_GPIO6(sid) ((sid) << 8 | ADC5_GEN3_AMUX3_= GPIO) +#define PM8550B_ADC5_GEN3_AMUX4_GPIO12(sid) ((sid) << 8 | ADC5_GEN3_AMUX4= _GPIO) + +#define PM8550B_ADC5_GEN3_CHG_TEMP(sid) ((sid) << 8 | ADC5_GEN3_CHG_TEMP) +#define PM8550B_ADC5_GEN3_USB_SNS_V_16(sid) ((sid) << 8 | ADC5_GEN3_USB_S= NS_V_16) +#define PM8550B_ADC5_GEN3_VIN_DIV16_MUX(sid) ((sid) << 8 | ADC5_GEN3_VIN_= DIV16_MUX) +#define PM8550B_ADC5_GEN3_VREF_BAT_THERM(sid) ((sid) << 8 | ADC5_GEN3_VRE= F_BAT_THERM) +#define PM8550B_ADC5_GEN3_IIN_FB(sid) ((sid) << 8 | ADC5_GEN3_IIN_FB) +#define PM8550B_ADC5_GEN3_TEMP_ALARM_LITE(sid) ((sid) << 8 | ADC5_GEN3_TE= MP_ALARM_LITE) +#define PM8550B_ADC5_GEN3_SMB_IIN(sid) ((sid) << 8 | ADC5_GEN3_IIN_SMB) +#define PM8550B_ADC5_GEN3_SMB_ICHG(sid) ((sid) << 8 | ADC5_GEN3_ICHG_SMB) +#define PM8550B_ADC5_GEN3_ICHG_FB(sid) ((sid) << 8 | ADC5_GEN3_ICHG_FB) + +/* 30k pull-up */ +#define PM8550B_ADC5_GEN3_AMUX_THM1_BATT_THERM_30K_PU(sid) ((sid) << 8 | A= DC5_GEN3_AMUX1_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM2_BATT_ID_30K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX2_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM3_SMB_TEMP_V_30K_PU(sid) ((sid) << 8 | A= DC5_GEN3_AMUX3_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM_30K_PU(sid) ((sid) << 8 | AD= C5_GEN3_AMUX4_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM5_OPTION_30K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX5_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10_30K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX6_THM_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX1_GPIO1_30K_PU(sid) ((sid) << 8 | ADC5_GEN3= _AMUX1_GPIO_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX2_GPIO5_30K_PU(sid) ((sid) << 8 | ADC5_GEN3= _AMUX2_GPIO_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX3_GPIO6_30K_PU(sid) ((sid) << 8 | ADC5_GEN3= _AMUX3_GPIO_30K_PU) +#define PM8550B_ADC5_GEN3_AMUX4_GPIO12_30K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX4_GPIO_30K_PU) + +/* 100k pull-up */ +#define PM8550B_ADC5_GEN3_AMUX_THM1_BATT_THERM_100K_PU(sid) ((sid) << 8 | = ADC5_GEN3_AMUX1_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM2_BATT_ID_100K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX2_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM3_SMB_TEMP_V_100K_PU(sid) ((sid) << 8 | = ADC5_GEN3_AMUX3_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM_100K_PU(sid) ((sid) << 8 | A= DC5_GEN3_AMUX4_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM5_OPTION_100K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX5_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10_100K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX6_THM_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX1_GPIO1_100K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX1_GPIO_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX2_GPIO5_100K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX2_GPIO_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX3_GPIO6_100K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX3_GPIO_100K_PU) +#define PM8550B_ADC5_GEN3_AMUX4_GPIO12_100K_PU(sid) ((sid) << 8 | ADC5_GE= N3_AMUX4_GPIO_100K_PU) + +/* 400k pull-up */ +#define PM8550B_ADC5_GEN3_AMUX_THM1_BATT_THERM_400K_PU(sid) ((sid) << 8 | = ADC5_GEN3_AMUX1_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM2_BATT_ID_400K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX2_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM3_SMB_TEMP_V_400K_PU(sid) ((sid) << 8 | = ADC5_GEN3_AMUX3_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM_400K_PU(sid) ((sid) << 8 | A= DC5_GEN3_AMUX4_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM5_OPTION_400K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX5_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10_400K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX6_THM_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX1_GPIO1_400K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX1_GPIO_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX2_GPIO5_400K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX2_GPIO_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX3_GPIO6_400K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX3_GPIO_400K_PU) +#define PM8550B_ADC5_GEN3_AMUX4_GPIO12_400K_PU(sid) ((sid) << 8 | ADC5_GE= N3_AMUX4_GPIO_400K_PU) + +/* 1/3 Divider */ +#define PM8550B_ADC5_GEN3_AMUX1_GPIO1_DIV3(sid) ((sid) << 8 | ADC5_GEN3_A= MUX1_GPIO_DIV3) +#define PM8550B_ADC5_GEN3_AMUX2_GPIO5_DIV3(sid) ((sid) << 8 | ADC5_GEN3_A= MUX2_GPIO_DIV3) +#define PM8550B_ADC5_GEN3_AMUX3_GPIO6_DIV3(sid) ((sid) << 8 | ADC5_GEN3_A= MUX3_GPIO_DIV3) + +#define PM8550B_ADC5_GEN3_VPH_PWR(sid) ((sid) << 8 | ADC5_GEN3_VPH_PWR) +#define PM8550B_ADC5_GEN3_VBAT_SNS_QBG(sid) ((sid) << 8 | ADC5_GEN3_VBAT_= SNS_QBG) +#define PM8550B_ADC5_GEN3_VBAT_SNS_CHGR(sid) ((sid) << 8 | ADC5_GEN3_VBAT= _SNS_CHGR) +#define PM8550B_ADC5_GEN3_VBAT_2S_MID_QBG(sid) ((sid) << 8 | ADC5_GEN3_VB= AT_2S_MID_QBG) +#define PM8550B_ADC5_GEN3_VBAT_2S_MID_CHGR(sid) ((sid) << 8 | ADC5_GEN3_V= BAT_2S_MID_CHGR) + +#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM8550B_H */ diff --git a/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550vx.h b/i= nclude/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550vx.h new file mode 100644 index 000000000000..c6d2857d5c0c --- /dev/null +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pm8550vx.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. + */ + +#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM8550VX_H +#define _DT_BINDINGS_QCOM_SPMI_VADC_PM8550VX_H + +#include + +/* ADC channels for PM8550VX_ADC for PMIC5 Gen3 */ +#define PM8550VS_ADC5_GEN3_REF_GND(sid) ((sid) << 8 | ADC5_GEN3_REF_GND) +#define PM8550VS_ADC5_GEN3_1P25VREF(sid) ((sid) << 8 | ADC5_GEN3_1P25VRE= F) +#define PM8550VS_ADC5_GEN3_VREF_VADC(sid) ((sid) << 8 | ADC5_GEN3_VREF_V= ADC) +#define PM8550VS_ADC5_GEN3_DIE_TEMP(sid) ((sid) << 8 | ADC5_GEN3_DIE_TEM= P) + +#define PM8550VE_ADC5_GEN3_OFFSET_REF(sid) ((sid) << 8 | ADC5_GEN3_REF_G= ND) +#define PM8550VE_ADC5_GEN3_1P25VREF(sid) ((sid) << 8 | ADC5_GEN3_1P25VRE= F) +#define PM8550VE_ADC5_GEN3_VREF_VADC(sid) ((sid) << 8 | ADC5_GEN3_VREF_V= ADC) +#define PM8550VE_ADC5_GEN3_DIE_TEMP(sid) ((sid) << 8 | ADC5_GEN3_DIE_TEMP) + +#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM8550VX_H */ diff --git a/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pmk8550.h b/in= clude/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pmk8550.h new file mode 100644 index 000000000000..2e43f7e3acb8 --- /dev/null +++ b/include/dt-bindings/iio/adc/qcom,spmi-adc5-gen3-pmk8550.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. + */ + +#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMK8550_H +#define _DT_BINDINGS_QCOM_SPMI_VADC_PMK8550_H + +#include + +/* ADC channels for PMK8550_ADC for PMIC5 Gen3 */ +#define PMK8550_ADC5_GEN3_REF_GND(sid) ((sid) << 8 | ADC5_GEN3_REF_GND) +#define PMK8550_ADC5_GEN3_1P25VREF(sid) ((sid) << 8 | ADC5_GEN3_1P25VREF) +#define PMK8550_ADC5_GEN3_VREF_VADC(sid) ((sid) << 8 | ADC5_GEN3_VREF_VAD= C) +#define PMK8550_ADC5_GEN3_DIE_TEMP(sid) ((sid) << 8 | ADC5_GEN3_DIE_TEMP) + +#define PMK8550_ADC5_GEN3_AMUX_THM1_XO_THERM(sid) ((sid) << 8 | ADC5_GEN3_= AMUX1_THM) +#define PMK8550_ADC5_GEN3_AMUX_THM2_GPIO1(sid) ((sid) << 8 | ADC5_GEN3_AM= UX2_THM) +#define PMK8550_ADC5_GEN3_AMUX_THM3_GPIO2(sid) ((sid) << 8 | ADC5_GEN3_AM= UX3_THM) +#define PMK8550_ADC5_GEN3_AMUX_THM4_GPIO3(sid) ((sid) << 8 | ADC5_GEN3_AM= UX4_THM) +#define PMK8550_ADC5_GEN3_AMUX_THM5_GPIO4(sid) ((sid) << 8 | ADC5_GEN3_AM= UX5_THM) +#define PMK8550_ADC5_GEN3_AMUX_THM6_GPIO5(sid) ((sid) << 8 | ADC5_GEN3_AM= UX6_THM) +#define PMK8550_ADC5_GEN3_AMUX1_GPIO6(sid) ((sid) << 8 | ADC5_GEN3_AMUX1_= GPIO) + +/* 30k pull-up */ +#define PMK8550_ADC5_GEN3_AMUX_THM1_XO_THERM_30K_PU(sid) ((sid) << 8 | ADC= 5_GEN3_AMUX1_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM2_GPIO1_30K_PU(sid) ((sid) << 8 | ADC5_= GEN3_AMUX2_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM3_GPIO2_30K_PU(sid) ((sid) << 8 | ADC5_= GEN3_AMUX3_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM4_GPIO3_30K_PU(sid) ((sid) << 8 | ADC5_= GEN3_AMUX4_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM5_GPIO4_30K_PU(sid) ((sid) << 8 | ADC5_= GEN3_AMUX5_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM6_GPIO5_30K_PU(sid) ((sid) << 8 | ADC5_= GEN3_AMUX6_THM_30K_PU) +#define PMK8550_ADC5_GEN3_AMUX1_GPIO6_30K_PU(sid) ((sid) << 8 | ADC5_GEN3= _AMUX1_GPIO_30K_PU) + +/* 100k pull-up */ +#define PMK8550_ADC5_GEN3_AMUX_THM1_XO_THERM_100K_PU(sid) ((sid) << 8 | AD= C5_GEN3_AMUX1_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM2_GPIO1_100K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX2_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM3_GPIO2_100K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX3_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM4_GPIO3_100K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX4_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM5_GPIO4_100K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX5_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM6_GPIO5_100K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX6_THM_100K_PU) +#define PMK8550_ADC5_GEN3_AMUX1_GPIO6_100K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX1_GPIO_100K_PU) + +/* 400k pull-up */ +#define PMK8550_ADC5_GEN3_AMUX_THM1_XO_THERM_400K_PU(sid) ((sid) << 8 | AD= C5_GEN3_AMUX1_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM2_GPIO1_400K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX2_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM3_GPIO2_400K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX3_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM4_GPIO3_400K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX4_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM5_GPIO4_400K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX5_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX_THM6_GPIO5_400K_PU(sid) ((sid) << 8 | ADC5= _GEN3_AMUX6_THM_400K_PU) +#define PMK8550_ADC5_GEN3_AMUX1_GPIO6_400K_PU(sid) ((sid) << 8 | ADC5_GEN= 3_AMUX1_GPIO_400K_PU) + +#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMK8550_H */ diff --git a/include/dt-bindings/iio/adc/qcom,spmi-vadc.h b/include/dt-bind= ings/iio/adc/qcom,spmi-vadc.h index ef07ecd4d585..ed786f6c3425 100644 --- a/include/dt-bindings/iio/adc/qcom,spmi-vadc.h +++ b/include/dt-bindings/iio/adc/qcom,spmi-vadc.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2012-2014,2018,2020 The Linux Foundation. All rights rese= rved. + * + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. */ =20 #ifndef _DT_BINDINGS_QCOM_SPMI_VADC_H @@ -300,4 +302,83 @@ #define ADC7_SBUx 0x94 #define ADC7_VBAT_2S_MID 0x96 =20 +/* ADC channels for PMIC5 Gen3 */ + +#define ADC5_GEN3_REF_GND 0x00 +#define ADC5_GEN3_1P25VREF 0x01 +#define ADC5_GEN3_VREF_VADC 0x02 +#define ADC5_GEN3_DIE_TEMP 0x03 + +#define ADC5_GEN3_AMUX1_THM 0x04 +#define ADC5_GEN3_AMUX2_THM 0x05 +#define ADC5_GEN3_AMUX3_THM 0x06 +#define ADC5_GEN3_AMUX4_THM 0x07 +#define ADC5_GEN3_AMUX5_THM 0x08 +#define ADC5_GEN3_AMUX6_THM 0x09 +#define ADC5_GEN3_AMUX1_GPIO 0x0a +#define ADC5_GEN3_AMUX2_GPIO 0x0b +#define ADC5_GEN3_AMUX3_GPIO 0x0c +#define ADC5_GEN3_AMUX4_GPIO 0x0d + +#define ADC5_GEN3_CHG_TEMP 0x10 +#define ADC5_GEN3_USB_SNS_V_16 0x11 +#define ADC5_GEN3_VIN_DIV16_MUX 0x12 +#define ADC5_GEN3_VREF_BAT_THERM 0x15 +#define ADC5_GEN3_IIN_FB 0x17 +#define ADC5_GEN3_TEMP_ALARM_LITE 0x18 +#define ADC5_GEN3_IIN_SMB 0x19 +#define ADC5_GEN3_ICHG_SMB 0x1b +#define ADC5_GEN3_ICHG_FB 0xa1 + +/* 30k pull-up1 */ +#define ADC5_GEN3_AMUX1_THM_30K_PU 0x24 +#define ADC5_GEN3_AMUX2_THM_30K_PU 0x25 +#define ADC5_GEN3_AMUX3_THM_30K_PU 0x26 +#define ADC5_GEN3_AMUX4_THM_30K_PU 0x27 +#define ADC5_GEN3_AMUX5_THM_30K_PU 0x28 +#define ADC5_GEN3_AMUX6_THM_30K_PU 0x29 +#define ADC5_GEN3_AMUX1_GPIO_30K_PU 0x2a +#define ADC5_GEN3_AMUX2_GPIO_30K_PU 0x2b +#define ADC5_GEN3_AMUX3_GPIO_30K_PU 0x2c +#define ADC5_GEN3_AMUX4_GPIO_30K_PU 0x2d + +/* 100k pull-up2 */ +#define ADC5_GEN3_AMUX1_THM_100K_PU 0x44 +#define ADC5_GEN3_AMUX2_THM_100K_PU 0x45 +#define ADC5_GEN3_AMUX3_THM_100K_PU 0x46 +#define ADC5_GEN3_AMUX4_THM_100K_PU 0x47 +#define ADC5_GEN3_AMUX5_THM_100K_PU 0x48 +#define ADC5_GEN3_AMUX6_THM_100K_PU 0x49 +#define ADC5_GEN3_AMUX1_GPIO_100K_PU 0x4a +#define ADC5_GEN3_AMUX2_GPIO_100K_PU 0x4b +#define ADC5_GEN3_AMUX3_GPIO_100K_PU 0x4c +#define ADC5_GEN3_AMUX4_GPIO_100K_PU 0x4d + +/* 400k pull-up3 */ +#define ADC5_GEN3_AMUX1_THM_400K_PU 0x64 +#define ADC5_GEN3_AMUX2_THM_400K_PU 0x65 +#define ADC5_GEN3_AMUX3_THM_400K_PU 0x66 +#define ADC5_GEN3_AMUX4_THM_400K_PU 0x67 +#define ADC5_GEN3_AMUX5_THM_400K_PU 0x68 +#define ADC5_GEN3_AMUX6_THM_400K_PU 0x69 +#define ADC5_GEN3_AMUX1_GPIO_400K_PU 0x6a +#define ADC5_GEN3_AMUX2_GPIO_400K_PU 0x6b +#define ADC5_GEN3_AMUX3_GPIO_400K_PU 0x6c +#define ADC5_GEN3_AMUX4_GPIO_400K_PU 0x6d + +/* 1/3 Divider */ +#define ADC5_GEN3_AMUX1_GPIO_DIV3 0x8a +#define ADC5_GEN3_AMUX2_GPIO_DIV3 0x8b +#define ADC5_GEN3_AMUX3_GPIO_DIV3 0x8c +#define ADC5_GEN3_AMUX4_GPIO_DIV3 0x8d + +#define ADC5_GEN3_VPH_PWR 0x8e +#define ADC5_GEN3_VBAT_SNS_QBG 0x8f + +#define ADC5_GEN3_VBAT_SNS_CHGR 0x94 +#define ADC5_GEN3_VBAT_2S_MID_QBG 0x96 +#define ADC5_GEN3_VBAT_2S_MID_CHGR 0x9d + +#define ADC5_GEN3_OFFSET_EXT2 0xf8 + #endif /* _DT_BINDINGS_QCOM_SPMI_VADC_H */ --=20 2.25.1 From nobody Mon Nov 25 03:04:08 2024 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 A214B1CFEDE; Wed, 30 Oct 2024 19:00:45 +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=1730314850; cv=none; b=oNhrFvEdo2zon0pY0JpEI3+nmuUSVE+4MjHqS88dYrggnBEX7NDmLkYOaqA2ZHHwntP3CQ29dcxS0SVnTxuVO5s49XLRGl713DEjr8aeDAo/9JcnfCdj7DsDU2LiZJyzlLcbGC6bKTNfl/j3L9P5crYL0gfL+X+v8w70T97Lsug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730314850; c=relaxed/simple; bh=gmw1kDOkt6a+avY+RffAKk5mou+gg54UZn5bAy8/lNM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lzp/QxNkaSgwHzdxcenk0yvP69FKmeAOmmkhlW8OT/tHulFxBSuRr7cuDp89cULZcVQLS2aOxTlh7optcY3kqqt+Ur289PzRJn/Qc6POq2zH1xaFN7NtHHVhigor0IjgFwxVHMc8Kr4zX4bPVKlPvxXyZZZNLDy9EQb/7WBgkrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mxVEI0h2; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mxVEI0h2" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UDWOId004036; Wed, 30 Oct 2024 19:00:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= jj/FBYAC3oGe0nOgIamtCPgsPiWO2tqBLr2TXuLo0CA=; b=mxVEI0h2hcl0tkb2 hqQ27nAjVUgYXcCTn/f1vxXdYdHq0qr1ohQKAb/CPAHxZV1x8HTxMicWW0hyXGWO E9aLy7bJYmZf3fplUQkdC4LyR7rQNYk5EgjkwABGcTh5zCt3U0AWhqVgLjSo+ZXi a36p9YXXXxZ1CDpjd9B5siO1LMEyCbFvmCjlLSK/FBBNVv2rjewz9wwcNzS+FeuI 6IQIYExptgxGJ+9u+GGcnKPyasclWoZqAztzYM32d7Ltu4nozsFEw4R7OY5LNJiM 9hd3cL6LGRrSxmLRhLyOBx8YMgvIonveGDu05REak43B9u5i3pwKXR7vIpBOOy4c PIk+ZA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42kns3gwch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:11 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49UJ0B5d003327 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:11 GMT Received: from hu-jprakash-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 30 Oct 2024 12:00:02 -0700 From: Jishnu Prakash To: , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Jishnu Prakash Subject: [PATCH V4 3/4] iio: adc: Add support for QCOM PMIC5 Gen3 ADC Date: Thu, 31 Oct 2024 00:28:53 +0530 Message-ID: <20241030185854.4015348-4-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241030185854.4015348-1-quic_jprakash@quicinc.com> References: <20241030185854.4015348-1-quic_jprakash@quicinc.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-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Oc_P-kmx10_ZAh1XOK0vWuAYXB-iwmPg X-Proofpoint-ORIG-GUID: Oc_P-kmx10_ZAh1XOK0vWuAYXB-iwmPg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410300150 Content-Type: text/plain; charset="utf-8" The ADC architecture on PMIC5 Gen3 is similar to that on PMIC5 Gen2, with all SW communication to ADC going through PMK8550 which communicates with other PMICs through PBS. One major difference is that the register interface used here is that of an SDAM (Shared Direct Access Memory) peripheral present on PMK8550. There may be more than one SDAM used for ADC5 Gen3 and each has eight channels, which may be used for either immediate reads (same functionality as previous PMIC5 and PMIC5 Gen2 ADC peripherals) or recurring measurements (same as ADC_TM functionality). By convention, we reserve the first channel of the first SDAM for all immediate reads and use the remaining channels across all SDAMs for ADC_TM monitoring functionality. Add support for PMIC5 Gen3 ADC driver for immediate read functionality. ADC_TM is implemented as an auxiliary thermal driver under this ADC driver. Signed-off-by: Jishnu Prakash --- Changes since v3: - Split out TM functionality into auxiliary driver in separate patch and added required changes in main driver. - Addressed other reviewer comments in main driver patch.=20 Changes since v1: - Removed datashet_name usage and implemented read_label() function - In probe, updated channel property in iio_chan_spec from individual channel to virtual channel and set indexed property to 1, due to the above change. - Updated order of checks in ISR - Removed the driver remove callback and replaced with callbacks in a devm_add_action call in probe. - Addressed other comments from reviewers. drivers/iio/adc/Kconfig | 25 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/qcom-spmi-adc5-gen3.c | 724 ++++++++++++++++++ include/linux/iio/adc/qcom-adc5-gen3-common.h | 233 ++++++ 4 files changed, 983 insertions(+) create mode 100644 drivers/iio/adc/qcom-spmi-adc5-gen3.c create mode 100644 include/linux/iio/adc/qcom-adc5-gen3-common.h diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 849c90203071..11f8cb1de085 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1165,6 +1165,31 @@ config QCOM_SPMI_ADC5 To compile this driver as a module, choose M here: the module will be called qcom-spmi-adc5. =20 +config QCOM_SPMI_ADC5_GEN3 + tristate "Qualcomm Technologies Inc. SPMI PMIC5 GEN3 ADC" + depends on SPMI && THERMAL + select REGMAP_SPMI + select QCOM_VADC_COMMON + help + This is the IIO Voltage PMIC5 Gen3 ADC driver for Qualcomm Technologies= Inc. PMICs. + + The driver supports reading multiple channels. The ADC is a 16-bit + sigma-delta ADC. The hardware supports calibrated results for + conversion requests and clients include reading phone power supply + voltage, on board system thermistors connected to the PMIC ADC, + PMIC die temperature, charger temperature, battery current, USB voltage + input and voltage signals connected to supported PMIC GPIO pins. The + hardware supports internal pull-up for thermistors and can choose betwe= en + a 30k, 100k or 400k ohm pull up using the ADC channels. + + In addition, the same driver supports ADC thermal monitoring devices to= o. + They appear as thermal zones with multiple trip points. A thermal clien= t sets + threshold temperature for both warm and cool trips and gets updated whe= n a + threshold is reached. + + To compile this driver as a module, choose M here: the module will + be called qcom-spmi-adc5-gen3. + config RCAR_GYRO_ADC tristate "Renesas R-Car GyroADC driver" depends on ARCH_RCAR_GEN2 || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index ee19afba62b7..1f8a02e608dd 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -100,6 +100,7 @@ obj-$(CONFIG_PAC1934) +=3D pac1934.o obj-$(CONFIG_PALMAS_GPADC) +=3D palmas_gpadc.o obj-$(CONFIG_QCOM_PM8XXX_XOADC) +=3D qcom-pm8xxx-xoadc.o obj-$(CONFIG_QCOM_SPMI_ADC5) +=3D qcom-spmi-adc5.o +obj-$(CONFIG_QCOM_SPMI_ADC5_GEN3) +=3D qcom-spmi-adc5-gen3.o obj-$(CONFIG_QCOM_SPMI_IADC) +=3D qcom-spmi-iadc.o obj-$(CONFIG_QCOM_SPMI_RRADC) +=3D qcom-spmi-rradc.o obj-$(CONFIG_QCOM_SPMI_VADC) +=3D qcom-spmi-vadc.o diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-s= pmi-adc5-gen3.c new file mode 100644 index 000000000000..41f7f6534745 --- /dev/null +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c @@ -0,0 +1,724 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserve= d. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ADC5_GEN3_VADC_SDAM 0x0 + +struct adc5_chip; + +/** + * @adc_tm: indicates TM type if the channel is used for TM measurements. + * @chip: pointer to top-level ADC device structure. + */ + +struct adc5_channel_prop { + struct adc5_channel_common_prop common_props; + int adc_tm; + struct adc5_chip *chip; +}; + +/** + * struct adc5_chip - ADC private structure. + * @dev: SPMI ADC5 Gen3 device. + * @num_sdams: number of SDAMs (Shared Direct Access Memory Module) being = used. + * @nchannels: number of ADC channels. + * @chan_props: array of ADC channel properties. + * @iio_chans: array of IIO channels specification. + * @complete: ADC result notification after interrupt is received. + * @lock: ADC lock for access to the peripheral, to prevent concurrent + * requests from multiple clients. + * @n_tm_channels: number of ADC channels used for TM measurements. + * @data: software configuration data. + */ +struct adc5_chip { + struct device *dev; + struct adc5_device_data dev_data; + unsigned int num_sdams; + unsigned int nchannels; + struct adc5_channel_prop *chan_props; + struct iio_chan_spec *iio_chans; + struct completion complete; + /* + * lock for access to the peripheral, to prevent concurrent + * requests from multiple clients. + */ + struct mutex lock; + const struct adc5_data *data; + unsigned int n_tm_channels; + struct auxiliary_device *tm_aux; +}; + +static int adc5_gen3_read_voltage_data(struct adc5_chip *adc, u16 *data) +{ + u8 rslt[2]; + int ret; + + ret =3D adc5_gen3_read(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_CH_= DATA0(0), rslt, 2); + if (ret) + return ret; + + *data =3D get_unaligned_le16(rslt); + + if (*data =3D=3D ADC5_USR_DATA_CHECK) { + dev_err(adc->dev, "Invalid data:%#x\n", *data); + return -EINVAL; + } + + dev_dbg(adc->dev, "voltage raw code:%#x\n", *data); + + return 0; +} + +#define ADC5_GEN3_READ_CONFIG_REGS 7 + +static int adc5_gen3_configure(struct adc5_chip *adc, struct adc5_channel_= common_prop *prop) +{ + u8 buf[ADC5_GEN3_READ_CONFIG_REGS]; + u8 conv_req =3D 0; + int ret; + + ret =3D adc5_gen3_read(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_SID= , buf, sizeof(buf)); + if (ret) + return ret; + + /* Write SID */ + buf[0] =3D FIELD_PREP(ADC5_GEN3_SID_MASK, prop->sid); + + /* + * Use channel 0 by default for immediate conversion and + * to indicate there is an actual conversion request + */ + buf[1] =3D ADC5_GEN3_CHAN_CONV_REQ | 0; + + buf[2] =3D ADC5_GEN3_TIME_IMMEDIATE; + + /* Digital param selection */ + adc5_gen3_update_dig_param(prop, &buf[3]); + + /* Update fast average sample value */ + buf[4] =3D FIELD_PREP(ADC5_GEN3_FAST_AVG_CTL_SAMPLES_MASK, prop->avg_samp= les) + | ADC5_GEN3_FAST_AVG_CTL_EN; + + /* Select ADC channel */ + buf[5] =3D prop->channel; + + /* Select HW settle delay for channel */ + buf[6] =3D FIELD_PREP(ADC5_GEN3_HW_SETTLE_DELAY_MASK, prop->hw_settle_tim= e); + + reinit_completion(&adc->complete); + + ret =3D adc5_gen3_write(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_SI= D, buf, sizeof(buf)); + if (ret) + return ret; + + conv_req =3D ADC5_GEN3_CONV_REQ_REQ; + return adc5_gen3_write(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_CON= V_REQ, &conv_req, + 1); +} + +/* + * Worst case delay from PBS for conversion time can be + * up to 500ms, when PBS has timed out twice, once for + * the initial attempt and once for a retry of the same + * transaction. + */ + +#define ADC5_GEN3_CONV_TIMEOUT_MS 501 + +static int adc5_gen3_do_conversion(struct adc5_chip *adc, + struct adc5_channel_common_prop *prop, u16 *data_volt) +{ + unsigned long rc; + int ret; + u8 val; + + guard(mutex)(&adc->lock); + ret =3D adc5_gen3_poll_wait_hs(&adc->dev_data, ADC5_GEN3_VADC_SDAM); + if (ret) + return ret; + + ret =3D adc5_gen3_configure(adc, prop); + if (ret) { + dev_err(adc->dev, "ADC configure failed with %d\n", ret); + return ret; + } + + /* No support for polling mode at present */ + rc =3D wait_for_completion_timeout(&adc->complete, + msecs_to_jiffies(ADC5_GEN3_CONV_TIMEOUT_MS)); + if (!rc) { + dev_err(adc->dev, "Reading ADC channel %s timed out\n", + prop->label); + return -ETIMEDOUT; + } + + ret =3D adc5_gen3_read_voltage_data(adc, data_volt); + if (ret) + return ret; + + val =3D BIT(0); + return adc5_gen3_status_clear(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_G= EN3_EOC_CLR, &val, + 1); +} + +static irqreturn_t adc5_gen3_isr(int irq, void *dev_id) +{ + u8 status, tm_status[2], eoc_status, val; + struct adc_tm5_auxiliary_drv *adrv_tm; + struct adc5_chip *adc =3D dev_id; + struct auxiliary_device *adev; + int ret; + + ret =3D adc5_gen3_read(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_STA= TUS1, &status, 1); + if (ret) { + dev_err(adc->dev, "adc read status1 failed with %d\n", ret); + return IRQ_HANDLED; + } + + ret =3D adc5_gen3_read(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_EOC= _STS, &eoc_status, + 1); + if (ret) { + dev_err(adc->dev, "adc read eoc status failed with %d\n", ret); + return IRQ_HANDLED; + } + + if (status & ADC5_GEN3_STATUS1_CONV_FAULT) { + dev_err_ratelimited(adc->dev, "Unexpected conversion fault, status:%#x, = eoc_status:%#x\n", + status, eoc_status); + val =3D ADC5_GEN3_CONV_ERR_CLR_REQ; + adc5_gen3_status_clear(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_CO= NV_ERR_CLR, + &val, 1); + return IRQ_HANDLED; + } + + /* CHAN0 is the preconfigured channel for immediate conversion */ + if (eoc_status & ADC5_GEN3_EOC_CHAN_0) + complete(&adc->complete); + + ret =3D adc5_gen3_read(&adc->dev_data, ADC5_GEN3_VADC_SDAM, ADC5_GEN3_TM_= HIGH_STS, + tm_status, 2); + if (ret) { + dev_err(adc->dev, "adc read TM status failed with %d\n", ret); + return IRQ_HANDLED; + } + + if (tm_status[0] || tm_status[1]) { + adev =3D adc->tm_aux; + if (!adev || !adev->dev.driver) { + dev_err(adc->dev, "adc_tm auxiliary device not initialized\n"); + return IRQ_HANDLED; + } + + adrv_tm =3D container_of(adev->dev.driver, struct adc_tm5_auxiliary_drv,= adrv.driver); + + if (adrv_tm && adrv_tm->tm_event_notify) + adrv_tm->tm_event_notify(adev); + else + dev_err(adc->dev, "adc_tm auxiliary driver not initialized\n"); + } + + dev_dbg(adc->dev, "Interrupt status:%#x, EOC status:%#x, high:%#x, low:%#= x\n", + status, eoc_status, tm_status[0], tm_status[1]); + + return IRQ_HANDLED; +} + +static int adc5_gen3_fwnode_xlate(struct iio_dev *indio_dev, + const struct fwnode_reference_args *iiospec) +{ + struct adc5_chip *adc =3D iio_priv(indio_dev); + int i, v_channel; + + for (i =3D 0; i < adc->nchannels; i++) { + v_channel =3D V_CHAN(adc->chan_props[i].common_props); + if (v_channel =3D=3D iiospec->args[0]) + return i; + } + + return -ENOENT; +} + +static int adc5_gen3_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, int *val2, + long mask) +{ + struct adc5_chip *adc =3D iio_priv(indio_dev); + struct adc5_channel_common_prop *prop; + u16 adc_code_volt; + int ret; + + prop =3D &adc->chan_props[chan->address].common_props; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + ret =3D adc5_gen3_do_conversion(adc, prop, &adc_code_volt); + if (ret) + return ret; + + ret =3D qcom_adc5_hw_scale(prop->scale_fn_type, prop->prescale, + adc->data, adc_code_volt, val); + if (ret) + return ret; + + return IIO_VAL_INT; + case IIO_CHAN_INFO_RAW: + ret =3D adc5_gen3_do_conversion(adc, prop, &adc_code_volt); + if (ret) + return ret; + *val =3D (int)adc_code_volt; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int adc5_gen3_read_label(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, char *label) +{ + struct adc5_chip *adc =3D iio_priv(indio_dev); + struct adc5_channel_prop *prop; + + prop =3D &adc->chan_props[chan->address]; + return sprintf(label, "%s\n", prop->common_props.label); +} + +static const struct iio_info adc5_gen3_info =3D { + .read_raw =3D adc5_gen3_read_raw, + .read_label =3D adc5_gen3_read_label, + .fwnode_xlate =3D adc5_gen3_fwnode_xlate, +}; + +struct adc5_channels { + unsigned int prescale_index; + enum iio_chan_type type; + long info_mask; + enum vadc_scale_fn_type scale_fn_type; +}; + +/* In these definitions, _pre refers to an index into adc5_prescale_ratios= . */ +#define ADC5_CHAN(_type, _mask, _pre, _scale) \ + { \ + .prescale_index =3D _pre, \ + .type =3D _type, \ + .info_mask =3D _mask, \ + .scale_fn_type =3D _scale, \ + }, \ + +#define ADC5_CHAN_TEMP(_pre, _scale) \ + ADC5_CHAN(IIO_TEMP, BIT(IIO_CHAN_INFO_PROCESSED), _pre, _scale) \ + +#define ADC5_CHAN_VOLT(_pre, _scale) \ + ADC5_CHAN(IIO_VOLTAGE, BIT(IIO_CHAN_INFO_PROCESSED), _pre, _scale) \ + +#define ADC5_CHAN_CUR(_pre, _scale) \ + ADC5_CHAN(IIO_CURRENT, BIT(IIO_CHAN_INFO_PROCESSED), _pre, _scale) \ + +static const struct adc5_channels adc5_gen3_chans_pmic[ADC5_MAX_CHANNEL] = =3D { + [ADC5_GEN3_REF_GND] =3D ADC5_CHAN_VOLT(0, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_1P25VREF] =3D ADC5_CHAN_VOLT(0, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_VPH_PWR] =3D ADC5_CHAN_VOLT(1, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_VBAT_SNS_QBG] =3D ADC5_CHAN_VOLT(1, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_USB_SNS_V_16] =3D ADC5_CHAN_TEMP(8, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_VIN_DIV16_MUX] =3D ADC5_CHAN_TEMP(8, SCALE_HW_CALIB_DEFAULT) + [ADC5_GEN3_DIE_TEMP] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_PMIC_THERM_PM7) + [ADC5_GEN3_TEMP_ALARM_LITE] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_PMIC_THERM_PM7) + [ADC5_GEN3_AMUX1_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX2_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX3_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX4_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX5_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX6_THM_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX1_GPIO_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX2_GPIO_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX3_GPIO_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) + [ADC5_GEN3_AMUX4_GPIO_100K_PU] =3D ADC5_CHAN_TEMP(0, + SCALE_HW_CALIB_THERM_100K_PU_PM7) +}; + +static int adc5_gen3_get_fw_channel_data(struct adc5_chip *adc, + struct adc5_channel_prop *prop, + struct fwnode_handle *fwnode) +{ + const char *name =3D fwnode_get_name(fwnode); + const struct adc5_data *data =3D adc->data; + u32 chan, value, varr[2], sid =3D 0; + struct device *dev =3D adc->dev; + const char *channel_name; + int ret; + + ret =3D fwnode_property_read_u32(fwnode, "reg", &chan); + if (ret < 0) + return dev_err_probe(dev, ret, "invalid channel number %s\n", name); + + /* + * Value read from "reg" is virtual channel number + * virtual channel number =3D sid << 8 | channel number + */ + sid =3D FIELD_GET(ADC5_GEN3_VIRTUAL_SID_MASK, chan); + chan =3D FIELD_GET(ADC5_GEN3_CHANNEL_MASK, chan); + + if (chan > ADC5_GEN3_OFFSET_EXT2) + return dev_err_probe(dev, -EINVAL, "%s invalid channel number %d\n", nam= e, chan); + + prop->common_props.channel =3D chan; + prop->common_props.sid =3D sid; + + channel_name =3D name; + fwnode_property_read_string(fwnode, "label", &channel_name); + prop->common_props.label =3D channel_name; + + value =3D data->decimation[ADC5_DECIMATION_DEFAULT]; + fwnode_property_read_u32(fwnode, "qcom,decimation", &value); + ret =3D qcom_adc5_decimation_from_dt(value, data->decimation); + if (ret < 0) + return dev_err_probe(dev, ret, "%#x invalid decimation %d\n", + chan, value); + prop->common_props.decimation =3D ret; + + prop->common_props.prescale =3D adc->data->adc_chans[chan].prescale_index; + ret =3D fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, = 2); + if (!ret) { + ret =3D qcom_adc5_prescaling_from_dt(varr[0], varr[1]); + if (ret < 0) + return dev_err_probe(dev, ret, "%#x invalid pre-scaling <%d %d>\n", + chan, varr[0], varr[1]); + prop->common_props.prescale =3D ret; + } + + value =3D data->hw_settle_1[VADC_DEF_HW_SETTLE_TIME]; + fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value); + ret =3D qcom_adc5_hw_settle_time_from_dt(value, data->hw_settle_1); + if (ret < 0) + return dev_err_probe(dev, ret, "%#x invalid hw-settle-time %d us\n", + chan, value); + prop->common_props.hw_settle_time =3D ret; + + value =3D BIT(VADC_DEF_AVG_SAMPLES); + fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value); + ret =3D qcom_adc5_avg_samples_from_dt(value); + if (ret < 0) + return dev_err_probe(dev, ret, "%#x invalid avg-samples %d\n", + chan, value); + prop->common_props.avg_samples =3D ret; + + if (fwnode_property_read_bool(fwnode, "qcom,ratiometric")) + prop->common_props.cal_method =3D ADC5_RATIOMETRIC_CAL; + else + prop->common_props.cal_method =3D ADC5_ABSOLUTE_CAL; + + prop->adc_tm =3D fwnode_property_read_bool(fwnode, "qcom,adc-tm"); + if (prop->adc_tm) { + adc->n_tm_channels++; + if (adc->n_tm_channels > ((adc->num_sdams * 8) - 1)) + return dev_err_probe(dev, -EINVAL, + "Number of TM nodes %u greater than channels supported:%u\n", + adc->n_tm_channels, (adc->num_sdams * 8) - 1); + } + + return 0; +} + +static const struct adc5_data adc5_gen3_data_pmic =3D { + .full_scale_code_volt =3D 0x70e4, + .adc_chans =3D adc5_gen3_chans_pmic, + .info =3D &adc5_gen3_info, + .decimation =3D (unsigned int [ADC5_DECIMATION_SAMPLES_MAX]) + {85, 340, 1360}, + .hw_settle_1 =3D (unsigned int [VADC_HW_SETTLE_SAMPLES_MAX]) + {15, 100, 200, 300, 400, 500, 600, 700, + 1000, 2000, 4000, 8000, 16000, 32000, + 64000, 128000}, +}; + +static const struct of_device_id adc5_match_table[] =3D { + { + .compatible =3D "qcom,spmi-adc5-gen3", + .data =3D &adc5_gen3_data_pmic, + }, + { } +}; +MODULE_DEVICE_TABLE(of, adc5_match_table); + +static int adc5_get_fw_data(struct adc5_chip *adc) +{ + const struct adc5_channels *adc_chan; + struct adc5_channel_prop *chan_props; + struct fwnode_handle *child =3D NULL; + struct iio_chan_spec *iio_chan; + unsigned int index =3D 0; + int ret; + + adc->nchannels =3D device_get_child_node_count(adc->dev); + if (!adc->nchannels) { + dev_err(adc->dev, "No ADC channels found\n"); + return -EINVAL; + } + + adc->iio_chans =3D devm_kcalloc(adc->dev, adc->nchannels, + sizeof(*adc->iio_chans), GFP_KERNEL); + if (!adc->iio_chans) + return -ENOMEM; + + adc->chan_props =3D devm_kcalloc(adc->dev, adc->nchannels, + sizeof(*adc->chan_props), GFP_KERNEL); + if (!adc->chan_props) + return -ENOMEM; + + chan_props =3D adc->chan_props; + adc->n_tm_channels =3D 0; + iio_chan =3D adc->iio_chans; + adc->data =3D device_get_match_data(adc->dev); + + device_for_each_child_node(adc->dev, child) { + ret =3D adc5_gen3_get_fw_channel_data(adc, chan_props, child); + if (ret < 0) + return ret; + + chan_props->chip =3D adc; + adc_chan =3D &adc->data->adc_chans[chan_props->common_props.channel]; + chan_props->common_props.scale_fn_type =3D adc_chan->scale_fn_type; + + iio_chan->channel =3D V_CHAN(chan_props->common_props); + iio_chan->info_mask_separate =3D adc_chan->info_mask; + iio_chan->type =3D adc_chan->type; + iio_chan->address =3D index; + iio_chan->indexed =3D 1; + iio_chan++; + chan_props++; + index++; + } + + return 0; +} + +static void adc5_gen3_uninit_aux(void *data) +{ + auxiliary_device_uninit(data); +} + +static void adc5_gen3_delete_aux(void *data) +{ + auxiliary_device_delete(data); +} + +static void adc5_gen3_aux_device_release(struct device *dev) +{ + struct auxiliary_device *aux =3D container_of(dev, struct auxiliary_devic= e, dev); + + kfree(aux); +} + +static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc) +{ + struct tm5_aux_dev_wrapper *aux_device; + int i, ret, i_tm =3D 0; + + aux_device =3D devm_kzalloc(adc->dev, sizeof(*aux_device), GFP_KERNEL); + if (!aux_device) + return -ENOMEM; + + aux_device->aux_dev.name =3D "adc5_tm_gen3"; + aux_device->aux_dev.dev.parent =3D adc->dev; + aux_device->aux_dev.dev.release =3D adc5_gen3_aux_device_release; + + aux_device->tm_props =3D devm_kcalloc(adc->dev, adc->n_tm_channels, + sizeof(*aux_device->tm_props), GFP_KERNEL); + if (!aux_device->tm_props) + return -ENOMEM; + + aux_device->dev_data =3D &adc->dev_data; + + for (i =3D 0; i < adc->nchannels; i++) { + if (!adc->chan_props[i].adc_tm) + continue; + aux_device->tm_props[i_tm] =3D adc->chan_props[i].common_props; + i_tm++; + } + + device_set_of_node_from_dev(&aux_device->aux_dev.dev, adc->dev); + + aux_device->n_tm_channels =3D adc->n_tm_channels; + + ret =3D auxiliary_device_init(&aux_device->aux_dev); + if (ret) { + kfree(&aux_device->aux_dev); + return ret; + } + ret =3D devm_add_action_or_reset(adc->dev, adc5_gen3_uninit_aux, &aux_dev= ice->aux_dev); + if (ret) + return ret; + + ret =3D auxiliary_device_add(&aux_device->aux_dev); + if (ret) + return ret; + ret =3D devm_add_action_or_reset(adc->dev, adc5_gen3_delete_aux, &aux_dev= ice->aux_dev); + if (!ret) + adc->tm_aux =3D &aux_device->aux_dev; + + return ret; +} + +void adc5_take_mutex_lock(struct device *dev, bool lock) +{ + struct iio_dev *indio_dev =3D dev_get_drvdata(dev->parent); + struct adc5_chip *adc =3D iio_priv(indio_dev); + + if (lock) + mutex_lock(&adc->lock); + else + mutex_unlock(&adc->lock); +} +EXPORT_SYMBOL_NS_GPL(adc5_take_mutex_lock, IIO_ADC5_GEN3); + +int adc5_gen3_get_scaled_reading(struct device *dev, struct adc5_channel_c= ommon_prop *common_props, + int *val) +{ + struct iio_dev *indio_dev =3D dev_get_drvdata(dev->parent); + struct adc5_chip *adc =3D iio_priv(indio_dev); + u16 adc_code_volt; + int ret; + + ret =3D adc5_gen3_do_conversion(adc, common_props, &adc_code_volt); + if (ret) + return ret; + + return qcom_adc5_hw_scale(common_props->scale_fn_type, common_props->pres= cale, + adc->data, adc_code_volt, val); +} +EXPORT_SYMBOL_NS_GPL(adc5_gen3_get_scaled_reading, IIO_ADC5_GEN3); + +int adc5_gen3_therm_code_to_temp(struct device *dev, struct adc5_channel_c= ommon_prop *common_props, + u16 code, int *val) +{ + struct iio_dev *indio_dev =3D dev_get_drvdata(dev->parent); + struct adc5_chip *adc =3D iio_priv(indio_dev); + + return qcom_adc5_hw_scale(common_props->scale_fn_type, common_props->pres= cale, + adc->data, code, val); +} +EXPORT_SYMBOL_NS_GPL(adc5_gen3_therm_code_to_temp, IIO_ADC5_GEN3); + +static int adc5_gen3_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct iio_dev *indio_dev; + struct adc5_chip *adc; + struct regmap *regmap; + int ret, i; + u32 *reg; + + regmap =3D dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*adc)); + if (!indio_dev) + return -ENOMEM; + + adc =3D iio_priv(indio_dev); + adc->dev_data.regmap =3D regmap; + adc->dev =3D dev; + + ret =3D device_property_count_u32(dev, "reg"); + if (ret < 0) + return ret; + + adc->num_sdams =3D ret; + adc->dev_data.num_sdams =3D adc->num_sdams; + + reg =3D devm_kcalloc(dev, adc->num_sdams, sizeof(u32), GFP_KERNEL); + if (!reg) + return -ENOMEM; + + ret =3D device_property_read_u32_array(dev, "reg", reg, adc->num_sdams); + if (ret) + return dev_err_probe(dev, ret, "Failed to read reg property, ret =3D %d\= n", ret); + + adc->dev_data.base =3D devm_kcalloc(dev, adc->num_sdams, sizeof(*adc->dev= _data.base), + GFP_KERNEL); + if (!adc->dev_data.base) + return -ENOMEM; + + platform_set_drvdata(pdev, indio_dev); + init_completion(&adc->complete); + mutex_init(&adc->lock); + + for (i =3D 0; i < adc->num_sdams; i++) { + adc->dev_data.base[i].base_addr =3D reg[i]; + + adc->dev_data.base[i].irq_name =3D devm_kasprintf(dev, GFP_KERNEL, "adc-= sdam%d", i); + if (!adc->dev_data.base[i].irq_name) + return -ENOMEM; + + ret =3D platform_get_irq_byname(pdev, adc->dev_data.base[i].irq_name); + if (ret < 0) + return dev_err_probe(dev, ret, "Getting IRQ %d by name failed, ret =3D = %d\n", + adc->dev_data.base[i].irq, ret); + adc->dev_data.base[i].irq =3D ret; + } + + ret =3D devm_request_irq(dev, adc->dev_data.base[ADC5_GEN3_VADC_SDAM].irq= , adc5_gen3_isr, + 0, adc->dev_data.base[ADC5_GEN3_VADC_SDAM].irq_name, adc); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to request SDAM%d irq, ret =3D %d= \n", + ADC5_GEN3_VADC_SDAM, ret); + + ret =3D adc5_get_fw_data(adc); + if (ret < 0) + return ret; + + if (adc->n_tm_channels > 0) + adc5_gen3_add_aux_tm_device(adc); + + indio_dev->name =3D pdev->name; + indio_dev->modes =3D INDIO_DIRECT_MODE; + indio_dev->info =3D &adc5_gen3_info; + indio_dev->channels =3D adc->iio_chans; + indio_dev->num_channels =3D adc->nchannels; + + return devm_iio_device_register(dev, indio_dev); +} + +static struct platform_driver adc5_gen3_driver =3D { + .driver =3D { + .name =3D "qcom-spmi-adc5-gen3", + .of_match_table =3D adc5_match_table, + }, + .probe =3D adc5_gen3_probe, +}; +module_platform_driver(adc5_gen3_driver); + +MODULE_DESCRIPTION("Qualcomm Technologies Inc. PMIC5 Gen3 ADC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/iio/adc/qcom-adc5-gen3-common.h b/include/linux/= iio/adc/qcom-adc5-gen3-common.h new file mode 100644 index 000000000000..785669d62caf --- /dev/null +++ b/include/linux/iio/adc/qcom-adc5-gen3-common.h @@ -0,0 +1,233 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + * + * Code shared between the main and auxiliary Qualcomm PMIC voltage ADCs + * of type ADC5 Gen3. + */ + +#ifndef QCOM_ADC5_GEN3_COMMON_H +#define QCOM_ADC5_GEN3_COMMON_H + +#include +#include +#include +#include + +#define ADC5_GEN3_HS 0x45 +#define ADC5_GEN3_HS_BUSY BIT(7) +#define ADC5_GEN3_HS_READY BIT(0) + +#define ADC5_GEN3_STATUS1 0x46 +#define ADC5_GEN3_STATUS1_CONV_FAULT BIT(7) +#define ADC5_GEN3_STATUS1_THR_CROSS BIT(6) +#define ADC5_GEN3_STATUS1_EOC BIT(0) + +#define ADC5_GEN3_TM_EN_STS 0x47 +#define ADC5_GEN3_TM_HIGH_STS 0x48 +#define ADC5_GEN3_TM_LOW_STS 0x49 + +#define ADC5_GEN3_EOC_STS 0x4a +#define ADC5_GEN3_EOC_CHAN_0 BIT(0) + +#define ADC5_GEN3_EOC_CLR 0x4b +#define ADC5_GEN3_TM_HIGH_STS_CLR 0x4c +#define ADC5_GEN3_TM_LOW_STS_CLR 0x4d +#define ADC5_GEN3_CONV_ERR_CLR 0x4e +#define ADC5_GEN3_CONV_ERR_CLR_REQ BIT(0) + +#define ADC5_GEN3_SID 0x4f +#define ADC5_GEN3_SID_MASK GENMASK(3, 0) + +#define ADC5_GEN3_PERPH_CH 0x50 +#define ADC5_GEN3_CHAN_CONV_REQ BIT(7) + +#define ADC5_GEN3_TIMER_SEL 0x51 +#define ADC5_GEN3_TIME_IMMEDIATE 0x1 + +#define ADC5_GEN3_DIG_PARAM 0x52 +#define ADC5_GEN3_DIG_PARAM_CAL_SEL_MASK GENMASK(5, 4) +#define ADC5_GEN3_DIG_PARAM_DEC_RATIO_SEL_MASK GENMASK(3, 2) + +#define ADC5_GEN3_FAST_AVG 0x53 +#define ADC5_GEN3_FAST_AVG_CTL_EN BIT(7) +#define ADC5_GEN3_FAST_AVG_CTL_SAMPLES_MASK GENMASK(2, 0) + +#define ADC5_GEN3_ADC_CH_SEL_CTL 0x54 +#define ADC5_GEN3_DELAY_CTL 0x55 +#define ADC5_GEN3_HW_SETTLE_DELAY_MASK GENMASK(3, 0) + +#define ADC5_GEN3_CH_EN 0x56 +#define ADC5_GEN3_HIGH_THR_INT_EN BIT(1) +#define ADC5_GEN3_LOW_THR_INT_EN BIT(0) + +#define ADC5_GEN3_LOW_THR0 0x57 +#define ADC5_GEN3_LOW_THR1 0x58 +#define ADC5_GEN3_HIGH_THR0 0x59 +#define ADC5_GEN3_HIGH_THR1 0x5a + +#define ADC5_GEN3_CH_DATA0(channel) (0x5c + (channel) * 2) +#define ADC5_GEN3_CH_DATA1(channel) (0x5d + (channel) * 2) + +#define ADC5_GEN3_CONV_REQ 0xe5 +#define ADC5_GEN3_CONV_REQ_REQ BIT(0) + +#define ADC5_GEN3_VIRTUAL_SID_MASK GENMASK(15, 8) +#define ADC5_GEN3_CHANNEL_MASK GENMASK(7, 0) +#define V_CHAN(x) \ + (FIELD_PREP(ADC5_GEN3_VIRTUAL_SID_MASK, (x).sid) | (x).channel) \ + +enum adc5_cal_method { + ADC5_NO_CAL =3D 0, + ADC5_RATIOMETRIC_CAL, + ADC5_ABSOLUTE_CAL +}; + +enum adc5_time_select { + MEAS_INT_DISABLE =3D 0, + MEAS_INT_IMMEDIATE, + MEAS_INT_50MS, + MEAS_INT_100MS, + MEAS_INT_1S, + MEAS_INT_NONE, +}; + +struct adc5_sdam_data { + u16 base_addr; + const char *irq_name; + int irq; +}; + +struct adc5_device_data { + struct regmap *regmap; + struct adc5_sdam_data *base; + int num_sdams; +}; + +/** + * struct adc5_channel_prop - ADC channel property. + * @channel: channel number, refer to the channel list. + * @cal_method: calibration method. + * @decimation: sampling rate supported for the channel. + * @sid: slave id of PMIC owning the channel. + * @label: Channel name used in device tree. + * @prescale: channel scaling performed on the input signal. + * @hw_settle_time: the time between AMUX being configured and the + * start of conversion. + * @avg_samples: ability to provide single result from the ADC + * that is an average of multiple measurements. + * @scale_fn_type: Represents the scaling function to convert voltage + * physical units desired by the client for the channel. + */ +struct adc5_channel_common_prop { + unsigned int channel; + enum adc5_cal_method cal_method; + unsigned int decimation; + unsigned int sid; + const char *label; + unsigned int prescale; + unsigned int hw_settle_time; + unsigned int avg_samples; + enum vadc_scale_fn_type scale_fn_type; +}; + +struct tm5_aux_dev_wrapper { + struct auxiliary_device aux_dev; + struct adc5_device_data *dev_data; + struct adc5_channel_common_prop *tm_props; + unsigned int n_tm_channels; +}; + +struct adc_tm5_auxiliary_drv { + struct auxiliary_driver adrv; + void (*tm_event_notify)(struct auxiliary_device *adev); +}; + +static int adc5_gen3_read(struct adc5_device_data *adc, unsigned int sdam_= index, + u16 offset, u8 *data, int len) +{ + return regmap_bulk_read(adc->regmap, adc->base[sdam_index].base_addr + of= fset, data, len); +} + +static int adc5_gen3_write(struct adc5_device_data *adc, unsigned int sdam= _index, + u16 offset, u8 *data, int len) +{ + return regmap_bulk_write(adc->regmap, adc->base[sdam_index].base_addr + o= ffset, data, len); +} + +/* + * Worst case delay from PBS in readying handshake bit + * can be up to 15ms, when PBS is busy running other + * simultaneous transactions, while in the best case, it is + * already ready at this point. Assigning polling delay and + * retry count accordingly. + */ + +#define ADC5_GEN3_HS_DELAY_MIN_US 100 +#define ADC5_GEN3_HS_DELAY_MAX_US 110 +#define ADC5_GEN3_HS_RETRY_COUNT 150 + +static int adc5_gen3_poll_wait_hs(struct adc5_device_data *adc, + unsigned int sdam_index) +{ + u8 conv_req =3D ADC5_GEN3_CONV_REQ_REQ; + int ret, count; + u8 status =3D 0; + + for (count =3D 0; count < ADC5_GEN3_HS_RETRY_COUNT; count++) { + ret =3D adc5_gen3_read(adc, sdam_index, ADC5_GEN3_HS, &status, 1); + if (ret) + return ret; + + if (status =3D=3D ADC5_GEN3_HS_READY) { + ret =3D adc5_gen3_read(adc, sdam_index, ADC5_GEN3_CONV_REQ, + &conv_req, 1); + if (ret) + return ret; + + if (!conv_req) + return 0; + } + + usleep_range(ADC5_GEN3_HS_DELAY_MIN_US, ADC5_GEN3_HS_DELAY_MAX_US); + } + + pr_err("Setting HS ready bit timed out, sdam_index:%d, status:%#x\n", sda= m_index, status); + return -ETIMEDOUT; +} + +static void adc5_gen3_update_dig_param(struct adc5_channel_common_prop *pr= op, u8 *data) +{ + /* Update calibration select and decimation ratio select */ + *data &=3D ~(ADC5_GEN3_DIG_PARAM_CAL_SEL_MASK | ADC5_GEN3_DIG_PARAM_DEC_R= ATIO_SEL_MASK); + *data |=3D FIELD_PREP(ADC5_GEN3_DIG_PARAM_CAL_SEL_MASK, prop->cal_method); + *data |=3D FIELD_PREP(ADC5_GEN3_DIG_PARAM_DEC_RATIO_SEL_MASK, prop->decim= ation); +} + +static int adc5_gen3_status_clear(struct adc5_device_data *adc, + int sdam_index, u16 offset, u8 *val, int len) +{ + u8 value; + int ret; + + ret =3D adc5_gen3_write(adc, sdam_index, offset, val, len); + if (ret) + return ret; + + /* To indicate conversion request is only to clear a status */ + value =3D 0; + ret =3D adc5_gen3_write(adc, sdam_index, ADC5_GEN3_PERPH_CH, &value, 1); + if (ret) + return ret; + + value =3D ADC5_GEN3_CONV_REQ_REQ; + return adc5_gen3_write(adc, sdam_index, ADC5_GEN3_CONV_REQ, &value, 1); +} + +void adc5_take_mutex_lock(struct device *dev, bool lock); +int adc5_gen3_get_scaled_reading(struct device *dev, struct adc5_channel_c= ommon_prop *common_props, + int *val); +int adc5_gen3_therm_code_to_temp(struct device *dev, struct adc5_channel_c= ommon_prop *common_props, + u16 code, int *val); + +#endif /* QCOM_VADC5_GEN3_COMMON_H */ --=20 2.25.1 From nobody Mon Nov 25 03:04:08 2024 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 430921CF7AC; Wed, 30 Oct 2024 19:00:47 +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=1730314851; cv=none; b=uh9Yxqkz1ULGyL/42cDtvxRVuCaJZOfmF6tSoTxZCl2GACEmIPrCqNJZsrazjqLq5ZwlUqjSCO2hrWhSn/2gsDH3kdgf7c84M0C1QbqwzkYMhkUcHZhqS2BA8C58u4GS24fgP8U4kTNMpvPmk/gn4whhyH6c0BF4EYcb/LjBfKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730314851; c=relaxed/simple; bh=85FFeWCPjZ5BceK9beWHqzMTOOmlqu4WYcmD2EXwaPo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g5Woj9dhW593Z18PG7SuR+AskK1Fo2/iES9NXbqeThjPs1QRH7EdFfhGqCc5UjzwOl0PkayuLM1qm3BsqrUa6f7I0SCl94nrRg3NrLfgguvHRyx7qbRYAGrpwj+FHmvPQCgKQ1Q4ZcPl5xn/DyQ9NAWafg/AuIyQA76XNkb7f6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Mr250hBH; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Mr250hBH" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49UDWHnQ004019; Wed, 30 Oct 2024 19:00:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ehRUpSySmh70GuAybDljNgGXHghNGM3v/4/sWwxRisI=; b=Mr250hBHpt1Ax7s2 w+2zvVmLE/moHB5OPGntuy8UsKC8ioCIr382eYxmFgrCFoW9s8/uP9ZmYdll1gQr GcAnlFiBe5FGzp02Pvl6n8J90SFq2dDTyOwfj+sDtsAhXleh7IYAV6RO8IyYGe6T izIZh6fmvwecEQcTnwUCp7Cdlh+KeYHifvD3Tq5dW2m/KY8cSgcDCUZEArP2fZSt DYVSOaYWVstpsVIi2y5hfCAcufgkDeTUHeOdMaruHMn77GNaxu3NkezsDAcLWPLU kiiWwSsU+fG8rTdj4xdxF75BWAmXAfDapuxyP7FKIwQwvqGw1NprWoeEw/qOiVHe eJVEBw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 42kns3gwcy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:20 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49UJ0JoS023582 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Oct 2024 19:00:19 GMT Received: from hu-jprakash-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 30 Oct 2024 12:00:11 -0700 From: Jishnu Prakash To: , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Jishnu Prakash Subject: [PATCH V4 4/4] thermal: qcom: add support for PMIC5 Gen3 ADC thermal monitoring Date: Thu, 31 Oct 2024 00:28:54 +0530 Message-ID: <20241030185854.4015348-5-quic_jprakash@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241030185854.4015348-1-quic_jprakash@quicinc.com> References: <20241030185854.4015348-1-quic_jprakash@quicinc.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-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: fwGSHzmOYQHXWP9NeD5SVSITkjn-sJVR X-Proofpoint-ORIG-GUID: fwGSHzmOYQHXWP9NeD5SVSITkjn-sJVR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410300150 Content-Type: text/plain; charset="utf-8" Add support for ADC_TM part of PMIC5 Gen3. This is an auxiliary driver under the Gen3 ADC driver, which implements the threshold setting and interrupt generating functionalities of QCOM ADC_TM drivers, used to support thermal trip points. Signed-off-by: Jishnu Prakash --- drivers/thermal/qcom/Kconfig | 11 + drivers/thermal/qcom/Makefile | 1 + drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c | 489 ++++++++++++++++++ 3 files changed, 501 insertions(+) create mode 100644 drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c diff --git a/drivers/thermal/qcom/Kconfig b/drivers/thermal/qcom/Kconfig index 2c7f3f9a26eb..f9876fb8606d 100644 --- a/drivers/thermal/qcom/Kconfig +++ b/drivers/thermal/qcom/Kconfig @@ -21,6 +21,17 @@ config QCOM_SPMI_ADC_TM5 Thermal client sets threshold temperature for both warm and cool and gets updated when a threshold is reached. =20 +config QCOM_SPMI_ADC_TM5_GEN3 + tristate "Qualcomm SPMI PMIC Thermal Monitor ADC5 Gen3" + depends on OF && SPMI && IIO && QCOM_SPMI_ADC5_GEN3 + select REGMAP_SPMI + select QCOM_VADC_COMMON + help + This enables the auxiliary thermal driver for the ADC5 Gen3 thermal + monitoring device. It shows up as a thermal zone with multiple trip poi= nts. + Thermal client sets threshold temperature for both warm and cool and + gets updated when a threshold is reached. + config QCOM_SPMI_TEMP_ALARM tristate "Qualcomm SPMI PMIC Temperature Alarm" depends on OF && SPMI && IIO diff --git a/drivers/thermal/qcom/Makefile b/drivers/thermal/qcom/Makefile index 0fa2512042e7..828d9e7bc797 100644 --- a/drivers/thermal/qcom/Makefile +++ b/drivers/thermal/qcom/Makefile @@ -4,5 +4,6 @@ obj-$(CONFIG_QCOM_TSENS) +=3D qcom_tsens.o qcom_tsens-y +=3D tsens.o tsens-v2.o tsens-v1.o tsens-v0_1.o \ tsens-8960.o obj-$(CONFIG_QCOM_SPMI_ADC_TM5) +=3D qcom-spmi-adc-tm5.o +obj-$(CONFIG_QCOM_SPMI_ADC_TM5_GEN3) +=3D qcom-spmi-adc-tm5-gen3.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) +=3D qcom-spmi-temp-alarm.o obj-$(CONFIG_QCOM_LMH) +=3D lmh.o diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c b/drivers/therma= l/qcom/qcom-spmi-adc-tm5-gen3.c new file mode 100644 index 000000000000..fa57f417d833 --- /dev/null +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c @@ -0,0 +1,489 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../thermal_hwmon.h" + +struct adc_tm5_gen3_chip; + +/** + * @adc_tm: indicates if the channel is used for TM measurements. + * @tm_chan_index: TM channel number used (ranging from 1-7). + * @timer: time period of recurring TM measurement. + * @tzd: pointer to thermal device corresponding to TM channel. + * @high_thr_en: TM high threshold crossing detection enabled. + * @low_thr_en: TM low threshold crossing detection enabled. + * @last_temp: last temperature that caused threshold violation, + * or a thermal TM channel. + * @last_temp_set: indicates if last_temp is stored. + */ + +struct adc_tm5_gen3_channel_props { + struct device *dev; + unsigned int timer; + unsigned int tm_chan_index; + unsigned int sdam_index; + struct adc5_channel_common_prop common_props; + bool high_thr_en; + bool low_thr_en; + bool meas_en; + struct adc_tm5_gen3_chip *chip; + struct thermal_zone_device *tzd; + int last_temp; + bool last_temp_set; +}; + +struct adc_tm5_gen3_chip { + struct adc5_device_data *dev_data; + struct adc_tm5_gen3_channel_props *chan_props; + unsigned int nchannels; + struct device *dev; + struct work_struct tm_handler_work; +}; + +static int get_sdam_from_irq(struct adc_tm5_gen3_chip *adc_tm5, int irq) +{ + int i; + + for (i =3D 0; i < adc_tm5->dev_data->num_sdams; i++) { + if (adc_tm5->dev_data->base[i].irq =3D=3D irq) + return i; + } + return -ENOENT; +} + +static irqreturn_t adctm5_gen3_isr(int irq, void *dev_id) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D dev_id; + u8 status, tm_status[2], val; + int ret, sdam_num; + + sdam_num =3D get_sdam_from_irq(adc_tm5, irq); + if (sdam_num < 0) { + dev_err(adc_tm5->dev, "adc irq %d not associated with an sdam\n", irq); + return IRQ_HANDLED; + } + + ret =3D adc5_gen3_read(adc_tm5->dev_data, sdam_num, ADC5_GEN3_STATUS1, &s= tatus, 1); + if (ret) { + dev_err(adc_tm5->dev, "adc read status1 failed with %d\n", ret); + return IRQ_HANDLED; + } + + if (status & ADC5_GEN3_STATUS1_CONV_FAULT) { + dev_err_ratelimited(adc_tm5->dev, "Unexpected conversion fault, status:%= #x\n", + status); + val =3D ADC5_GEN3_CONV_ERR_CLR_REQ; + adc5_gen3_status_clear(adc_tm5->dev_data, sdam_num, ADC5_GEN3_CONV_ERR_C= LR, &val, + 1); + return IRQ_HANDLED; + } + + ret =3D adc5_gen3_read(adc_tm5->dev_data, sdam_num, ADC5_GEN3_TM_HIGH_STS= , tm_status, 2); + if (ret) { + dev_err(adc_tm5->dev, "adc read TM status failed with %d\n", ret); + return IRQ_HANDLED; + } + + if (tm_status[0] || tm_status[1]) + schedule_work(&adc_tm5->tm_handler_work); + + dev_dbg(adc_tm5->dev, "Interrupt status:%#x, TM status:%#x, high:%#x, low= :%#x\n", + status, tm_status, tm_status[0], tm_status[1]); + + return IRQ_HANDLED; +} + +static int adc5_gen3_tm_status_check(struct adc_tm5_gen3_chip *adc_tm5, + int sdam_index, u8 *tm_status, u8 *buf) +{ + int ret; + + ret =3D adc5_gen3_read(adc_tm5->dev_data, sdam_index, ADC5_GEN3_TM_HIGH_S= TS, tm_status, 2); + if (ret) { + dev_err(adc_tm5->dev, "adc read TM status failed with %d\n", ret); + return ret; + } + + ret =3D adc5_gen3_status_clear(adc_tm5->dev_data, sdam_index, ADC5_GEN3_T= M_HIGH_STS_CLR, + tm_status, 2); + if (ret) { + dev_err(adc_tm5->dev, "adc status clear conv_req failed with %d\n", ret); + return ret; + } + + ret =3D adc5_gen3_read(adc_tm5->dev_data, sdam_index, ADC5_GEN3_CH_DATA0(= 0), buf, 16); + if (ret) + dev_err(adc_tm5->dev, "adc read data failed with %d\n", ret); + + return ret; +} + +static void tm_handler_work(struct work_struct *work) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D container_of(work, struct adc_tm5_g= en3_chip, + tm_handler_work); + struct adc_tm5_gen3_channel_props *chan_prop; + u8 tm_status[2] =3D {0}; + u8 buf[16] =3D {0}; + int i, ret =3D 0, sdam_index =3D -1; + + for (i =3D 0; i < adc_tm5->nchannels; i++) { + bool upper_set =3D false, lower_set =3D false; + int temp, offset; + u16 code =3D 0; + + chan_prop =3D &adc_tm5->chan_props[i]; + offset =3D chan_prop->tm_chan_index; + + adc5_take_mutex_lock(adc_tm5->dev, true); + if (chan_prop->sdam_index !=3D sdam_index) { + sdam_index =3D chan_prop->sdam_index; + ret =3D adc5_gen3_tm_status_check(adc_tm5, sdam_index, tm_status, buf); + if (ret) { + adc5_take_mutex_lock(adc_tm5->dev, false); + break; + } + } + + if ((tm_status[0] & BIT(offset)) && chan_prop->high_thr_en) + upper_set =3D true; + + if ((tm_status[1] & BIT(offset)) && chan_prop->low_thr_en) + lower_set =3D true; + adc5_take_mutex_lock(adc_tm5->dev, false); + + if (!(upper_set || lower_set)) + continue; + + code =3D get_unaligned_le16(&buf[2 * offset]); + pr_debug("ADC_TM threshold code:%#x\n", code); + + ret =3D adc5_gen3_therm_code_to_temp(adc_tm5->dev, &chan_prop->common_pr= ops, code, + &temp); + if (ret) { + dev_err(adc_tm5->dev, "Invalid temperature reading, ret =3D %d, code=3D= %#x\n", + ret, code); + continue; + } + + chan_prop->last_temp =3D temp; + chan_prop->last_temp_set =3D true; + thermal_zone_device_update(chan_prop->tzd, THERMAL_TRIP_VIOLATED); + } +} + +static int adc_tm5_gen3_get_temp(struct thermal_zone_device *tz, int *temp) +{ + struct adc_tm5_gen3_channel_props *prop =3D thermal_zone_device_priv(tz); + struct adc_tm5_gen3_chip *adc_tm5; + + if (!prop || !prop->chip) + return -EINVAL; + + adc_tm5 =3D prop->chip; + + if (prop->last_temp_set) { + pr_debug("last_temp: %d\n", prop->last_temp); + prop->last_temp_set =3D false; + *temp =3D prop->last_temp; + return 0; + } + + return adc5_gen3_get_scaled_reading(adc_tm5->dev, &prop->common_props, te= mp); +} + +static int _adc_tm5_gen3_disable_channel(struct adc_tm5_gen3_channel_props= *prop) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D prop->chip; + int ret; + u8 val; + + prop->high_thr_en =3D false; + prop->low_thr_en =3D false; + + ret =3D adc5_gen3_poll_wait_hs(adc_tm5->dev_data, prop->sdam_index); + if (ret) + return ret; + + val =3D BIT(prop->tm_chan_index); + ret =3D adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_TM= _HIGH_STS_CLR, + &val, 1); + if (ret) + return ret; + + val =3D MEAS_INT_DISABLE; + ret =3D adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_TI= MER_SEL, &val, 1); + if (ret) + return ret; + + /* To indicate there is an actual conversion request */ + val =3D ADC5_GEN3_CHAN_CONV_REQ | prop->tm_chan_index; + ret =3D adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_PE= RPH_CH, &val, 1); + if (ret) + return ret; + + val =3D ADC5_GEN3_CONV_REQ_REQ; + return adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_CON= V_REQ, &val, 1); +} + +static int adc_tm5_gen3_disable_channel(struct adc_tm5_gen3_channel_props = *prop) +{ + return _adc_tm5_gen3_disable_channel(prop); +} + +# define ADC_TM5_GEN3_CONFIG_REGS 12 + +static int adc_tm5_gen3_configure(struct adc_tm5_gen3_channel_props *prop, + int low_temp, int high_temp) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D prop->chip; + u8 conv_req =3D 0, buf[ADC_TM5_GEN3_CONFIG_REGS]; + u16 adc_code; + int ret; + + ret =3D adc5_gen3_poll_wait_hs(adc_tm5->dev_data, prop->sdam_index); + if (ret < 0) + return ret; + + ret =3D adc5_gen3_read(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_SID= , buf, sizeof(buf)); + if (ret < 0) + return ret; + + /* Write SID */ + buf[0] =3D FIELD_PREP(ADC5_GEN3_SID_MASK, prop->common_props.sid); + + /* + * Select TM channel and indicate there is an actual + * conversion request + */ + buf[1] =3D ADC5_GEN3_CHAN_CONV_REQ | prop->tm_chan_index; + + buf[2] =3D prop->timer; + + /* Digital param selection */ + adc5_gen3_update_dig_param(&prop->common_props, &buf[3]); + + /* Update fast average sample value */ + buf[4] &=3D ~ADC5_GEN3_FAST_AVG_CTL_SAMPLES_MASK; + buf[4] |=3D prop->common_props.avg_samples | ADC5_GEN3_FAST_AVG_CTL_EN; + + /* Select ADC channel */ + buf[5] =3D prop->common_props.channel; + + /* Select HW settle delay for channel */ + buf[6] =3D FIELD_PREP(ADC5_GEN3_HW_SETTLE_DELAY_MASK, prop->common_props.= hw_settle_time); + + /* High temperature corresponds to low voltage threshold */ + if (high_temp !=3D INT_MAX) { + prop->low_thr_en =3D true; + adc_code =3D qcom_adc_tm5_gen2_temp_res_scale(high_temp); + put_unaligned_le16(adc_code, &buf[8]); + } else { + prop->low_thr_en =3D false; + } + + /* Low temperature corresponds to high voltage threshold */ + if (low_temp !=3D -INT_MAX) { + prop->high_thr_en =3D true; + adc_code =3D qcom_adc_tm5_gen2_temp_res_scale(low_temp); + put_unaligned_le16(adc_code, &buf[10]); + } else { + prop->high_thr_en =3D false; + } + + buf[7] =3D 0; + if (prop->high_thr_en) + buf[7] |=3D ADC5_GEN3_HIGH_THR_INT_EN; + if (prop->low_thr_en) + buf[7] |=3D ADC5_GEN3_LOW_THR_INT_EN; + + ret =3D adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_SI= D, buf, sizeof(buf)); + if (ret < 0) + return ret; + + conv_req =3D ADC5_GEN3_CONV_REQ_REQ; + return adc5_gen3_write(adc_tm5->dev_data, prop->sdam_index, ADC5_GEN3_CON= V_REQ, &conv_req, + 1); +} + +static int adc_tm5_gen3_set_trip_temp(struct thermal_zone_device *tz, + int low_temp, int high_temp) +{ + struct adc_tm5_gen3_channel_props *prop =3D thermal_zone_device_priv(tz); + struct adc_tm5_gen3_chip *adc_tm5; + int ret; + + if (!prop || !prop->chip) + return -EINVAL; + + adc_tm5 =3D prop->chip; + + dev_dbg(adc_tm5->dev, "channel:%s, low_temp(mdegC):%d, high_temp(mdegC):%= d\n", + prop->common_props.label, low_temp, high_temp); + + adc5_take_mutex_lock(adc_tm5->dev, true); + if (high_temp =3D=3D INT_MAX && low_temp <=3D -INT_MAX) + ret =3D adc_tm5_gen3_disable_channel(prop); + else + ret =3D adc_tm5_gen3_configure(prop, low_temp, high_temp); + adc5_take_mutex_lock(adc_tm5->dev, false); + + return ret; +} + +static const struct thermal_zone_device_ops adc_tm_ops =3D { + .get_temp =3D adc_tm5_gen3_get_temp, + .set_trips =3D adc_tm5_gen3_set_trip_temp, +}; + +static int adc_tm5_register_tzd(struct adc_tm5_gen3_chip *adc_tm5) +{ + unsigned int i, channel; + struct thermal_zone_device *tzd; + + for (i =3D 0; i < adc_tm5->nchannels; i++) { + channel =3D V_CHAN(adc_tm5->chan_props[i].common_props); + tzd =3D devm_thermal_of_zone_register(adc_tm5->dev, channel, + &adc_tm5->chan_props[i], &adc_tm_ops); + + if (IS_ERR(tzd)) { + if (PTR_ERR(tzd) =3D=3D -ENODEV) { + dev_warn(adc_tm5->dev, "thermal sensor on channel %d is not used\n", + channel); + continue; + } + return dev_err_probe(adc_tm5->dev, PTR_ERR(tzd), + "Error registering TZ zone:%ld for channel:%d\n", + PTR_ERR(tzd), channel); + } + adc_tm5->chan_props[i].tzd =3D tzd; + devm_thermal_add_hwmon_sysfs(adc_tm5->dev, tzd); + } + return 0; +} + +static void adc5_gen3_clear_work(void *data) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D data; + + cancel_work_sync(&adc_tm5->tm_handler_work); +} + +static void adc5_gen3_disable(void *data) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D data; + int i; + + adc5_take_mutex_lock(adc_tm5->dev, true); + /* Disable all available TM channels */ + for (i =3D 0; i < adc_tm5->nchannels; i++) + _adc_tm5_gen3_disable_channel(&adc_tm5->chan_props[i]); + + adc5_take_mutex_lock(adc_tm5->dev, false); +} + +static void adctm_event_handler(struct auxiliary_device *adev) +{ + struct adc_tm5_gen3_chip *adc_tm5 =3D auxiliary_get_drvdata(adev); + + schedule_work(&adc_tm5->tm_handler_work); +} + +static int adc_tm5_probe(struct auxiliary_device *aux_dev, const struct au= xiliary_device_id *id) +{ + struct adc_tm5_gen3_chip *adc_tm5; + struct tm5_aux_dev_wrapper *aux_dev_wrapper; + struct device *dev =3D &aux_dev->dev; + int i, ret; + + adc_tm5 =3D devm_kzalloc(&aux_dev->dev, sizeof(*adc_tm5), GFP_KERNEL); + if (!adc_tm5) + return -ENOMEM; + + aux_dev_wrapper =3D container_of(aux_dev, struct tm5_aux_dev_wrapper, aux= _dev); + + adc_tm5->dev =3D dev; + adc_tm5->dev_data =3D aux_dev_wrapper->dev_data; + adc_tm5->nchannels =3D aux_dev_wrapper->n_tm_channels; + adc_tm5->chan_props =3D devm_kcalloc(adc_tm5->dev, aux_dev_wrapper->n_tm_= channels, + sizeof(*adc_tm5->chan_props), GFP_KERNEL); + if (!adc_tm5->chan_props) + return -ENOMEM; + + for (i =3D 0; i < adc_tm5->nchannels; i++) { + adc_tm5->chan_props[i].common_props =3D aux_dev_wrapper->tm_props[i]; + adc_tm5->chan_props[i].timer =3D MEAS_INT_1S; + adc_tm5->chan_props[i].sdam_index =3D (i + 1) / 8; + adc_tm5->chan_props[i].tm_chan_index =3D (i + 1) % 8; + adc_tm5->chan_props[i].chip =3D adc_tm5; + } + + ret =3D devm_add_action_or_reset(adc_tm5->dev, adc5_gen3_disable, adc_tm5= ); + if (ret) + return ret; + + for (i =3D 1; i < adc_tm5->dev_data->num_sdams; i++) { + ret =3D devm_request_threaded_irq(adc_tm5->dev, adc_tm5->dev_data->base[= i].irq, NULL, + adctm5_gen3_isr, IRQF_ONESHOT, + adc_tm5->dev_data->base[i].irq_name, adc_tm5); + if (ret < 0) + return ret; + } + + INIT_WORK(&adc_tm5->tm_handler_work, tm_handler_work); + ret =3D devm_add_action(adc_tm5->dev, adc5_gen3_clear_work, adc_tm5); + if (ret) + return ret; + + ret =3D adc_tm5_register_tzd(adc_tm5); + if (ret) + return ret; + + auxiliary_set_drvdata(aux_dev, adc_tm5); + return 0; +} + +static const struct auxiliary_device_id adctm5_auxiliary_id_table[] =3D { + { .name =3D "qcom_spmi_adc5_gen3.adc5_tm_gen3", }, + {}, +}; + +MODULE_DEVICE_TABLE(auxiliary, adctm5_auxiliary_id_table); + +static struct adc_tm5_auxiliary_drv adctm5gen3_auxiliary_drv =3D { + .adrv =3D { + .id_table =3D adctm5_auxiliary_id_table, + .probe =3D adc_tm5_probe, + }, + .tm_event_notify =3D adctm_event_handler, +}; + +static int __init adctm5_init_module(void) +{ + return auxiliary_driver_register(&adctm5gen3_auxiliary_drv.adrv); +} + +static void __exit adctm5_exit_module(void) +{ + auxiliary_driver_unregister(&adctm5gen3_auxiliary_drv.adrv); +} + +module_init(adctm5_init_module); +module_exit(adctm5_exit_module); + +MODULE_DESCRIPTION("SPMI PMIC Thermal Monitor ADC driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_ADC5_GEN3); --=20 2.25.1