From patchwork Sun Feb 11 20:51:57 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: 199515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2100450dyd; Sun, 11 Feb 2024 12:54:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4LH44Dy3zatPEkVeob6T71ig25vIowaO/boEyvGYITopgk72kMlzr+nngYao6vIwhwsspD3zuvbWuu/qMqtMBZPpliQ== X-Google-Smtp-Source: AGHT+IF7f0dwPKbg9a3KVDeUPXoDn6KykMewjd27r0+uajRIC7nHfQeww/+GtVi9FbPjTdCS4yG1 X-Received: by 2002:a62:c702:0:b0:6e0:3bf5:4052 with SMTP id w2-20020a62c702000000b006e03bf54052mr3840297pfg.25.1707684848207; Sun, 11 Feb 2024 12:54:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707684848; cv=pass; d=google.com; s=arc-20160816; b=rhrRwrPwyrDNK1nUKNzFs/M4WRARYf/uDiY3jd7nMa0E5UYxCjeeMZN2CEOetjkqcx hwtE1fr1JuWnoJT1jxkLt55a3rL4bm86A098Sk8JII9KCaNtEZPyaOI1wcpXktnHhW2+ Fvrn7NCzeqt/Mj0+rIEBT834VoQsSUD2ArJea3XwKt1zuVbi+SUMkRtMzO/FKv1GB6GU qWQuCeyCUCoXuujFRivJCdqlIiIiNowgikXUNLhtDnnPmJuZlJUFnKKTwPJHQFEkIRSv c2YaY0aC79nRp91th3mKEZvAURut3ceTlTKOOPhwKsx1UXvs7esm1YzWUhqXVZIAfvnR 7nhQ== 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=4mpHyaWv6skW4Tl/DLmIWJHKfAI8yk1fK0g3EuGGOoU=; fh=GOO0wD3fY1MaeSR77LDbPFWFmitnx4oRLsqqB9wlbuI=; b=A6h3a//e/sgF7ttzl/7GSi4JXm8o+5Hz0d0NsFq8fqAqbWXd9SJ1pB+bVjfbXnGPRI 7FZQ0G7iflzWsjwfRGI4wo/zaJ2zfbBcrrY1MjXs+DW7GB19+TlFkXgxyREj6/v19phB 7SX5HhVV4sQSVmJpuTyeLLapmwn00yuG4GWbq8qLVGwvwUHtkS7eMkmv4Lvp5rnAp5Q6 EVquWcs/BzsZ8eCLJ/C7ZyIdEdVAxYqnPKi63hyBdA+Hs1qVTtEtAMZVrC3c5c839wlh 3KNK4ZZF5Nnac0S7OE998U0jfuV/4EttZWqaXUEZ3+PR4dFd4wZbWiz+M6fAOLE7RmDF z6+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=RHpm9zAZ; 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-60956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60956-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCXTwpX2G8rzaAQR9qfjmbcArXBgc9ddorMgGUkkkHEqwImI5rvbEsB169Zs6eaaSihQXwIz28SErf2aKdciwPiVvPJIsA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e14-20020aa78c4e000000b006d9a6f39e36si3870408pfd.252.2024.02.11.12.54.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 12:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=RHpm9zAZ; 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-60956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60956-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 67942B22746 for ; Sun, 11 Feb 2024 20:53:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 432565FF06; Sun, 11 Feb 2024 20:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="RHpm9zAZ" 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 5A1C05381E; Sun, 11 Feb 2024 20:52:21 +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=1707684744; cv=none; b=KKGHsp/5/0AnvEjlLETncWza3+T1v9JfaTSmlzXmTAcPITu8pupAiozVtmPV6kJIUCgqtcFLwJ7un0i2OgZ4efmwOebeJYuI8Y0xvPqOby6xFVKii63bPYIuS5YWN7yVqyl19aHdy0wngL9vUWsRk2x4LQAT8srXRRKFcGTIdGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707684744; c=relaxed/simple; bh=uqEZgYBsSQiZQx5PZMW8uvMomw0NsNNRKqLIfbms9vQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TjZqt/eaCRtLDmVmaHEuKZERQUZ3nSJuJO4Gw7Ps8yFeqhLD38zSvYWxEfCumJzJny3WI2pMiVUwSPSWmqMv9uX2kT6KFEmHS5sFzKplZ5IAvbpWTbDVz/rCEoRVPP7DMmqvhp/eFx0hNKFiJKKgPGdg8wN4RqlGa2DJ61TojJs= 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=RHpm9zAZ; 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=1707684739; bh=uqEZgYBsSQiZQx5PZMW8uvMomw0NsNNRKqLIfbms9vQ=; h=From:To:Cc:Subject:Date:References:From; b=RHpm9zAZ/zyVkl1fbT8+59goSiqB5NXzv0QZmi+ubstofQhpUUlHG7yC6t9mr/Frh XDicwu0+GPS34pRpYs7a3QGfJn5gqxRS0usFHkr5f2fCZrFKtQaD+xIwH82FhHprJi p421qfYa5NYTxlAJE/z/wsyX2EYFc0iBQEasLnZs= 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 , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ond?= =?utf-8?q?=C5=99ej_Jirman?= Subject: [PATCH 1/4] dt-bindings: vendor-prefix: Add prefix for Voltafield Date: Sun, 11 Feb 2024 21:51:57 +0100 Message-ID: <20240211205211.2890931-2-megi@xff.cz> In-Reply-To: <20240211205211.2890931-1-megi@xff.cz> References: <20240211205211.2890931-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: 1790637347406427808 X-GMAIL-MSGID: 1790637347406427808 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 Sun Feb 11 20:51:58 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: 199514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2100390dyd; Sun, 11 Feb 2024 12:53:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUSOSed/KjDYnFBR5QQontID/EJxwCj67VpXomAELKESke4NqGDgJj0EnJRSUS2F11gCM99+C6OyIDStYC7YXn75WZmpg== X-Google-Smtp-Source: AGHT+IGfi4i4T7b9qPcPkVWrxySnPXxrYivfzhwAhzsEu1ZaVVTTqSOKjwTU+hAh1xR+QU6XzFkw X-Received: by 2002:a05:6870:3911:b0:219:27ca:1cb0 with SMTP id b17-20020a056870391100b0021927ca1cb0mr5872326oap.15.1707684837208; Sun, 11 Feb 2024 12:53:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707684837; cv=pass; d=google.com; s=arc-20160816; b=o+FSwWKr4AJm2/+CFysv9LH2w4LsqI/e5RHpaqilkscmD45dj7oBNZOAXrpjp6cKD0 n7v2on1A8Kxj1+m+ZdKxIjzTHjAe+niZCftUm/CBGzIPeDViINFEIZWdBvJgymoefMjV asfiOiRPB1rB/BxWM1nqCaOfIk003KK7DoMTnhQ++JIdPHMmHKV64OUHCGEhr+BMRxPS zUtyaBSVUEidNY74dx3OTfH5+NnuTdOgTuNhE5KGbPaP4J8OedO4W9oD51oPgwJXEOTZ HGi+F/g8zKEmQpI1HtiKRyNhJ7kr3GwG1w+kL37SvjQeSxqF12rbwav6xOxA43CwJj7r KaqQ== 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=3pks1APbLQm9QAFocpxXcHLPhCUtc7b12LHhLIOmE7s=; fh=IVNiTwVuUWzcaBtjSiaYOUcPmdReWZEzL82V5f23OV0=; b=ybSkbzrjmcjCWRGTzoIO1yII7Gq1vptLOcXAHO1xAJS09mIVfnufLuAtuJUOYGBmaK ZWmL7Qu3bod8V6fVcA4jAf6CWVdfP0eaI9fzu6OzMjA8yuIsRAnHKqt+Xgt1UgzNCJF5 Mvs3P1IqTwd+FrLv4JJOX4f/qUwacimF0tj3UFRVuV8APE0AeiotobRKW2gq84Ge2cBy OVGAV9V3UCbdLAVcyNAlejaU+6heDbYBpT/UqQwTks2KjKzHcr+Sf5bm4UzoiSGiqyIp yRHkR4u88AxKr/5OtygJFwB0GzVGs+ynt0QD+nFpIya+XPImcH7TYBfVQE9XM0lh6NLe j1kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=b199vNbE; 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-60954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60954-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCVvmboG6O7/WCWVDUv5LMvCFH8tp5qlisBpaUagdPLLYIyB0hnlX1VUdaWIUAcNx0YJHkwD0TvJ19nQJL++56k68LwO8Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m65-20020a633f44000000b005dc4f58ab1dsi5316689pga.408.2024.02.11.12.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 12:53:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=b199vNbE; 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-60954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60954-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8D9B6B21C44 for ; Sun, 11 Feb 2024 20:53:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D03575FEF1; Sun, 11 Feb 2024 20:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="b199vNbE" 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 9BA8C5DF10; Sun, 11 Feb 2024 20:52:21 +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=1707684744; cv=none; b=EJQV9kjX1km0yQwRZUmfujIhJAU+s+KVcVOvc9KIFmav9n7PkjmAi4oXuUKWppHsWs29dOqfWLJ4NiLK7So488St0JzDXovuOQXV7NHSqNMoDwOWHtKtmqzkx7a8Lmpq0sCVe39Z4RgEp/p3L/fXR9m3thI9vCYXWMqUglTN78k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707684744; c=relaxed/simple; bh=RY4ulIBr47Q0nyCLXIK7t8729sReukS+pt9cj0YsfDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eVMR6SkoPK4x4Evch324+mcuj+aQFqVJuu9V1K6+N6xBznMjfsNEDnponlLi7gvLeK2x064EsNTLOonDHUxHTdS8mct4Jlydg5VXACeDlE61DjrrlrLncRyZW+ZJM3grb7R4Zt3XLIDcgGyRJft0rrcRTwCq7nLqX7JkkmEsaBs= 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=b199vNbE; 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=1707684739; bh=RY4ulIBr47Q0nyCLXIK7t8729sReukS+pt9cj0YsfDA=; h=From:To:Cc:Subject:Date:References:From; b=b199vNbE2m8c/4zJ/MMKmOL1ppqreK+7IhuqOTR0Vksbiyb+19t1OiJPkXbxPZuE7 Va+chEoMp/DkV5Sr/yGgIVYaVD9LShDAfuWhnoVmNj77mKPAefF0BKMCzbhfdl0Q6l CHva/mETNjdgcTkrfxNROhm01U1VITSFW7/zP5MY= 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 , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Ond?= =?utf-8?q?=C5=99ej_Jirman?= Subject: [PATCH 2/4] dt-bindings: iio: magnetometer: Add DT binding for Voltafield AF8133J Date: Sun, 11 Feb 2024 21:51:58 +0100 Message-ID: <20240211205211.2890931-3-megi@xff.cz> In-Reply-To: <20240211205211.2890931-1-megi@xff.cz> References: <20240211205211.2890931-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: 1790637335885191218 X-GMAIL-MSGID: 1790637335885191218 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 --- .../iio/magnetometer/voltafield,af8133j.yaml | 58 +++++++++++++++++++ 1 file changed, 58 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..ab56c0f798ad --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/voltafield,af8133j.yaml @@ -0,0 +1,58 @@ +# 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: + - voltafield,af8133j + + reg: + maxItems: 1 + + reset-gpios: + description: | + an pin needed for AF8133J to set the reset state. This should be usually + active low. + + avdd-supply: + description: | + an optional regulator that needs to be on to provide AVDD power (Working + power, usually 3.3V) to the sensor. + + dvdd-supply: + description: | + an optional regulator that needs to be on to provide DVDD power (Digital + IO power, 1.8V~AVDD) to the sensor. + + mount-matrix: + description: an optional 3x3 mounting rotation matrix. + +required: + - compatible + - reg + +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 Sun Feb 11 20:51: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: 199516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2100475dyd; Sun, 11 Feb 2024 12:54:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXihKru6N71jgMUHhcEJCgsqJfHi8ObBwk+pWvUFZlPGd0dhQWoyUCm8CpYWrOzZPPjgk37md0KFxqGbpsffIXdze82oQ== X-Google-Smtp-Source: AGHT+IHB3q07sBjwG12Nn5dSiTXJMAWAncx1kOzlQAI0s/xx5gGi50BZpK4svXIg11ERSvZsemlF X-Received: by 2002:a05:6a21:1585:b0:19e:a9e6:baf with SMTP id nr5-20020a056a21158500b0019ea9e60bafmr4276456pzb.0.1707684853774; Sun, 11 Feb 2024 12:54:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707684853; cv=pass; d=google.com; s=arc-20160816; b=DmwIdQKno1fp5rvkMP20a5XnUBO98lzYF03Y86tAVzO7IqnACLMkOrjafXH8R+S24R h/8IsGG9oIgQdxZ6FjyjexS6ToWGYCoN4gS4PzPpwxhkXQLbpWnff9r9klcKu7GXq+in IueJdbk15P0QKCaTOlzrwLowye9Eymg+xfqN2m/BrwiQoTGFjIX1PnrwV7bGUk07iHye XUBAym4mqhU/ndQlz3r6N2bIIZLyy/IAliJbEQ2EgWaIqcavHcQ4cjbW5XJKnY8+4BvI s8y6Ey7WrRm3M1EdUjYnhdcwoxK5ajiuhtyvPQUSd1u2xGVQTuHMna3hozWIQZp9s/2X YOHQ== 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=ARttq2lWnuRS4mhPFvY/AlqBwVDB9UW9KMb3LJGzkUw=; fh=GPDrlHkj1ho3zFUjSWsansZomYYlJHmRg0k4t2x5tVU=; b=B/D0FYMwcZUAVmhrOBf6gWwUSnyZgzCUD8JD9XXIhUHtmhe7D8QlsFGHon2iInar9f VWWTi9VAlgJLZrgwy8MTl/ma5FGBcVrfhBVOG/DoTQa6Ldn48XieBECovr0DypZmcENI PMP5smmnBCfbVfwFDfrgk31q7AjUahBTHn1kqEBYv8iE+vj+MpA1cw7ECfhf+UjDn1S3 Z9u0xxOndoKevRlw6+g7jhdM0zA8jnNLElkt8zDILmiDmBnwnCaU377ezNprOfpveBdc 08/1E+tO4oljDWxX3Ru+u2NO0Bjcjm5+8ZridH++NL2QyNgLoRiX5hDYfb5d0ZpqsFVn qcow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=dmzPbnUS; 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-60957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCUrOL+Od0uRM1/x7bTyK83QhzYV0nyu6j3pou3KH7D8ijQWQJv3LP8kzMDYOEJ94DYegavvMMHSyK0y/w6prnS663FYSA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l4-20020a170902f68400b001d91e7378b2si5452647plg.373.2024.02.11.12.54.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 12:54:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=dmzPbnUS; 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-60957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60957-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DAD14B21BA2 for ; Sun, 11 Feb 2024 20:53:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DB0A5FF10; Sun, 11 Feb 2024 20:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="dmzPbnUS" 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 8A1595DF09; Sun, 11 Feb 2024 20:52:21 +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=1707684744; cv=none; b=OTuOJy04TFg3bxQKufFUUbgINPYaOBjv4Uwg9kvplyqyxUsxCndHn14UE1aJhKr0hFHS6/JTUY7nEZIbsn696mgWkCPU2LE8Ke/PzLgU1z5KZxxZA0oU/ZnbMo5+cLGnWrSX40O60AN8Flreth9l+HOC+OFEpwZTmRzYqaE5C4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707684744; c=relaxed/simple; bh=w4dFeJN6ekT4fZLMgY0MSjyE6BSqXIkBWnDC/steBeE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=igJjiftaCU3tywFDJpzV99C1OXbVupXm/A2NrvomezLINg0Ok71yBpKA9K/sA7j0HX+9aVxp0wbBZDu1CsXE+wu9OKLXRTQD+LJkvp8lm/ExSopw/26U3oDr922TRl1aIS+ePkwUQilRF12pVqdOI+EHuI7TfZy3ApHb12kjHj4= 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=dmzPbnUS; 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=1707684739; bh=w4dFeJN6ekT4fZLMgY0MSjyE6BSqXIkBWnDC/steBeE=; h=From:To:Cc:Subject:Date:References:From; b=dmzPbnUSBN3rAZwsOXvc/kuP3DbzWzuU8f2O5UamPg5Fc1RazlMXoyFd7M1trUqUi 75UG+FaleqqPP0yOWPlNQ/llBfxEU3g60GCK+q7CDDVSInLXwae9sEfZtYa9ENSW3t UQHHXT/OMUIr73IFC1CCh1y4Optr4iI5l3BXQIsI= 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 , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] MAINTAINERS: Add an entry for AF8133J driver Date: Sun, 11 Feb 2024 21:51:59 +0100 Message-ID: <20240211205211.2890931-4-megi@xff.cz> In-Reply-To: <20240211205211.2890931-1-megi@xff.cz> References: <20240211205211.2890931-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: 1790637353150264879 X-GMAIL-MSGID: 1790637353150264879 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 dc5ca7a042b5..cc691f61a77e 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 From patchwork Sun Feb 11 20:52: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: 199513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2100325dyd; Sun, 11 Feb 2024 12:53:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBW1l4HZcPy4SxYTWbZdVvgaEpIhsa02yGpe3D0gX0benwpdNZ5yUWVEZrCmMNwh+J1pZL/fkCroEe96CgiYKPDw/xgQ== X-Google-Smtp-Source: AGHT+IE2D8FAxcc/Bmk+gjQVV4puj7IOByB3zsXxgDT9qkcdxItEu6w1N5P4iv0qkkF04iAR/X6v X-Received: by 2002:a05:6512:238b:b0:511:79ac:ec0f with SMTP id c11-20020a056512238b00b0051179acec0fmr4154292lfv.26.1707684825268; Sun, 11 Feb 2024 12:53:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707684825; cv=pass; d=google.com; s=arc-20160816; b=CMPecXOtlMyo0ywQUVrtE6mzu934uZOJ8+nq90V/lnYSvf9qWyPTZdCZdmCaVyMGjW ulquma6pexyQy6hzzN7wBq6iZhf48lLMECjTCDDwBW35J7LIN+qBO3U8WTIEcRcpgfLr 5y1Is/7ZuevsoiuO5AuJs1cctSvPaYlMW1B16VmcZwWJyAcR48CvromP0hPdVJxAfE1w hwZLvPmIUyHb35fo2nCR6BtLmYrwFf5g8SrpzgQSDL0crf1QJMkhUan/7AQlybfrr23g +yE6Hq/f0gxGrUZYWAbKJqHdOAdrOefQMCTMaHFi8obSxqzj10KV1IiHaFSxBuGt842t JXUA== 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=ZfHsDdshHWcEGjVF9sXvXt4y3guxEAwGP+ur9ISXejE=; fh=JELNuq0zP2L4wf/D4LQ6c/FtoPrGMwhxJb4c+lsO9x8=; b=mHEKJAC/J1J5Gav7mlApV+uXw4Pj+K9JMXUcdcc6XDIqMUiGCOw8XYNFb0bsb4BIrX omW4kylZ/Fjh82g2vk2rHzhpzvB/LfDpyI5AhUJ60LftlZtcwIXTNroT+rLn0oRne0rz e3GGt29/kxwQ+bs4OScDO/+y2sVYbnzfZmI2kiWOAiNU7Zo1pA2VLlgZqkiStcuaRE0f yFotU+Yo3J1tYbYOIK50sAMErhlcQlOtr8YuCqYqD4rZqBej/NmThizaCyksqFJMHVXb CgCnqjqq7B4092HyGS40/2Usem/UoV9YKji9XL8lOEFHxVvKdjVtNIW1WFHiO8HuG+WA AeZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=cMG0Rd1m; 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-60955-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60955-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCVfmb468xQv0AoJW8nB5R2sIpzoI3FEfI5mHPIA6BGJNXD7bUwoZGH59ejgNF4R+hA1baFjfZrAyyvUYVVr9yycavfCdQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e17-20020a170906081100b00a37e33a8320si3250744ejd.296.2024.02.11.12.53.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 12:53:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60955-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=cMG0Rd1m; 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-60955-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60955-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 AF4CE1F21E57 for ; Sun, 11 Feb 2024 20:53:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BFCF60241; Sun, 11 Feb 2024 20:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="cMG0Rd1m" 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 CFBD05DF17; Sun, 11 Feb 2024 20:52:21 +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=1707684744; cv=none; b=GP63cHg3//NH7+ZVXa9+NbU9It7DxaTyK9nUe+fM9iVtV4X6qV2VAiJrFAkptzr5rV6HhyRP3C2jXisakwOnSkY1dLlN49UpRySLX2r38+fMqOVwHldnjgPNQbDJhMAmuzaPlXukfW9moLvAhq6z8TT3A9xDp8tqMLyrpdofpjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707684744; c=relaxed/simple; bh=sGJfZ0pBAohYea+/o3cn3GaNQ7Qkrpbx1driDycLncU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IcatnNgzGAuZehxr5piTTurd2V3+21NthR17GEyiaNdbdZ75Ra2spR7Dc1wDgtrRNUdniYqLGqJEHyGctTynB6A+D0coBqtkjcIaEywwKJTMIQ8YV0L43DwjHQgMSrkHbV0VY+PLz0tlx4zMy71HWWvJFPHHRd2yjfLdyFhTgO8= 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=cMG0Rd1m; 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=1707684739; bh=sGJfZ0pBAohYea+/o3cn3GaNQ7Qkrpbx1driDycLncU=; h=From:To:Cc:Subject:Date:References:From; b=cMG0Rd1mw64FVn58YSzRjfvtpNpnGc6fPtEE0v1lLuxiyFkKAJz9ax22tnCzLtw8O mkjAfz/vnXTPa0umKjJwo1xM3dzD7ZlFZdbhqFk7RglDMJHOwKyK6zuxaFFzDdAi5s SBKsHorlypiXfpJl4sfBhr7G+hGjJjrw1Zg+wFx4= 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 , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dalton Durst , Shoji Keita , Ondrej Jirman Subject: [PATCH 4/4] iio: magnetometer: add a driver for Voltafield AF8133J magnetometer Date: Sun, 11 Feb 2024 21:52:00 +0100 Message-ID: <20240211205211.2890931-5-megi@xff.cz> In-Reply-To: <20240211205211.2890931-1-megi@xff.cz> References: <20240211205211.2890931-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: 1790637323309016797 X-GMAIL-MSGID: 1790637323309016797 From: Icenowy Zheng AF8133J is a simple I2C-connected magnetometer, without interrupts. Add a simple IIO driver for it. Signed-off-by: Icenowy Zheng Signed-off-by: Dalton Durst Signed-off-by: Shoji Keita Signed-off-by: Ondrej Jirman --- drivers/iio/magnetometer/Kconfig | 12 + drivers/iio/magnetometer/Makefile | 1 + drivers/iio/magnetometer/af8133j.c | 525 +++++++++++++++++++++++++++++ 3 files changed, 538 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..0b03417ba134 --- /dev/null +++ b/drivers/iio/magnetometer/af8133j.c @@ -0,0 +1,525 @@ +// 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 +#include + +#define AF8133J_DRV_NAME "af8133j" + +#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", +}; + +#define AF8133J_NUM_SUPPLIES ARRAY_SIZE(af8133j_supply_names) + +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[AF8133J_NUM_SUPPLIES]; + + bool powered; + 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 < 0) { + 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 < 0) { + 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 int af8133j_power_up(struct af8133j_data *data) +{ + struct device *dev = &data->client->dev; + int ret; + + if (data->powered) + return 0; + + ret = regulator_bulk_enable(AF8133J_NUM_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); + + data->powered = true; + return 0; +} + +static void af8133j_power_down(struct af8133j_data *data) +{ + if (!data->powered) + return; + + gpiod_set_value_cansleep(data->reset_gpiod, 1); + regulator_bulk_disable(AF8133J_NUM_SUPPLIES, data->supplies); + data->powered = false; +} + +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 < 0) + 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 < 0) + return ret; + + ret = regmap_write(data->regmap, + AF8133J_REG_STATE, AF8133J_REG_STATE_STBY); + if (ret < 0) + 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) { + dev_err(dev, "failed to power on\n"); + return ret; + } + + mutex_lock(&data->mutex); + + ret = af8133j_take_measurement(data); + if (ret == 0) + ret = regmap_bulk_read(data->regmap, AF8133J_REG_OUT, + buf, sizeof(__le16) * 3); + + mutex_unlock(&data->mutex); + + pm_runtime_mark_last_busy(dev); + if (pm_runtime_put_autosuspend(dev)) + dev_err(dev, "failed to power off\n"); + + 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 < 0) + 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; + *val2 = af8133j_scales[data->range == AF8133J_REG_RANGE_12G ? 0 : 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) +{ + u8 range; + int ret; + + 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; + + ret = regmap_write(data->regmap, AF8133J_REG_RANGE, range); + if (ret == 0) + 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); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + mutex_lock(&data->mutex); + ret = af8133j_set_scale(data, val, val2); + mutex_unlock(&data->mutex); + return ret; + 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 == 0) + iio_push_to_buffers_with_timestamp(indio_dev, &sample, timestamp); + + 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 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 < AF8133J_NUM_SUPPLIES; i++) + data->supplies[i].supply = af8133j_supply_names[i]; + ret = devm_regulator_bulk_get(dev, AF8133J_NUM_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; + + ret = af8133j_reset(data); + if (ret) { + af8133j_power_down(data); + return ret; + } + + ret = af8133j_product_check(data); + if (ret) { + af8133j_power_down(data); + return ret; + } + + af8133j_power_down(data); + + indio_dev->info = &af8133j_info; + indio_dev->name = AF8133J_DRV_NAME; + 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 < 0) + 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_set_autosuspend_delay(dev, 500); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + + return 0; +} + +static void af8133j_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct af8133j_data *data = iio_priv(indio_dev); + struct device *dev = &data->client->dev; + + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); + + af8133j_power_down(data); +} + +static int __maybe_unused 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 __maybe_unused af8133j_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct af8133j_data *data = iio_priv(indio_dev); + int ret; + + ret = af8133j_power_up(data); + if (ret) + return ret; + + ret = af8133j_reset(data); + if (ret) { + af8133j_power_down(data); + return ret; + } + + return 0; +} + +const struct dev_pm_ops af8133j_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SET_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_DRV_NAME, + .of_match_table = af8133j_of_match, + .pm = &af8133j_pm_ops, + }, + .probe = af8133j_probe, + .remove = af8133j_remove, + .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");