From nobody Fri Dec 19 00:39:57 2025 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2041.outbound.protection.outlook.com [40.107.22.41]) (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 6F7A42D78D; Fri, 15 Dec 2023 12:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=axis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b="Mn+vXCRi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G+HwuC2WpPt/S1kV/5DHIHd6qPJPtqlvZWeiyg5Z4khStY2r8VRAnvK+DAeEw8EN5f/J1wphuLl/e98kl/L2JuXCRp+D1OdanwzAeG3qVHDVv9tHC2AE1QWvEC6kjopVup2Gc+qSbyeKhzn3WD8QduG5FBMlSnsLlxbeBhRAW/5bmoBV4QtzQKR7wWxJ5B6Upio/RRKVkL4at5A4PXuFuUtIbhqyFE1TfKCxgeVa1Kfdv6oJp4UuDDtrE8EzwIo/u81l5LhBz2JkeBFUEm8WKkIKDJzkFShoBc+iv4UgeBff3ZG/0ow29z3E6uPT3m1TPvfj3J+dWJ8+rWc5Yu9fDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gVlbeHodaBkyuhB5Z61CiMDCxmOr9AuX3+iIVFnYsh0=; b=agmmpmegXNw3VwBW0alhbJ/w4Zj4GwJSkU+6LPcCtfmkiyrgN/mkZvwBafpOvU7lBrfBiEYxjooGw94Oob9eQBJpWYaeaD2Z4zffLYLoXJmj6P4IgHhqgmuTEeqFZ2vz6ZRwsOnidm+sH679u+ZwHPiiwkQYbYmUy2RnoXThFdyF+UgXf4Z1MO+TMCymwwRKENx9UYJx+ixL2BIQTvDQ9rDkUaBWi9ZIdV8eGvgbpMNq0dm3o6l01+DVMOYncfEnb/kE32ol2roAen37aUQIXkWcSW+7D1BltjYEri/YL5Xrk10yog/+REpX7zvvSzaSjtoURIdQfuBZXZYp/E4IEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gVlbeHodaBkyuhB5Z61CiMDCxmOr9AuX3+iIVFnYsh0=; b=Mn+vXCRi+uRrkcEp1SsLgpoT9FML4X9sQqWYcAPXzgII/7hqnAEqsAzxdnwVOZuQy33YTa6lswcLPgBX9oap1vdVVd/MgJQL4TS1sLSj7eHpvbvQYL7Qwt/tCz5EgV2wNxNZvVO9FBB4kXW16QY/Fx5UVcqXVdAVp1zRYzd8oQ4= Received: from AM6PR0502CA0053.eurprd05.prod.outlook.com (2603:10a6:20b:56::30) by GV1PR02MB8404.eurprd02.prod.outlook.com (2603:10a6:150:5b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Fri, 15 Dec 2023 12:43:18 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:20b:56:cafe::f7) by AM6PR0502CA0053.outlook.office365.com (2603:10a6:20b:56::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Fri, 15 Dec 2023 12:43:18 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Fri, 15 Dec 2023 12:43:18 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 15 Dec 2023 13:43:17 +0100 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 15 Dec 2023 13:43:17 +0100 Received: from pc42775-2107.se.axis.com (pc42775-2107.se.axis.com [10.94.129.29]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 38A681002F; Fri, 15 Dec 2023 13:43:17 +0100 (CET) Received: by pc42775-2107.se.axis.com (Postfix, from userid 21033) id 3164F2FEDDC; Fri, 15 Dec 2023 13:43:17 +0100 (CET) From: =?utf-8?q?M=C3=A5rten_Lindahl?= Date: Fri, 15 Dec 2023 13:43:04 +0100 Subject: [PATCH 1/2] iio: core: Introduce resolution standard attribute Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20231212-vcnl4000-ps-hd-v1-1-1c62a95828c0@axis.com> References: <20231212-vcnl4000-ps-hd-v1-0-1c62a95828c0@axis.com> In-Reply-To: <20231212-vcnl4000-ps-hd-v1-0-1c62a95828c0@axis.com> To: Jonathan Cameron , Lars-Peter Clausen CC: , , , =?utf-8?q?M=C3=A5rten_Lindahl?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702644197; l=1316; i=marten.lindahl@axis.com; s=20230329; h=from:subject:message-id; bh=g78eLtKzeNWvee2JE6hc8/3fxzoe/g0pF2pOlQRG5Ms=; b=FmTbhaJ1pgQvYSUi3Q2drgMCYi9CXjVTDGLaMMjDVj2nrMgcFg7pBBCdDCjNRpOd8XkgxpLUo 1hj1GPmI2o5Cj2NntxrpkXPFbdEKaWinHsL+pi4khf4rbOpuY5faaI0 X-Developer-Key: i=marten.lindahl@axis.com; a=ed25519; pk=JfbjqFPJnIDIQOkJBeatC8+S3Ax3N0RIdmN+fL3wXgw= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A4:EE_|GV1PR02MB8404:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a12726a-b255-4e3d-3bef-08dbfd6b69d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VH2uQg+Fs98kqjHXa5QV6sO/C/QC+axOJopxp2akJ/slPIR+bCUPPNQwhNE/L33CyRjkAjW8Ra+v2epIdE4404J00Qev1QC5lhj8jDSrdG+nxfxltZCMjAZ0lhpm2ZDIHNB1XdmSTGSCUk/EHU4iqVYDi6hhIjy2vOJ/yStj79JDTHcAawxOboJFUgWxyzXowXbw8s+4ZoeB6RTgVT3RqjepEHYYHuQPqycaL12P52m5rCNTfD6Y64E1CwftcSb5R3m8a+MAbI4dYjHlrfBnrpxcKxjbDCNIA+o7kCygP+d/jIgwH5jnBdBTfZpQNJzEKBTcpS9qNN5P4lBHjAtoAYkRhIf2RUdtgvmQfC+rYhYwoX/9bgKnyJoYNV1Lf6243Jd8FcPCpcTy3c20OGzQIhcBhcC9TurPA6U2vHcrsINavopVh+4HZTqZ2DHOc2gxqc0HC6uKDGSz26oI//lJ617KtwjZuSmJlF7F6gMTvoXMh/9X+kJ1IlA/FNvM8FrJYK4h8NCUTDdRzK2LH2UyPR89yHYhgw4GC/xyR6olt2lpk5Uj/HMc9uQ2oYn3RZCZ+2QeWSCfILiKHhqOvtGny8TOOJvqDSRew5JU8OtK6544I6Y7FM3MoP0GD2uw8OuxqtCktzGbxSYioyyIPMQOmK5dyCZLPcxCxp4DkgYMMG+LeOKVdtVyPEvF1Pc/O39Oux2oO0S2wuTLMIrDrAnGsIzKe/vkO12ElZGf0Yjlm0XqbKF4IaE4g3xGgKqtTGsstG2oRKzIHMtcwK6vC5RdKw== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(39860400002)(346002)(396003)(230922051799003)(1800799012)(451199024)(64100799003)(82310400011)(186009)(36840700001)(46966006)(40470700004)(86362001)(36756003)(40480700001)(356005)(81166007)(40460700003)(82740400003)(478600001)(6666004)(70586007)(54906003)(70206006)(336012)(26005)(6266002)(107886003)(41300700001)(2616005)(47076005)(2906002)(316002)(110136005)(42186006)(5660300002)(36860700001)(426003)(4326008)(8676002)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 12:43:18.1654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a12726a-b255-4e3d-3bef-08dbfd6b69d5 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR02MB8404 Introduce a new IIO standard attribute to set bit resolution of the data *_raw readings dynamically using sysfs. Needed to set 16 bit data width (high definition) with the VCNL4040 driver. Signed-off-by: M=C3=A5rten Lindahl --- drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-cor= e.c index c77745b594bd..4316e0290404 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -182,6 +182,7 @@ static const char * const iio_chan_info_postfix[] =3D { [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] =3D "thermocouple_type", [IIO_CHAN_INFO_CALIBAMBIENT] =3D "calibambient", [IIO_CHAN_INFO_ZEROPOINT] =3D "zeropoint", + [IIO_CHAN_INFO_RESOLUTION] =3D "resolution", }; /** * iio_device_id() - query the unique ID for the device diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 117bde7d6ad7..7de4d83ca105 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -68,6 +68,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_THERMOCOUPLE_TYPE, IIO_CHAN_INFO_CALIBAMBIENT, IIO_CHAN_INFO_ZEROPOINT, + IIO_CHAN_INFO_RESOLUTION, }; =20 #endif /* _IIO_TYPES_H_ */ --=20 2.30.2 From nobody Fri Dec 19 00:39:57 2025 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2088.outbound.protection.outlook.com [40.107.8.88]) (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 6E9492D7A7; Fri, 15 Dec 2023 12:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=axis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b="UQU3CUJW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQtRQbfnUhmrLLeZDiCMPzjKiJin+4CuPdGNalu0iopEC7Jf8xRd1Kf+xub/7A+/mk9Uw8jJPO2kZFwevh0tkfCknPvYjnXt6B0SLX5TxXpn0tniJwAChKbWjfo4Nk2AjS+EwC/UmfAD1FhWqrSnc/gGVbbGy3azEV+OgVMz6jVOKBU0y441cpl2jL5lBwQe0NwirQELkKzEcoFzxcadMswJs+KYMuwcWDa3YiqVDYOfR8bi461ephVPw9vLwd6Xpyi51XsVTEZdlQEdqZ0wsBjJTkZh+JrU1YMPq29e/pVW8iV5R7kHjK858xXZ1OYdt2ke47zDWG8B6vUaXB4KhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5UgEm6jGXUzmxCyOfqh+FEbc0eSkL1Nw/Y/sNtqWYjA=; b=FSxKoZPHEbob1uHsyJSy3E+HvD0oUkcbpkZBLX6vifgRfLITuDFlI3PgjcomuQPpceqgpwwUuOFWW7VG54agy4afdhWvlPCWJQfrHBSP5kNBA4/N2OBEI6Pp2qbOhl4Di72RrwOsw/7VhI5exbd2vQUeFSP4blTW2+Vv1NEjrNhqmIuaJ1Q+K9V1AE8WFhMs2qvIy71QC0ldLJd1r5VXgYyx//R53b16+bxjmzG5hTUux6motThuw7F4QUPCdbrj6Ie0GCuPQKBuEd+7PLVZVHjGnec+cA7uJqU18Rgnpi8pVTh1YDcTP5ch+hCdURdlhMSsleSYoTKMnqlkC9Si5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5UgEm6jGXUzmxCyOfqh+FEbc0eSkL1Nw/Y/sNtqWYjA=; b=UQU3CUJWt+BsAQjsJ4GMxigB8JDLdtWp1rYRftMfnBwH14V9Jw1XriQk4fX1499395ICMCtxG2HzKukkuyem8GfvDVqagxDQr0Vx3MjgR2gagA/0j94H6A2gGG4v4toMvWVPPrU6ITMUQtzQZcBOwiJTss3qnMR2khPTUlLgxJE= Received: from AM6PR0502CA0059.eurprd05.prod.outlook.com (2603:10a6:20b:56::36) by AS1PR02MB8003.eurprd02.prod.outlook.com (2603:10a6:20b:4d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Fri, 15 Dec 2023 12:43:18 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:20b:56:cafe::3f) by AM6PR0502CA0059.outlook.office365.com (2603:10a6:20b:56::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28 via Frontend Transport; Fri, 15 Dec 2023 12:43:18 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Fri, 15 Dec 2023 12:43:17 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 15 Dec 2023 13:43:17 +0100 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 15 Dec 2023 13:43:17 +0100 Received: from pc42775-2107.se.axis.com (pc42775-2107.se.axis.com [10.94.129.29]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 3A83C10035; Fri, 15 Dec 2023 13:43:17 +0100 (CET) Received: by pc42775-2107.se.axis.com (Postfix, from userid 21033) id 33A952FA7D1; Fri, 15 Dec 2023 13:43:17 +0100 (CET) From: =?utf-8?q?M=C3=A5rten_Lindahl?= Date: Fri, 15 Dec 2023 13:43:05 +0100 Subject: [PATCH 2/2] iio: light: vcnl4000: Add ps high definition for vcnl4040 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20231212-vcnl4000-ps-hd-v1-2-1c62a95828c0@axis.com> References: <20231212-vcnl4000-ps-hd-v1-0-1c62a95828c0@axis.com> In-Reply-To: <20231212-vcnl4000-ps-hd-v1-0-1c62a95828c0@axis.com> To: Jonathan Cameron , Lars-Peter Clausen CC: , , , =?utf-8?q?M=C3=A5rten_Lindahl?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702644197; l=4875; i=marten.lindahl@axis.com; s=20230329; h=from:subject:message-id; bh=reQw6rieOSSDmthGg/ptStNM7AqQg+3POYVpmRVbC9Y=; b=h3k/+cK/LLd8JNNgMqbfIPnCuQ/rnpMr+QFVUZ/Wlt9rsmY08JPmtm19YfKb/z3cEivHOajml Ff9BOSaxk71CmX0CkL9M2/SoAI/Hx2usFBLJegjRWklwkK0Z4vkP8qS X-Developer-Key: i=marten.lindahl@axis.com; a=ed25519; pk=JfbjqFPJnIDIQOkJBeatC8+S3Ax3N0RIdmN+fL3wXgw= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A4:EE_|AS1PR02MB8003:EE_ X-MS-Office365-Filtering-Correlation-Id: e1b7effa-f846-4f97-66e9-08dbfd6b697f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rpAkTTLNsOF8QiTJEljo4FkUxS4PCIbB/rvQh2w8eCf1zatSDfjwlM7HHTVnEoALshhRVXx2qs4lMwl1l+lX/DWJUzuBDwjBuLZ+uXhIuA1554s5kfGRANXQQkKIY14v9abRXts3y38j/IAPIyM781yFJfTWh2BONxYaIRXzSyQg4DLqAM0f/fsOcIuXJF8rQuT4fhN+xTAppC5AMP99wUae6UVCvxoj17PuDeqGEZI8tGl4NFN9XIPIlwQ6cdp3y3N2kYjdVHxSZhAJ14GpPOXiUSemvtMuPnSvZoj4a0pLKYHOV6qWSAQmF72zn5KMSE7ucxOpAo7KPLddIGTqPIjeutZK5BuK2oJ5iJn4yXeeq5mJnWcWoWqSCkrh+t74Mr//KFFY0jGihUHWaxCb+6F7C3LlQtZ3mOTzBStyGh1LIvpqFpdrSq383yibNXUc4GR03Xr5gv388WevzWxYgJnwX3AvFUttOu9RjX9jKkJlGK4kNg6VpwjxpT810Q963DMWl+tmxgyKyirXgixa68n7tG4obTCyUD72p3Ivy6nSJb+m1Hk04L3PyXaN16GrQC389bFThq17uLoWdMIRL4BL1ZP5vfIdWvLh0mFzBg+tZ2gV8jqBGpw8XhfCbPiPbzEIpRRi6CXjTSoZflACc0yNqkps4Tj1bZPy/hDj6VSLwfcgEQoMPKdLL3zzIW+yTRMQZhcWqmtYOlqcijgCuI3WyFHrfoFkiF/l+gfIOwhsZclQ+zVhsHK/oAGlqDZ2mQUkfyEdwHuOqCOug9gc3Q== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(39860400002)(136003)(346002)(396003)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(6666004)(2616005)(6266002)(66574015)(336012)(26005)(107886003)(426003)(478600001)(83380400001)(86362001)(47076005)(8936002)(8676002)(4326008)(36860700001)(54906003)(70586007)(70206006)(316002)(42186006)(110136005)(40480700001)(5660300002)(36756003)(356005)(81166007)(82740400003)(41300700001)(40460700003)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 12:43:17.6029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1b7effa-f846-4f97-66e9-08dbfd6b697f X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR02MB8003 The vcnl4040 proximity sensor defaults to 12 bit data resolution, but the chip also supports 16 bit data resolution, which is called proximity high definition (PS_HD). Add read/write attribute for proximity resolution, and read attribute for available proximity resolution values for the vcnl4040 chip. Signed-off-by: M=C3=A5rten Lindahl --- drivers/iio/light/vcnl4000.c | 87 ++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index fdf763a04b0b..2addff635b79 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -90,6 +90,7 @@ #define VCNL4040_PS_CONF1_PS_SHUTDOWN BIT(0) #define VCNL4040_PS_CONF2_PS_IT GENMASK(3, 1) /* Proximity integration tim= e */ #define VCNL4040_CONF1_PS_PERS GENMASK(5, 4) /* Proximity interrupt persis= tence setting */ +#define VCNL4040_PS_CONF2_PS_HD BIT(11) /* Proximity high definition */ #define VCNL4040_PS_CONF2_PS_INT GENMASK(9, 8) /* Proximity interrupt mode= */ #define VCNL4040_PS_CONF3_MPS GENMASK(6, 5) /* Proximity multi pulse numb= er */ #define VCNL4040_PS_MS_LED_I GENMASK(10, 8) /* Proximity current */ @@ -170,6 +171,11 @@ static const int vcnl4040_ps_calibbias_ua[][2] =3D { {0, 200000}, }; =20 +static const int vcnl4040_ps_resolutions[2] =3D { + 12, + 16 +}; + static const int vcnl4040_als_persistence[] =3D {1, 2, 4, 8}; static const int vcnl4040_ps_persistence[] =3D {1, 2, 3, 4}; static const int vcnl4040_ps_oversampling_ratio[] =3D {1, 2, 4, 8}; @@ -880,6 +886,54 @@ static ssize_t vcnl4040_write_ps_calibbias(struct vcnl= 4000_data *data, int val) return ret; } =20 +static ssize_t vcnl4040_read_ps_resolution(struct vcnl4000_data *data, int= *val, int *val2) +{ + int ret; + + ret =3D i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1); + if (ret < 0) + return ret; + + ret =3D FIELD_GET(VCNL4040_PS_CONF2_PS_HD, ret); + if (ret >=3D ARRAY_SIZE(vcnl4040_ps_resolutions)) + return -EINVAL; + + *val =3D vcnl4040_ps_resolutions[ret]; + *val2 =3D 0; + + return ret; +} + +static ssize_t vcnl4040_write_ps_resolution(struct vcnl4000_data *data, in= t val) +{ + unsigned int i; + int ret; + u16 regval; + + for (i =3D 0; i < ARRAY_SIZE(vcnl4040_ps_resolutions); i++) { + if (val =3D=3D vcnl4040_ps_resolutions[i]) + break; + } + + if (i >=3D ARRAY_SIZE(vcnl4040_ps_resolutions)) + return -EINVAL; + + mutex_lock(&data->vcnl4000_lock); + + ret =3D i2c_smbus_read_word_data(data->client, VCNL4200_PS_CONF1); + if (ret < 0) + goto out_unlock; + + regval =3D (ret & ~VCNL4040_PS_CONF2_PS_HD); + regval |=3D FIELD_PREP(VCNL4040_PS_CONF2_PS_HD, i); + ret =3D i2c_smbus_write_word_data(data->client, VCNL4200_PS_CONF1, + regval); + +out_unlock: + mutex_unlock(&data->vcnl4000_lock); + return ret; +} + static int vcnl4000_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -950,6 +1004,16 @@ static int vcnl4000_read_raw(struct iio_dev *indio_de= v, default: return -EINVAL; } + case IIO_CHAN_INFO_RESOLUTION: + switch (chan->type) { + case IIO_PROXIMITY: + ret =3D vcnl4040_read_ps_resolution(data, val, val2); + if (ret < 0) + return ret; + return IIO_VAL_INT; + default: + return -EINVAL; + } default: return -EINVAL; } @@ -987,6 +1051,13 @@ static int vcnl4040_write_raw(struct iio_dev *indio_d= ev, default: return -EINVAL; } + case IIO_CHAN_INFO_RESOLUTION: + switch (chan->type) { + case IIO_PROXIMITY: + return vcnl4040_write_ps_resolution(data, val); + default: + return -EINVAL; + } default: return -EINVAL; } @@ -1035,6 +1106,16 @@ static int vcnl4040_read_avail(struct iio_dev *indio= _dev, default: return -EINVAL; } + case IIO_CHAN_INFO_RESOLUTION: + switch (chan->type) { + case IIO_PROXIMITY: + *vals =3D (int *)vcnl4040_ps_resolutions; + *length =3D ARRAY_SIZE(vcnl4040_ps_resolutions); + *type =3D IIO_VAL_INT; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } default: return -EINVAL; } @@ -1808,10 +1889,12 @@ static const struct iio_chan_spec vcnl4040_channels= [] =3D { .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_INT_TIME) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) | - BIT(IIO_CHAN_INFO_CALIBBIAS), + BIT(IIO_CHAN_INFO_CALIBBIAS) | + BIT(IIO_CHAN_INFO_RESOLUTION), .info_mask_separate_available =3D BIT(IIO_CHAN_INFO_INT_TIME) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) | - BIT(IIO_CHAN_INFO_CALIBBIAS), + BIT(IIO_CHAN_INFO_CALIBBIAS) | + BIT(IIO_CHAN_INFO_RESOLUTION), .ext_info =3D vcnl4000_ext_info, .event_spec =3D vcnl4040_event_spec, .num_event_specs =3D ARRAY_SIZE(vcnl4040_event_spec), --=20 2.30.2