From patchwork Wed Mar 8 09:02:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 66117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp222155wrd; Wed, 8 Mar 2023 01:09:10 -0800 (PST) X-Google-Smtp-Source: AK7set8Q1r10Gn5Psaevt7dYy+eoBg7UgxymdORQiHzoGSR1/T0YIXJH4zBkwXCdQJtCh1ohCf4T X-Received: by 2002:a17:902:c94b:b0:19c:f84b:58be with SMTP id i11-20020a170902c94b00b0019cf84b58bemr20594190pla.3.1678266549998; Wed, 08 Mar 2023 01:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678266549; cv=none; d=google.com; s=arc-20160816; b=My3dGw/NNnZQOdJn8oCJPmwB5WiRhzNAwIMhTcLerUCN4HgmDAhdwBTwxzHCOTTJTr KQYvRMBHW+md7wjS19Z9qZlVKFpUMvsLveI9DfH4rmRHEsx9iDq+zC5cIPGcV60GRF7q YbU5IcE3qN0rq22GXLl1ifi8oDh2jvVyWIYEF5qMTvGSuIemSg5P+mOjjVAzUdDGhHcL Fe5+g+ALDh+ySFiRSEIGBWJwH9pZ1QDJ+WkvEfAN2aimmEh60Pb6GtmMfGEzzYcaHqwx 9C16S2ScZ/CDa1HNl4G88aCgn/5ARjrwPftCIbSkpd858dSJuF9HiLmo61c5bW7S4Jep EEOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0Lzu9bzEGqcu2KmMdZnQFwDXwVJpSW2jAVAy1BeLRyY=; b=0kAs3MQ6ElGfg1gVpP+uZiaFXx1mG+ayVd0YBEzoT+yeN7tg2H5YXCCvxNCrZe2FU6 ulJDQORGPIGgOWdCzCcUZhHf8aoh7G8UGcVCW1sX4TG5lXXvQ5FsxKSF/dbmFIypYUWX yPNKF8JsXIZcEPxiVeKayvHhZcER33udL5dnPlWRHoIs6skbg/kkD0oJ3oIhUu5yOFUl MV0M2KPNyMz21nIQEqyHAwZFUNO647Kx7uARJBjxcnbruS13wO6OCoWaMhTGM9BLjso2 i2MKzhvRNXd/NYHRzF/PJxiv6mkRzLzxzpEMo/pMyGHJ2hB/AtCjEw530Oi8xYbBM+MI lfTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oeXzRPdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a170902c10400b0019e6185116esi13398723pli.274.2023.03.08.01.08.57; Wed, 08 Mar 2023 01:09:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oeXzRPdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjCHJCi (ORCPT + 99 others); Wed, 8 Mar 2023 04:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjCHJCc (ORCPT ); Wed, 8 Mar 2023 04:02:32 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEFAC9609B; Wed, 8 Mar 2023 01:02:29 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id s11so62761658edy.8; Wed, 08 Mar 2023 01:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678266148; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Lzu9bzEGqcu2KmMdZnQFwDXwVJpSW2jAVAy1BeLRyY=; b=oeXzRPdGt3zyzDQNXPT58ahdDhTnpdodkZqd2euRE/JqRnO6nI/tJGwG9l9ywshUxF Dt40RzzWSWmXyjpSzpPo4Wew+2j0baFjasmMaYRMGAeUCq0/wcYC/Jjz3L/jdqFdj6Qr XMVaWk8rIdsQr6Qm+terGnqznbaxgdTfdDLabXOI8lLdElv0vRATTL/vcieH8Y3lNEFe qAHpP2h07WFzjjH81BTP/nORscSehU1S1uwCk4nRNZ/BSSdYAjCgaFnzz/wOcaQKaZNw F9/hlRwDGw8oC20bmkBo85YCfPXd3Q1+vLippv9+gMPo3yYlRkyp5SSMKmGkwVK2DN/j RgAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266148; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Lzu9bzEGqcu2KmMdZnQFwDXwVJpSW2jAVAy1BeLRyY=; b=Uk0LZaVFlRYv/2UThrwh2L1TlQg98G28f+aVtLeNek3pd15V1aa0iFr9eNe+iz059E twjaVfELuepjoSwXObnLwNOcXszwR2WibN9S3EpOocieFEczJivAYHXH9rFsA9pBUSEy 3mdRp1y7M8YlP+9fN5cl6m4b2eLT0zzrvM03ueqd5STPw7zdj90zQIhUGoVamhwP7oMn zhFSm/iN2JUQ2/wqL2St1BPQtECUn5dHV3LVTM36lJzUVk0Zwp2bamreKp1dXFkyx1+3 NloTt8Gd2TpktfLWcdv+WvZYHZ+xXVl3lFQWMCK5DpIZw7JEw7BTWQvDn75obnd14c8P 3CcA== X-Gm-Message-State: AO0yUKV5V4aqxOYefMfEjLFvN+c+qURsOA/pg4vRovj+krJuFyDr2gKh DlEUBBGgfmsPib0HxEEip+I= X-Received: by 2002:a17:906:fca8:b0:8ae:707:e129 with SMTP id qw8-20020a170906fca800b008ae0707e129mr16319860ejb.19.1678266148422; Wed, 08 Mar 2023 01:02:28 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id j7-20020a17090643c700b008caaae1f1e1sm7153709ejn.110.2023.03.08.01.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 01:02:28 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/4] dt-bindings: iio: light: add apds990x binding Date: Wed, 8 Mar 2023 11:02:16 +0200 Message-Id: <20230308090219.12710-2-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230308090219.12710-1-clamor95@gmail.com> References: <20230308090219.12710-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759790026155742152?= X-GMAIL-MSGID: =?utf-8?q?1759790026155742152?= Add dt-binding for apds990x ALS/proximity sensor. Signed-off-by: Svyatoslav Ryhel --- .../bindings/iio/light/avago,apds990x.yaml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/avago,apds990x.yaml diff --git a/Documentation/devicetree/bindings/iio/light/avago,apds990x.yaml b/Documentation/devicetree/bindings/iio/light/avago,apds990x.yaml new file mode 100644 index 000000000000..9b47e13f88e3 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/avago,apds990x.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/avago,apds990x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Avago APDS990x ALS and proximity sensor + +maintainers: + - Samu Onkalo + +description: | + APDS990x is a combined ambient light and proximity sensor. ALS and + proximity functionality are highly connected. ALS measurement path + must be running while the proximity functionality is enabled. + +properties: + compatible: + const: avago,apds990x + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: true + vled-supply: true + + avago,pdrive: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 32 + description: | + Drive value used in configuring control register. + + avago,ppcount: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 32 + description: | + Number of pulses used for proximity sensor calibration. + +additionalProperties: false + +required: + - compatible + - reg + - interrupt + - vdd-supply + - vled-supply + - avago,pdrive + - avago,ppcount + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@39 { + compatible = "avago,apds990x"; + reg = <0x39>; + + interrupt-parent = <&gpio>; + interrupts = <82 IRQ_TYPE_EDGE_RISING>; + + vdd-supply = <&vdd_3v0_proxi>; + vled-supply = <&vdd_1v8_sen>; + + avago,pdrive = <0x00>; + avago,ppcount = <0x03>; + }; + }; +... From patchwork Wed Mar 8 09:02:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 66124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp229414wrd; Wed, 8 Mar 2023 01:30:03 -0800 (PST) X-Google-Smtp-Source: AK7set9TsyL+S3laQfJQUfAZ0FWddzAlF+UgAhEWvFzeXVvyMZQ04qozKc80hAOj2ZFfXSFQFLfh X-Received: by 2002:a17:907:6d91:b0:878:58e6:f1eb with SMTP id sb17-20020a1709076d9100b0087858e6f1ebmr21536468ejc.23.1678267803699; Wed, 08 Mar 2023 01:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678267803; cv=none; d=google.com; s=arc-20160816; b=sUc4qepg9kW8kVMUhmDYWdhnEYxlVbdeAigrfx6RRaHMkn5rqFIZMohTMJYQvj5S2C qXoSK0WkOv4s1h0YkD0p7+oD3CiklbIsPvanGcOWFyV8DAHLm8b17za+rs/oBHBL6eb4 FnKCHBceME4YwwuZ/sTHWFtw66UDb/15754Q5ndz3hhb0UuUzm9uF4+LT1ibttG9txdT ot6nGV4DtVLHILwa7jWSdi952cX+pLcODj42bL5UwCdJmN8abeWRZ3eeWV4rRQKIfgSG g8cLNtBejnJfciUFcqcvAokAvrGVWkZkZXhv7OkJ6aB5ob/nPVTAwDuA/hGZmYwsfzph 972Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pEL5i+l5uJgUeWQVuHHqsyYYkfIaU6CMwZkdIb7+3Eo=; b=wnBdnL7tq1DO/BAcreFDv8Dt2AZifqVq9OHuRfUSMU6TZYyMxNaX44zM1G8w/Nfzgq ybbJ/M+fK7BFLNQxNZKZuTQe9Sxc7Rg02bg7HFhYEYR3KOK3FIyAqnmilbyDczQn/JU3 SF2OlLv1G4EWhI9nGuxqty6jfZGUSYrG58mF24tKJOeK2Nm6WpOjBodjIpQT0xkpva8Q fqPh1WpUX+2OWmlfgH/5J0zEBRkEpaK23a2wCScp7skgMxokHxOM+xvjuyg1//nekwWk lwrJPVxD+7M1o3MZ8oSgEyhpQrbYG/6zh8KrFvstgcKATAh63sV/RD5D3V+Hsj9H2lAi d1zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HcERTqYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a05640214c300b004be3964ffdcsi15258902edx.517.2023.03.08.01.29.40; Wed, 08 Mar 2023 01:30:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HcERTqYK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbjCHJCp (ORCPT + 99 others); Wed, 8 Mar 2023 04:02:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbjCHJCd (ORCPT ); Wed, 8 Mar 2023 04:02:33 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A8995E2E; Wed, 8 Mar 2023 01:02:31 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id o12so62712222edb.9; Wed, 08 Mar 2023 01:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678266149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pEL5i+l5uJgUeWQVuHHqsyYYkfIaU6CMwZkdIb7+3Eo=; b=HcERTqYKjrUqYLYOThQfCLeydPrBYa/Wj5A1D8Q2PYj/5MMPtCnDCYIB5Y7AndyFHG T9jRhZ159tegwOhWRZXJ5FGj12/B6Iwr0zU5AE+eIUY1kf6QyHsm7OcAWiDOa1kk+f8l kKkjebrwIhay65THKbPPIHUFYDl0bXYGNytWGLbnIvYvadUNgccu1sk1TijyORw/JVtC k3/GQnhYEnhWgbGRfwSTcDLuk0uOQhHwQxZtHX6kNCC6PfPszAj6wYR6fsBdwPNnKYqU gJxxhK2IxQp3c1kezVY9SGFbFlnZ6a7N8lvtzJGW0adkc21jo0LVJj/Gr9Qq9WZQVdCX uGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pEL5i+l5uJgUeWQVuHHqsyYYkfIaU6CMwZkdIb7+3Eo=; b=LQXY5wW3MYMCkWEZbO4rF2JYfjZwunZu0v8GeVq1iF2NDaeIgVySE5GAKDOBBW2JQH 4IhXlOvy/XHa5PsEFMQbIXcoXgqTKzQdnGn04mHJAtly+44etFUsTCU7lHTAWxsRnUXz P/67VRonWK2HYysdZtC1bF4iYH+NsLGFlc46rV9tTWubmiPvgfCLUZS911eBi1Vg4xCl nk44+AdKH9Z8388eFUvFNZm5lkyMcHdHhBtZAcELRURRuF5clgQHHXtPLGWwKKOFW0iW UhZmA5AAyoElyF2hy9xfKb7/MBVgETbRWSfDYeHC0ZW1EZYdyF36zZk6RTelbpg2Z/NP /8Qg== X-Gm-Message-State: AO0yUKX9AE90ETXSXb4b3MtJcXmMp4Jnkx91WOrNHNTY9wpSrrEsX8Wf Ap1H6wLDJXxeu1wvj6qupu8= X-Received: by 2002:a17:906:ca5a:b0:8b2:abc7:1ef9 with SMTP id jx26-20020a170906ca5a00b008b2abc71ef9mr17204205ejb.68.1678266149422; Wed, 08 Mar 2023 01:02:29 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id j7-20020a17090643c700b008caaae1f1e1sm7153709ejn.110.2023.03.08.01.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 01:02:29 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/4] misc: adps990x: convert to OF Date: Wed, 8 Mar 2023 11:02:17 +0200 Message-Id: <20230308090219.12710-3-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230308090219.12710-1-clamor95@gmail.com> References: <20230308090219.12710-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759791340530938556?= X-GMAIL-MSGID: =?utf-8?q?1759791340530938556?= Add ability to get essential values from device tree. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 56 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 0024503ea6db..c53ead5a575d 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -180,8 +180,8 @@ static const u16 arates_hz[] = {10, 5, 2, 1}; static const u8 apersis[] = {1, 2, 4, 5}; /* Regulators */ -static const char reg_vcc[] = "Vdd"; -static const char reg_vled[] = "Vled"; +static const char reg_vcc[] = "vdd"; +static const char reg_vled[] = "vled"; static int apds990x_read_byte(struct apds990x_chip *chip, u8 reg, u8 *data) { @@ -1048,9 +1048,38 @@ static struct attribute *sysfs_attrs_ctrl[] = { }; static const struct attribute_group apds990x_attribute_group[] = { - {.attrs = sysfs_attrs_ctrl }, + { .attrs = sysfs_attrs_ctrl }, }; +static int apds990x_of_probe(struct i2c_client *client, + struct apds990x_chip *chip) +{ + struct apds990x_platform_data *pdata; + u32 ret, val; + + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + ret = device_property_read_u32(&client->dev, "avago,pdrive", &val); + if (ret) { + dev_info(&client->dev, "pdrive property is missing: ret %d\n", ret); + return ret; + } + pdata->pdrive = val; + + ret = device_property_read_u32(&client->dev, "avago,ppcount", &val); + if (ret) { + dev_info(&client->dev, "ppcount property is missing: ret %d\n", ret); + return ret; + } + pdata->ppcount = val; + + chip->pdata = pdata; + + return 0; +} + static int apds990x_probe(struct i2c_client *client) { struct apds990x_chip *chip; @@ -1065,13 +1094,10 @@ static int apds990x_probe(struct i2c_client *client) init_waitqueue_head(&chip->wait); mutex_init(&chip->mutex); - chip->pdata = client->dev.platform_data; - if (chip->pdata == NULL) { - dev_err(&client->dev, "platform data is mandatory\n"); - err = -EINVAL; - goto fail1; - } + chip->pdata = client->dev.platform_data; + if (!chip->pdata) + apds990x_of_probe(client, chip); if (chip->pdata->cf.ga == 0) { /* set uncovered sensor default parameters */ @@ -1160,8 +1186,7 @@ static int apds990x_probe(struct i2c_client *client) err = request_threaded_irq(client->irq, NULL, apds990x_irq, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW | - IRQF_ONESHOT, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "apds990x", chip); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", @@ -1252,11 +1277,16 @@ static int apds990x_runtime_resume(struct device *dev) #endif +static const struct of_device_id apds990x_match_table[] = { + { .compatible = "avago,apds990x" }, + { }, +}; +MODULE_DEVICE_TABLE(of, apds990x_match_table); + static const struct i2c_device_id apds990x_id[] = { {"apds990x", 0 }, {} }; - MODULE_DEVICE_TABLE(i2c, apds990x_id); static const struct dev_pm_ops apds990x_pm_ops = { @@ -1270,12 +1300,12 @@ static struct i2c_driver apds990x_driver = { .driver = { .name = "apds990x", .pm = &apds990x_pm_ops, + .of_match_table = apds990x_match_table, }, .probe_new = apds990x_probe, .remove = apds990x_remove, .id_table = apds990x_id, }; - module_i2c_driver(apds990x_driver); MODULE_DESCRIPTION("APDS990X combined ALS and proximity sensor"); From patchwork Wed Mar 8 09:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 66121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp227348wrd; Wed, 8 Mar 2023 01:23:59 -0800 (PST) X-Google-Smtp-Source: AK7set83YAzkAlx3JgsemFYqYoBaZGolwUl4zx14ku840Tac99HFrbks4BZ4kauufxPkFsxp2dea X-Received: by 2002:a05:6402:5154:b0:4af:5aa1:6646 with SMTP id n20-20020a056402515400b004af5aa16646mr14607177edd.14.1678267439542; Wed, 08 Mar 2023 01:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678267439; cv=none; d=google.com; s=arc-20160816; b=Oo/YY/LLvYwygSBe3jd7NyqDuDHVAdPOgPOhS5Z0rRGMt+DF0HizUE48MwetA+gWcy Lg7MByUpCy8Fzg7bEyyVMVwvWH6LT2aYxrpsx2o8C4VT/VZGqgqOmbNaQu2O8HN8ZSlg H338gfXKO8xX1mOepT5KfG5Qa9Vt+zB90Gtdr8sa+H0/aRwbpMlGksBYwk5CblVfdxsi 9eBCSyYe9z1EVK8fKAAw17SD9DpzOuKV55uCpuebNrfmBc6ArRvcoTmMdNPzA3M5CZfj 2s0c1kovuf3CQzL+33fzS2+QZRylhYxA3h+m6xBYsQsnY/ZH2mu/03k0IDGwf87blZi5 4zvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=55SQUAk//QC5U//Z8hGQWQU2CP1NvhaerZos5P4MWWc=; b=cbIRKDJ9vgyWT5p+3I45IDMngu7j0ZaJnOLsK/1s445dKZgwVaVQHxQCf0l8ZxBO+Y HATxJm2Bp3sNzHvkwzBNAX+8Iv+5jqyngiOWMw2/vKPooI1pHVBIxNR0bfrifUJam8fI RGET5NvnAx9f7lrBNAQ+K2EZvb7P60xL6mTgbhD+FbQmu8Z0rhD4B+HpOoAqFAPtk1iw SlKIFiQm2x92Af6jvHlDu/Qsty/ADBuyOjgvzqT5b42RTfp9lBK+E+qVP3dge7COvbrW a9cSiF+kfzsq/cgiHLI1HnB9Iw6KbcTtuPVbNw8dGL4dGwLb5a536yNP86gICKTxQSj+ naKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gWn8+BVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020aa7c38a000000b004acc5e8b8f6si10418447edq.312.2023.03.08.01.23.34; Wed, 08 Mar 2023 01:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gWn8+BVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbjCHJC6 (ORCPT + 99 others); Wed, 8 Mar 2023 04:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjCHJCg (ORCPT ); Wed, 8 Mar 2023 04:02:36 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3275996F08; Wed, 8 Mar 2023 01:02:32 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id da10so62850208edb.3; Wed, 08 Mar 2023 01:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678266150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=55SQUAk//QC5U//Z8hGQWQU2CP1NvhaerZos5P4MWWc=; b=gWn8+BVpTHoRPUxvtiQ3hKY2CCkGfffM6VhgnzaaI0D0eOJJGoxfuHYd3WGZ39gjbE eXm+BWXvQmzpb4PzRaVrm5E4ugykb1mMChvt3IHapyZCRkH0ZfRKr2tvz6PvW+TCM0Kn ibZpxPEsyX0iqdOzETv01MpzD4d4A8tc5YJYaeeroG4yJx6TYx4XZpjg6ZQun58RcqS6 CB3xaxuf3CFDtpOQN6PmBm7nH5mVhoihwaGXLFecA79m8stDq5mzL7UMn7UCFYqkpuGs VS8wWGzGO07FX0x8xKh2aGe7QTRtGXAYCFWVq5AOom1LZAOQ5njWertcaBjSJn9t83RY mQwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=55SQUAk//QC5U//Z8hGQWQU2CP1NvhaerZos5P4MWWc=; b=sQKvcFDNWKA6/sM6e18hEMPonxqfLVw30HuLFKHU2qFksEdKp0Rg5Pit3QNUzJ6C7O QXDuoKVgX+xH1e3YdhcDnc03NcUvreH+xn+SfW0CRsexkbOL2PtTsgRXCkte6re0D2wD Ln2pMBaY/aJz4r0ZMXl2NDUiMVkZOZOCQtaY93emzCa6op9zFM0wzgvLqjO07FQyYBYe fFQJ5J+C5M4uygdsH1hF3foLtX+NIUgIhGNbDpG0VSzOxXFo5M3R5bfSSLWKDmY4ywtU ZO3PhtJ1ZrbXGrgctHslqxpwHVezVA0Q6whBWFylqaEqRkE2+LVHIXU8y1rwLLNOxm32 EYig== X-Gm-Message-State: AO0yUKXucJYPVdMdH9IJdVnx/E38mQ0jUswSebIKCexaHr2YT2cZ9Gfl 2s3GN0QNnTmsN7vNUjFPPIU= X-Received: by 2002:a17:907:5cb:b0:8b1:3a23:8ec7 with SMTP id wg11-20020a17090705cb00b008b13a238ec7mr22344377ejb.43.1678266150516; Wed, 08 Mar 2023 01:02:30 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id j7-20020a17090643c700b008caaae1f1e1sm7153709ejn.110.2023.03.08.01.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 01:02:30 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/4] misc: apds990x: convert to IIO Date: Wed, 8 Mar 2023 11:02:18 +0200 Message-Id: <20230308090219.12710-4-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230308090219.12710-1-clamor95@gmail.com> References: <20230308090219.12710-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759790958418786297?= X-GMAIL-MSGID: =?utf-8?q?1759790958418786297?= Convert old sysfs export to an IIO look. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 794 ++++++++++++++++++++-------------------- 1 file changed, 403 insertions(+), 391 deletions(-) diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index c53ead5a575d..0352962d6d89 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -20,6 +20,9 @@ #include #include +#include +#include + /* Register map */ #define APDS990X_ENABLE 0x00 /* Enable of states and interrupts */ #define APDS990X_ATIME 0x01 /* ALS ADC time */ @@ -100,6 +103,21 @@ #define APDS990X_LUX_OUTPUT_SCALE 10 +enum { + APDS990X_LUX_RANGE_ATTR = 1, + APDS990X_LUX_CALIB_FORMAT_ATTR, + APDS990X_LUX_CALIB_ATTR, + APDS990X_LUX_RATE_AVAIL_ATTR, + APDS990X_LUX_RATE_ATTR, + APDS990X_LUX_THRESH_ABOVE_ATTR, + APDS990X_LUX_THRESH_BELOW_ATTR, + APDS990X_PROX_SENSOR_RANGE_ATTR, + APDS990X_PROX_THRESH_ABOVE_VALUE_ATTR, + APDS990X_PROX_REPORTING_MODE_ATTR, + APDS990X_PROX_REPORTING_MODE_AVAIL_ATTR, + APDS990X_CHIP_ID_ATTR, +}; + /* Reverse chip factors for threshold calculation */ struct reverse_factors { u32 afactor; @@ -116,7 +134,7 @@ struct apds990x_chip { struct regulator_bulk_data regs[2]; wait_queue_head_t wait; - int prox_en; + bool prox_en; bool prox_continuous_mode; bool lux_wait_fresh_res; @@ -235,12 +253,8 @@ static int apds990x_write_word(struct apds990x_chip *chip, u8 reg, u16 data) static int apds990x_mode_on(struct apds990x_chip *chip) { - /* ALS is mandatory, proximity optional */ u8 reg = APDS990X_EN_AIEN | APDS990X_EN_PON | APDS990X_EN_AEN | - APDS990X_EN_WEN; - - if (chip->prox_en) - reg |= APDS990X_EN_PIEN | APDS990X_EN_PEN; + APDS990X_EN_WEN | APDS990X_EN_PIEN | APDS990X_EN_PEN; return apds990x_write_byte(chip, APDS990X_ENABLE, reg); } @@ -473,7 +487,8 @@ static int apds990x_ack_int(struct apds990x_chip *chip, u8 mode) static irqreturn_t apds990x_irq(int irq, void *data) { - struct apds990x_chip *chip = data; + struct iio_dev *indio_dev = data; + struct apds990x_chip *chip = iio_priv(indio_dev); u8 status; apds990x_read_byte(chip, APDS990X_STATUS, &status); @@ -498,12 +513,10 @@ static irqreturn_t apds990x_irq(int irq, void *data) chip->lux = chip->lux_raw; chip->lux_wait_fresh_res = false; wake_up(&chip->wait); - sysfs_notify(&chip->client->dev.kobj, - NULL, "lux0_input"); } } - if ((status & APDS990X_ST_PINT) && chip->prox_en) { + if (status & APDS990X_ST_PINT) { u16 clr_ch; apds990x_read_word(chip, APDS990X_CDATAL, &clr_ch); @@ -525,8 +538,6 @@ static irqreturn_t apds990x_irq(int irq, void *data) chip->prox_data = 0; else if (!chip->prox_continuous_mode) chip->prox_data = APDS_PROX_RANGE; - sysfs_notify(&chip->client->dev.kobj, - NULL, "prox0_raw"); } } mutex_unlock(&chip->mutex); @@ -619,102 +630,67 @@ static int apds990x_chip_off(struct apds990x_chip *chip) return 0; } -static ssize_t apds990x_lux_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - ssize_t ret; - u32 result; - long timeout; - - if (pm_runtime_suspended(dev)) - return -EIO; - - timeout = wait_event_interruptible_timeout(chip->wait, - !chip->lux_wait_fresh_res, - msecs_to_jiffies(APDS_TIMEOUT)); - if (!timeout) - return -EIO; - - mutex_lock(&chip->mutex); - result = (chip->lux * chip->lux_calib) / APDS_CALIB_SCALER; - if (result > (APDS_RANGE * APDS990X_LUX_OUTPUT_SCALE)) - result = APDS_RANGE * APDS990X_LUX_OUTPUT_SCALE; - - ret = sprintf(buf, "%d.%d\n", - result / APDS990X_LUX_OUTPUT_SCALE, - result % APDS990X_LUX_OUTPUT_SCALE); - mutex_unlock(&chip->mutex); - return ret; -} +static const char * const reporting_modes[] = { "trigger", "periodic" }; -static DEVICE_ATTR(lux0_input, S_IRUGO, apds990x_lux_show, NULL); - -static ssize_t apds990x_lux_range_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", APDS_RANGE); -} - -static DEVICE_ATTR(lux0_sensor_range, S_IRUGO, apds990x_lux_range_show, NULL); - -static ssize_t apds990x_lux_calib_format_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", APDS_CALIB_SCALER); -} - -static DEVICE_ATTR(lux0_calibscale_default, S_IRUGO, - apds990x_lux_calib_format_show, NULL); - -static ssize_t apds990x_lux_calib_show(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t apds990x_lux_prox_show(struct device *dev, + struct device_attribute *attr, + char *buf) { - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%u\n", chip->lux_calib); -} - -static ssize_t apds990x_lux_calib_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - unsigned long value; - int ret; - - ret = kstrtoul(buf, 0, &value); - if (ret) - return ret; - - chip->lux_calib = value; + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct apds990x_chip *chip = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + int i, len = 0; + + mutex_lock(&indio_dev->mlock); + switch ((u32)this_attr->address) { + case APDS990X_LUX_RANGE_ATTR: + len = sprintf(buf, "%u\n", APDS_RANGE); + break; + case APDS990X_LUX_CALIB_FORMAT_ATTR: + len = sprintf(buf, "%u\n", APDS_CALIB_SCALER); + break; + case APDS990X_LUX_CALIB_ATTR: + len = sprintf(buf, "%u\n", chip->lux_calib); + break; + case APDS990X_LUX_RATE_AVAIL_ATTR: + for (i = 0; i < ARRAY_SIZE(arates_hz); i++) + len += sprintf(buf + len, "%d ", arates_hz[i]); + len = sprintf(buf + len - 1, "\n"); + break; + case APDS990X_LUX_RATE_ATTR: + len = sprintf(buf, "%d\n", chip->arate); + break; + case APDS990X_LUX_THRESH_ABOVE_ATTR: + len = sprintf(buf, "%d\n", chip->lux_thres_hi); + break; + case APDS990X_LUX_THRESH_BELOW_ATTR: + len = sprintf(buf, "%d\n", chip->lux_thres_lo); + break; + case APDS990X_PROX_SENSOR_RANGE_ATTR: + len = sprintf(buf, "%u\n", APDS_PROX_RANGE); + break; + case APDS990X_PROX_THRESH_ABOVE_VALUE_ATTR: + len = sprintf(buf, "%d\n", chip->prox_thres); + break; + case APDS990X_PROX_REPORTING_MODE_ATTR: + len = sprintf(buf, "%s\n", + reporting_modes[!!chip->prox_continuous_mode]); + break; + case APDS990X_PROX_REPORTING_MODE_AVAIL_ATTR: + len = sprintf(buf, "%s %s\n", + reporting_modes[0], reporting_modes[1]); + break; + case APDS990X_CHIP_ID_ATTR: + len = sprintf(buf, "%s %d\n", chip->chipname, chip->revision); + break; + default: + return -EINVAL; + } + mutex_unlock(&indio_dev->mlock); return len; } -static DEVICE_ATTR(lux0_calibscale, S_IRUGO | S_IWUSR, apds990x_lux_calib_show, - apds990x_lux_calib_store); - -static ssize_t apds990x_rate_avail(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int i; - int pos = 0; - - for (i = 0; i < ARRAY_SIZE(arates_hz); i++) - pos += sprintf(buf + pos, "%d ", arates_hz[i]); - sprintf(buf + pos - 1, "\n"); - return pos; -} - -static ssize_t apds990x_rate_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", chip->arate); -} - static int apds990x_set_arate(struct apds990x_chip *chip, int rate) { int i; @@ -740,154 +716,8 @@ static int apds990x_set_arate(struct apds990x_chip *chip, int rate) (chip->prox_persistence << APDS990X_PPERS_SHIFT)); } -static ssize_t apds990x_rate_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - unsigned long value; - int ret; - - ret = kstrtoul(buf, 0, &value); - if (ret) - return ret; - - mutex_lock(&chip->mutex); - ret = apds990x_set_arate(chip, value); - mutex_unlock(&chip->mutex); - - if (ret < 0) - return ret; - return len; -} - -static DEVICE_ATTR(lux0_rate_avail, S_IRUGO, apds990x_rate_avail, NULL); - -static DEVICE_ATTR(lux0_rate, S_IRUGO | S_IWUSR, apds990x_rate_show, - apds990x_rate_store); - -static ssize_t apds990x_prox_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret; - struct apds990x_chip *chip = dev_get_drvdata(dev); - - if (pm_runtime_suspended(dev) || !chip->prox_en) - return -EIO; - - mutex_lock(&chip->mutex); - ret = sprintf(buf, "%d\n", chip->prox_data); - mutex_unlock(&chip->mutex); - return ret; -} - -static DEVICE_ATTR(prox0_raw, S_IRUGO, apds990x_prox_show, NULL); - -static ssize_t apds990x_prox_range_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", APDS_PROX_RANGE); -} - -static DEVICE_ATTR(prox0_sensor_range, S_IRUGO, apds990x_prox_range_show, NULL); - -static ssize_t apds990x_prox_enable_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", chip->prox_en); -} - -static ssize_t apds990x_prox_enable_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - unsigned long value; - int ret; - - ret = kstrtoul(buf, 0, &value); - if (ret) - return ret; - - mutex_lock(&chip->mutex); - - if (!chip->prox_en) - chip->prox_data = 0; - - if (value) - chip->prox_en++; - else if (chip->prox_en > 0) - chip->prox_en--; - - if (!pm_runtime_suspended(dev)) - apds990x_mode_on(chip); - mutex_unlock(&chip->mutex); - return len; -} - -static DEVICE_ATTR(prox0_raw_en, S_IRUGO | S_IWUSR, apds990x_prox_enable_show, - apds990x_prox_enable_store); - -static const char *reporting_modes[] = {"trigger", "periodic"}; - -static ssize_t apds990x_prox_reporting_mode_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%s\n", - reporting_modes[!!chip->prox_continuous_mode]); -} - -static ssize_t apds990x_prox_reporting_mode_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - int ret; - - ret = sysfs_match_string(reporting_modes, buf); - if (ret < 0) - return ret; - - chip->prox_continuous_mode = ret; - return len; -} - -static DEVICE_ATTR(prox0_reporting_mode, S_IRUGO | S_IWUSR, - apds990x_prox_reporting_mode_show, - apds990x_prox_reporting_mode_store); - -static ssize_t apds990x_prox_reporting_avail_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%s %s\n", reporting_modes[0], reporting_modes[1]); -} - -static DEVICE_ATTR(prox0_reporting_mode_avail, S_IRUGO | S_IWUSR, - apds990x_prox_reporting_avail_show, NULL); - - -static ssize_t apds990x_lux_thresh_above_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", chip->lux_thres_hi); -} - -static ssize_t apds990x_lux_thresh_below_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - - return sprintf(buf, "%d\n", chip->lux_thres_lo); -} - -static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, - const char *buf) +static int apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, + const char *buf) { unsigned long thresh; int ret; @@ -908,98 +738,165 @@ static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, if (!chip->lux_wait_fresh_res) apds990x_refresh_athres(chip); mutex_unlock(&chip->mutex); - return ret; + return ret; } -static ssize_t apds990x_lux_thresh_above_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) +static ssize_t apds990x_lux_prox_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) { - struct apds990x_chip *chip = dev_get_drvdata(dev); - int ret = apds990x_set_lux_thresh(chip, &chip->lux_thres_hi, buf); + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct apds990x_chip *chip = iio_priv(indio_dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + unsigned long value; + int ret; - if (ret < 0) + ret = kstrtoul(buf, 0, &value); + if (ret) return ret; - return len; -} -static ssize_t apds990x_lux_thresh_below_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - int ret = apds990x_set_lux_thresh(chip, &chip->lux_thres_lo, buf); - - if (ret < 0) - return ret; - return len; -} + mutex_lock(&indio_dev->mlock); + switch ((u32)this_attr->address) { + case APDS990X_LUX_CALIB_ATTR: + chip->lux_calib = value; + break; + case APDS990X_LUX_RATE_ATTR: + mutex_lock(&chip->mutex); + ret = apds990x_set_arate(chip, value); + mutex_unlock(&chip->mutex); -static DEVICE_ATTR(lux0_thresh_above_value, S_IRUGO | S_IWUSR, - apds990x_lux_thresh_above_show, - apds990x_lux_thresh_above_store); + if (ret < 0) + return ret; + break; + case APDS990X_LUX_THRESH_ABOVE_ATTR: + ret = apds990x_set_lux_thresh(chip, + &chip->lux_thres_hi, buf); -static DEVICE_ATTR(lux0_thresh_below_value, S_IRUGO | S_IWUSR, - apds990x_lux_thresh_below_show, - apds990x_lux_thresh_below_store); + if (ret < 0) + return ret; + break; + case APDS990X_LUX_THRESH_BELOW_ATTR: + ret = apds990x_set_lux_thresh(chip, + &chip->lux_thres_lo, buf); -static ssize_t apds990x_prox_threshold_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); + if (ret < 0) + return ret; + break; + case APDS990X_PROX_THRESH_ABOVE_VALUE_ATTR: + if (value > APDS_RANGE || value == 0 || + value < APDS_PROX_HYSTERESIS) + return -EINVAL; - return sprintf(buf, "%d\n", chip->prox_thres); -} + mutex_lock(&chip->mutex); -static ssize_t apds990x_prox_threshold_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - struct apds990x_chip *chip = dev_get_drvdata(dev); - unsigned long value; - int ret; + chip->prox_thres = value; + apds990x_force_p_refresh(chip); - ret = kstrtoul(buf, 0, &value); - if (ret) - return ret; + mutex_unlock(&chip->mutex); + break; + case APDS990X_PROX_REPORTING_MODE_ATTR: + ret = sysfs_match_string(reporting_modes, buf); + if (ret < 0) + return ret; - if ((value > APDS_RANGE) || (value == 0) || - (value < APDS_PROX_HYSTERESIS)) + chip->prox_continuous_mode = ret; + break; + default: return -EINVAL; + } - mutex_lock(&chip->mutex); - chip->prox_thres = value; - - apds990x_force_p_refresh(chip); - mutex_unlock(&chip->mutex); + mutex_unlock(&indio_dev->mlock); return len; } -static DEVICE_ATTR(prox0_thresh_above_value, S_IRUGO | S_IWUSR, - apds990x_prox_threshold_show, - apds990x_prox_threshold_store); +/* ALS ATTRIBUTES */ +static IIO_DEVICE_ATTR(in_illuminance_range, 0444, + apds990x_lux_prox_show, + NULL, + APDS990X_LUX_RANGE_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_calib_format, 0444, + apds990x_lux_prox_show, + NULL, + APDS990X_LUX_CALIB_FORMAT_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_calibscale, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_LUX_CALIB_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_rate_avail, 0444, + apds990x_lux_prox_show, + NULL, + APDS990X_LUX_RATE_AVAIL_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_rate, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_LUX_RATE_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_thresh_above_value, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_LUX_THRESH_ABOVE_ATTR); + +static IIO_DEVICE_ATTR(in_illuminance_thresh_below_value, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_LUX_THRESH_BELOW_ATTR); + +/* PROX ATTRIBUTES */ +static IIO_DEVICE_ATTR(in_proximity_sensor_range, 0444, + apds990x_lux_prox_show, + NULL, + APDS990X_PROX_SENSOR_RANGE_ATTR); + +static IIO_DEVICE_ATTR(in_proximity_reporting_mode, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_PROX_REPORTING_MODE_ATTR); + +static IIO_DEVICE_ATTR(in_proximity_reporting_mode_avail, 0644, + apds990x_lux_prox_show, + NULL, + APDS990X_PROX_REPORTING_MODE_AVAIL_ATTR); + +static IIO_DEVICE_ATTR(in_proximity_thresh_above_value, 0644, + apds990x_lux_prox_show, + apds990x_lux_prox_store, + APDS990X_PROX_THRESH_ABOVE_VALUE_ATTR); + +static IIO_DEVICE_ATTR(chip_id, 0444, + apds990x_lux_prox_show, + NULL, + APDS990X_CHIP_ID_ATTR); + +static struct attribute *apds990x_attributes[] = { + &iio_dev_attr_in_illuminance_calib_format.dev_attr.attr, + &iio_dev_attr_in_illuminance_range.dev_attr.attr, + &iio_dev_attr_in_illuminance_calibscale.dev_attr.attr, + &iio_dev_attr_in_illuminance_rate.dev_attr.attr, + &iio_dev_attr_in_illuminance_rate_avail.dev_attr.attr, + &iio_dev_attr_in_illuminance_thresh_above_value.dev_attr.attr, + &iio_dev_attr_in_illuminance_thresh_below_value.dev_attr.attr, + &iio_dev_attr_in_proximity_sensor_range.dev_attr.attr, + &iio_dev_attr_in_proximity_thresh_above_value.dev_attr.attr, + &iio_dev_attr_in_proximity_reporting_mode.dev_attr.attr, + &iio_dev_attr_in_proximity_reporting_mode_avail.dev_attr.attr, + &iio_dev_attr_chip_id.dev_attr.attr, + NULL +}; -static ssize_t apds990x_power_state_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n", !pm_runtime_suspended(dev)); - return 0; -} +static const struct attribute_group apds990x_attribute_group = { + .attrs = apds990x_attributes, +}; -static ssize_t apds990x_power_state_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) +static void apds990x_power_state_switch(struct apds990x_chip *chip, bool state) { - struct apds990x_chip *chip = dev_get_drvdata(dev); - unsigned long value; - int ret; + struct device *dev = &chip->client->dev; - ret = kstrtoul(buf, 0, &value); - if (ret) - return ret; - - if (value) { + if (state) { pm_runtime_get_sync(dev); mutex_lock(&chip->mutex); chip->lux_wait_fresh_res = true; @@ -1010,46 +907,80 @@ static ssize_t apds990x_power_state_store(struct device *dev, if (!pm_runtime_suspended(dev)) pm_runtime_put(dev); } - return len; } -static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR, - apds990x_power_state_show, - apds990x_power_state_store); - -static ssize_t apds990x_chip_id_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int apds990x_lux_raw(struct apds990x_chip *chip) { - struct apds990x_chip *chip = dev_get_drvdata(dev); + struct device *dev = &chip->client->dev; + int ret; + long timeout; + + if (pm_runtime_suspended(dev)) + return -EIO; + + timeout = wait_event_interruptible_timeout(chip->wait, + !chip->lux_wait_fresh_res, + msecs_to_jiffies(APDS_TIMEOUT)); + if (!timeout) + return -EIO; + + mutex_lock(&chip->mutex); + + ret = (chip->lux * chip->lux_calib) / APDS_CALIB_SCALER; + if (ret > (APDS_RANGE * APDS990X_LUX_OUTPUT_SCALE)) + ret = APDS_RANGE * APDS990X_LUX_OUTPUT_SCALE; - return sprintf(buf, "%s %d\n", chip->chipname, chip->revision); + mutex_unlock(&chip->mutex); + + return ret; } -static DEVICE_ATTR(chip_id, S_IRUGO, apds990x_chip_id_show, NULL); - -static struct attribute *sysfs_attrs_ctrl[] = { - &dev_attr_lux0_calibscale.attr, - &dev_attr_lux0_calibscale_default.attr, - &dev_attr_lux0_input.attr, - &dev_attr_lux0_sensor_range.attr, - &dev_attr_lux0_rate.attr, - &dev_attr_lux0_rate_avail.attr, - &dev_attr_lux0_thresh_above_value.attr, - &dev_attr_lux0_thresh_below_value.attr, - &dev_attr_prox0_raw_en.attr, - &dev_attr_prox0_raw.attr, - &dev_attr_prox0_sensor_range.attr, - &dev_attr_prox0_thresh_above_value.attr, - &dev_attr_prox0_reporting_mode.attr, - &dev_attr_prox0_reporting_mode_avail.attr, - &dev_attr_chip_id.attr, - &dev_attr_power_state.attr, - NULL -}; +static int apds990x_prox_raw(struct apds990x_chip *chip) +{ + struct device *dev = &chip->client->dev; + long timeout; + u16 clr_ch; -static const struct attribute_group apds990x_attribute_group[] = { - { .attrs = sysfs_attrs_ctrl }, -}; + if (!chip->prox_en) { + chip->prox_data = 0; + return chip->prox_data; + } + + if (pm_runtime_suspended(dev)) + return -EIO; + + timeout = wait_event_interruptible_timeout(chip->wait, + !chip->lux_wait_fresh_res, + msecs_to_jiffies(APDS_TIMEOUT)); + if (!timeout) + return -EIO; + + mutex_lock(&chip->mutex); + + apds990x_read_word(chip, APDS990X_CDATAL, &clr_ch); + /* + * If ALS channel is saturated at min gain, + * proximity gives false posivite values. + * Just ignore them. + */ + if (chip->again_meas == 0 && + clr_ch == chip->a_max_result) + chip->prox_data = 0; + else + apds990x_read_word(chip, + APDS990X_PDATAL, + &chip->prox_data); + + apds990x_refresh_pthres(chip, chip->prox_data); + if (chip->prox_data < chip->prox_thres) + chip->prox_data = 0; + else if (!chip->prox_continuous_mode) + chip->prox_data = 1; + + mutex_unlock(&chip->mutex); + + return chip->prox_data; +} static int apds990x_of_probe(struct i2c_client *client, struct apds990x_chip *chip) @@ -1080,15 +1011,114 @@ static int apds990x_of_probe(struct i2c_client *client, return 0; } +static int apds990x_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct apds990x_chip *chip = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + apds990x_power_state_switch(chip, true); + + switch (chan->type) { + case IIO_LIGHT: + *val = apds990x_lux_raw(chip); + break; + case IIO_PROXIMITY: + *val = apds990x_prox_raw(chip); + break; + default: + break; + } + + apds990x_power_state_switch(chip, false); + + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_LIGHT: + case IIO_PROXIMITY: + default: + *val = 1; + break; + } + + return IIO_VAL_INT; + + case IIO_CHAN_INFO_ENABLE: + switch (chan->type) { + case IIO_PROXIMITY: + *val = chip->prox_en; + default: + break; + } + + return IIO_VAL_INT; + } + return -EINVAL; +} + +static int apds990x_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, + int val2, long mask) +{ + struct apds990x_chip *chip = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_ENABLE: + switch (chan->type) { + case IIO_PROXIMITY: + mutex_lock(&chip->mutex); + chip->prox_en = val; + mutex_unlock(&chip->mutex); + default: + break; + } + + return 0; + } + return -EINVAL; +} + +static const struct iio_chan_spec apds990x_channels[] = { + { + .type = IIO_LIGHT, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_PROXIMITY, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_ENABLE), + }, +}; + +static const struct iio_info apds990x_info = { + .attrs = &apds990x_attribute_group, + .read_raw = apds990x_read_raw, + .write_raw = apds990x_write_raw, +}; + static int apds990x_probe(struct i2c_client *client) { struct apds990x_chip *chip; + struct iio_dev *indio_dev; int err; - chip = kzalloc(sizeof *chip, GFP_KERNEL); - if (!chip) + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); + if (!indio_dev) return -ENOMEM; + indio_dev->info = &apds990x_info; + indio_dev->name = "apds990x"; + indio_dev->channels = apds990x_channels; + indio_dev->num_channels = ARRAY_SIZE(apds990x_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + chip = iio_priv(indio_dev); i2c_set_clientdata(client, chip); chip->client = client; @@ -1140,17 +1170,17 @@ static int apds990x_probe(struct i2c_client *client) chip->regs[0].supply = reg_vcc; chip->regs[1].supply = reg_vled; - err = regulator_bulk_get(&client->dev, - ARRAY_SIZE(chip->regs), chip->regs); + err = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot get regulators\n"); - goto fail1; + return err; } err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot enable regulators\n"); - goto fail2; + return err; } usleep_range(APDS_STARTUP_DELAY, 2 * APDS_STARTUP_DELAY); @@ -1158,7 +1188,7 @@ static int apds990x_probe(struct i2c_client *client) err = apds990x_detect(chip); if (err < 0) { dev_err(&client->dev, "APDS990X not found\n"); - goto fail3; + return err; } pm_runtime_set_active(&client->dev); @@ -1173,39 +1203,29 @@ static int apds990x_probe(struct i2c_client *client) err = chip->pdata->setup_resources(); if (err) { err = -EINVAL; - goto fail3; + goto fail; } } - err = sysfs_create_group(&chip->client->dev.kobj, - apds990x_attribute_group); - if (err < 0) { - dev_err(&chip->client->dev, "Sysfs registration failed\n"); - goto fail4; - } - - err = request_threaded_irq(client->irq, NULL, - apds990x_irq, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "apds990x", chip); + err = devm_request_threaded_irq(&client->dev, client->irq, + NULL, apds990x_irq, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "apds990x", indio_dev); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); - goto fail5; + goto fail; } - return err; -fail5: - sysfs_remove_group(&chip->client->dev.kobj, - &apds990x_attribute_group[0]); -fail4: + + err = iio_device_register(indio_dev); + if (err) + goto fail; + + return 0; +fail: if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); -fail3: - regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); -fail2: - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); -fail1: - kfree(chip); + return err; } @@ -1213,10 +1233,6 @@ static void apds990x_remove(struct i2c_client *client) { struct apds990x_chip *chip = i2c_get_clientdata(client); - free_irq(client->irq, chip); - sysfs_remove_group(&chip->client->dev.kobj, - apds990x_attribute_group); - if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); @@ -1225,10 +1241,6 @@ static void apds990x_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); - - kfree(chip); } #ifdef CONFIG_PM_SLEEP From patchwork Wed Mar 8 09:02:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 66120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp226266wrd; Wed, 8 Mar 2023 01:20:45 -0800 (PST) X-Google-Smtp-Source: AK7set/w852lULWHxDjAphtxxnZaW44xV/YaVXYfYMF9RmwWSHAwUi/QsrZ95peGpdz/LI+aNoVl X-Received: by 2002:a17:903:492:b0:19e:2609:7bdb with SMTP id jj18-20020a170903049200b0019e26097bdbmr17100345plb.67.1678267245263; Wed, 08 Mar 2023 01:20:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678267245; cv=none; d=google.com; s=arc-20160816; b=HMlEzeSDXBgK5xSXAr+PXOvjqNQwpItfVyL3W5p+Qp7nn7hfuTWRnX5/IFcSCYfnip Z+Uxmvx5aLnOSJAZQlDzI9pHg8h/cDTEscTvMFkaFrs7swoxKTiTuJj04i0pDLxrsL/Y VSH1d59f6GShW0BJLRTW8TJprjYtGNCKRO8eVajtnIBU0lG1LfkYCITYratiEaBKXVE9 sER71vgcXpQDnLtxL3HVDV1dlR5pwsRqJ0Jl9KkL9Uj0T8DZa8vQutD98KF2+HF3Pw3w lOQh8lsjfivcq7BREX0TTxM16lnqMN2IsVQys2BbTGjqxi7495FWDRMBUHxUtCuR6hk8 u1Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TEBnaA7Pocw3dv+NsTA6Pe6Z7NrAaUzWWBCKZZ7bpik=; b=A70JVKkpwEyXVf7YIit80wOAEOSmtZjKF2iaOLGVmtzxcQjPhUuISzsdsYWcpq/IaJ Mmt47/pC/ZHbACGBPAIE6PaMpk65kMzxfd5/iUXrNi7VQLAeqxoPerIrsvLcBUQF5sPP EpEP5vTFBxF8MXqVJYs7/sU+7lDOTEh4NNrwi20MpSbQdSVhZCH/XOyfr5YlFYlS3wE2 JjrFpRgc2eHcazVGHd9+9Qg/8VpDcGWWz+cjiPQqVPSQngwFGOEitXVR+RIGY7mrmqqC 51TCEirQacmjmg9sU0FA8xmv0eF0APF7ikatKrVmxVJei6VngJSfWnz3moaGEp2IC6Hq EdiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XUIxg1o+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq6-20020a170903284600b0019a96871dd6si13312894plb.220.2023.03.08.01.20.31; Wed, 08 Mar 2023 01:20:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XUIxg1o+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbjCHJCv (ORCPT + 99 others); Wed, 8 Mar 2023 04:02:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjCHJCe (ORCPT ); Wed, 8 Mar 2023 04:02:34 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 094B596630; Wed, 8 Mar 2023 01:02:33 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id ay14so59058960edb.11; Wed, 08 Mar 2023 01:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678266151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TEBnaA7Pocw3dv+NsTA6Pe6Z7NrAaUzWWBCKZZ7bpik=; b=XUIxg1o+QTWEt4lY8LFNcNA6q9TOsxPd5LnR7Al1Ho74+ONybkBrE9xoh0LoUg3pue QZTkcVjfNlU+XvVeKKuEHo61q2rU1XAxZXUi24Bh56XarWx8SHuvMp0DTVrl0//u3WnY 0GbOqKZdiFEXG0KM2lBru/BD9MOW8abOT0PyEPP/am15BvinLSiVbGhElLK6x2sOsJvH Jqu0xsCKuy+J+HIcdmibFJjOpXM+uAPCGrcxY39B8DmagFo/NvB9UN3WKgWHLonF7o7f nbyhCEeoPKGCUbYTLAzoOtQAc04uE09bGcjkFT6XG4/a5WPJBVZQLqmLf6a9Gnk7vnhI a7zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TEBnaA7Pocw3dv+NsTA6Pe6Z7NrAaUzWWBCKZZ7bpik=; b=Ff0vfCpCm+hLFh+sUVom/HqGvqZUJW0rhoalIFq+ws9/FHVhV0DjqfPf7d6JkIlfEm P89J05lEWXg+uNObamn9TSTimHjM2jaJPBS/9QhINIRd7sn9ljUIirvZHU/74QZWE6rR 8JZOuHVh+HiPJSIp3pkxqpCoTREknoKAdZ3rO6h4k+9CZEbYAjzpBaTvAk+Of3nk4juq 1GwIFxHjz1aigozqNfob4N8KnX15VdV9J1vmk3UvDQv0XSmp9UyChooyG8XYxZOoDy7L OtulX7nTDet+rtmTit1aftCal594d2hFehjqaIqTSxAf2UW0ggYsLqm9V5F+zyisyRja j3tw== X-Gm-Message-State: AO0yUKV4S7kJWjigO7sBzjzgPPZOQQFv2V/aSfVNvMUxUyn0r5n13jWQ Ckujy6pTp7chz3mJZ6yxU/E= X-Received: by 2002:a17:906:718d:b0:8b1:81eb:158f with SMTP id h13-20020a170906718d00b008b181eb158fmr17410801ejk.62.1678266151580; Wed, 08 Mar 2023 01:02:31 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id j7-20020a17090643c700b008caaae1f1e1sm7153709ejn.110.2023.03.08.01.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 01:02:31 -0800 (PST) From: Svyatoslav Ryhel To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Dmitry Osipenko Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/4] iio: light: move apds990x into proper place Date: Wed, 8 Mar 2023 11:02:19 +0200 Message-Id: <20230308090219.12710-5-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230308090219.12710-1-clamor95@gmail.com> References: <20230308090219.12710-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759790755278145826?= X-GMAIL-MSGID: =?utf-8?q?1759790755278145826?= Since now apds990x supports IIO, it should be moved here from misc folder. Signed-off-by: Svyatoslav Ryhel --- drivers/iio/light/Kconfig | 10 ++++++++++ drivers/iio/light/Makefile | 1 + drivers/{misc => iio/light}/apds990x.c | 0 drivers/misc/Kconfig | 10 ---------- drivers/misc/Makefile | 1 - 5 files changed, 11 insertions(+), 11 deletions(-) rename drivers/{misc => iio/light}/apds990x.c (100%) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 0d4447df7200..49c17eb72c73 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -73,6 +73,16 @@ config APDS9300 To compile this driver as a module, choose M here: the module will be called apds9300. +config APDS990X + tristate "APDS990X combined als and proximity sensors" + depends on I2C + help + Say Y here if you want to build a driver for Avago APDS990x + combined ambient light and proximity sensor chip. + + To compile this driver as a module, choose M here: the + module will be called apds990x. If unsure, say N here. + config APDS9960 tristate "Avago APDS9960 gesture/RGB/ALS/proximity sensor" select REGMAP_I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 6f23817fae6f..f1ff7934318b 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_ADUX1020) += adux1020.o obj-$(CONFIG_AL3010) += al3010.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o +obj-$(CONFIG_APDS990X) += apds990x.o obj-$(CONFIG_APDS9960) += apds9960.o obj-$(CONFIG_AS73211) += as73211.o obj-$(CONFIG_BH1750) += bh1750.o diff --git a/drivers/misc/apds990x.c b/drivers/iio/light/apds990x.c similarity index 100% rename from drivers/misc/apds990x.c rename to drivers/iio/light/apds990x.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 9947b7892bd5..2856b6c57ca0 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -359,16 +359,6 @@ config SENSORS_BH1770 To compile this driver as a module, choose M here: the module will be called bh1770glc. If unsure, say N here. -config SENSORS_APDS990X - tristate "APDS990X combined als and proximity sensors" - depends on I2C - help - Say Y here if you want to build a driver for Avago APDS990x - combined ambient light and proximity sensor chip. - - To compile this driver as a module, choose M here: the - module will be called apds990x. If unsure, say N here. - config HMC6352 tristate "Honeywell HMC6352 compass" depends on I2C diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 87b54a4a4422..3e3e510cb315 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -18,7 +18,6 @@ obj-$(CONFIG_PHANTOM) += phantom.o obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o obj-$(CONFIG_QCOM_FASTRPC) += fastrpc.o obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o -obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/