From patchwork Fri Sep 13 09:57:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Gedenryd X-Patchwork-Id: 13803207 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2059.outbound.protection.outlook.com [40.107.103.59]) (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 146C11B654F; Fri, 13 Sep 2024 09:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221450; cv=fail; b=d7BVSitvMLrhbCfkhFhOfnMQliedxtcnUlaBGWOwPoihdUwhYGRYw8DhQOaeb5MgWtQD2BicQVdgcWR4ixK1SX2i+UU7mZQ8nkzVqWt9n19FYCd9Vn1hc4zHyMEP6N0I43uQVF9UxupGrpKSZPPfB+hVrAJ1rDFAX/HdmeJoZfY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221450; c=relaxed/simple; bh=aqY/vAVBSMH8SLZlhZ2rUTWyaKlm3LSZXGMGn4Xs3YI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=FyAFtj5J4HCmQWB1g48hISs82eMul9BuOoasYkPA8+s0byZUjqg8Oc7zuN6abUACQcJInhHdQ/rkYqJAVhe59LZmXpbgzg8Fq4vJmAhFTmLgY7pzOWrD/bDqMn6AJEhXxE3eVc8OG46+HLItm9gH5HPri3jg3R3OylqiSdxwYQg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com; spf=pass smtp.mailfrom=axis.com; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b=hdZEyzdg; arc=fail smtp.client-ip=40.107.103.59 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="hdZEyzdg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DFOCh9Iztdlg1cuYIdGXYb4lnLqGYcZTeH1GegxnE9VE4YPmaJhmt6IcYvNdI9QICWpRYV5BIKZ2dool84IWb6U8xjsfNSzTYoAqvhOhXF/mzqgCh2ABD1Obee8QvyHp9qbILEWUgg+c0zxSZhJwPLLxiYckmEupBTDrmkB0yYqy4RWmQS3vegqmPz/HOIhZhezv2FGqzbjHsNsSVBZkR3dlDw6KtZtLMKccBiWnXEtbZZyKt2ejca0pGlOlMmu9VCi55DUbmZedfonc6hHCoUMicRbmMK63vbyJLNl91YUGpj7GGvBMAoGUwd9+sntXsuqBGj8wt5lazUugUGf+Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LFPN0SBSr6PbHgcghlFBv+QWPvrLlELhnAj1xrXcBOo=; b=lFOsKjRY0meGO/v5tqjfDQ8EXSm1DaturDsjr3t4USBELN0+Sios/W3RS9f78g48OcJDMB1jT80HrD+Jwxps9yM9CbnnjuMEz0hgMHBQLuVsL97ZkREjr07Zm3nlkCgKpjyJAI5QgXYD3MjA3n8xovcXXwM+LTzRFr8qMcZGH87jHmjmKX/eycie2Fg9Gzc3JVvgRgQHr6RvLrmfhmeYkzbrKaJTdzuQ3gdUCkLxyaULhQ0bjlF1E3FUwvwYX86IO7/IiNSYKP5w0Ab9EflDKTXWX1cuEHBfzz5flVcYwnSP7m1jNxgMXZ9mflRryGJB2xRxSVx6aKBmxi8PpEOaWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=pass (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=LFPN0SBSr6PbHgcghlFBv+QWPvrLlELhnAj1xrXcBOo=; b=hdZEyzdgLB0aSSgpd/ALdlu/gybGhyIpGzNySE2jbBD+hXvyIj37ktS+3jMx2/y7DPrISsK65GVm2C8P4Im75V23nKSiDIz9TcETkJgY3c8Rzf2dfpjTPTB9xbecz1C7Gmj11C6+qfMrP6hvL+Rlw84mhJPZYNUhElouWwCJDuw= Received: from DU7P250CA0025.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::14) by DB9PR02MB7260.eurprd02.prod.outlook.com (2603:10a6:10:25c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.18; Fri, 13 Sep 2024 09:57:24 +0000 Received: from DU6PEPF0000B61E.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::3f) by DU7P250CA0025.outlook.office365.com (2603:10a6:10:54f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.26 via Frontend Transport; Fri, 13 Sep 2024 09:57:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by DU6PEPF0000B61E.mail.protection.outlook.com (10.167.8.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:57:23 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 11:57:22 +0200 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.2507.39 via Frontend Transport; Fri, 13 Sep 2024 11:57:22 +0200 Received: from pc55303-2334.se.axis.com (pc55303-2334.se.axis.com [10.94.180.8]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id F34892D9; Fri, 13 Sep 2024 11:57:21 +0200 (CEST) Received: by pc55303-2334.se.axis.com (Postfix, from userid 18269) id F04B522FC7E6; Fri, 13 Sep 2024 11:57:21 +0200 (CEST) From: Emil Gedenryd Date: Fri, 13 Sep 2024 11:57:02 +0200 Subject: [PATCH v2 1/3] iio: light: opt3001: add missing full-scale range value Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240913-add_opt3002-v2-1-69e04f840360@axis.com> References: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> In-Reply-To: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andreas Dannenberg CC: , , , Emil Gedenryd , X-Mailer: b4 0.14.1 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B61E:EE_|DB9PR02MB7260:EE_ X-MS-Office365-Filtering-Correlation-Id: ce0347f9-80f7-4acf-3d19-08dcd3da776c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3pSDHWNRZHAi0Lsx5nEnAP1sI093rTd?= =?utf-8?q?NPzwDQ6oV8KLrTJsjMyUgbusR5ZB8qiaEFRjb/RTSPc1OXBS1G+jM7t1IodAKpViv?= =?utf-8?q?Bk8fb1WmAkC8ETX3GA5n7R1VRXimbmyy7hSkmxwr/0DVwrcwk0xSUCTZWMOqmMyy8?= =?utf-8?q?5P+GwtZaSrYBi9BniF9g8tD4GdFVXhnfMbaYXRx5ZaNoIBnImEhE9Gf6ndXo86Ftq?= =?utf-8?q?4ti94CAVe2KNL+PAw4UcFL80p/8cbB4EdXkbRia1MJeHNrg7yBBDNDrEAEWrU7oOD?= =?utf-8?q?5igEjENrD2jZhqLPKaOal0O2l2T7CL0vBzLT0E14aQCx7JMdgAhLin0PMZ8apdGcv?= =?utf-8?q?s6H1J5PSzXPeWnmcBCsj/WIVbyFKM1tcfAcSjEClEL4Nu/at/F3Mhz+2G+JI8PSg9?= =?utf-8?q?KgC9Zi+H3Jcm1b+D4hBHhPMIL/B/UNytG2WhCLVMuMRzQ23mRFeJL031XVfDnbKO4?= =?utf-8?q?iuA/kiKxpHPGzYRmoh45C/+28qfbTg/PPlAWN0f4mOFCf29KMvftbo4qoc1En0fDj?= =?utf-8?q?dK4j1IWxUCST3uB/HeQTJqlM2ryuY20fxG0dJmj3xAzGjGdgfsrlyQZKy0dT2Sd/y?= =?utf-8?q?tR/PrmPyX50yt6RM46lu+Iqc87PoVzsGmwReKdZdXGV3CIkMceUPDIlBtRIcO6pcb?= =?utf-8?q?g6lyeBuFR5h1HK4HzGSXAt6isvYRt+8pLJxd2LjtFqj4oez00iactUGoYBuEa6bu/?= =?utf-8?q?fCwHXVL+4BWAQlXjJbEJkeKfdnqfg8D0yEuA6QqBzVekfudM5XuCW9WNMqdheqpSj?= =?utf-8?q?WtbnB/yRDO2Fq+rTJODTSvNYqE2zoBKp6/BWypf/7uFHx26tWNSyFrKCnJmwLG/V0?= =?utf-8?q?WN3kwuNCZVKnB93CgCI/BlFoRzcAKXleiqKJLfOtBja4wyIbEk/mIKUf8zb5CR8k5?= =?utf-8?q?J0DYhwLNtC/DkpR8ZPVy87rAU+H/9x08kq5m2y3igspHNGbRTQ2fvyq6Mk8uCN94c?= =?utf-8?q?URKUP0zokQb8cnmYk29LR5iSeB4geEuHQm5KvQu1PgOFiQNi5pgk7jS0+1pb000Cy?= =?utf-8?q?HtYESrHdkeAXoCOAeqQqrA+SDkFvN/m2HR02bAI7XlGlhEYGLE+nBFGE6uyGW4uhl?= =?utf-8?q?NlY9y0hK3O1ljeG9xBGA+O+vGcuQj/ao9QKRb3CMsMbO+YgE5XPkyV8keopZO08ZJ?= =?utf-8?q?FxnDIoRsehJa8m6Uaq12uUzdAQw4Fi4fMXm+aUuB6MMwmE/b5Cjp1tjvHKTvsUwNk?= =?utf-8?q?rsgU/I9MQhJs2FoeRWjDZafrZFcvTj8Ed5KZZOQkP/j+OP8YXnrqPCrcT40FmubY1?= =?utf-8?q?ZH2IbgjpV5gyJVnLAUyLbPPwkUp05JqNkpIUvo5MrcZrrFYbHiP9MYElfVB7RCfS6?= =?utf-8?q?DE5nS/Z4oKAZXErXgEkUj5ZrKD2/xhhrYzGzLYLVV2LqXSuI8Em6J4FCPShoW/En8?= =?utf-8?q?XsBzLIK5G51?= 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:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:57:23.8900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce0347f9-80f7-4acf-3d19-08dcd3da776c 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: DU6PEPF0000B61E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR02MB7260 The opt3001 driver uses predetermined full-scale range values to determine what exponent to use for event trigger threshold values. The problem is that one of the values specified in the datasheet is missing from the implementation. This causes larger values to be scaled down to an incorrect exponent, effectively reducing the maximum settable threshold value by a factor of 2. Add missing full-scale range array value. Fixes: 94a9b7b1809f ("iio: light: add support for TI's opt3001 light sensor") Signed-off-by: Emil Gedenryd --- drivers/iio/light/opt3001.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index 887c4b776a86..176e54bb48c3 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c @@ -138,6 +138,10 @@ static const struct opt3001_scale opt3001_scales[] = { .val = 20966, .val2 = 400000, }, + { + .val = 41932, + .val2 = 800000, + }, { .val = 83865, .val2 = 600000, From patchwork Fri Sep 13 09:57:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Gedenryd X-Patchwork-Id: 13803210 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2053.outbound.protection.outlook.com [40.107.21.53]) (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 6F7861D7E5C; Fri, 13 Sep 2024 09:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221456; cv=fail; b=iGFnpYXi+nAjRV4KmMFvY2qjIKFascXtroXB0qKdJ8GaKJoj/gCfK3PB/2HNhFA0aE5rrItTdjPudtCr6zc22KSGN/EjIWXV/jPSuYxG9wkCowDjwPpIORq0F5Eejrvr3rmNuu4Mq554D4H4AflK3SKw06g8vr/jwdZ7C8TyE0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221456; c=relaxed/simple; bh=M0UnoOHRx95iVf+2P5gVJS/5zwelZ4YxJSY4dc2wyNU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Z8xz9l0J9io9ssCpexQORNYpsnqiEuuWvFmouy9260K3wCJthvQp1llFU2uUl6NPQSMOv6HGsdqWbL3u2eEXMH1zwp9QfEghQCnX7UvdcxJyjp4jYT+qVqGsf9gcDI9crnTHPW+F1T9KxOisZ2YyXpmOeKlAfymXsjflJnV+x/s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com; spf=pass smtp.mailfrom=axis.com; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b=HfHNTMvB; arc=fail smtp.client-ip=40.107.21.53 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="HfHNTMvB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BtRMgw+aUwrVqcTh4a9nFthbpB+gNEW6GKdXNrLoszzbv/5veWxlk1UWmXVxEp0QNnu3OqoGf+EuRYnr0T6afMoBmIjHKTMRhRONb9MVQ3Kcj5eDMMUsC59CVZQSKVKI1ucUz/aG2gq1ahdT9Q074ASr/LjEoEx+jk1HOB6AZX991DR6N9ucAZLnzlac+rJrL8ucTz9btExmWvq7+70TahOnw1QHhKptSqLhHF4JMomYjLolsOpU6nXw7f7VQnKxp6iLaJT4lEDnOXphVEca5jnclbuhLYHMAlw99Kkf0SKalspc0Tootq9/RtvcsrPSDiEPOQWDNaPjZvaxSenG3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qRdsqO/jwDv/bXZ4gNFo59wg4CaWRjYLQXOu+aoKz28=; b=Mq2pUz4xheT/tEQfz1MjZ2G8h3zuxsi8ScOtsSswzjWhlHtKVYaT1A1jkOp+OcjYirrMCXQc7wmDuDifYByoBZ+u3liWSPZFMZJWsTRb6yNCpitOQzLfh93ym6GygyV5gMPJtv1oxTgN9xSFmRLHAExyTYO1EIr+xQiY7fKOcT7lgdov0QxMF4e2fLo3ZFiy5Mk0D2MFkCyJxV/Ad0/ix4Osr9bJxgiOQLhzwj2Kzd4H4+py7SCwXRuc/vjtZoWl7iXIJ+JKcOliNZanWOG2JUeuON94Joe/SYxTNWbGygr+4WP62CWNTnxrLVYBRJy/QuFX1MHMmyUrklWcc/sPhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=pass (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=qRdsqO/jwDv/bXZ4gNFo59wg4CaWRjYLQXOu+aoKz28=; b=HfHNTMvBTsikY8FVt1bu5EO2DfbXS7M5mdrmYoPgmaa3JsNYRUqhBuPsBOtz9FrOVs706Z3turC1WwKI9QMLHqPvOubT/Ei3KDllJ959/FxRNcfoETLLflilMXu1Q1TrAK8DDPJAr6hWDS5zWvStpgWamremBRR8e+ynLgaEauw= Received: from DBBPR09CA0019.eurprd09.prod.outlook.com (2603:10a6:10:c0::31) by PAXPR02MB7885.eurprd02.prod.outlook.com (2603:10a6:102:287::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25; Fri, 13 Sep 2024 09:57:28 +0000 Received: from DU2PEPF00028CFE.eurprd03.prod.outlook.com (2603:10a6:10:c0:cafe::aa) by DBBPR09CA0019.outlook.office365.com (2603:10a6:10:c0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.27 via Frontend Transport; Fri, 13 Sep 2024 09:57:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by DU2PEPF00028CFE.mail.protection.outlook.com (10.167.242.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:57:25 +0000 Received: from SE-MAILARCH01W.axis.com (10.20.40.15) 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.2507.39; Fri, 13 Sep 2024 11:57:22 +0200 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAILARCH01W.axis.com (10.20.40.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 11:57:22 +0200 Received: from se-intmail02x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Fri, 13 Sep 2024 11:57:22 +0200 Received: from pc55303-2334.se.axis.com (pc55303-2334.se.axis.com [10.94.180.8]) by se-intmail02x.se.axis.com (Postfix) with ESMTP id 009C1F4; Fri, 13 Sep 2024 11:57:22 +0200 (CEST) Received: by pc55303-2334.se.axis.com (Postfix, from userid 18269) id F234F230ECAA; Fri, 13 Sep 2024 11:57:21 +0200 (CEST) From: Emil Gedenryd Date: Fri, 13 Sep 2024 11:57:03 +0200 Subject: [PATCH v2 2/3] dt-bindings: iio: light: opt3001: add compatible for opt3002 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240913-add_opt3002-v2-2-69e04f840360@axis.com> References: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> In-Reply-To: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andreas Dannenberg CC: , , , Emil Gedenryd , X-Mailer: b4 0.14.1 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028CFE:EE_|PAXPR02MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: 999ae0e3-f502-442d-c62a-08dcd3da782a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?tG6O7Nyl5SNmsnI/Xe1EqCYrIwacQcE?= =?utf-8?q?Peu0gEadwG/ituhI7M5DJ3IXbfNRApizVyBS82h0xAjr/jQog9t3q/72rZtvzO9Ia?= =?utf-8?q?A9EB21f5G2pAzAuDBj4WbPtY6aMweeIk+sv2MOtQaKsDH21X3/z30A60TM+q4Autd?= =?utf-8?q?gsKl9HWoC54M0ijN18ZAkyOMZ9Vl8t8AtBer+gYdSlOJyx2j36DRC9h+DelbZ3gQU?= =?utf-8?q?hAT64J280a7NZFXXxpZQQCcqTWPm49dSA/T4uh4sIF+FmPQRjnG/qSc3Uug4kumiL?= =?utf-8?q?stUwg4Py/+hIHBXZeLGgsH+rierYlYzziRVWF75gmHCnZdKGdBKpFPlPhuuJjYtN3?= =?utf-8?q?RjPyPDf+yv8nAqxxajvzWZog2I9v2wvpbC4zTOYGCg2C+Edc2Zyb0ezCaK67yegOf?= =?utf-8?q?s1UAqV6z16fHr7lJIiyqBmuWXNfZ0SyjheONmKC6ud3Ahjc6WlN4PYVwaqP4AN5FV?= =?utf-8?q?dUVB3YvyD2QTYkerz+Zyh9aCs8k0+aZ1SWJru5WkymRSP/pGkZF5DoSfc9hkFzjUX?= =?utf-8?q?K6LVwjyl43UyEfJ6WNTG9SArOtZb8lbsHZI88igewyry5PwQwqmgVOfDoy01HqtWJ?= =?utf-8?q?pQB91UuALSixkbC/0xm4gHcTylYNxN3qnTgBLmHEZ9eKcuA+Vra/IXhka/xH0EBCm?= =?utf-8?q?vE3121VOD7IAdW5uf67yAdvuIq8QZ+A9u4Y554qHa2DAs7Rvc4XhJaMsnDlrc9H1o?= =?utf-8?q?NnU8sHfaM4fmXipjdnLghRA3pUmR232z4p5NsPReiRK7rsLaEU/njCVhZUENnmKgE?= =?utf-8?q?PlbmyXFEgLyGpXr0Y+N/nc0Khg2QLIMBx4dxbTHzWRYdP9sdlLlSYUqvBldIv0+LG?= =?utf-8?q?ajIGZh6f5DjKHS0dDJmChOXiBfiJry29rnxLyjzTaeBPu9lfSYDQ1Clx+UdL38Jr4?= =?utf-8?q?w0Bq25VkFmM88ldGE8n7deHojCfOaQ3V29h9yki4TaYVE0t0juO407UEqcA0zu8vG?= =?utf-8?q?HfhLtrxsNKz3WJ3TttPzZsQyYbxtSxJdFZF6MGF9ghE/5uZwzj3a8t4tFlU41ymMj?= =?utf-8?q?QUlgO94ju8BYs1UZcNnzWs4qgyscffHbJgnLm1zkWxy6WesPwnKgRTU9UJOJ7uvvJ?= =?utf-8?q?Ug492aEQlYfcZJ6azacttyjlJDXsR+sERX4oNF+/iSrorOm3se3MhNpmtBx2brPEF?= =?utf-8?q?quqY026S9v1lLqTEzpn2XYNdYPp0XuWZG+lW2mJIJuUh0mY+IATx7Ur1E6f3zPcaW?= =?utf-8?q?tOGIfiN8x6iIajz7vcpJiXCD6s8pK6Tjp52aIWv/DPlFgsAj0ODdWMVwnwWym/EDd?= =?utf-8?q?YdNTX5rD+DTPXkfHCX5YfgN6R0da3DNwctSGHHesc4sg3drRR718zqoee7nmCi8ym?= =?utf-8?q?vP7qCJ+gEmwachWBtHOu/BbW29HwIyaqapcG7KnsvYbx94m417FFgY3R31QEj0IuA?= =?utf-8?q?CyC2JipccWU?= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:57:25.1386 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 999ae0e3-f502-442d-c62a-08dcd3da782a 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: DU2PEPF00028CFE.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR02MB7885 OPT3002 is a Light-to-Digital Sensor by TI with support for wide-range spectrum light. Add the compatible string of opt3002. Signed-off-by: Emil Gedenryd Acked-by: Conor Dooley --- Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml b/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml index 441e9343fc97..67ca8d08256a 100644 --- a/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml +++ b/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml @@ -15,7 +15,9 @@ description: | properties: compatible: - const: ti,opt3001 + enum: + - ti,opt3001 + - ti,opt3002 reg: maxItems: 1 From patchwork Fri Sep 13 09:57:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Gedenryd X-Patchwork-Id: 13803209 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011071.outbound.protection.outlook.com [52.101.65.71]) (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 CDFC31D7E53; Fri, 13 Sep 2024 09:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221456; cv=fail; b=PVfOYl/+VLqqB0ZC/4QKqH6UF8FnPUfimeX24+syUtaEIykDA0mNj2g5DzABNq55CMgoHy6x13n9CPES/HSnG5Q8dVE6vTUKoGVFq0LkoqJcUEOf2E4ennkTs+yqiPSiOVTjCFkmsjJSgP+1oaZb9yzCBfRwNzjeWgV6t9P0ybI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726221456; c=relaxed/simple; bh=VISKJJYia7Aa4vdw2dFeTCgzjq2obdYcTwso2QuUm4Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=VjJUZKzWZAyfKCBJCOr360VOXK9QBp1lnd8U82WSSCda+H16Lnqtj7r11GvR3k/9XJrmSFuhgzoKc9sELGb9AxW+JP+bVT/4LtJR5fsMhCCDvS+A9OMefuxVpKU+QnZDKWmvTAA8s7JegvitJvxG3D+MYb1bpcEM6JoZ/iXmZjs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=axis.com; spf=pass smtp.mailfrom=axis.com; dkim=pass (1024-bit key) header.d=axis.com header.i=@axis.com header.b=hVefQoOu; arc=fail smtp.client-ip=52.101.65.71 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="hVefQoOu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DOfgnmxUwT4Up9RhRpZYcsxZeRNqgQU1404Ma9t66Y1tz6Dsn0FHmKRuuUss/BSGy6EeRwJbkvU3RUw9SEEkegwg61tMy76FyYwurUOtG2+kugp6GWfwFI/Eqy5mgQcJ/Fu2LVbNhMYYfkUrjkKlj9JY+gbsToadS09OBdoeSXNrA7ZH2tcnXmBR9IA2oxVW0oGWmiSbkel/Z/zkp4ypf6tl2UQCV6wCXRRa502p0ei4WxrY+Siw+XJYJpVcJaEhESWKKy+ORNiFSCc9YL8VLjrDxhuUpmTFuewqLJmuGHGCBepwmV32pwV6hlBm1Oi/dvqJ98eDcYBMy1TvAnR7mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=tuau6s/hloR8fSpT7lZe6PdV9ovjOkQoNcrp/tpud6I=; b=t7ZFOwzB3qG+3FsfLwmlgUBohIbOUWGBnkJarmBOS3DIEgxMIUCr6k8DlRAzuA4gIIQcSVkeOvVvgA+aLy0U80DycXYlE7W1q+BqqIwt5XdVowhXvEIhZtVlp4Ukq6XmEoB6OZqsTxhohU3JeZf9thmVdycXDxrcO3k6ACNaxM1JJ3b0y4da5wgBTLtcn5g8gT/RLgO7drOablLqidrdJ8AZ4UlrsjTHwEATj5yi7RGnfezhimdRXwl1o2ngnPahEZpqXicHt0aIq0669racdscvSnJyMF3fT6OQTKPG3s39bARfCLIdB8b/4YwMxCUPqrlkiOAFLH4AoLGe/fvkvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=kernel.org smtp.mailfrom=axis.com; dmarc=pass (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=tuau6s/hloR8fSpT7lZe6PdV9ovjOkQoNcrp/tpud6I=; b=hVefQoOuPhzhd7YQKc3T7Iodhp26M6SG6kLcAx4bms7VY2kX6k4pKL4E7UU/YdygVKjhox0J6fKnpvhBIvPcya3kzo/++omyOTUMcnjUVtzQutikE5XdbUDdFMfW4s4IT1kdn71aJQvSU+pweAAulm/PSl4lwosjp4ioVV1OqYo= Received: from DBBPR09CA0013.eurprd09.prod.outlook.com (2603:10a6:10:c0::25) by GV2PR02MB8458.eurprd02.prod.outlook.com (2603:10a6:150:a8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.19; Fri, 13 Sep 2024 09:57:24 +0000 Received: from DU2PEPF00028CFE.eurprd03.prod.outlook.com (2603:10a6:10:c0:cafe::c7) by DBBPR09CA0013.outlook.office365.com (2603:10a6:10:c0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Fri, 13 Sep 2024 09:57:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by DU2PEPF00028CFE.mail.protection.outlook.com (10.167.242.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:57:24 +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.2507.39; Fri, 13 Sep 2024 11:57:22 +0200 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.2507.39 via Frontend Transport; Fri, 13 Sep 2024 11:57:22 +0200 Received: from pc55303-2334.se.axis.com (pc55303-2334.se.axis.com [10.94.180.8]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 02839343; Fri, 13 Sep 2024 11:57:22 +0200 (CEST) Received: by pc55303-2334.se.axis.com (Postfix, from userid 18269) id F3EE122F8D75; Fri, 13 Sep 2024 11:57:21 +0200 (CEST) From: Emil Gedenryd Date: Fri, 13 Sep 2024 11:57:04 +0200 Subject: [PATCH v2 3/3] iio: light: opt3001: add support for TI's opt3002 light sensor Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240913-add_opt3002-v2-3-69e04f840360@axis.com> References: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> In-Reply-To: <20240913-add_opt3002-v2-0-69e04f840360@axis.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andreas Dannenberg CC: , , , Emil Gedenryd , X-Mailer: b4 0.14.1 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028CFE:EE_|GV2PR02MB8458:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a8f0129-89e2-4451-06fa-08dcd3da77aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?64K7nGTUdf7VtGWxU7Woz4c8T3XfKcE?= =?utf-8?q?J3ejwWBIRcuimmlsPAalk5uDMm3b/AuIOlSZ3CZa1decLVISFD7G4I/BFhNz7gqyU?= =?utf-8?q?38sRxbqlWfqXNj7EHXp8bkcMndb6rmotHGzsHaP4z9u/Rs79SYffTfBrYf501T8Yt?= =?utf-8?q?B1Gj9sDrhdWE0lESFHETr8gmXhliExV5D4MbzsBC9U0gYrATsz53XKC+bloq8eckm?= =?utf-8?q?UEUwQqLrG2csa8mxZdjdx8pv1LdO2XuKwXDuFx/mxsizE2NPKVHHWUQ7e2cqhbD0P?= =?utf-8?q?JuEjB3h7SpKIatz8CiR3lXuFZsRPbgfDiKiwWu22P+nHoeP+Br1rLe1nD/ZxtkDYh?= =?utf-8?q?Tdmyqu5CIaIbf7Sn7dXGiuMHD6RVF2hNq9SU7T1mGgt29DuMGTQCLMY8/QX4ZTu6Y?= =?utf-8?q?a67w4S3zn+tnKu5PdNVGthaAm7idPFrxIEC9JLJSPBaeEYcfLtJB5p6WpxnB8hZZR?= =?utf-8?q?ci3SgnV3gpptzhxMmUDJlRQvBAN0KorSxWHWQjkqlwmx3QzoLhY47x8HD+BaGd7/6?= =?utf-8?q?2yXcuppciu3hjtMYbx07wKF2BQRETsDc2Yvf5GZoafiF9lkz1uAGUOecjfM+nZ8sv?= =?utf-8?q?fUF6zpZf2tk8M90xlWY8+J0t7t++JLCQvnJhL/vXtUUOH26J/Irt+DqNUssOknoF7?= =?utf-8?q?oZoRLVFZYwFKy8XObtzpG4aTSOkHnCNVAg5tTFh49yEd8HBjjpnk4Zu4SdmsR2kmf?= =?utf-8?q?B51yjQXqBSWE9ko9TzJcKEgvhTkm/ku5Vs++1J0miruv/B3SKXILOMkdioxbZSlaS?= =?utf-8?q?SOqi1kR8XX4K8Zu9NT10055yw24Mt/f8mp81kZhoBQDyPsy70pqzGoS4fzHwhHgjt?= =?utf-8?q?SNmnUuvYvCqG/Ua7xLCH3t9tioEqdt+zgNeELsKTolp4yiy4UHDYZIU9sv7m1/01V?= =?utf-8?q?U8fDBjd/NoXPFy6G80t4/3oytaVlO/7GxkE13OYLNp0FJrOCTitmJCTLZrPo0D79t?= =?utf-8?q?jKRLC4WiBty/PJ/9Xkw5MID/ycJ3Xkea3pAfmJFclD7JZ9DQqzSZNl++oo6A2mbvc?= =?utf-8?q?becfbf0WKsCOGExO2VcOjkpQO0Ye14XrHgzVgE3Oh/ffy16MEUnCHoRJ4Cgez+jwv?= =?utf-8?q?X22C1sPQfJNcuPND1O3+2pm+g2VDPyMz14zmrxUOysRYRErPwbzanz7fAE+Y9cb2W?= =?utf-8?q?PP1bUliizsMjX5mX2odjY+ufYaFyK9RsSBxiFsvmjNdpt/I/aq1VIETCC02AnnXLn?= =?utf-8?q?b6tz5e7zD5Gd4SJlMyrfHC/D0mVEa4FQQzNUwgdymHLtR/xcCgCIIye18Pqv5FzX2?= =?utf-8?q?870OqR8UOv+lYN9r7yQEOuZqT8cBbAFsiyMcWwOrRWEyp01TbfyvsWpQZv+697VkQ?= =?utf-8?q?9Wv1nv4PsEMAtmh8ETxGtmeKAcJsHjHhwYz5zQvnmCtUQIHtobGU/0pyfQe+6M3+e?= =?utf-8?q?WMtwos4tGgP?= 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:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:57:24.2949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a8f0129-89e2-4451-06fa-08dcd3da77aa 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: DU2PEPF00028CFE.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR02MB8458 TI's opt3002 light sensor shares most properties with the opt3001 model, with the exception of supporting a wider spectrum range. Add support for TI's opt3002 by extending the TI opt3001 driver. Datasheet: https://www.ti.com/product/OPT3002 Signed-off-by: Emil Gedenryd --- drivers/iio/light/Kconfig | 2 +- drivers/iio/light/opt3001.c | 169 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 138 insertions(+), 33 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index b68dcc1fbaca..c35bf962dae6 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -461,7 +461,7 @@ config OPT3001 depends on I2C help If you say Y or M here, you get support for Texas Instruments - OPT3001 Ambient Light Sensor. + OPT3001 Ambient Light Sensor, OPT3002 Light-to-Digital Sensor. If built as a dynamically linked module, it will be called opt3001. diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index 176e54bb48c3..83c49f4517b7 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c @@ -70,6 +70,21 @@ #define OPT3001_RESULT_READY_SHORT 150 #define OPT3001_RESULT_READY_LONG 1000 +struct opt3001_scale { + int val; + int val2; +}; + +struct opt300x_chip_info { + const struct iio_chan_spec (*channels)[2]; + enum iio_chan_type chan_type; + const struct opt3001_scale (*scales)[12]; + int factor_whole; + int factor_integer; + int factor_decimal; + bool has_id; +}; + struct opt3001 { struct i2c_client *client; struct device *dev; @@ -79,6 +94,7 @@ struct opt3001 { bool result_ready; wait_queue_head_t result_ready_queue; u16 result; + const struct opt300x_chip_info *chip_info; u32 int_time; u32 mode; @@ -92,11 +108,6 @@ struct opt3001 { bool use_irq; }; -struct opt3001_scale { - int val; - int val2; -}; - static const struct opt3001_scale opt3001_scales[] = { { .val = 40, @@ -148,21 +159,68 @@ static const struct opt3001_scale opt3001_scales[] = { }, }; +static const struct opt3001_scale opt3002_scales[] = { + { + .val = 4914, + .val2 = 0, + }, + { + .val = 9828, + .val2 = 0, + }, + { + .val = 19656, + .val2 = 0, + }, + { + .val = 39312, + .val2 = 0, + }, + { + .val = 78624, + .val2 = 0, + }, + { + .val = 157248, + .val2 = 0, + }, + { + .val = 314496, + .val2 = 0, + }, + { + .val = 628992, + .val2 = 0, + }, + { + .val = 1257984, + .val2 = 0, + }, + { + .val = 2515968, + .val2 = 0, + }, + { + .val = 5031936, + .val2 = 0, + }, + { + .val = 10063872, + .val2 = 0, + }, +}; + static int opt3001_find_scale(const struct opt3001 *opt, int val, int val2, u8 *exponent) { int i; - - for (i = 0; i < ARRAY_SIZE(opt3001_scales); i++) { - const struct opt3001_scale *scale = &opt3001_scales[i]; - + for (i = 0; i < ARRAY_SIZE(*opt->chip_info->scales); i++) { + const struct opt3001_scale *scale = &(*opt->chip_info->scales)[i]; /* - * Combine the integer and micro parts for comparison - * purposes. Use milli lux precision to avoid 32-bit integer - * overflows. + * Compare the integer and micro parts to determine value scale. */ - if ((val * 1000 + val2 / 1000) <= - (scale->val * 1000 + scale->val2 / 1000)) { + if (val < scale->val || + (val == scale->val && val2 <= scale->val2)) { *exponent = i; return 0; } @@ -174,11 +232,14 @@ static int opt3001_find_scale(const struct opt3001 *opt, int val, static void opt3001_to_iio_ret(struct opt3001 *opt, u8 exponent, u16 mantissa, int *val, int *val2) { - int lux; + int ret; + int whole = opt->chip_info->factor_whole; + int integer = opt->chip_info->factor_integer; + int decimal = opt->chip_info->factor_decimal; - lux = 10 * (mantissa << exponent); - *val = lux / 1000; - *val2 = (lux - (*val * 1000)) * 1000; + ret = whole * (mantissa << exponent); + *val = ret / integer; + *val2 = (ret - (*val * integer)) * decimal; } static void opt3001_set_mode(struct opt3001 *opt, u16 *reg, u16 mode) @@ -225,7 +286,18 @@ static const struct iio_chan_spec opt3001_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(1), }; -static int opt3001_get_lux(struct opt3001 *opt, int *val, int *val2) +static const struct iio_chan_spec opt3002_channels[] = { + { + .type = IIO_INTENSITY, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_INT_TIME), + .event_spec = opt3001_event_spec, + .num_event_specs = ARRAY_SIZE(opt3001_event_spec), + }, + IIO_CHAN_SOFT_TIMESTAMP(1), +}; + +static int opt3001_get_processed(struct opt3001 *opt, int *val, int *val2) { int ret; u16 mantissa; @@ -397,14 +469,14 @@ static int opt3001_read_raw(struct iio_dev *iio, if (opt->mode == OPT3001_CONFIGURATION_M_CONTINUOUS) return -EBUSY; - if (chan->type != IIO_LIGHT) + if (chan->type != opt->chip_info->chan_type) return -EINVAL; mutex_lock(&opt->lock); switch (mask) { case IIO_CHAN_INFO_PROCESSED: - ret = opt3001_get_lux(opt, val, val2); + ret = opt3001_get_processed(opt, val, val2); break; case IIO_CHAN_INFO_INT_TIME: ret = opt3001_get_int_time(opt, val, val2); @@ -428,7 +500,7 @@ static int opt3001_write_raw(struct iio_dev *iio, if (opt->mode == OPT3001_CONFIGURATION_M_CONTINUOUS) return -EBUSY; - if (chan->type != IIO_LIGHT) + if (chan->type != opt->chip_info->chan_type) return -EINVAL; if (mask != IIO_CHAN_INFO_INT_TIME) @@ -479,6 +551,9 @@ static int opt3001_write_event_value(struct iio_dev *iio, { struct opt3001 *opt = iio_priv(iio); int ret; + int whole; + int integer; + int decimal; u16 mantissa; u16 value; @@ -497,7 +572,12 @@ static int opt3001_write_event_value(struct iio_dev *iio, goto err; } - mantissa = (((val * 1000) + (val2 / 1000)) / 10) >> exponent; + whole = opt->chip_info->factor_whole; + integer = opt->chip_info->factor_integer; + decimal = opt->chip_info->factor_decimal; + + mantissa = (((val * integer) + (val2 / decimal)) / whole) >> exponent; + value = (exponent << 12) | mantissa; switch (dir) { @@ -610,7 +690,7 @@ static int opt3001_read_id(struct opt3001 *opt) ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_DEVICE_ID); if (ret < 0) { dev_err(opt->dev, "failed to read register %02x\n", - OPT3001_DEVICE_ID); + OPT3001_DEVICE_ID); return ret; } @@ -692,6 +772,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) struct opt3001 *opt = iio_priv(iio); int ret; bool wake_result_ready_queue = false; + enum iio_chan_type chan_type = opt->chip_info->chan_type; if (!opt->ok_to_ignore_lock) mutex_lock(&opt->lock); @@ -707,13 +788,13 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) OPT3001_CONFIGURATION_M_CONTINUOUS) { if (ret & OPT3001_CONFIGURATION_FH) iio_push_event(iio, - IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, + IIO_UNMOD_EVENT_CODE(chan_type, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), iio_get_time_ns(iio)); if (ret & OPT3001_CONFIGURATION_FL) iio_push_event(iio, - IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, + IIO_UNMOD_EVENT_CODE(chan_type, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), iio_get_time_ns(iio)); @@ -746,7 +827,7 @@ static int opt3001_probe(struct i2c_client *client) struct iio_dev *iio; struct opt3001 *opt; int irq = client->irq; - int ret; + int ret = 0; iio = devm_iio_device_alloc(dev, sizeof(*opt)); if (!iio) @@ -755,12 +836,14 @@ static int opt3001_probe(struct i2c_client *client) opt = iio_priv(iio); opt->client = client; opt->dev = dev; + opt->chip_info = device_get_match_data(&client->dev); mutex_init(&opt->lock); init_waitqueue_head(&opt->result_ready_queue); i2c_set_clientdata(client, iio); - ret = opt3001_read_id(opt); + if (opt->chip_info->has_id) + ret = opt3001_read_id(opt); if (ret) return ret; @@ -769,8 +852,8 @@ static int opt3001_probe(struct i2c_client *client) return ret; iio->name = client->name; - iio->channels = opt3001_channels; - iio->num_channels = ARRAY_SIZE(opt3001_channels); + iio->channels = *opt->chip_info->channels; + iio->num_channels = ARRAY_SIZE(*opt->chip_info->channels); iio->modes = INDIO_DIRECT_MODE; iio->info = &opt3001_info; @@ -825,14 +908,36 @@ static void opt3001_remove(struct i2c_client *client) } } +static const struct opt300x_chip_info opt3001_chip_info = { + .channels = &opt3001_channels, + .chan_type = IIO_LIGHT, + .scales = &opt3001_scales, + .factor_whole = 10, + .factor_integer = 1000, + .factor_decimal = 1000, + .has_id = true, +}; + +static const struct opt300x_chip_info opt3002_chip_info = { + .channels = &opt3002_channels, + .chan_type = IIO_INTENSITY, + .scales = &opt3002_scales, + .factor_whole = 12, + .factor_integer = 10, + .factor_decimal = 100000, + .has_id = false, +}; + static const struct i2c_device_id opt3001_id[] = { - { "opt3001" }, + { "opt3001", (kernel_ulong_t)&opt3001_chip_info }, + { "opt3002", (kernel_ulong_t)&opt3002_chip_info }, { } /* Terminating Entry */ }; MODULE_DEVICE_TABLE(i2c, opt3001_id); static const struct of_device_id opt3001_of_match[] = { - { .compatible = "ti,opt3001" }, + { .compatible = "ti,opt3001", .data = &opt3001_chip_info }, + { .compatible = "ti,opt3002", .data = &opt3002_chip_info }, { } }; MODULE_DEVICE_TABLE(of, opt3001_of_match);