From patchwork Tue Nov 29 06:45:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Loacker X-Patchwork-Id: 27089 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp168036wrr; Mon, 28 Nov 2022 22:47:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/rGFksglWqoFa/pnPK6ftKxxuEXZdkCabBatR+DKOdvkZxmhhtiW+3avW8bDq1edabYdD X-Received: by 2002:a17:90a:4147:b0:214:2214:869e with SMTP id m7-20020a17090a414700b002142214869emr66249908pjg.76.1669704458016; Mon, 28 Nov 2022 22:47:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669704458; cv=pass; d=google.com; s=arc-20160816; b=yImb+67mCdBsqdhKwDmYYDJamvm/bg554662TXNloEQYEhWT1qaOWIFfTcsaEXXHWU t9dSij4KUxX14v9em9W29QcRt71MNcK8v0PzljCwO9YAzdY+KZ87pQi2UAjqJ7a63I29 95O5K7KcDzhHpH6PtSVlMB/Tq7estBGwtasaWchGO83VX2ZDlAQLyaM1+U6ii2OZ1mFf k81AByqk5oY7yDLPmcQAMC2t6Y330hNiAkXG7aGPFLledxfeD5RVNnCDMUJpj6oZVZ2x UZlZicgsbWI75qJ2wI77Ma8T1bkqmfArA0kcxDPPfUv9HSXJGgHjYFvC3PvBR6fUWypY IOHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JXIVuJRJhG8u0ZCsKopcTrojv3oMYxClgYiutAfHyc4=; b=hgdlvOUMGbA4SSWExhPLNalCt61NJ7xyP9t79djKbqK13WCm/GnQfd/ZQr+wBFzDho OKItnehlPSq7km6Q308YsTn0FKNaXLeL28DOyCmt57pRUo/JUnAGhV6KcjIR3xu06gSO 8rKRm+3IjRRlf7qy1NSVq41XYHB4nVs3wzXw/NKlCWVHdQaJp0MZAc+zppJ17+Yo14/j JD6fql3HaQJi4Ch+VOSg2WBvGYT9Ffa1zTSGdivNHz+8c2ikBtnfuwMqeczz3eakKtm7 FqGUCwQhemXbQpjVxBLOoHT87BwXFruQG0qeV/NS+P5iMvZKQP/wPKX5TqBAcqO9S94M I92w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=ZIXFi8Md; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 192-20020a6301c9000000b004701ea564desi15464295pgb.783.2022.11.28.22.47.25; Mon, 28 Nov 2022 22:47:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=ZIXFi8Md; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiK2GqH (ORCPT + 99 others); Tue, 29 Nov 2022 01:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiK2Gp7 (ORCPT ); Tue, 29 Nov 2022 01:45:59 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2087.outbound.protection.outlook.com [40.107.14.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3954286EE; Mon, 28 Nov 2022 22:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+M/Yh2gO2aQS8TH1rv7aZv09V78PZTGndPGM3SnbiBunfiRyeoi5+Fdr86THw295p1AXDoVa5l2tYwG1o2p53RhSmSzACDpRg3lwSgUXqo2tNSw6moGK82amY6e9a/xUXKbL9tWJyStlVduQ/fuHPeJlEcjaP1w1wS4KhWzHrbOHcQYjsgd+snfQvzEBLjEANDwKRSOoYt3vjgkukc/6tzNyTfDu8sRkJbwH4pGjAzhSngBSq5lg1jXyqiqYGofVq3+nZK6t9QnRA1zt3B+xX8Jo5r5zPHlPiCrBeAg0wqYVVH3esv/vMqS2Bgd0G/5n6ADyIVoH2yA+xG04rd6gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JXIVuJRJhG8u0ZCsKopcTrojv3oMYxClgYiutAfHyc4=; b=oCmH2rYlnFu6mBL+pMAfOT+i9g5u4UfKXO0B0OVTX93w44AyBhKZWhKQ+8YGIwJhRdejOANpQy5ViT0w4GPEfqCiL+1B27T/Hk9Pznqov4uIVD3taCs/W+eyqr8LkoUfdBpnqBpPYA3nFTXWQvnr15ARA4YzNlzP/dK8UVE/K68nGEgvcT6r/xFo7EYViHTJGyyNqBl9a+VW1J+BWCCQoRlbn+OIxVuVtlyhZ10KGds8278TELw98M3kSaDCj0zseEUW0mBinpKZ7uHCqBP6uP2hWeFKeIo8IXVOsSsxEubiX1ZiPA+RP+Pw6o5dTQUBIdA6j7k4/J6Alsc4KFrx8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JXIVuJRJhG8u0ZCsKopcTrojv3oMYxClgYiutAfHyc4=; b=ZIXFi8MdyT72tv7qlb3HdnL0wtjkS4vQImaIq+KiF0rjFCK7hghAF20lDJdiY87uvftcuYg1DMApDoX3zWUkko22O+UOhmsclC2hDeQrn9ZgWg4+qk5XjrNEWxpf7yLalrcN84ZHa1ikhFi5HLFOXbpSUBwecppwVnXf6oyOBwE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) by AS4PR08MB7685.eurprd08.prod.outlook.com (2603:10a6:20b:504::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8; Tue, 29 Nov 2022 06:45:56 +0000 Received: from VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454]) by VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454%6]) with mapi id 15.20.5880.008; Tue, 29 Nov 2022 06:45:56 +0000 From: Gerald Loacker To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Jakob Hauser , Linus Walleij , Nikita Yushchenko , Michael Riesch , Gerald Loacker Subject: [PATCH v4 1/3] iio: add struct declaration for iio types Date: Tue, 29 Nov 2022 07:45:38 +0100 Message-Id: <20221129064540.3218982-2-gerald.loacker@wolfvision.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> References: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> X-ClientProxiedBy: VI1PR10CA0107.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::36) To VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB4544:EE_|AS4PR08MB7685:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c704da6-9068-4d7b-9f22-08dad1d55e45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KWi4O3/RzXJ9LZb3kja6TUSCemPS9yJA4m02NPvUj28O0b1dY9y3QKPQXTB9DTn6OzTBNg86COiyr6MyRSpzR4HDLoQcYTmy8nfgc+XMWOFO1EozQFY1/RlWuYYSSTaHmYQXIon9kbNFLW7mZHx+hrLmQdKTt6JAqKia+U1AwtCgykUZUixcXfkOL7qQxYVGw2obBTXEdHcMAJYOthIA8zVvWAuRF8agerWU2QlqY2wZMYA4l3EVFr65c4g8VsVMkFdXuTfBffP5UZzRFCPTm0fE9VgTP/2iDY7P2GgTNbeSmC/uewhqv+5zunL1obvM1oiq9ikr6GTpCl45oZofgcW8deSHoOvoSpph12k678Kr1FAA00fwxB3pVVq4c2sV+nb3FX/jZAP3QWiK37SvTpQqzrIo3qQkY+nyLBA5nSl86vdEObNijxug9QZfn0bnYnUNjWpkrfsTc/7fTR4yj76zUmwMh62chlFmuQjm02A65i7lhjDchayykEZsb97jJpxYsz/lHIAS+r6CRen7z5mpQdtzgw7DmVavV6SJlP3W6M8UWj6qt2ke25YgIRdhbelW58tfhbtJN08Lw1fgn84cdDFrl4m6F4Tfeq/DebTFV+oYetWyouqOH9PiF8QOXbrsSNSg7YWQUXoNqt3Lx3DO50FAUADjyl3aSDyZjWPSQJAFxOGHcsdXJmLvchl0fDf6sYAiT8TWrJv1SqCnIg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB4544.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(376002)(136003)(346002)(39850400004)(396003)(451199015)(6506007)(6486002)(86362001)(52116002)(478600001)(107886003)(6666004)(36756003)(26005)(316002)(2616005)(41300700001)(8936002)(6512007)(1076003)(54906003)(4744005)(5660300002)(7416002)(44832011)(38350700002)(38100700002)(2906002)(66946007)(66556008)(4326008)(66476007)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X9c8GiOzzAS20shZaVe+6cVLX+iLkOkow2b6nTFagqL2ns7yr66eRSE43vyUEYOdMlsWMhOV0mPDiYsRVXQ1jtA5s8pV7qipB/sEjJJFXBVzbz1GYmQDHQVhFXJNyxFXCXirM70MDTXndaWcxmffRetH8lwhXuQHha4VditJTecqS5WmZkRtdBVDht5yNWlWDod6zWA5K42WkwYc07UYYA3/SDyE/PJbnG3j7eWJ3EQ669OQ+fFArNyNSrdb1rtrF3D+mLc+tBZ1Nw2NR0Ui4Te05EGFTZM1rIEum/Y8WYk8LOLOm+yXYO9+PPJ/naaQ4Si4kjru4+ngtIFSLbN04YrEwcqNtwoQeGB3CfAd6Phjm1Y35usFvwjfozV8IfPYZhn7qXVBExJWNfZD0RH9Iad8IkMj7ABCOyswiwjg5ov/TLZm+QRAUkBWM2uaMJCnGARD83EkrlQ95blYDF6f4qQ6YYLIVEgxWGZlcM2jKL7tqrbqIqIsDz7MO/ByM4xgP588n5BzOqWFIvvls1qzKAlc5Z5/AX1SCONnhDseiSI7qn4sRRmXkLdkuCeBZ8kZcbQTQCSw4O22KotLRn3+N9dc0gJsj0fMYoPirzVn5miVt2JHaOYBwn6lr40DCjSaO4rwgB2MTpiKx9BwS3pYw4F19WjrmJg0CFxrp2q/BqcOdh+MGeaZqZfnlP8ImtmQrZXPY3mwFMZOGBTaKO+QNetEJafQDQMHrqvW/Gsosz9yickceTb2m53fG0MiIbkUNAORQr2RlAZtgvtSeCX8fzKMU8jpBgMAguOXVCyECtcIWfccKkYydyGGf2g4K6sZYi318Fd5tEpHHb7f72bzbL1OSRBqdnyLO2jRNV/dxAqnjtj73PmSxUaSid7EuZxsAoIxslALBeQkODwkU9bAE8zh0mwfefA6KgYeS2Jx4cjuNSmNSxnFHjqL92gXaghMGRqWXZUnWFmNpeuocnsnRTtsXrRLG16UKHSxz5tebWaxXaTD9PRBhCVBPE/+3KXDS1SVwVq6OC77oTcjkXKBdQq8KQ7MDgJjJdUGPLyV+yLf3Pd7Ca0coXnTnmkF69lJDgnkjOkHkFv1jKub0Z+iZEMllX0NuXVo4wQ2yiresjAs+D5bdl1oU2T9dawUcc+Adk3Xa86vH2y2QFRKM8+osub6FR62tZmcebe3Rmyf3kspwFn1fPwqrsSVbhTOyAcd/mQ45/HhIUBD7H/JVepaMxJxre0bwXu+tGEkA0pFOuePWPWm1YdUgV1FKul7rtSLbOwCu74MbOv1HIfDoDkj+mEakoN4nrLRax850Nbt0ViE3VgPFHtJiv3TiiBQElVR6pbEJpz5BL11PAxxJFbJl80GnRzGAZS5U83NLgGXd4Cf+w7tjw6/p7NrpbwNeirfX+CG2W8gXOEJraNJdAEEWgBEUUKV6d9Kt1H8PwTcq7fMurmEdneBELuOYKRvbNYqf/4PXzfBpmKCdqhd7p0qGgusUWW+rbVJeeD4diLgocxbYdxNd6H73WegEbUoOVY6UMnkKGoJ6xnXtj8y6HR6CJYrWHV16VY5jir68get7i6tMQDXBHZHkb51c6ii2Fcpfi2u3rM/yuP1YXFk67+1lQ== X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 8c704da6-9068-4d7b-9f22-08dad1d55e45 X-MS-Exchange-CrossTenant-AuthSource: VI1PR08MB4544.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 06:45:56.7769 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cIjKufc3gpTv+M8SfsSmEPOojaZZOozks26AOCN9r64DK95D/3NYvuyrtzOd59YwBXAKQJCJOk2xqV2ELj2i3ugP8arikKDFJOP7c+hT10k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7685 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750812021775628847?= X-GMAIL-MSGID: =?utf-8?q?1750812021775628847?= Add struct for iio type arrays such as IIO_AVAIL_LIST which can be used instead of int arrays. Signed-off-by: Gerald Loacker Reviewed-by: Andy Shevchenko --- Changes in v4: - Add only struct for IIO_VAL_INT_PLUS_MICRO iio type. include/linux/iio/iio.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index f0ec8a5e5a7a..e5101bef50c5 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -381,6 +381,11 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev); #define INDIO_MAX_RAW_ELEMENTS 4 +struct iio_val_int_plus_micro { + int integer; + int micro; +}; + struct iio_trigger; /* forward declaration */ /** From patchwork Tue Nov 29 06:45:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerald Loacker X-Patchwork-Id: 27090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp168208wrr; Mon, 28 Nov 2022 22:48:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5iDfNTAthv43VeENJoUebOX9fpGQlV8D/P1N/WvY84+yYdpl0Vlj8CLPU5rh6ygK/thD7o X-Received: by 2002:aa7:96d2:0:b0:574:2447:947d with SMTP id h18-20020aa796d2000000b005742447947dmr32966258pfq.32.1669704502815; Mon, 28 Nov 2022 22:48:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669704502; cv=pass; d=google.com; s=arc-20160816; b=KssziJo+mucRaxZBLNa5QwWHF4qngv8SbCsXU41suZknxKCMR0M9kLh+lpTLmixxHU banxUo3OLwc9jh5VZxCM6SFK5KznKqZPmboDnGXmROEJx+etOZEGkgWqXsY4YsX+TNdV A/h+BXmYyBxbhm4CRolHjZubRmjYjLiHIXIdIbodKTVGjQuGvxHJFSEGWxwCGr8OwTmQ 1eR0Zr+qWe4jzutk56/oDG2n6HsJIzKzZaUQxXDEa5o0R7JNQJnPn5qvbi5YJ2oXeXlD O9fAXkfeVu3iFW7e1vgcFpNR0a0P+WmmcBB+EaXraJWDxmDmaahG6kz7JggcP7g4MV4m 6Fzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IghivhoFXPCp07cRabnAVKMCM9GCgoMI0kJ1DwDuyrE=; b=a9IFmDKCxOiupMP6AeKWmP+lK2ylx9fF8rjZU/7J0IrFkZrlQmkS+/BjSO1QrJ4Ob6 trYIuQZdwFEdxDy7Okgtw4RRhnSELg9ZbaKi5qZOGz0K2VxQGup0FPhScsZwzx3XR+wP ght6WCKMc/UoW7xN1hv0yOAvswKjW2ON9yPRBrDWc/owr86i61iKJ+L7sJ6rleOMjnp7 y4xFyU3W5nIo9VZ3DZ+yCfuFRbh28T+qviSLSq5UfEnUoTmsIg3amloHqBk4Gsb3CUKS 7Ht3ZC+n9SHsdYpEam5JV/BRkXwVGE3hlgetKo0xNFWxlYXbRLRBlbnJ5wB3YYBitxCL ujrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=WeTAVaEU; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a056a0021d000b00574277cb38bsi14225361pfj.375.2022.11.28.22.48.10; Mon, 28 Nov 2022 22:48:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=WeTAVaEU; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiK2GqP (ORCPT + 99 others); Tue, 29 Nov 2022 01:46:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiK2GqB (ORCPT ); Tue, 29 Nov 2022 01:46:01 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2087.outbound.protection.outlook.com [40.107.14.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D503E218BE; Mon, 28 Nov 2022 22:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oemw4uvjArMSPOjG9AJ/sAKfoSF3Pj3XIzSWQNnh2OIrlbIyZMYpQnPpSMHr+hpRSWQDKmAVvAQaYzAwnaP4Z682Y/mafpadYRYlV+EVQvg8/+P6Ok+sjwauNv2cstwpXL5KCPJyD2jYuihkXBtKqFmFwh25Nmwbe5njUXjRDAp3trpky/NZdxobSu5CaD2H4cv1bn7Dad2OVG0/VbMz9nwAtQWV9hYb4vAz8939dbeEatlS+meuNY5jiB21OAnwCr7NdWRY+s8zc98qw3/KHgcLEG6uEw2pBPOaoZfiuaP/ki+FMkGGhTi7/vuUwTzAU8oyXl8sqOKqfiPpU8Hsvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IghivhoFXPCp07cRabnAVKMCM9GCgoMI0kJ1DwDuyrE=; b=VHkjGeg66RxG7wTw8e8xY6caxgxOiyhsqFPiwaIVaVikf8J23E5MdiJeEVoLwa5WRjg8DuQf0hCpPsfBlW2kOxYLu6PG9Dh+sCebAZzVLesC1MB6tuujLu6C/GWblyTLq01xrY5U1pXlw1vMhhBEKSJ12+XdB+eHy2EW3L295pO+2uikQZEfsf2ppGams9/H+dqPb16A5syVBJN8pP6n7WTFGEuLk9jC9fOV8621+DeCCl0AwboBkH7ReQTQE1vFPpUuuXaMUChLM7/MxVaB/oASQ7Vi0ioVPCerDbasEslXJRMplejrf7K5Wksltz4qtN3mJpfsV/rh4HK4RRdH0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IghivhoFXPCp07cRabnAVKMCM9GCgoMI0kJ1DwDuyrE=; b=WeTAVaEU8z1j8MswDS8W+wgWva3DDoOpEtH786pZw3Yz7ZxKhf7FubTv0Mr4Mv8x5lKhREL2JT+/9Emna7D/EOcIao9Jv8Gi4D3VKVZw0aykUUSFwQvdv69GprmzOHPGH8fPubcIupdr5Xq3Pxv9+gxJd9zRwF1ChElxX+aVp70= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) by AS4PR08MB7685.eurprd08.prod.outlook.com (2603:10a6:20b:504::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8; Tue, 29 Nov 2022 06:45:57 +0000 Received: from VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454]) by VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454%6]) with mapi id 15.20.5880.008; Tue, 29 Nov 2022 06:45:57 +0000 From: Gerald Loacker To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Jakob Hauser , Linus Walleij , Nikita Yushchenko , Michael Riesch , Gerald Loacker , Krzysztof Kozlowski Subject: [PATCH v4 2/3] dt-bindings: iio: magnetometer: add ti tmag5273 documentation file Date: Tue, 29 Nov 2022 07:45:39 +0100 Message-Id: <20221129064540.3218982-3-gerald.loacker@wolfvision.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> References: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> X-ClientProxiedBy: VI1PR10CA0107.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::36) To VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB4544:EE_|AS4PR08MB7685:EE_ X-MS-Office365-Filtering-Correlation-Id: ce25c3e9-57a7-4e68-9748-08dad1d55ec1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W+nG2vu8esayOSHNW5tPsLidU0D4o1yrCzz6GTdLjavM8nu5vqlGnrywugNgnOzaOe1YKr5iTTaRDzCWAx4BYfhx731G7SU+rEn3DvyB0yL8KRICVIzwZXh8PbjYLKerXTo0KXu4/4eZRg1bGtexsjnhnvz7C3RYgrwo7Cjn6ybVCUA3o831fWFfdHag+mss+kJZRn1n9SKzUiDHUFIfUcYTUlCeKr5bQ9hZk53g6tnrKXtaNK6Ka5tfQoikAcdczfvzPrH6zPYp2lhF5NbMEQxozBo74IBTEZNNTnVfo+UM4lskrzXpB9jfEuWVgvdQsZzsy1f3HCXPEL3JrL11DA9S7PVCakD9ZjJugBehClDZ/os6jO0QSgsXAKVEna4A0stcdjD+LrPY1UsUTotbJUw18FrP/ZPZ5BF4tlV3Kq50ZVNObzym3dl7Dhf6C1OOGh7wHipl/0Cx68vDSKr51nJfqn4qbKdDskzqxJuvrG6RfXwjxZ+KjgM+wVK6WfVXddOqGxLpKA0S4QHCUH+/RX0Wg4p/s9AGDHwby8zlX9ai5YkH8hk37X40pcCS7ttufjNU160ZqzzCJihRIyzuo/uGCmNZhrGh+Wf7LqcoSGqzJ0YwA/Pd6LD2dKhar8/k+f0ItFq0eKXtqP5GaIAeXGe1gXx2E2vDDhV8BvO2gqdt9hPjTwakZEv4wZjm/TZhf66cRLt1wpiiE6OPJnIudTx37ZsmP8wIG9o6C9YoGNDzocu5geHj2YbZPgiAkB43 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB4544.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(376002)(136003)(346002)(39850400004)(396003)(451199015)(966005)(6506007)(6486002)(86362001)(52116002)(478600001)(6666004)(36756003)(26005)(316002)(2616005)(41300700001)(8936002)(6512007)(1076003)(54906003)(5660300002)(7416002)(44832011)(38350700002)(38100700002)(2906002)(66946007)(66556008)(4326008)(66476007)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/UjKtTJEvj2eT4UCbM9XMCFoRwNa?= =?utf-8?q?R+EW0tsNflZIyzCRzWQ5eOh4rH2u/Ya3rcHUa06XoNFd3Cy58TLkzwT6R9SA8tbpc?= =?utf-8?q?vXCqZfoDU263A7VuHyToclCESbmRCIxVJ9Y3QcpzCcIMZLS8/SUZpYEsvrQX/gOUa?= =?utf-8?q?uM2Qvk5kH1k/79V1ggQF3tulkbzVOSghgAiVbiMlyO8eozHqEa48+FZDj3tmG7S13?= =?utf-8?q?1gCcxGZ4mRqzXAOHT+bGCAEqzRESXlhA80YHhGBSUUsu+v5OvtrPYYPRgFH1J1mWO?= =?utf-8?q?ApE6TgMe56D90ZN/9gyMyULxE+iJ9OhvTLhPXB0ySO9GEZSwIloniJ0P0KOJLhVnV?= =?utf-8?q?FQydZKQjj4udXB7kN+HitLnxKwH/nerBxGTRs5pAu49+3888nZ76ILPFImwUEhofz?= =?utf-8?q?C1n886sj+aGYfPUhDJSxWKt0DlH7zXhrE1neOs8jraMHYHV/cLRMii5oCpo5wEu1g?= =?utf-8?q?25crV8JTIsTFRtv+vzO9e31ED+jqG4/WPgNYWwXlhDKnX07eJ5SvfdSNYDrDJ/5BI?= =?utf-8?q?64j2TwRgop+CARjWm900Pj5r/2D1ViLUwjtwgoIxMoxg8I2iI7lxw3lMZCL4NzLZ3?= =?utf-8?q?pcNZDK87xrud5SEF75b7z/BbAhHeEOVAeRnuv597Zs+obzSux4TecabpSycTxRK9M?= =?utf-8?q?KZ5Efi9kMFhcDjhpqEXCOcAM3b6YVfT7dddQJzmV6P8FoKmlhNcnayUcY2T5NRF96?= =?utf-8?q?2pt6R7+nrlGWFUq9CP1hrycLUcaVIoeOCqQlLLvpaW0U0WAKYucy4ljmhXtDd5c7E?= =?utf-8?q?k3oRDEWPUn4MBQKnDjEvzhqLKkdHLG/Nzox7BsM5lgaVz143n/f1OI3XuemU8Rk7F?= =?utf-8?q?TpQsfhwP1Iw1ieXj9s7RxXX5F4S/YomU3q6X60rzTeV0ER3Somz43Ppi7WEyiKrTn?= =?utf-8?q?vrr/OrHia2WVQZ547y3JkQaWyeuzMATOHXorGE8h2V5H9rRLkRXLXh5tHZEJqM9hS?= =?utf-8?q?VDe4EBZd9KARrkb/gU0Hlm9zTBdB3uvkb9sXhht7k5CWKzXx7qEyo3R/z8Lrnzle4?= =?utf-8?q?VDAlcWqK2uG/dZOQEQS0UyPrnE0I1F2xXqpdQkgAOle/nz5aS3N/eT5wGA4VPe3lp?= =?utf-8?q?ZiM0etBuvkvXQY4HcniMmLfa1RlaaqWT0sskxov41BqTak6A8/aLBOXFBbMWA1HiG?= =?utf-8?q?QRQZekbtz4TEurf/qa0g32xXnYkjRmYQTHimXvlJ/Ks7NBEC2O65gVLJQLgqsOaQB?= =?utf-8?q?eA85kwHnZ5Lsl3z54CP9vIEZBjcPgc4QPPbwoop3H+PzhNacmIIDunusSCjJxTPgR?= =?utf-8?q?Xj+elk8Ahx6ym76rOEeLFwbIJZPDN4+2f/ddxoDypMGh3QpqJuNSET5NuJA/iB5oG?= =?utf-8?q?MsHGhjTaa1OB2neopq70BxyUbP28eCdBZaxPdaVeoZr4TsOaFVlQatSV/68SZ3a+z?= =?utf-8?q?CrjxfReniR1Redepjx42q86WqDVOARa7gIj02Lzh5URp4/5EwSIDh21+vKo+eXjnU?= =?utf-8?q?4YpPyNYYVPb8u/G4vjPY+nWGvwYsDpLMkX4V5XTPrWkFQTeS5WFl+J02LLA6I72Fw?= =?utf-8?q?YVxwbuSZaelS7yz8erjSYHOrqedM3HIbPw=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: ce25c3e9-57a7-4e68-9748-08dad1d55ec1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR08MB4544.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 06:45:57.5424 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G4WbfHQl2REHgcKVqWxKxmeZh2fIbiG4DkTpk6CrSv1r2DSx1YN+AXwyI8CB+y4jsYACLjTlE4n8INNEUnNXIAvnqzEAd1oB0IW5mExX3eo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7685 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750812069076177268?= X-GMAIL-MSGID: =?utf-8?q?1750812069076177268?= Add bindings for TI TMAG5273. Signed-off-by: Gerald Loacker Reviewed-by: Krzysztof Kozlowski --- Changes in v4: - no changes Changes in v3: - dropped quotes from strings Changes in v2: - Removed nodename - Changed angle-enable to angle-measurement and used strings - Added interrupts - Removed vcc-supply from required properties - Changed i2c-0 to i2c in examples .../iio/magnetometer/ti,tmag5273.yaml | 75 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml b/Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml new file mode 100644 index 000000000000..121d540b7b6e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/ti,tmag5273.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI TMAG5273 Low-Power Linear 3D Hall-Effect Sensor + +maintainers: + - Gerald Loacker + +description: + The TI TMAG5273 is a low-power linear 3D Hall-effect sensor. This device + integrates three independent Hall-effect sensors in the X, Y, and Z axes. + The device has an integrated temperature sensor available. The TMAG5273 + can be configured through the I2C interface to enable any combination of + magnetic axes and temperature measurements. An integrated angle calculation + engine (CORDIC) provides full 360° angular position information for both + on-axis and off-axis angle measurement topologies. The angle calculation is + performed using two user-selected magnetic axes. + +properties: + compatible: + const: ti,tmag5273 + + reg: + maxItems: 1 + + "#io-channel-cells": + const: 1 + + ti,angle-measurement: + $ref: /schemas/types.yaml#/definitions/string + description: + Enables angle measurement in the selected plane. + If not specified, "x-y" will be anables as default. + enum: + - off + - x-y + - y-z + - x-z + + vcc-supply: + description: + A regulator providing 1.7 V to 3.6 V supply voltage on the VCC pin, + typically 3.3 V. + + interrupts: + description: + The low active interrupt can be configured to be fixed width or latched. + Interrupt events can be configured to be generated from magnetic + thresholds or when a conversion is completed. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@35 { + compatible = "ti,tmag5273"; + reg = <0x35>; + #io-channel-cells = <1>; + ti,angle-measurement = "x-z"; + vcc-supply = <&vcc3v3>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index cf0f18502372..ea7acec52f8b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20613,6 +20613,12 @@ L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Odd Fixes F: sound/soc/codecs/tas571x* +TI TMAG5273 MAGNETOMETER DRIVER +M: Gerald Loacker +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml + TI TRF7970A NFC DRIVER M: Mark Greer L: linux-wireless@vger.kernel.org From patchwork Tue Nov 29 06:45:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Loacker X-Patchwork-Id: 27091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp168498wrr; Mon, 28 Nov 2022 22:49:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4I8XFdLhlJaIbXKUKAPrwK4WlQJ4m5cS3Y9vvg6jiImfZDwGzMoP4bLtgY/kyxpwRgGldb X-Received: by 2002:a17:907:d60c:b0:7ae:e592:6d83 with SMTP id wd12-20020a170907d60c00b007aee5926d83mr22898747ejc.699.1669704553958; Mon, 28 Nov 2022 22:49:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669704553; cv=pass; d=google.com; s=arc-20160816; b=SkjQXCkQzpSWkhRAqQopNUPmjCiOqm7yBieegrupgOgzTp5VQLBbTs5VPHLRI5SnSH +rCd4qNeUZZs1dBpU/zriZOvm9IcBkE1hD6VXIgUD1XnWzGTPCCbgJMXyXn0Sb6DcqG1 zcP1YXE6U15qfO1m/LkVmUL1LL9RPsjsr2Y/Pwbqhx7tEHHF4/OQNC6PnfccjAthlWAS M/9G+kXoLYEEPbvtdZZQK/MYe+DMufi6IVXSJpioEXpzErpHvXT3no3yma7FKj4W+Qp/ b1u2gzZBlcNqhsYf/yKhBPMS+cR2kw+/B902OejzD4fn7ygIurQXMrkf4ns8+s7xF4y5 Mi+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LGjEWJ85I6MBWiAeTQPn+T7xmucHNDdjLRiW5/NHSDQ=; b=SLpndPl2SIC/dP1b4uCbXtsx71fg/Ym4iEHWiZpN6R83g55fth85VsH+0yogIisLZ/ Q+E7OwGzoZBnaBR/DJO228pD2lqfYF33PHbh8j9SaTFGq2K/CV3Y+ZG355Ay8JSsYHqs 9HE8Gi8+hkD6vCQ+2Q3AoLd6V07a/2/gS2jGmn1rEsiy1bmSh8crwfAU8DlmfIcadukg rIIzq7/BL+oBljhbuxnozEnrf2jt0Dlgwcl5FIo+bCQSmjaY+kGMwOoaKtIKi6rDYFQD g3ZxKJn/TqDL3eM0a8Ws5WQAVWomGqSfyH+KsJpkgFWmHoazYj9VtlVL4IHoS9F2Nu7u hAOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=O4Y9rGej; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg3-20020a1709072cc300b007811ace1701si10409199ejc.445.2022.11.28.22.48.43; Mon, 28 Nov 2022 22:49:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=O4Y9rGej; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbiK2GqU (ORCPT + 99 others); Tue, 29 Nov 2022 01:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbiK2GqH (ORCPT ); Tue, 29 Nov 2022 01:46:07 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2081.outbound.protection.outlook.com [40.107.14.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32D4537CF; Mon, 28 Nov 2022 22:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hylUi2rjvIAV/ZiGDiXtzaJlE/vJaNMmOrjFhn92hAzTfE8jwJ5P8o+2DXWwDgi9cRyahdj0ZzuUB0HsCe9ssFwD2Wq+lcaAV1WHCCiw8zaZbBVRESISKbFYul003pUa2cWSbVZsQj3Dt2XUEXDcjwrh6fmGqyUB6tPL8t+zt2pgBJ9GowvSoznM0O47s8x0AkTptMEhWLr4iJr2RfyMSP0yWLA5rm6oN/jxc2MoWYGoh5MA2v08ArhyAwCgrrQ/ZHoHJNia/laUXovYQzrhlBZ8hesGd6jU8LcG3P+KVE5zxCRE1GLVcCfQtbo8HqyvrGJnBEHklpu4Ji3pWXZ7jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LGjEWJ85I6MBWiAeTQPn+T7xmucHNDdjLRiW5/NHSDQ=; b=HmHTkUdKJqsG5315fEou7QByCfI+KdAc3iAvmNPl80FFiXVFAIEFwkM7Z3h4RRKfjiQ6ersQz7X56u5iWzaVUKuQNsJsEVDHojM2DXZhyGZQN+BjdcpeD0UqspZXuwVCrG1lr4GpvqZjYoVaxTwFwi+ClOK7HehWJOWjki7XmbVkAJMsrq0rrnwAAANbWyKWG4/Qlo6+po9v8FvykJpzyiyFUXFpiJ72LIeKUuoz5W/fb3fo7e6o9/9cRZZLSAy/xHJb6V+zUBqnnXsn8aXOLBr9Con5udV3cyuYX6mBWmdo6Wo5LqQJDSkk7r2JQ0A7o485exscuPQOGFYPA8iysA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LGjEWJ85I6MBWiAeTQPn+T7xmucHNDdjLRiW5/NHSDQ=; b=O4Y9rGej5S3Ieklvrq/XdTAzpfL4uc+nukhyobwkuEfFQXJonJsKbUlie1FVZMQuXSaLjStp1esqkPRm6dZB6nNwMVOw9w2MQZsD54AI/Zvz1NjfCeeYqRVxUv/Iyz1hJWXCaClbTvr+uvQMhfQZLxiAJQV41s/NPwmP38/dDXE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) by AS4PR08MB7685.eurprd08.prod.outlook.com (2603:10a6:20b:504::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8; Tue, 29 Nov 2022 06:46:02 +0000 Received: from VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454]) by VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454%6]) with mapi id 15.20.5880.008; Tue, 29 Nov 2022 06:46:02 +0000 From: Gerald Loacker To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Jakob Hauser , Linus Walleij , Nikita Yushchenko , Michael Riesch , Gerald Loacker Subject: [PATCH v4 3/3] iio: magnetometer: add ti tmag5273 driver Date: Tue, 29 Nov 2022 07:45:40 +0100 Message-Id: <20221129064540.3218982-4-gerald.loacker@wolfvision.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> References: <20221129064540.3218982-1-gerald.loacker@wolfvision.net> X-ClientProxiedBy: VI1PR10CA0107.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:28::36) To VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB4544:EE_|AS4PR08MB7685:EE_ X-MS-Office365-Filtering-Correlation-Id: 10d363e2-59fc-40cb-ef41-08dad1d561d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cxcwwnwledMBHB/79XT/LLUibf3wWRb+Bktg6zE7OqaO7qxNN++/l2tVviF4IUgZAlUSn5sOUB7P3uRXEkgpLk4fZ1TneoNu0x+uM6uTxIl2iP2zM7bzQywUXPkDc1kmA+WQXNGYj9j5LWemfYvlnLiLX3QU5vN2Jk9AwXjiaCjW7gyAeD/Eb64V0LIX+qmoQQ5fBdvscBa9BIMORiHWr40FbCjJmtT+NrQbDuxWYJHmzK8aXfnLw84SvFwejsqMsJBD+AARB9SPaMrxVabaJ8aPsd++sFjnR+l816E3t9FHAZ32Ckg4bD04ciUVtELJpcPM/EhbkND3uo2iQ81Phqjln4oD1lJX+5f/esxlRj2Xd1z0ys1IojW2SVrOromkkxlO2kns6nhHeNWq5jJ9+I49/6f7sIZwKZDX2odm6UeIEluNB6qTet7Nie+2YV4UFpeoQciSBmV0S1Sh4f0Dq330OjUt3afMOauKakgdhKum695CUIy+TkwLXTmSlzI7lOEVgabzC+RIlpZ4TPXV326sG8ENoxMxLNaFtonf2oIc1CWjxoMYqeKjmZhpHXond2xcdTcQF8jx4zay5QsEHK+KHN+p+q2zzCSYa9Y0JfW0+W67RbaP+XR2chm695VfnO2MvRLkq2IOTq5Uahz2ZjRrtV2PWrWckM/y2gnInPkQta7paxLsVvdxoMoaWTTmG+7r1aRhiyAzExQddefb8F7QmbbVzZ5M4CftQE1B7ls= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB4544.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(376002)(136003)(346002)(39850400004)(396003)(451199015)(966005)(6506007)(6486002)(83380400001)(86362001)(52116002)(478600001)(107886003)(6666004)(36756003)(26005)(316002)(2616005)(41300700001)(8936002)(6512007)(1076003)(54906003)(5660300002)(7416002)(30864003)(44832011)(38350700002)(38100700002)(2906002)(66946007)(66556008)(4326008)(66476007)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rcOQekUAEGBEGzNLo5wKmkUx/dTo8apaICB/v+E6SFlLMk481I6wdvoGmJXtnFDDYOWNBuHH+SaQoOW4Bw20kip5JtzZkyu3wEcvt1a7/tIi4Tk+to5PjeNVnpD+EwhMQ6FG/mbYtgISANJ0ivwHGplbQyRIvFLjFgsfNEN7fh1lvcYpREq0CtYmbPypOJ/gSiHAEoja07uFowSsR6QbnA1/i9wb+NVnAes2/SqiYDdTEmRdK+ujS23mDrHIwL90uT2RogF3nbmhKcN/HRaLm7uUbimmQLevlxzg1P/1owLzqb9wVR6el3lx2ziuJzlgMhNc2hc/qatNEp9QKqty8jTqEqYPjXY5a2Ec6mPdD2INUvYBAlvz8HCtcPkCYJ+K2sGWAiHVuAKEMlBn5NgL/Y/BhVkcWFoW9fG4eRJv6Q41c3poAXqq4Oe0cuaXNeJjeftIwKnvCG/iOorA/E7r1BuEMkvx/4tkmZXS9sxvv0HZRsi2Fbw7fJOE84pIwL4ZFAnWBySDfCdoHurSanm6rAENWZbmhJ4q86UBDG97cAgZk6qDWeRDrUFAYuR3rbZw45fhIP7txKtFamsEHLkOuphpD7EdCuWONTymu/Gp6njL+TMavKBRGbPCRH/RIGYqU+6A48pkFAIVBhsGc0SKSunb4jlP1ksvmgc57uRimipAfZUl6iafo95Uk1uH4NrfWR4pbzJqFYaz0kpO/AvFAYPHpwuWQ0qcOHFLYznJksfg86EZfIh2rKYI34v2djontcuubRFLACQixK/ZHVAM7g5XDsH5P4xIETVhVCfNWfbxht/Dw5E/9qSxwXErQlru1giRZnF/bHOvWvwuVcVnVz2XHhNNo7UwuXBxA/vWKazzj5GMwrNTar0/mt6r8aIGA7Cpe02XoxN0W0efkT5n4G2aPaCzmyyNNifAKgSqVd8rtM7gwqHVywysKeW5831nvexVZf3bVfNcoBvaJi5cgpCo+rr9qpRQrQU4SGkp4/bDFvxrX4KPAXacMJWUwZ7T3Bo51lal7c4gs4P3CIk0gmKvCsckl9/lfl5vWa28VD98Wm9YaYB0+P0sVU/fQxTpIJxg/cy14UUrSv6H2po3/JvyNNQs19iJEh/Wh0RvMcumtoJ6SQ/QjXlSf0K8pJUBCW3E2hWWhC7MMc19vWL59Vtg/xXdweVvTWxdCYk90jdfwYfoDbnySjN0L46ZHXtsOCfdHp9Jucy/oy23+SedsD8LB0Olv90uWj23WDIu1r09fWIyMhrfIYXuDmvpRl0xha+PX2qR+t2qQ7FxmRmyNr0lPFeFYClMtXlXoy8y49gpHkvyG8WwXw+kXSFGG0AfqNok6EPn95daSlUGuRTnkcsVJxcwQBrmr5ivSyeP3LIq9TNIbwABoMOr7kgQyvoOXOg+9adr1dCr6xkon9cA1K36ONAMMn3bvT+5sr4TmBkyc5l0rq2YaZWalVJg/4U6E+dFAGN0jouuHv8a/EW8budv3KjvsSLsJgGmjvD48u5XdnDCPIaSMjbROMJzeyaZMppxol+W/iZDbj8yOX2fEgidT6EE2WjcQaGx3FNck1j5YtwPyh1SM/1j8l7fGtlBPPi48PxFiwvP4XzI1Y65nA== X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 10d363e2-59fc-40cb-ef41-08dad1d561d1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR08MB4544.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 06:46:02.7296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZU6Oq/klHzMTOiMFikgFFFD3zmiJZnATnbnWaCZSl8pgXpdb9J2rJ/vzMfgRLl43chePLTY9NW/px6Hrn+JoD1GWmFJfHyGdrFzwNgL0BB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7685 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750812121864177181?= X-GMAIL-MSGID: =?utf-8?q?1750812121864177181?= Add support for TI TMAG5273 Low-Power Linear 3D Hall-Effect Sensor. Additionally to temperature and magnetic X, Y and Z-axes the angle and magnitude are reported. The sensor is operating in continuous measurement mode and changes to sleep mode if not used for 5 seconds. Datasheet: https://www.ti.com/lit/gpn/tmag5273 Signed-off-by: Gerald Loacker --- Changes in v4: - Renamed struct iio_val_int_plus_micro members - Simplified tmag5273_write_scale() - Removed unnecessary '!= 0' - Fixed regmap max_register - Simplified tmag5273_read_device_property() - Fixed some line breaks Changes in v3: - Added include | Reported-by: kernel test robot - Added include - Removed - Added missing "static const" for tmag5273_avg_table - Documented Device ID - Fixed index of tmag5273_scale definition - Clarify TMAG5273_MAG_CH_EN_X_Y_Z as an index - Removed unnecessary print - Introduced tmag5273_write_scale() and tmag5273_write_osr() helper functions - Use of match_string() - Format Changes in v2: - Implemented suggestions from review and cleaned up probe function. This results in changes all over the tmag5273.c code. MAINTAINERS | 1 + drivers/iio/magnetometer/Kconfig | 12 + drivers/iio/magnetometer/Makefile | 2 + drivers/iio/magnetometer/tmag5273.c | 731 ++++++++++++++++++++++++++++ 4 files changed, 746 insertions(+) create mode 100644 drivers/iio/magnetometer/tmag5273.c diff --git a/MAINTAINERS b/MAINTAINERS index ea7acec52f8b..9d20b5780051 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20618,6 +20618,7 @@ M: Gerald Loacker L: linux-iio@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/iio/magnetometer/ti,tmag5273.yaml +F: drivers/iio/magnetometer/tmag5273.c TI TRF7970A NFC DRIVER M: Mark Greer diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index b91fc5e6a26e..467819335588 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -208,6 +208,18 @@ config SENSORS_RM3100_SPI To compile this driver as a module, choose M here: the module will be called rm3100-spi. +config TI_TMAG5273 + tristate "TI TMAG5273 Low-Power Linear 3D Hall-Effect Sensor" + depends on I2C + select REGMAP_I2C + help + Say Y here to add support for the TI TMAG5273 Low-Power + Linear 3D Hall-Effect Sensor. + + This driver can also be compiled as a module. + To compile this driver as a module, choose M here: the module + will be called tmag5273. + config YAMAHA_YAS530 tristate "Yamaha YAS530 family of 3-Axis Magnetometers (I2C)" depends on I2C diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index b9f45b7fafc3..b1c784ea71c8 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -29,4 +29,6 @@ obj-$(CONFIG_SENSORS_RM3100) += rm3100-core.o obj-$(CONFIG_SENSORS_RM3100_I2C) += rm3100-i2c.o obj-$(CONFIG_SENSORS_RM3100_SPI) += rm3100-spi.o +obj-$(CONFIG_TI_TMAG5273) += tmag5273.o + obj-$(CONFIG_YAMAHA_YAS530) += yamaha-yas530.o diff --git a/drivers/iio/magnetometer/tmag5273.c b/drivers/iio/magnetometer/tmag5273.c new file mode 100644 index 000000000000..d3579004cb58 --- /dev/null +++ b/drivers/iio/magnetometer/tmag5273.c @@ -0,0 +1,731 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Driver for the TI TMAG5273 Low-Power Linear 3D Hall-Effect Sensor + * + * Copyright (C) 2022 WolfVision GmbH + * + * Author: Gerald Loacker + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define TMAG5273_DEVICE_CONFIG_1 0x00 +#define TMAG5273_DEVICE_CONFIG_2 0x01 +#define TMAG5273_SENSOR_CONFIG_1 0x02 +#define TMAG5273_SENSOR_CONFIG_2 0x03 +#define TMAG5273_X_THR_CONFIG 0x04 +#define TMAG5273_Y_THR_CONFIG 0x05 +#define TMAG5273_Z_THR_CONFIG 0x06 +#define TMAG5273_T_CONFIG 0x07 +#define TMAG5273_INT_CONFIG_1 0x08 +#define TMAG5273_MAG_GAIN_CONFIG 0x09 +#define TMAG5273_MAG_OFFSET_CONFIG_1 0x0A +#define TMAG5273_MAG_OFFSET_CONFIG_2 0x0B +#define TMAG5273_I2C_ADDRESS 0x0C +#define TMAG5273_DEVICE_ID 0x0D +#define TMAG5273_MANUFACTURER_ID_LSB 0x0E +#define TMAG5273_MANUFACTURER_ID_MSB 0x0F +#define TMAG5273_T_MSB_RESULT 0x10 +#define TMAG5273_T_LSB_RESULT 0x11 +#define TMAG5273_X_MSB_RESULT 0x12 +#define TMAG5273_X_LSB_RESULT 0x13 +#define TMAG5273_Y_MSB_RESULT 0x14 +#define TMAG5273_Y_LSB_RESULT 0x15 +#define TMAG5273_Z_MSB_RESULT 0x16 +#define TMAG5273_Z_LSB_RESULT 0x17 +#define TMAG5273_CONV_STATUS 0x18 +#define TMAG5273_ANGLE_RESULT_MSB 0x19 +#define TMAG5273_ANGLE_RESULT_LSB 0x1A +#define TMAG5273_MAGNITUDE_RESULT 0x1B +#define TMAG5273_DEVICE_STATUS 0x1C + +#define TMAG5273_AUTOSLEEP_DELAY_MS 5000 +#define TMAG5273_MAX_AVERAGE 32 + +/* + * bits in the TMAG5273_MANUFACTURER_ID_LSB / MSB register + * 16-bit unique manufacturer ID 0x49 / 0x54 = "TI" + */ +#define TMAG5273_MANUFACTURER_ID 0x5449 + +/* bits in the TMAG5273_DEVICE_CONFIG_1 register */ +#define TMAG5273_AVG_MODE_MASK GENMASK(4, 2) +#define TMAG5273_AVG_1_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 0) +#define TMAG5273_AVG_2_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 1) +#define TMAG5273_AVG_4_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 2) +#define TMAG5273_AVG_8_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 3) +#define TMAG5273_AVG_16_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 4) +#define TMAG5273_AVG_32_MODE FIELD_PREP(TMAG5273_AVG_MODE_MASK, 5) + +/* bits in the TMAG5273_DEVICE_CONFIG_2 register */ +#define TMAG5273_OP_MODE_MASK GENMASK(1, 0) +#define TMAG5273_OP_MODE_STANDBY FIELD_PREP(TMAG5273_OP_MODE_MASK, 0) +#define TMAG5273_OP_MODE_SLEEP FIELD_PREP(TMAG5273_OP_MODE_MASK, 1) +#define TMAG5273_OP_MODE_CONT FIELD_PREP(TMAG5273_OP_MODE_MASK, 2) +#define TMAG5273_OP_MODE_WAKEUP FIELD_PREP(TMAG5273_OP_MODE_MASK, 3) + +/* bits in the TMAG5273_SENSOR_CONFIG_1 register */ +#define TMAG5273_MAG_CH_EN_MASK GENMASK(7, 4) +#define TMAG5273_MAG_CH_EN_X_Y_Z 7 + +/* bits in the TMAG5273_SENSOR_CONFIG_2 register */ +#define TMAG5273_Z_RANGE_MASK BIT(0) +#define TMAG5273_X_Y_RANGE_MASK BIT(1) +#define TMAG5273_ANGLE_EN_MASK GENMASK(3, 2) +#define TMAG5273_ANGLE_EN_OFF 0 +#define TMAG5273_ANGLE_EN_X_Y 1 +#define TMAG5273_ANGLE_EN_Y_Z 2 +#define TMAG5273_ANGLE_EN_X_Z 3 + +/* bits in the TMAG5273_T_CONFIG register */ +#define TMAG5273_T_CH_EN BIT(0) + +/* bits in the TMAG5273_DEVICE_ID register */ +#define TMAG5273_VERSION_MASK GENMASK(1, 0) + +/* bits in the TMAG5273_CONV_STATUS register */ +#define TMAG5273_CONV_STATUS_COMPLETE BIT(0) + +enum tmag5273_channels { + TEMPERATURE = 0, + AXIS_X, + AXIS_Y, + AXIS_Z, + ANGLE, + MAGNITUDE, +}; + +enum tmag5273_scale_index { + MAGN_RANGE_LOW = 0, + MAGN_RANGE_HIGH, + MAGN_RANGE_NUM +}; + +/* state container for the TMAG5273 driver */ +struct tmag5273_data { + struct device *dev; + unsigned int devid; + unsigned int version; + char name[16]; + unsigned int conv_avg; + unsigned int scale; + enum tmag5273_scale_index scale_index; + unsigned int angle_measurement; + struct regmap *map; + struct regulator *vcc; + + /* + * Locks the sensor for exclusive use during a measurement (which + * involves several register transactions so the regmap lock is not + * enough) so that measurements get serialized in a + * first-come-first-serve manner. + */ + struct mutex lock; +}; + +static const char *const tmag5273_angle_names[] = { "off", "x-y", "y-z", "x-z" }; + +/* + * Averaging enables additional sampling of the sensor data to reduce the noise + * effect, but also increases conversion time. + */ +static const unsigned int tmag5273_avg_table[] = { + 1, 2, 4, 8, 16, 32, +}; + +/* + * Magnetic resolution in Gauss for different TMAG5273 versions. + * Scale[Gauss] = Range[mT] * 1000 / 2^15 * 10, (1 mT = 10 Gauss) + * Only version 1 and 2 are valid, version 0 and 3 are reserved. + */ +static const struct iio_val_int_plus_micro tmag5273_scale[][MAGN_RANGE_NUM] = { + { { 0, 0 }, { 0, 0 } }, + { { 0, 12200 }, { 0, 24400 } }, + { { 0, 40600 }, { 0, 81200 } }, + { { 0, 0 }, { 0, 0 } }, +}; + +static int tmag5273_get_measure(struct tmag5273_data *data, s16 *t, s16 *x, + s16 *y, s16 *z, u16 *angle, u16 *magnitude) +{ + unsigned int status, val; + __be16 reg_data[4]; + int ret; + + mutex_lock(&data->lock); + + /* + * Max. conversion time is 2425 us in 32x averaging mode for all three + * channels. Since we are in continuous measurement mode, a measurement + * may already be there, so poll for completed measurement with + * timeout. + */ + ret = regmap_read_poll_timeout(data->map, TMAG5273_CONV_STATUS, status, + status & TMAG5273_CONV_STATUS_COMPLETE, + 100, 10000); + if (ret) { + dev_err_probe(data->dev, ret, + "timeout waiting for measurement\n"); + goto out_unlock; + } + + ret = regmap_bulk_read(data->map, TMAG5273_T_MSB_RESULT, reg_data, + sizeof(reg_data)); + if (ret) + goto out_unlock; + *t = be16_to_cpu(reg_data[0]); + *x = be16_to_cpu(reg_data[1]); + *y = be16_to_cpu(reg_data[2]); + *z = be16_to_cpu(reg_data[3]); + + ret = regmap_bulk_read(data->map, TMAG5273_ANGLE_RESULT_MSB, + ®_data[0], sizeof(reg_data[0])); + if (ret) + goto out_unlock; + /* + * angle has 9 bits integer value and 4 bits fractional part + * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + * 0 0 0 a a a a a a a a a f f f f + */ + *angle = be16_to_cpu(reg_data[0]); + + ret = regmap_read(data->map, TMAG5273_MAGNITUDE_RESULT, &val); + if (ret < 0) + goto out_unlock; + *magnitude = val; + +out_unlock: + mutex_unlock(&data->lock); + return ret; +} + +static int tmag5273_write_osr(struct tmag5273_data *data, int val) +{ + int i; + + if (val == data->conv_avg) + return 0; + + for (i = 0; i < ARRAY_SIZE(tmag5273_avg_table); i++) { + if (tmag5273_avg_table[i] == val) + break; + } + if (i == ARRAY_SIZE(tmag5273_avg_table)) + return -EINVAL; + data->conv_avg = val; + + return regmap_update_bits(data->map, TMAG5273_DEVICE_CONFIG_1, + TMAG5273_AVG_MODE_MASK, + FIELD_PREP(TMAG5273_AVG_MODE_MASK, i)); +} + +static int tmag5273_write_scale(struct tmag5273_data *data, int scale_micro) +{ + u32 value; + int i; + + for (i = 0; i < ARRAY_SIZE(tmag5273_scale[0]); i++) { + if (tmag5273_scale[data->version][i].micro == scale_micro) + break; + } + if (i == ARRAY_SIZE(tmag5273_scale[0])) + return -EINVAL; + data->scale_index = i; + + if (data->scale_index == MAGN_RANGE_LOW) + value = 0; + else + value = TMAG5273_Z_RANGE_MASK | TMAG5273_X_Y_RANGE_MASK; + + return regmap_update_bits(data->map, TMAG5273_SENSOR_CONFIG_2, + TMAG5273_Z_RANGE_MASK | TMAG5273_X_Y_RANGE_MASK, value); +} + +static int tmag5273_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct tmag5273_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *vals = tmag5273_avg_table; + *type = IIO_VAL_INT; + *length = ARRAY_SIZE(tmag5273_avg_table); + return IIO_AVAIL_LIST; + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_MAGN: + *type = IIO_VAL_INT_PLUS_MICRO; + *vals = (int *)tmag5273_scale[data->version]; + *length = ARRAY_SIZE(tmag5273_scale[data->version]) * + MAGN_RANGE_NUM; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +static int tmag5273_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, int *val, + int *val2, long mask) +{ + struct tmag5273_data *data = iio_priv(indio_dev); + s16 t, x, y, z; + u16 angle, magnitude; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + case IIO_CHAN_INFO_RAW: + ret = pm_runtime_resume_and_get(data->dev); + if (ret < 0) + return ret; + + ret = tmag5273_get_measure(data, &t, &x, &y, &z, &angle, &magnitude); + if (ret) + return ret; + + pm_runtime_mark_last_busy(data->dev); + pm_runtime_put_autosuspend(data->dev); + + switch (chan->address) { + case TEMPERATURE: + *val = t; + return IIO_VAL_INT; + case AXIS_X: + *val = x; + return IIO_VAL_INT; + case AXIS_Y: + *val = y; + return IIO_VAL_INT; + case AXIS_Z: + *val = z; + return IIO_VAL_INT; + case ANGLE: + *val = angle; + return IIO_VAL_INT; + case MAGNITUDE: + *val = magnitude; + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_TEMP: + /* + * Convert device specific value to millicelsius. + * Resolution from the sensor is 60.1 LSB/celsius and + * the reference value at 25 celsius is 17508 LSBs. + */ + *val = 10000; + *val2 = 601; + return IIO_VAL_FRACTIONAL; + case IIO_MAGN: + /* Magnetic resolution in uT */ + *val = 0; + *val2 = tmag5273_scale[data->version] + [data->scale_index].micro; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_ANGL: + /* + * Angle is in degrees and has four fractional bits, + * therefore use 1/16 * pi/180 to convert to radiants. + */ + *val = 1000; + *val2 = 916732; + return IIO_VAL_FRACTIONAL; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_OFFSET: + switch (chan->type) { + case IIO_TEMP: + *val = -266314; + return IIO_VAL_INT; + default: + return -EINVAL; + } + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *val = data->conv_avg; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + +static int tmag5273_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, + int val2, long mask) +{ + struct tmag5273_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + return tmag5273_write_osr(data, val); + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_MAGN: + if (val) + return -EINVAL; + return tmag5273_write_scale(data, val2); + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +#define TMAG5273_AXIS_CHANNEL(axis, index) \ + { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type_available = \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .info_mask_shared_by_all_available = \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ + .address = index, \ + .scan_index = index, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ + } + +static const struct iio_chan_spec tmag5273_channels[] = { + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + .address = TEMPERATURE, + .scan_index = TEMPERATURE, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_CPU, + }, + }, + TMAG5273_AXIS_CHANNEL(X, AXIS_X), + TMAG5273_AXIS_CHANNEL(Y, AXIS_Y), + TMAG5273_AXIS_CHANNEL(Z, AXIS_Z), + { + .type = IIO_ANGL, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .info_mask_shared_by_all_available = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .address = ANGLE, + .scan_index = ANGLE, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_CPU, + }, + }, + { + .type = IIO_DISTANCE, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_all = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .info_mask_shared_by_all_available = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + .address = MAGNITUDE, + .scan_index = MAGNITUDE, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(6), +}; + +static const struct iio_info tmag5273_info = { + .read_avail = &tmag5273_read_avail, + .read_raw = &tmag5273_read_raw, + .write_raw = &tmag5273_write_raw, +}; + +static bool tmag5273_volatile_reg(struct device *dev, unsigned int reg) +{ + return reg >= TMAG5273_T_MSB_RESULT && reg <= TMAG5273_MAGNITUDE_RESULT; +} + +static const struct regmap_config tmag5273_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = TMAG5273_DEVICE_STATUS, + .volatile_reg = tmag5273_volatile_reg, +}; + +static int tmag5273_set_operating_mode(struct tmag5273_data *data, + unsigned int val) +{ + return regmap_write(data->map, TMAG5273_DEVICE_CONFIG_2, val); +} + +static void tmag5273_read_device_property(struct tmag5273_data *data) +{ + struct device *dev = data->dev; + const char *str; + int ret; + + data->angle_measurement = TMAG5273_ANGLE_EN_X_Y; + + ret = device_property_read_string(dev, "ti,angle-measurement", &str); + if (ret) + return; + + ret = match_string(tmag5273_angle_names, + ARRAY_SIZE(tmag5273_angle_names), str); + if (ret < 0) + dev_warn(dev, "unexpected read angle-measurement property: %s\n", str); + else + data->angle_measurement = ret; +} + +static int tmag5273_chip_init(struct tmag5273_data *data) +{ + int ret; + + ret = regmap_write(data->map, TMAG5273_DEVICE_CONFIG_1, + TMAG5273_AVG_32_MODE); + if (ret) + return ret; + data->conv_avg = 32; + + ret = regmap_write(data->map, TMAG5273_DEVICE_CONFIG_2, + TMAG5273_OP_MODE_CONT); + if (ret) + return ret; + + ret = regmap_write(data->map, TMAG5273_SENSOR_CONFIG_1, + FIELD_PREP(TMAG5273_MAG_CH_EN_MASK, + TMAG5273_MAG_CH_EN_X_Y_Z)); + if (ret) + return ret; + + ret = regmap_write(data->map, TMAG5273_SENSOR_CONFIG_2, + FIELD_PREP(TMAG5273_ANGLE_EN_MASK, + data->angle_measurement)); + if (ret) + return ret; + data->scale_index = MAGN_RANGE_LOW; + + return regmap_write(data->map, TMAG5273_T_CONFIG, TMAG5273_T_CH_EN); +} + +static int tmag5273_wake_up_and_check_device_id(struct tmag5273_data *data) +{ + __le16 devid; + int val, ret; + + /* + * If we come from sleep with power already activated, the + * first I2C command wakes up the chip but will fail. + * Time to go to stand-by mode from sleep mode is 50us + * typically. During this time no I2C access is possible. + */ + regmap_read(data->map, TMAG5273_DEVICE_ID, &val); + usleep_range(80, 200); + ret = regmap_read(data->map, TMAG5273_DEVICE_ID, &val); + if (ret) + return dev_err_probe(data->dev, ret, "failed to power on device\n"); + data->version = FIELD_PREP(TMAG5273_VERSION_MASK, val); + + ret = regmap_bulk_read(data->map, TMAG5273_MANUFACTURER_ID_LSB, &devid, + sizeof(devid)); + if (ret) + return dev_err_probe(data->dev, ret, "failed to read device ID\n"); + data->devid = le16_to_cpu(devid); + + switch (data->devid) { + case TMAG5273_MANUFACTURER_ID: + snprintf(data->name, sizeof(data->name), "tmag5273x%1u", data->version); + if (data->version < 1 || data->version > 2) + dev_warn(data->dev, "Unsupported device %s\n", data->name); + return 0; + default: + dev_warn(data->dev, "Unknown device ID 0x%x\n", data->devid); + return 0; + } +} + +static void tmag5273_power_down(void *data) +{ + tmag5273_set_operating_mode(data, TMAG5273_OP_MODE_SLEEP); +} + +static int tmag5273_probe(struct i2c_client *i2c) +{ + struct device *dev = &i2c->dev; + struct tmag5273_data *data; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + data->dev = dev; + i2c_set_clientdata(i2c, indio_dev); + + data->map = devm_regmap_init_i2c(i2c, &tmag5273_regmap_config); + if (IS_ERR(data->map)) + return dev_err_probe(dev, PTR_ERR(data->map), + "failed to allocate register map\n"); + + mutex_init(&data->lock); + + ret = devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "failed to enable regulator\n"); + + ret = tmag5273_wake_up_and_check_device_id(data); + if (ret) + return ret; + + ret = tmag5273_set_operating_mode(data, TMAG5273_OP_MODE_CONT); + if (ret) + return dev_err_probe(dev, ret, "failed to power on device\n"); + + /* + * Register powerdown deferred callback which suspends the chip + * after module unloaded. + * + * TMAG5273 should be in SUSPEND mode in the two cases: + * 1) When driver is loaded, but we do not have any data or + * configuration requests to it (we are solving it using + * autosuspend feature). + * 2) When driver is unloaded and device is not used (devm action is + * used in this case). + */ + ret = devm_add_action_or_reset(dev, tmag5273_power_down, data); + if (ret) + return dev_err_probe(dev, ret, "failed to add powerdown action\n"); + + ret = pm_runtime_set_active(dev); + if (ret < 0) + return ret; + + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; + + pm_runtime_get_noresume(dev); + pm_runtime_set_autosuspend_delay(dev, TMAG5273_AUTOSLEEP_DELAY_MS); + pm_runtime_use_autosuspend(dev); + + tmag5273_read_device_property(data); + + ret = tmag5273_chip_init(data); + if (ret) + return dev_err_probe(dev, ret, "failed to init device\n"); + + indio_dev->info = &tmag5273_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->name = data->name; + indio_dev->channels = tmag5273_channels; + indio_dev->num_channels = ARRAY_SIZE(tmag5273_channels); + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "device register failed\n"); + + return 0; +} + +static int tmag5273_runtime_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct tmag5273_data *data = iio_priv(indio_dev); + int ret; + + ret = tmag5273_set_operating_mode(data, TMAG5273_OP_MODE_SLEEP); + if (ret) + dev_err(dev, "failed to power off device (%pe)\n", ERR_PTR(ret)); + + return ret; +} + +static int tmag5273_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct tmag5273_data *data = iio_priv(indio_dev); + int ret; + + /* + * Time to go to stand-by mode from sleep mode is 50us + * typically. During this time no I2C access is possible. + */ + tmag5273_set_operating_mode(data, TMAG5273_OP_MODE_CONT); + usleep_range(80, 200); + ret = tmag5273_set_operating_mode(data, TMAG5273_OP_MODE_CONT); + if (ret) + dev_err(dev, "failed to power on device (%pe)\n", ERR_PTR(ret)); + + return ret; +} + +static DEFINE_RUNTIME_DEV_PM_OPS(tmag5273_pm_ops, tmag5273_runtime_suspend, + tmag5273_runtime_resume, NULL); + +static const struct i2c_device_id tmag5273_id[] = { + { "tmag5273" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, tmag5273_id); + +static const struct of_device_id tmag5273_of_match[] = { + { .compatible = "ti,tmag5273" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, tmag5273_of_match); + +static struct i2c_driver tmag5273_driver = { + .driver = { + .name = "tmag5273", + .of_match_table = tmag5273_of_match, + .pm = pm_ptr(&tmag5273_pm_ops), + }, + .probe_new = tmag5273_probe, + .id_table = tmag5273_id, +}; +module_i2c_driver(tmag5273_driver); + +MODULE_DESCRIPTION("TI TMAG5273 Low-Power Linear 3D Hall-Effect Sensor driver"); +MODULE_AUTHOR("Gerald Loacker "); +MODULE_LICENSE("GPL");