From patchwork Mon Feb 12 17:53:53 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: 199981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp93961dyb; Mon, 12 Feb 2024 10:26:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqX7A5zZ6Gl2Hc1QP8gRN0vzU1jPIDdmWg/NLPUrYpWJxC9PsDrIiuO0FAwWFMDIuaoRvzFOhEeVziDfSEq5eXMs1ETQ== X-Google-Smtp-Source: AGHT+IFNK9rqmLx+BB8Q1FFnv/yNYa+DtHqn81LoJ9/mabPtjXMVkkqvW+mnyXSyDpvGSVzDn2az X-Received: by 2002:a05:6a21:8ccc:b0:19e:9af8:40e3 with SMTP id ta12-20020a056a218ccc00b0019e9af840e3mr6618007pzb.16.1707762402971; Mon, 12 Feb 2024 10:26:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707762402; cv=pass; d=google.com; s=arc-20160816; b=0LoLT4tubqzUP6bGa/xWewACJiezRSQdz06kk7P3Hs9fWbktK3AoLeG5Mt/1GXfUmo JDZ/wKVqI7+wPT33wD3TJxUMcZQF35KrYsGsxjHUhq2AcYdc/Up64ZCLkxWaX9KaRe6l LI/UlxhDEPBs2qFMeVQErMzlbP1xvJi05HRuoJKzyUKq4b1CJ7BKd4PnidKE8Ilw99lD o6z9THb5EgqbaCpD0YwdQbWxJuw7LcVVwXORpPeiI8vcox+lMWtneAsWh4QkGx19vuFx numA9Voh4WLHfwKFc5uAKwaau5WFZDFJS98uVKS/l7nLwB0TUnB+s73s+nx4TmffCAlU U/ZQ== 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=Zlh/IWa5K/mjJEFswNmvMVqyqKtXuuV1VBYooXdCWxg=; b=YGHI4+UrIy2aN4u5vrCQ28oYNxwHhDvv/i5CievNnu8Ia7feJ89UVq5vGF4IoTkw8j 0u8tNScwEqffIuIAB2VgDiHu9fdnJ5yPjZ0jdF8PneUDAUPFO/35/yRg3zKJWTs0uesF J6dwsQBw1QK2fuRbZ13l2SZyS8+GKBOwjy5pQg3pfWF9qzw7mpbGK9w4UpJzaniUT5rG X3mJGfwQiPSXScIO36u6MWingkIkQ7uED59medvSb5s1wP6bG1V2VxUpji9xn/JTaaI9 ojYS1gD/AahxgakGsin8rU9HFiJQt6aADPyXrkxdoqdk0E7oZWl3QHx+NvoRyQZ51mxj s5qA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=Q15r1vqZ; 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-62150-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62150-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCXkgeHjl0iIuE1ByNLGTbmyjK4yd6U3VgV2rHs/23DRCxTG41HOcUqdXvraQqqzm8/en300sS4qckbn9U1JieZDJsk9AA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z68-20020a633347000000b005d760d1af1csi600074pgz.460.2024.02.12.10.26.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:26:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62150-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=Q15r1vqZ; 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-62150-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62150-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 B1CDDB2A1E8 for ; Mon, 12 Feb 2024 17:58:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 989BD4CE1B; Mon, 12 Feb 2024 17:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="Q15r1vqZ" 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 009B345BE8; Mon, 12 Feb 2024 17:54:15 +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=1707760458; cv=none; b=IzuReJtOoKvb/Cb69CZg/5r4/88ehmJYTanAV79GE/bEx3oFTOeetH2pglFIftDyMDXGRofwBqHFL5v8cDyJRptTUGyPdMatfz+l+oCuHmF87rmY0da22uiNwfBTcSbd5LBZ5i9r7Kk5KfxlvUh1h5tM67Mz5f4fCKlr8nQm2BI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760458; c=relaxed/simple; bh=0doP8NnUjaTfFjdMWPvwgVTOH9eAL0HI3FuMS2w8NvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZniEPYKuaOiExaF4KvBH/c0/5azfsPv0aMDTaJWtPLQD+Z39sYnWmfZFVL7wVn8jGK+BoVLC5DUzLCxpyOUCz1//8PtpnPzGtvPNo02mpVoDNKhIrpp7S6gpRawqWDoM86Ff8B16dcVbN6kkaCuKR34dX7+gKhjt93CEk7tR6FU= 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=Q15r1vqZ; 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=1707760453; bh=0doP8NnUjaTfFjdMWPvwgVTOH9eAL0HI3FuMS2w8NvY=; h=From:To:Cc:Subject:Date:References:From; b=Q15r1vqZ4gduuegRPgA2R/8nGOaW4ZWeE/pcy9ZKsX7Awcnnp1830TOGdT33wbJY3 YVac8xAzV270WqTJFjfyHm/u3MgSkJMr0o7Lbfzr0ploVARQhrsPDRa8ZYrtcym1P3 hLGKpC6yw0scauuS7b7KyfWj0/rJjj/5+RSP1mSc= 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 v2 1/4] dt-bindings: vendor-prefix: Add prefix for Voltafield Date: Mon, 12 Feb 2024 18:53:53 +0100 Message-ID: <20240212175410.3101973-2-megi@xff.cz> In-Reply-To: <20240212175410.3101973-1-megi@xff.cz> References: <20240212175410.3101973-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: 1790718669814558053 X-GMAIL-MSGID: 1790718669814558053 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 Mon Feb 12 17:53:54 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: 199980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp93906dyb; Mon, 12 Feb 2024 10:26:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUiROn7dsRqdQ+ZDr6ZIZn4oO+LF3zzHRjOdUVtrctkNEsT2bDEGqk2p2p4p6ZBTKdBZ1jTRTmbPSi8tMZHuuBXlPEMFQ== X-Google-Smtp-Source: AGHT+IFCxOY8jAq53JpFJGpcYFL6HeYwUzRh2ayhTKsW+pSJmqvfUS5dBN0g8k5SsDMlETwK120t X-Received: by 2002:a17:903:489:b0:1d9:751f:3746 with SMTP id jj9-20020a170903048900b001d9751f3746mr6473347plb.49.1707762396019; Mon, 12 Feb 2024 10:26:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707762396; cv=pass; d=google.com; s=arc-20160816; b=MGdeHSZPS02x469kcG0WPSKxvXMFfGFjyZ0T1ueEMWTTarQpnYkmL550Vhk+Xox7H3 jMcB5/J9o5qnoR+XQimM8RuI/yaH+0ZoburFjTi30JNGXPL+QL8Ho0/9v7sWFMFMPF4F l/OIUnwnV5j1ZqyiiGSEGbEDvtJP/ZuS+FvrVRjbS5l7vBf5M94FklPmWwzCoAtJAz6I dS82Rl9UAlPu4Lk75wAtu2OGbPd+xQ7TEha1PRkjZJrGWp7xM8kHbgweBO8lNZ1ztjBc sCrqWcNjr/PzXr8GkjAyd7TcUayYrC94HhH1fcehl3b+ZvfLnjymZzMovOSJg2qsK00N DAYA== 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=5T7EhmOku2KKpjHHLouL2eWIz2MSP0Su4QqpE2iLans=; fh=0pdE9TOMGc1yTf+fll7vWKhTw+iX+zwpZkeXheKjjqw=; b=vLyIe2qEFtdbJQQsu4kLQ+12VK1ZmB0KOwAMesbR0jbqrrMx5WWP7786IsEmlEZDiI nCuWdWAU+ue0g5mZjfIZuP7cVLEIb/cNcUZjYjidu4K9rUcBN6RSx9NFuoFSS5vnns1q qX7SFh7QwbGJGDNk99ffuf/87kdd/m7Y9W2TAvbqCHdVvrN+tivyWAVmZiiIQ4GIumBw DPxVC7HOkp+eYe534bj+YpgnzscOF8d9cEyObz2CzHYeHZpPuLP+FX8eo0U6uNvuWhvP 8f927dazrYnUrMxdLrjuGDjxXzlkWRhmpUo433sASxsb08jYAWfNqi+hCnCPbtjj/VjJ Rdcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=xnSouA+T; 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-62151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62151-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCW9tGkeZQ/5jj/qRL/5Cty2LZVI3/ueZmcZlnCa0VB1aRVjMllNlf+1zg/J9G9rYiybk3251Sb+R8AgQFhhuKQ86tmmCQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n1-20020a170902d2c100b001d7105e7ff9si590887plc.546.2024.02.12.10.26.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:26:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=xnSouA+T; 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-62151-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62151-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 7B014B2B09B for ; Mon, 12 Feb 2024 17:58:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 183544D13B; Mon, 12 Feb 2024 17:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="xnSouA+T" 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 2D3F945BEC; Mon, 12 Feb 2024 17:54:16 +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=1707760459; cv=none; b=LTtP8QOCRxDj+ewGJWUTvzVGVaaa4yF34RCXJJjNfR3YqjGFBMFFJQ2pbbhlzBqaa2CcyptusNQpd8IEDaq6J0O28vdLsS3zOef0bV/i/QMTebjOVn3IHrLz2OIevzWhYlxkgnoc0EK+howItnTxp12d3cuM/LGZqU9CfPkhSdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760459; c=relaxed/simple; bh=oF9i+Z8BdopTqVTnBumsz4Nu/Iy7VmW+wAYqm2kOVt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oAczeDaRutAVU3R1hRHcj11/a6l5LLLaSv2eorYjKi15D1gtL65s4u2hIF7EytkHEjZo9nILTIv6wH/82SSKJzsqGjLh8uFm6MZwA3YFX5QdlmaRW3iVfOdnD+Y7g7wgbLOIcrGeYPgvEEzmOKpwuSWauzecgoBnU/N652DZ1DA= 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=xnSouA+T; 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=1707760454; bh=oF9i+Z8BdopTqVTnBumsz4Nu/Iy7VmW+wAYqm2kOVt4=; h=From:To:Cc:Subject:Date:References:From; b=xnSouA+T8OAdh2amQX5sJlpaKHMJ6LK8nbkiDRhmQOwVNcjGBl6Po95bAsnLkyn04 tfvwds7hXsmDCuHnNEZFqgqmz3Pk4S02ZYCn0u1EUkSp/pVFjbXN7iQ8MWS6x/IQFa ixxH0fx3VrR4yuhzef3IN1J7F9gaBFoHI3lsVfJs= 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?= Subject: [PATCH v2 2/4] dt-bindings: iio: magnetometer: Add Voltafield AF8133J Date: Mon, 12 Feb 2024 18:53:54 +0100 Message-ID: <20240212175410.3101973-3-megi@xff.cz> In-Reply-To: <20240212175410.3101973-1-megi@xff.cz> References: <20240212175410.3101973-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: 1790718661931870527 X-GMAIL-MSGID: 1790718661931870527 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 Mon Feb 12 17:53:55 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: 199969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp75680dyb; Mon, 12 Feb 2024 09:58:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVmj7l71wYSRi9aGBdVw1tExH8NEKB9gz1CegUu+SrXn1bT1rP2T4oXDN1geHkGlhuP5VNYbsVBvZq98RK7HNbI/p1zGQ== X-Google-Smtp-Source: AGHT+IHcZznWhxqlID0X9OkziAM3hThv5Q7RuLvNkmydn/EYb3m8oSNLcTfBIJXh9WL3UsdE1SWe X-Received: by 2002:a05:6402:3198:b0:561:8918:9f6d with SMTP id di24-20020a056402319800b0056189189f6dmr4373592edb.9.1707760709634; Mon, 12 Feb 2024 09:58:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707760709; cv=pass; d=google.com; s=arc-20160816; b=feYA1x5Ilfu85jSQyoHLyvwW7nafY3jt1NDUiZkuQrPIL0HDc4qICMEA1EtrSkvN3z dNsEVmmA+SZMU8O2BuvTxEAYMAzr1AR+EQAOB/qxTY96EuQyPAGh3u/UxQ+26mWB73e4 kOjhhB2XtUBrI85MyVshUZHbvovDWM4up5ce/erL0CGPBwRHbTz3jYs0e3HyIyv6a75Q w1lyxkAULe5fif0xyUI2HJ6IuDdJMNeGlUDTgWvZoJ1wHI1ye4znEIC6QXB3n6du88d5 bTIDcJo71s8ab5TGF03qgHPt5+7Q/k36GiphIFSK2Vtr9kWuY/B9fXXEbxzO+PvvzHB3 Lm3w== 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=kWFMTaCJ5JpaBM0NZzoCT10MgH7SKlT37EPVkL6G+yM=; fh=mGePg0Z57VsNrm5Dqad1aIyRGzq/xwBSGpxRi7a0wZ0=; b=ciGaLp0n4lDkG0xAFQZC+8pZZY6fT9fA5FP0cmkd/9JW8FNfFEHfSMuoMgaW0K9V98 64fdABUqXi2fGVWUdH4JJMuBLFuPEQnUNzWrDP9XTBFFsgY9HxhnM6RoPh0hkcFzv4Kk bMShGWR5rjQBgrpsCXBA8JxUU9D5TA7jlSgFmyMpEvLknQlfp4mTvy+dCZLYg63uaypv UIje4zoxA+XKqyOLwQAD4z2NJOCmK9KU8WWB9q3Y3wvZgqnusb6ti3J6z+Cbz6YNcI9M ssJ0kDFDZ6uZak3C1cv9C4cm5ZRNyumBazPSzqdwzUDd/+SUychKrxdqkgUt6aAViJbU HrwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=bAGGdHac; 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-62148-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62148-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCUvjbVzZDU2GCqqM1tCTjrmLaw8yel6PYidOjvHJ1Bkfcmf2Dh7Ym8Feqbh4CJ7IZ+JfY0hUfceVhzTjLStX8Xl4xjmoA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b36-20020a509f27000000b005612fce7eb2si2930088edf.297.2024.02.12.09.58.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:58:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62148-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=bAGGdHac; 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-62148-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62148-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 18F851F2261A for ; Mon, 12 Feb 2024 17:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A347C4D5AC; Mon, 12 Feb 2024 17:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="bAGGdHac" 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 2D3DC45BE6; Mon, 12 Feb 2024 17:54:16 +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=1707760458; cv=none; b=OIZ0QUltwfNRYj/zo3b7Ll/9QUxWUcrHEo5xTEarAdjtUJV0WZt+ABIheECtkdiNpEOUeJpkE+7HgNo/nlnRP7EUffPqfdX+2HS8Fl6+NMrzT14XDAEoFtkw1N+pZT6Gh1DKr0KY8vX2q7a2KcfVXidMvuBuHjn4VobMtqpj5Jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760458; c=relaxed/simple; bh=Dre3xFkOEmvb+OBLI78OWTYhB5fzKgvXBnfovWXmJOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MAJ3RBwkmVlImb5ZU6dJcN/18gkKovUYaYY31cyCrIwdN8o1CsGrexOar9IlTg0Bg2CUxcanXyBM7+32Gxly5D5QPAvClof6BjLt1G23629Wsjda8aT0SYfmCsLAOcQojbMQc9RC+4GKoVlW9Qfe8pHV/hEVDfcNaZBZ0joigNQ= 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=bAGGdHac; 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=1707760454; bh=Dre3xFkOEmvb+OBLI78OWTYhB5fzKgvXBnfovWXmJOE=; h=From:To:Cc:Subject:Date:References:From; b=bAGGdHacHyUIin9nwu0JaeJiTsqYEUpjJV1XMhMlpxigrZOnzcCNTY/ip09HDs5mP iu29FcwaSJFrIb1Wn8c+f/ir115SupRiXMunbY3SIOk6XBjAA+44kaAnZac72fi1kw C//vQCxMBpX7ZjK++As7L9H91H23g80Qa3HTXFhs= 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 v2 3/4] iio: magnetometer: add a driver for Voltafield AF8133J magnetometer Date: Mon, 12 Feb 2024 18:53:55 +0100 Message-ID: <20240212175410.3101973-4-megi@xff.cz> In-Reply-To: <20240212175410.3101973-1-megi@xff.cz> References: <20240212175410.3101973-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: 1790716893831925047 X-GMAIL-MSGID: 1790716893831925047 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 --- drivers/iio/magnetometer/Kconfig | 12 + drivers/iio/magnetometer/Makefile | 1 + drivers/iio/magnetometer/af8133j.c | 528 +++++++++++++++++++++++++++++ 3 files changed, 541 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..1f64a2337f6e --- /dev/null +++ b/drivers/iio/magnetometer/af8133j.c @@ -0,0 +1,528 @@ +// 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 < 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 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 < 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) { + /* + * 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 < 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; + + 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)) + 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); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + scoped_guard(mutex, &data->mutex) + ret = af8133j_set_scale(data, val, val2); + 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) + 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; + struct device *dev = &data->client->dev; + + pm_runtime_disable(dev); + if (!pm_runtime_status_suspended(dev)) + af8133j_power_down(data); + pm_runtime_enable(dev); +} + +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 < 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_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 Mon Feb 12 17:53:56 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: 199979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp93718dyb; Mon, 12 Feb 2024 10:26:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTKDXNRH3SieRFZFJvictJuPcjx5dt5TTfdNiVR/Uxev7uxTXBHjMItlWd+YAuX3uJRMrz3ZkFXnSDMHjP2Llm97Oxhg== X-Google-Smtp-Source: AGHT+IHsUBUlPhu3eQYI3yaZBo93Xny4L9IcwGdfa2YQGSMQHsOeUUvy9RgtwKghBMbXZ0dPwoEQ X-Received: by 2002:a05:6a20:d38a:b0:19e:2d04:d783 with SMTP id iq10-20020a056a20d38a00b0019e2d04d783mr5520450pzb.4.1707762369308; Mon, 12 Feb 2024 10:26:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707762369; cv=pass; d=google.com; s=arc-20160816; b=h4HDQyCeeRKIV9qfsEiw2Ns8JVk1Tmp/prQ+1ta2hLK6a6aSms6tV2bSoHYs3FOFGm 0fT/r/5D5yP3BZZEMGtirwjz66FVJ8HdZ2YxQET/liCQhevTmbvC+ldXGj6agkEjabJL tgdybazC1mQYJVcGM6gFGGsC+cXESrDbyW6ZKIdEd5tAx96+aKQgMSgY82Tbh71fZkv0 /BFQyptA2SgedYstOalagflRbGQ1EsXXNtp+50OeVMTHDRTB/K/NGW2dL0qP8znbuwu3 u+a29WwUKmanWWLzZwFYXyECreuhROqVcrEc9EnVX+uK0Fpnr/1Nlw17ltyH5lirtBMY VUUA== 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=rxP3MaXcqBZuoB/St/zC4jrs60ot1JnK5WMDszT8jpg=; b=g1Sz6N2y5oJbCMjDBOSGP182s+zmVFK1Y+J4S4Lz/PlrxE8PjaPBeazRYkBr6hgmcA U45q+ivoSH2HbNI95fFUQ6ZQYYEehyLAOWELWiq2g9W+nCh+Gz8qm0I34WDuncLrYNXA ogfUGlhy/RJpjOJIre49Z6YLFp53YObNHGh9/nvEn/vg+b/0nRZ8In2t18HG+16b0JJH w5ba+zPpD6Oej8YliD6CZWKdrY4GQOHkJFN1LIu6077nJV1rcP6ovi1L/58lnPrhVRN5 PpSMrrZCMFpcO8dxJbo8yoh4thwJr7Lg5AM8qSGQsGZcNzGiXD7jYipKvTEpBO4Du40f 5SaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="g6PZhm/P"; 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-62149-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62149-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz X-Forwarded-Encrypted: i=2; AJvYcCWOcGuQBR1slYJhMazRkoyQWfmUwxQIJmz/ZAl33R/uVT3lYTTfTIOKqz4XxeqK1X82bnlC6qZtZXcpJZcIffH8Y+0owg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z68-20020a633347000000b005d760d1af1csi600074pgz.460.2024.02.12.10.26.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:26:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62149-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="g6PZhm/P"; 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-62149-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62149-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 27858B2AE7E for ; Mon, 12 Feb 2024 17:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 985934CE17; Mon, 12 Feb 2024 17:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="g6PZhm/P" 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 8AFE645BED; Mon, 12 Feb 2024 17:54:16 +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=1707760458; cv=none; b=F3xMLZTBC0JJ4glsUhofYXD29DGRdVVI+ZmpDL1PLwapBnewz+iHyMAXN+aw5py0lMPYdDsMUshAbHZsw1o8z39d5W9LTIDwdWNGMKouueN0JOrGfavcT8WLVaXkGaWN7ItuYAQ+RE4XEbxR9X1pmTFWz3NMYuHheno2nrqDFz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760458; c=relaxed/simple; bh=w4dFeJN6ekT4fZLMgY0MSjyE6BSqXIkBWnDC/steBeE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EIlC4X8rmpv50Zj1eYv96EkQFk4myQclATHGXYiH40HQghgGeiPY6xpPYBjSKTLMRl+o+OjxdiKFGXhxJyheTlSBor6FI7enwn7FOYBRB/UnuEzFB0ANzncLmC1+7VQ0XJOdhL1755TcM9+/2kkUr4goI2lEpR72Xc2cmZl9ZL0= 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=g6PZhm/P; 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=1707760454; bh=w4dFeJN6ekT4fZLMgY0MSjyE6BSqXIkBWnDC/steBeE=; h=From:To:Cc:Subject:Date:References:From; b=g6PZhm/Prk73mVVUFfWlw4G87khYBj4/3uYUDF/qZlgJkO/84G1G8JzUCaTlQ7Nrv LqO0FKEtTuLxXb2fm0k2ijhFcouznFtXWihL5gSj33pNfBHvmtyaLEpxAvzyhkTxCS r2mWGyLtDitwYKtdbkZqu2jxcGjBNQ7fbQX1K0vU= 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 v2 4/4] MAINTAINERS: Add an entry for AF8133J driver Date: Mon, 12 Feb 2024 18:53:56 +0100 Message-ID: <20240212175410.3101973-5-megi@xff.cz> In-Reply-To: <20240212175410.3101973-1-megi@xff.cz> References: <20240212175410.3101973-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: 1790718634230213440 X-GMAIL-MSGID: 1790718634230213440 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