From patchwork Fri Feb 16 18:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 202323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp716967dyb; Fri, 16 Feb 2024 10:51:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9E3Bv/pQVwhokgpZ5WfAIZ9W2s+zk+YpTdA0yahZsOGHGWfjZc8RRyQxUeNFJSS50XKASOTvpFJgDQ3J6EOOZ2sHUcw== X-Google-Smtp-Source: AGHT+IFjVgydva7MldjL2qC3pna5Cq946szGCI4BIK4wZ9ZZ2xH7JMaRbfCjJNfAIwM4M2RiMurE X-Received: by 2002:a17:906:3941:b0:a3d:2e36:192d with SMTP id g1-20020a170906394100b00a3d2e36192dmr4044048eje.75.1708109490062; Fri, 16 Feb 2024 10:51:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708109490; cv=pass; d=google.com; s=arc-20160816; b=FfuZLzy8MAeWqmLhWr+QfvbrR5EUYYMCKUQ756uQGWs4bbUOd4ZaYk/TXpf0Qw8Nf+ 3WOmAtXXuqhwCpPmz7lFJlSbX2/xDsOSCppfTFFA+Gp6FYkdo5bo0lEh0A7AHEq0zsD8 ivAzsFe+ZRLj7dA3G7M8Q1/fptV/WhO4tUAEIYYfjwYDlk8qpFpBGkr7MGPPSv1yfpwr XHqGNvmb5GoEbvc+EsNka4TGY+JDxH1Z4R123ih+hnpCrRHfRXcQo1AJSH9Qzdw95RiF zAs3xgTobW04exZ3dQyBbTB4gs/caSFTz+dIOPAPx0j4PbPAjMj7m0eAqPqdT8XUZ9hU h+Ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QTxYiJEOx1Qg0unA+hk2BUQm1rwAiOH4rQF+vaGPCR8=; fh=FlvTRwYX9WjBPcDCRuYT4qdJfYKKkOy7hQm7P2dqcic=; b=RmaXnI6Xlia+O4FC1moprqC1WQa41UTDujfGQz8RRkuqKgPVZWJsOka/AQmHa78Hmg V81XmPTzNyMEmLGC7nwnCSBsSqUeYb/UgWtbStI5aHO7M8LjDULiP2LUBwF5J5TWioL9 NwUST4VJSfenTSoNOEa71m/ASM6Ty2Ihvz7gxchyTN9M2oBZW6o9D0VJzFcs5tyj4iYh ujYOg9J9olVoqHdl76K6oXjGgPqkpH0Bj7l0HkAOu3vfVrYM3atJrh7W+9u3BwLaJHSi /ndc5IGbG7JXzliEeH5xuBNfCQ4U2jAT4ZlFZEFlQowu5sRA1kVgFRjTzFKKCrtoETxi 3m1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="vfW7/1tH"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69206-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69206-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t24-20020a1709064f1800b00a3d3c66dc40si173128eju.43.2024.02.16.10.51.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:51:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69206-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="vfW7/1tH"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69206-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69206-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A9A041F24621 for ; Fri, 16 Feb 2024 18:51:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32D8A13AA3E; Fri, 16 Feb 2024 18:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="vfW7/1tH" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EA531350E8; Fri, 16 Feb 2024 18:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109421; cv=none; b=PUjtRcgDtjnCTLOVRMtwx8aVbR7fAIFyxBIp40PSbSlYp3VPpaSKtUGLgRzSJ/c8cu60fE0U91p856oEriprk9Xb+JsjX+736Oj6s1MV2iXUMhDZl9NjX1VMn48XFVa7ZXQTRJ8HHp8TPA0VnpgRpx1jfVM8a2OXERKl5CW3bP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109421; c=relaxed/simple; bh=0doP8NnUjaTfFjdMWPvwgVTOH9eAL0HI3FuMS2w8NvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JP3b3caxayUOtJeIhbZR705n0smeL5JBe8gtUTPatPELv16s8QR4j4booWmRVFNuMgC9KOiSPTXOXcq4j2ub71U0QuWBm4rFqeG97QmiLM1fgs+CQxxv5u93eQZcrM+rVLv6YLlxnxy10HIpKOOsyDt3sM4119lWzyHOYeZYjA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=vfW7/1tH; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708109416; bh=0doP8NnUjaTfFjdMWPvwgVTOH9eAL0HI3FuMS2w8NvY=; h=From:To:Cc:Subject:Date:References:From; b=vfW7/1tHEvRH5pJC4NO7TkAiymKpscLom2BWRN4PH8aNGa37o2pejToqou6XGaopw /BH8hziympJPHgegWPyLKSt5udPV06rv92q5DMai5GOSwq5mdRcU1BLEq4/QptfLfB 8gxwp/lAzXex45m8smUWiqXDuoLUPU97O8yodP+Y= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrey Skvortsov Cc: Icenowy Zheng , Dalton Durst , Shoji Keita , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ond?= =?utf-8?q?=C5=99ej_Jirman?= , Krzysztof Kozlowski Subject: [PATCH v3 1/4] dt-bindings: vendor-prefix: Add prefix for Voltafield Date: Fri, 16 Feb 2024 19:49:59 +0100 Message-ID: <20240216185008.1370618-2-megi@xff.cz> In-Reply-To: <20240216185008.1370618-1-megi@xff.cz> References: <20240216185008.1370618-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791082616637743811 X-GMAIL-MSGID: 1791082616637743811 From: Icenowy Zheng Voltafile Technology Corp. is a company that produces MEMS sensors. Add a DT vendor prefix for it. Signed-off-by: Icenowy Zheng Signed-off-by: Ondřej Jirman Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 1a0dc04f1db4..82e9f64c90ff 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1534,6 +1534,8 @@ patternProperties: description: VoCore Studio "^voipac,.*": description: Voipac Technologies s.r.o. + "^voltafield,.*": + description: Voltafield Technology Corp. "^vot,.*": description: Vision Optical Technology Co., Ltd. "^vxt,.*": From patchwork Fri Feb 16 18:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 202324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp717041dyb; Fri, 16 Feb 2024 10:51:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOdqo4kEMqrSBmaqSzViE4W0LeAujfAZLkvSUjXZ4t5kLQfCBpisQd1caudG2BABlUIku+NOrRuvj+WErT9FZmAmeDvA== X-Google-Smtp-Source: AGHT+IHAYSFYqS5arGx6z2dm4SFkPmpZUINLHRYJHbITq2FFoG4gO0C+iXtCwThcY4iC/vElfaNf X-Received: by 2002:ac8:5994:0:b0:42d:c742:3652 with SMTP id e20-20020ac85994000000b0042dc7423652mr7822310qte.30.1708109497262; Fri, 16 Feb 2024 10:51:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708109497; cv=pass; d=google.com; s=arc-20160816; b=JSAKFFRScP7/bFrhZO7XHC3CDJ7xD0ElB/9XAmUPLU7S6bxe7qzQ+7xDFhyTXCo/oZ 5k6oUzji/4bfKnzQdRv6FLzXSBdObJvjmSPTL/4OCxF/TNiNeDVQB0ZFwlL7DE8fswuv A3IgehnK5pWjC/BskK1CV3iSHcHVq5/B+/lqP1HLhiM0jJ8Ze1F5Shra4Au8YagmNZxv FJ17+q4DTJWsMgP2/AL0ItCAGiBx8wOVUhbuXuQpPoCoPivMWBqamKWBz9qTnnT3FFKp AP56kpjrpm7ENr/AP4bTYUXme1yQUf5AFqMZoiG1Rh8AqcNsHZ36w/dfn8sRS2d3rk// 5NvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gZsthg0LUjyLfISZmU8raagqBQjcgBxhBYsrULLV5rE=; fh=zHwNYHO6VgPzYuzf1LgzanCXD3ZVvxcYnm0QJLg6r0E=; b=A4rBmoPTlTR9UujPmrIGZLE5vuIbq/myxEgwgeKM7ZzajUQwVBY6Ipg3qLfYcdulWt PxQH/8val1iPEXOolomHOw9+xla2BC75rrZyv0Et74I2l7FlwiPGH0k0hI29Czyzniw3 UWET++8/1UJ2f+maOvQvhez3z+PRo0wFdRTcDnNtuU4D/w5TSNm5bgo7fNXFYw8sbMaB y9YOJBqgcKZjCYRRa25lD+n0FKViBYDaJkh2w6/MoyzWuED0Y0y3bTNwxRb56x27QXwz 7y8TEbWGJha4XC2rW/6bUwHVGS8q+LXp8FGPwZyTD7c194W3+V1/83x3Ee9rRk/TyDIx 2WGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=QN4IOHq7; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i18-20020ac85e52000000b0042c7d02bf1esi495212qtx.161.2024.02.16.10.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:51:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=QN4IOHq7; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9BB991C236FF for ; Fri, 16 Feb 2024 18:51:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 507C11419A1; Fri, 16 Feb 2024 18:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="QN4IOHq7" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DF121339B1; Fri, 16 Feb 2024 18:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109422; cv=none; b=WXAoS4JymXo1vtbfchtUeRDpN1fpZ9Tbqi6uu6xCo4f6Mn6LELdY7Uy9uqzLDMewbpOll56+A/zEKYL9nKJH0DstAvat3q9rD44Ifz4VQhKyIU5k/gALfcMr6aBu7C2VzSjD+DpNK3JOFnnoLdcKKN+PHvUqcjrcPKIPJ0i2ep8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109422; c=relaxed/simple; bh=MzFWAiynKIMfBbcmFyJFSn3s5kPBd8miZrCSWWhxnWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O6DwL2KuEhgWfI9ZdfQCk40S1au0GhxjHJQPJvdAQtmEMXFTnZy+lBY6T5HfQiEUjaS/KHr4Av0UBQvMp2XIfojUOCVG5RlNsY+ca8w1hkB7+6U97UaGOUgmG/6pbhN9t7KDBGqQWJPkb882HoBe+VnbSb2Ajn7jWmUw6zDDdes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=QN4IOHq7; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708109416; bh=MzFWAiynKIMfBbcmFyJFSn3s5kPBd8miZrCSWWhxnWw=; h=From:To:Cc:Subject:Date:References:From; b=QN4IOHq7BlavFvAkl+8X+T0McgyiMLgH9xVxteDKFHXdf1rY9BA3lOF72pfWweGN2 oS3uNWJkohj802NTT10VZuaRT6SckI6gj+evmsE7TqL+wFtQT+yH/yIbyLzgabinOX b5a+zYKmQcch11L2NwB2q91OsOEtQZ8WsGLl2vdY= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrey Skvortsov Cc: Icenowy Zheng , Dalton Durst , Shoji Keita , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ond?= =?utf-8?q?=C5=99ej_Jirman?= , Conor Dooley Subject: [PATCH v3 2/4] dt-bindings: iio: magnetometer: Add Voltafield AF8133J Date: Fri, 16 Feb 2024 19:50:00 +0100 Message-ID: <20240216185008.1370618-3-megi@xff.cz> In-Reply-To: <20240216185008.1370618-1-megi@xff.cz> References: <20240216185008.1370618-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791082623884470606 X-GMAIL-MSGID: 1791082623884470606 From: Icenowy Zheng Voltafield AF8133J is a simple magnetometer sensor produced by Voltafield Technology Corp, with dual power supplies (one for core and one for I/O) and active-low reset pin. The sensor has configurable range 1.2 - 2.2 mT and a software controlled standby mode. Add a device tree binding for it. Signed-off-by: Icenowy Zheng Signed-off-by: Ondřej Jirman Reviewed-by: Conor Dooley --- .../iio/magnetometer/voltafield,af8133j.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml b/Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml new file mode 100644 index 000000000000..b6ab01a6914a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/voltafield,af8133j.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Voltafield AF8133J magnetometer sensor + +maintainers: + - Ondřej Jirman + +properties: + compatible: + const: voltafield,af8133j + + reg: + maxItems: 1 + + reset-gpios: + description: + A signal for active low reset input of the sensor. (optional; if not + used, software reset over I2C will be used instead) + + avdd-supply: + description: + A regulator that provides AVDD power (Working power, usually 3.3V) to + the sensor. + + dvdd-supply: + description: + A regulator that provides DVDD power (Digital IO power, 1.8V - AVDD) + to the sensor. + + mount-matrix: + description: An optional 3x3 mounting rotation matrix. + +required: + - compatible + - reg + - avdd-supply + - dvdd-supply + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@1c { + compatible = "voltafield,af8133j"; + reg = <0x1c>; + avdd-supply = <®_dldo1>; + dvdd-supply = <®_dldo1>; + reset-gpios = <&pio 1 1 GPIO_ACTIVE_LOW>; + }; + }; From patchwork Fri Feb 16 18:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 202325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp717068dyb; Fri, 16 Feb 2024 10:51:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMB/Zenbn7TbbWmNHPVx1CH9PHHcHUj2xhxFElTazXcguFnjUbL5kkncJHwDDQuQJGrM4QWLFl9dgh69x2V2WbuNhEMA== X-Google-Smtp-Source: AGHT+IGjK8moDXsUTUvIBhALvJEcxaDGmkaz0HUEMxuITGIF3+B9bBy6OsBIWG1ji/BH1T0IpkgI X-Received: by 2002:a2e:908c:0:b0:2d1:1e10:2983 with SMTP id l12-20020a2e908c000000b002d11e102983mr3735587ljg.31.1708109500975; Fri, 16 Feb 2024 10:51:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708109500; cv=pass; d=google.com; s=arc-20160816; b=QGBBdXWAFQ/+qrNWC3jLBf82Niq4lvmq6wfa9Q6UAAuMeQgRVc6u4uRWoeQjU+2w9u +iasDitk+lbQwoqZsJRVjo4jLdhywM3fhCH7Kvnr/d6HaUb8G8JehwivAklytefitEgR FZnfjlhwXQu7ZlGFsgQ+stuc52YpzLMU0J6UcUh0HFn3zhKa+iQnOzSXK4UoNz4h5t9W jt3WDT9sf3CL3A8S0n84xI+zAbHojByFaNNHFkmLAkewTxjegS7XOBvyXisrj/rNDjow KAEt9HnTzlxgyYEr9QhCJTxeBq5EMNi02/hkKhbJx5AGI6ivApCWGvpg13Fd1juok9s6 0MMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o69IG82zrGzoX4Qd3+wDq+dZgJJkYl6B4QORAuG9hOs=; fh=I1ONzpNysVdaJuH+G7zRdkgwwVw2zNKVo3nB+KlK6QQ=; b=zAwGAH04gaximutxmC5rHg4ethfBM8ynN/WSZ6M7rMawr/WV9c92MsV0WdLrLThKJy owJlOSP6ldT7d3WK2NOVqzSfvyVaBEVor5MSjLwC2itc47wGsoCuf6wk11Zf55ywdscu 6563o8iPmUx6FZcoZaqrDUg4h2gUCZ45YoVrtO9ETSpChL7cbfJjxICCYDnSOFg15qsV vlS3OGcIl7A2qxPjMAWpG+A62l2xmSpLyEBmD4GYDajgSUraJLcbJHHQVf2X3gkUPoaB gPrQzby9gM8nkdW54LzdPqk84G+S/xO2zh2917H8iOqnW//MT2uof4UPP071Pca7yJNu 5Epg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=Hjgy1aB1; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69204-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69204-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cq12-20020a056402220c00b005640c1ce464si191135edb.626.2024.02.16.10.51.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:51:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69204-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=Hjgy1aB1; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69204-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69204-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 15BC81F2178B for ; Fri, 16 Feb 2024 18:51:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90CF31419BF; Fri, 16 Feb 2024 18:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="Hjgy1aB1" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8927F1353E4; Fri, 16 Feb 2024 18:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109420; cv=none; b=I8fQ65Mpp+cEdU7O9WXIjGgxEaQQuFllmISSKpcrezaRHT63ArOAgrUnZzU7peTx+K8TkuQQwG9zbj2xj4/bT0up0egeieltnMdGy1bQMAVhf0qdvcTPTshJja6WZU5Hf2qaxE+TMhU3q/j7kxjN6xNSwZ2n87lzmvver8LZ+xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109420; c=relaxed/simple; bh=tbJz+VoRPmCXahHuYcaY5Ch3kNggxKmAUarvUk99t+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=niVFqpz1jF3nbBJIQum1fo51QcMMxUjcq7oLbmVhMqNZOjvhX0sepP8T4RmyLzQxtZ5rOqR4Lwsum+sdAbOaBKNVGXVCKRxWQbt53FJSFOP6/W553d8FANLLpD2U3S/ZFdKlLlWbxmqQTNSnPesZooDBVF8c22yXAJnz1n5SjkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=Hjgy1aB1; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708109416; bh=tbJz+VoRPmCXahHuYcaY5Ch3kNggxKmAUarvUk99t+A=; h=From:To:Cc:Subject:Date:References:From; b=Hjgy1aB1M5GIBNIOcz3ZuTGOoMH4QQ219YExRy4yC7eKHWjs7kBwGh/lj2M8f1TqA /eCAyPVooRpd0dIYDyW/tw+r0pkRy/amX4QW4tGbf5pI78O4mJnzf5PjzNBfYmQ8gH PMVTDypcHtngzKrulPTRfFEUsXzXcrqtU1X8nrkQ= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrey Skvortsov Cc: Icenowy Zheng , Dalton Durst , Shoji Keita , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ondrej Jirman Subject: [PATCH v3 3/4] iio: magnetometer: add a driver for Voltafield AF8133J magnetometer Date: Fri, 16 Feb 2024 19:50:01 +0100 Message-ID: <20240216185008.1370618-4-megi@xff.cz> In-Reply-To: <20240216185008.1370618-1-megi@xff.cz> References: <20240216185008.1370618-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791082628547854824 X-GMAIL-MSGID: 1791082628547854824 From: Icenowy Zheng AF8133J is a simple I2C-connected magnetometer, without interrupts. Add a simple IIO driver for it. Co-developed-by: Icenowy Zheng Signed-off-by: Icenowy Zheng Signed-off-by: Dalton Durst Signed-off-by: Shoji Keita Co-developed-by: Ondrej Jirman Signed-off-by: Ondrej Jirman Reviewed-by: Andrey Skvortsov Tested-by: Andrey Skvortsov --- drivers/iio/magnetometer/Kconfig | 12 + drivers/iio/magnetometer/Makefile | 1 + drivers/iio/magnetometer/af8133j.c | 524 +++++++++++++++++++++++++++++ 3 files changed, 537 insertions(+) create mode 100644 drivers/iio/magnetometer/af8133j.c diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 38532d840f2a..cd2917d71904 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -6,6 +6,18 @@ menu "Magnetometer sensors" +config AF8133J + tristate "Voltafield AF8133J 3-Axis Magnetometer" + depends on I2C + depends on OF + select REGMAP_I2C + help + Say yes here to build support for Voltafield AF8133J I2C-based + 3-axis magnetometer chip. + + To compile this driver as a module, choose M here: the module + will be called af8133j. + config AK8974 tristate "Asahi Kasei AK8974 3-Axis Magnetometer" depends on I2C diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index b1c784ea71c8..ec5c46fbf999 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -4,6 +4,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_AF8133J) += af8133j.o obj-$(CONFIG_AK8974) += ak8974.o obj-$(CONFIG_AK8975) += ak8975.o obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o diff --git a/drivers/iio/magnetometer/af8133j.c b/drivers/iio/magnetometer/af8133j.c new file mode 100644 index 000000000000..fcb4f0a8e633 --- /dev/null +++ b/drivers/iio/magnetometer/af8133j.c @@ -0,0 +1,524 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * af8133j.c - Voltafield AF8133J magnetometer driver + * + * Copyright 2021 Icenowy Zheng + * Copyright 2024 Ondřej Jirman + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define AF8133J_REG_OUT 0x03 +#define AF8133J_REG_PCODE 0x00 +#define AF8133J_REG_PCODE_VAL 0x5e +#define AF8133J_REG_STATUS 0x02 +#define AF8133J_REG_STATUS_ACQ BIT(0) +#define AF8133J_REG_STATE 0x0a +#define AF8133J_REG_STATE_STBY 0x00 +#define AF8133J_REG_STATE_WORK 0x01 +#define AF8133J_REG_RANGE 0x0b +#define AF8133J_REG_RANGE_22G 0x12 +#define AF8133J_REG_RANGE_12G 0x34 +#define AF8133J_REG_SWR 0x11 +#define AF8133J_REG_SWR_PERFORM 0x81 + +static const char * const af8133j_supply_names[] = { + "avdd", + "dvdd", +}; + +struct af8133j_data { + struct i2c_client *client; + struct regmap *regmap; + struct mutex mutex; + struct iio_mount_matrix orientation; + + struct gpio_desc *reset_gpiod; + struct regulator_bulk_data supplies[ARRAY_SIZE(af8133j_supply_names)]; + + u8 range; +}; + +enum af8133j_axis { + AXIS_X = 0, + AXIS_Y, + AXIS_Z, +}; + +static struct iio_mount_matrix * +af8133j_get_mount_matrix(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct af8133j_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info af8133j_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, af8133j_get_mount_matrix), + { } +}; + +#define AF8133J_CHANNEL(_si, _axis) { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_ ## _axis, \ + .address = AXIS_ ## _axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE), \ + .ext_info = af8133j_ext_info, \ + .scan_index = _si, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_LE, \ + }, \ +} + +static const struct iio_chan_spec af8133j_channels[] = { + AF8133J_CHANNEL(0, X), + AF8133J_CHANNEL(1, Y), + AF8133J_CHANNEL(2, Z), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + +static int af8133j_product_check(struct af8133j_data *data) +{ + struct device *dev = &data->client->dev; + unsigned int val; + int ret; + + ret = regmap_read(data->regmap, AF8133J_REG_PCODE, &val); + if (ret) { + dev_err(dev, "Error reading product code (%d)\n", ret); + return ret; + } + + if (val != AF8133J_REG_PCODE_VAL) { + dev_err(dev, "Invalid product code (0x%02x)\n", val); + return -EINVAL; + } + + return 0; +} + +static int af8133j_reset(struct af8133j_data *data) +{ + struct device *dev = &data->client->dev; + int ret; + + if (data->reset_gpiod) { + /* If we have GPIO reset line, use it */ + gpiod_set_value_cansleep(data->reset_gpiod, 1); + udelay(10); + gpiod_set_value_cansleep(data->reset_gpiod, 0); + } else { + /* Otherwise use software reset */ + ret = regmap_write(data->regmap, AF8133J_REG_SWR, + AF8133J_REG_SWR_PERFORM); + if (ret) { + dev_err(dev, "Failed to reset the chip\n"); + return ret; + } + } + + /* Wait for reset to finish */ + usleep_range(1000, 1100); + + /* Restore range setting */ + if (data->range == AF8133J_REG_RANGE_22G) { + ret = regmap_write(data->regmap, AF8133J_REG_RANGE, data->range); + if (ret) + return ret; + } + + return 0; +} + +static void af8133j_power_down(struct af8133j_data *data) +{ + gpiod_set_value_cansleep(data->reset_gpiod, 1); + regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies); +} + +static int af8133j_power_up(struct af8133j_data *data) +{ + struct device *dev = &data->client->dev; + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies); + if (ret) { + dev_err(dev, "Could not enable regulators\n"); + return ret; + } + + gpiod_set_value_cansleep(data->reset_gpiod, 0); + + /* Wait for power on reset */ + usleep_range(15000, 16000); + + ret = af8133j_reset(data); + if (ret) { + af8133j_power_down(data); + return ret; + } + + return 0; +} + +static int af8133j_take_measurement(struct af8133j_data *data) +{ + unsigned int val; + int ret; + + ret = regmap_write(data->regmap, + AF8133J_REG_STATE, AF8133J_REG_STATE_WORK); + if (ret) + return ret; + + /* The datasheet says "Mesaure Time <1.5ms" */ + ret = regmap_read_poll_timeout(data->regmap, AF8133J_REG_STATUS, val, + val & AF8133J_REG_STATUS_ACQ, + 500, 1500); + if (ret) + return ret; + + ret = regmap_write(data->regmap, + AF8133J_REG_STATE, AF8133J_REG_STATE_STBY); + if (ret) + return ret; + + return 0; +} + +static int af8133j_read_measurement(struct af8133j_data *data, __le16 buf[3]) +{ + struct device *dev = &data->client->dev; + int ret; + + ret = pm_runtime_resume_and_get(dev); + if (ret) { + /* + * Ignore EACCES because that happens when RPM is disabled + * during system sleep, while userspace leave eg. hrtimer + * trigger attached and IIO core keeps trying to do measurements. + */ + if (ret != -EACCES) + dev_err(dev, "Failed to power on (%d)\n", ret); + return ret; + } + + scoped_guard(mutex, &data->mutex) { + ret = af8133j_take_measurement(data); + if (ret) + goto out_rpm_put; + + ret = regmap_bulk_read(data->regmap, AF8133J_REG_OUT, + buf, sizeof(__le16) * 3); + } + +out_rpm_put: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return ret; +} + +static const int af8133j_scales[][2] = { + [0] = { 0, 366210 }, // 12 gauss + [1] = { 0, 671386 }, // 22 gauss +}; + +static int af8133j_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct af8133j_data *data = iio_priv(indio_dev); + __le16 buf[3]; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = af8133j_read_measurement(data, buf); + if (ret) + return ret; + + *val = sign_extend32(le16_to_cpu(buf[chan->address]), + chan->scan_type.realbits - 1); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + + if (data->range == AF8133J_REG_RANGE_12G) + *val2 = af8133j_scales[0][1]; + else + *val2 = af8133j_scales[1][1]; + + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } +} + +static int af8133j_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SCALE: + *vals = (const int *)af8133j_scales; + *length = ARRAY_SIZE(af8133j_scales) * 2; + *type = IIO_VAL_INT_PLUS_NANO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static int af8133j_set_scale(struct af8133j_data *data, + unsigned int val, unsigned int val2) +{ + struct device *dev = &data->client->dev; + u8 range; + int ret = 0; + + if (af8133j_scales[0][0] == val && af8133j_scales[0][1] == val2) + range = AF8133J_REG_RANGE_12G; + else if (af8133j_scales[1][0] == val && af8133j_scales[1][1] == val2) + range = AF8133J_REG_RANGE_22G; + else + return -EINVAL; + + pm_runtime_disable(dev); + + /* + * When suspended, just store the new range to data->range to be + * applied later during power up. + */ + if (!pm_runtime_status_suspended(dev)) + scoped_guard(mutex, &data->mutex) + ret = regmap_write(data->regmap, + AF8133J_REG_RANGE, range); + + pm_runtime_enable(dev); + + data->range = range; + return ret; +} + +static int af8133j_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct af8133j_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + return af8133j_set_scale(data, val, val2); + default: + return -EINVAL; + } +} + +static int af8133j_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + return IIO_VAL_INT_PLUS_NANO; +} + +static const struct iio_info af8133j_info = { + .read_raw = af8133j_read_raw, + .read_avail = af8133j_read_avail, + .write_raw = af8133j_write_raw, + .write_raw_get_fmt = af8133j_write_raw_get_fmt, +}; + +static irqreturn_t af8133j_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct af8133j_data *data = iio_priv(indio_dev); + s64 timestamp = iio_get_time_ns(indio_dev); + struct { + __le16 values[3]; + s64 timestamp __aligned(8); + } sample; + int ret; + + memset(&sample, 0, sizeof(sample)); + + ret = af8133j_read_measurement(data, sample.values); + if (ret) + goto out_done; + + iio_push_to_buffers_with_timestamp(indio_dev, &sample, timestamp); + +out_done: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static const struct regmap_config af8133j_regmap_config = { + .name = "af8133j_regmap", + .reg_bits = 8, + .val_bits = 8, + .max_register = AF8133J_REG_SWR, + .cache_type = REGCACHE_NONE, +}; + +static void af8133j_power_down_action(void *ptr) +{ + struct af8133j_data *data = ptr; + + if (!pm_runtime_status_suspended(&data->client->dev)) + af8133j_power_down(data); +} + +static int af8133j_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct af8133j_data *data; + struct iio_dev *indio_dev; + struct regmap *regmap; + int ret, i; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + regmap = devm_regmap_init_i2c(client, &af8133j_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "regmap initialization failed\n"); + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + data->regmap = regmap; + data->range = AF8133J_REG_RANGE_12G; + mutex_init(&data->mutex); + + data->reset_gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(data->reset_gpiod)) + return dev_err_probe(dev, PTR_ERR(data->reset_gpiod), + "Failed to get reset gpio\n"); + + for (i = 0; i < ARRAY_SIZE(af8133j_supply_names); i++) + data->supplies[i].supply = af8133j_supply_names[i]; + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), + data->supplies); + if (ret) + return ret; + + ret = iio_read_mount_matrix(dev, &data->orientation); + if (ret) + return dev_err_probe(dev, ret, "Failed to read mount matrix\n"); + + ret = af8133j_power_up(data); + if (ret) + return ret; + + pm_runtime_set_active(dev); + + ret = devm_add_action_or_reset(dev, af8133j_power_down_action, data); + if (ret) + return ret; + + ret = af8133j_product_check(data); + if (ret) + return ret; + + indio_dev->info = &af8133j_info; + indio_dev->name = "af8133j"; + indio_dev->channels = af8133j_channels; + indio_dev->num_channels = ARRAY_SIZE(af8133j_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + &af8133j_trigger_handler, NULL); + if (ret) + return dev_err_probe(&client->dev, ret, + "Failed to setup iio triggered buffer\n"); + + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to register iio device"); + + pm_runtime_get_noresume(dev); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_autosuspend_delay(dev, 500); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; + + pm_runtime_put_autosuspend(dev); + + return 0; +} + +static int af8133j_runtime_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct af8133j_data *data = iio_priv(indio_dev); + + af8133j_power_down(data); + + return 0; +} + +static int af8133j_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct af8133j_data *data = iio_priv(indio_dev); + + return af8133j_power_up(data); +} + +const struct dev_pm_ops af8133j_pm_ops = { + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + RUNTIME_PM_OPS(af8133j_runtime_suspend, af8133j_runtime_resume, NULL) +}; + +static const struct of_device_id af8133j_of_match[] = { + { .compatible = "voltafield,af8133j", }, + { } +}; +MODULE_DEVICE_TABLE(of, af8133j_of_match); + +static const struct i2c_device_id af8133j_id[] = { + { "af8133j", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, af8133j_id); + +static struct i2c_driver af8133j_driver = { + .driver = { + .name = "af8133j", + .of_match_table = af8133j_of_match, + .pm = pm_ptr(&af8133j_pm_ops), + }, + .probe = af8133j_probe, + .id_table = af8133j_id, +}; + +module_i2c_driver(af8133j_driver); + +MODULE_AUTHOR("Icenowy Zheng "); +MODULE_AUTHOR("Ondřej Jirman "); +MODULE_DESCRIPTION("Voltafield AF8133J magnetic sensor driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Feb 16 18:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 202322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp716805dyb; Fri, 16 Feb 2024 10:51:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2UpUlxgLYg4Ysnot0gJGDapeiM7z997s49dNHiDvkaHgy30cYjfDLbmvMLo5YWg1hST1w+1Gyu4a3RIDmA9SKpUIU9w== X-Google-Smtp-Source: AGHT+IEUYBpch97rqvLxFUIT0bHTEOHdDUdVv1joqith+XjVk5hciN0HefomLC8RxcFecVF1rExg X-Received: by 2002:aa7:d30d:0:b0:563:d26a:6566 with SMTP id p13-20020aa7d30d000000b00563d26a6566mr2506244edq.18.1708109473481; Fri, 16 Feb 2024 10:51:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708109473; cv=pass; d=google.com; s=arc-20160816; b=XEa+lCfvBJvxZMSDrgG8jyicCc6itn3dSyQfNK66HOIpSAWAgWbv+BhM7bsbZttm0i O6DTRY9ORMuV1Mz//3B3cMXeMxHnx6PMUgozGcTUBwtyk+LG+iik/q/DjPGnPq92ucxT S33FPYIrUvOxpI2XX6x9kdzgrWvneR8AC3OYEbD3qtOeeWzm+6rvS4aWcjc58EtbnJBe JDvA2YOX+8wEsf7+dCnpdi2FKz+xVzUZHoFmjhRqEaDURrbbWuuWD8hHqfA4GbvtGj4Q 01JB0K7CIRMz4cvT+Gssc7rAOQol05psXYqMx5TH9+D/qFHiRx6f/m1gu8N+F8DsVFxB ButA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=e+CJnsXI4iDD/2ERSfMzFPc7gl6W42Fi6Dc53GGlHjY=; fh=d9zgdqCmRx36+BVYAt1Fzz77IeXQIiiUNWHDpCCL3Ro=; b=eo9/F0CBjIYHJ1RdGidf6fr1OAHJVhK2hfZGemxhNo40QFyw62GTI6UbMQ32iRTeB3 H8rQc4h04hJtnXZJDxQ3KygM6zOtugo9g5XnMZVnV+mFRghlkixTbOd+1xzZbnXynRWu TBJvSmUITzpHpSn23iTzpQr7QPge5Ei92TigzIFcCgkkW3nnumY37jiaqE23AJ8tp7mK nxqpvEFwnO2aZ6qOM78W9sOkTh6cV8GAOeS2R7hY2cpySp8UEywyaZssUWbTqEcyTI5Z mjDkVbG0IZd0XluYxpwiGh2vSEJ5Tz2aHHEyVScI4OZ03ZWJEE3wwYbT/UUqlXhxuU18 TfNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=vAWv73XJ; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69205-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69205-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a3-20020a05640233c300b00561e7d87078si203736edc.559.2024.02.16.10.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:51:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69205-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=vAWv73XJ; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-69205-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69205-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1B4811F24705 for ; Fri, 16 Feb 2024 18:51:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7B501386B3; Fri, 16 Feb 2024 18:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="vAWv73XJ" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91501353F0; Fri, 16 Feb 2024 18:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109421; cv=none; b=G1aJVX7wMLnX+b1CtfI/NYMMm9wPHjUmB6aRcxr8ORDMoSc1wFU8AuIuAal04BYH/bckNKp1yR+/GZWIR+t7PELRz42/kVBPC5tdUqhnX0O8O2e2Y43FQz5D09yhMuEkJuNqEieEmnK58bjoneOcMjn7ZbsvGYHg6clu69beY3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708109421; c=relaxed/simple; bh=ggOOHXc5HreBSJwVQw7MwB2dcdf4Tv7xliEtFE73NVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YvQGi+7jwXMWPZP1lxRiCi2fJcvmowtWOHkD34GSb41SZ33dshpCdgIgp/ZKwIZX0+A4SyA6/QFK+FAgecjg2JiJ8meuFpgnU1DyTEFQ3k3YIW3VU+I05OJ0Q3fByuo3A3cnhq03vQu7NC0x/v4g1PLHSi8D+wtJKUeTE2BouP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=vAWv73XJ; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708109416; bh=ggOOHXc5HreBSJwVQw7MwB2dcdf4Tv7xliEtFE73NVk=; h=From:To:Cc:Subject:Date:References:From; b=vAWv73XJ3heeLQdQH8c+ATkeeCIBM1v4II1JHlPiquE3eJtbpVdSD6YUunhoxubXu WjJNSc2aUu0IL2TajFNut6wWCRP20Dqm89Xio5rC5dVxgkliYtytNX+0Rx3hsc7XOu Ua7g8gDdWM6xo07h9ONowM9ixxxCjixRTNadlmc8= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrey Skvortsov Cc: Ondrej Jirman , Icenowy Zheng , Dalton Durst , Shoji Keita , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] MAINTAINERS: Add an entry for AF8133J driver Date: Fri, 16 Feb 2024 19:50:02 +0100 Message-ID: <20240216185008.1370618-5-megi@xff.cz> In-Reply-To: <20240216185008.1370618-1-megi@xff.cz> References: <20240216185008.1370618-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791082599119782408 X-GMAIL-MSGID: 1791082599119782408 From: Ondrej Jirman As I am submitting the driver and have the device to test. I'll maintain the driver. Signed-off-by: Ondrej Jirman --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 73d898383e51..67f4974ac803 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -579,6 +579,12 @@ F: drivers/iio/accel/adxl372.c F: drivers/iio/accel/adxl372_i2c.c F: drivers/iio/accel/adxl372_spi.c +AF8133J THREE-AXIS MAGNETOMETER DRIVER +M: Ondřej Jirman +S: Maintained +F: Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml +F: drivers/iio/magnetometer/af8133j.c + AF9013 MEDIA DRIVER L: linux-media@vger.kernel.org S: Orphan