From patchwork Fri Jul 13 11:50:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mircea Caprioru X-Patchwork-Id: 10523127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D65D7602A0 for ; Fri, 13 Jul 2018 12:06:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3C6C29AA4 for ; Fri, 13 Jul 2018 12:06:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B794929AA9; Fri, 13 Jul 2018 12:06:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF25529AB7 for ; Fri, 13 Jul 2018 12:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729751AbeGMMUY (ORCPT ); Fri, 13 Jul 2018 08:20:24 -0400 Received: from mail-eopbgr710042.outbound.protection.outlook.com ([40.107.71.42]:21224 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729699AbeGMMUY (ORCPT ); Fri, 13 Jul 2018 08:20:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RwjfC1G6Vr6enu8tBYt1rWKRbR35hwtSnRQ1vz2zFkE=; b=UsYP5HmKmFAitx1ef6Dw9Fu49+s5Z5o/vcdB0Xxn4itEsDl5Ex26JwvA4DdG86nvafsj5HB0PG3UgID1ukPUUIMZDq9N+HNFiva+oSBpoKVUfPaygAfNKRLLw/hsRODm6ki/5HqcehTIpFm1MsniKF76Cf1/J+wrcuEWkCBs9Dg= Received: from MWHPR03CA0005.namprd03.prod.outlook.com (2603:10b6:300:117::15) by BN6PR03MB3121.namprd03.prod.outlook.com (2603:10b6:405:3c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Fri, 13 Jul 2018 11:50:53 +0000 Received: from BL2FFO11FD023.protection.gbl (2a01:111:f400:7c09::121) by MWHPR03CA0005.outlook.office365.com (2603:10b6:300:117::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.952.19 via Frontend Transport; Fri, 13 Jul 2018 11:50:52 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2FFO11FD023.mail.protection.outlook.com (10.173.161.102) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.906.21 via Frontend Transport; Fri, 13 Jul 2018 11:50:52 +0000 Received: from NWD2HUBCAS8.ad.analog.com (nwd2hubcas8.ad.analog.com [10.64.69.108]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id w6DBoqDe027583 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 13 Jul 2018 04:50:52 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS8.ad.analog.com (10.64.69.108) with Microsoft SMTP Server id 14.3.301.0; Fri, 13 Jul 2018 07:50:51 -0400 Received: from mircea-Latitude-E6540.analog.com ([10.50.1.102]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w6DBonuX017358; Fri, 13 Jul 2018 07:50:50 -0400 From: Mircea Caprioru To: , , , CC: , Mircea Caprioru Subject: [PATCH] iio: adxl345: Add support for the ADXL375 Date: Fri, 13 Jul 2018 14:50:44 +0300 Message-ID: <20180713115044.32301-1-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39860400002)(346002)(376002)(136003)(2980300002)(438002)(199004)(189003)(53416004)(6306002)(106466001)(476003)(126002)(2616005)(110136005)(16586007)(186003)(486006)(336012)(44832011)(478600001)(966005)(47776003)(72206003)(106002)(316002)(54906003)(1857600001)(4326008)(426003)(51416003)(5660300001)(39060400002)(8936002)(50466002)(2906002)(86362001)(36756003)(2201001)(246002)(48376002)(7636002)(8676002)(26005)(77096007)(305945005)(356003)(1076002)(107886003)(6666003)(50226002)(7696005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB3121; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD023; 1:2b7eTiFayCzAmGPlrnrnqr5/bhPPn9RKs6zwmmdK9sNXVNTspTwLYmGSuia8IdMbFGvEhZ7gdyOlOl2xEUA2llV8BVn4o6pb9quRkeHcy6m5VUDXJ48d0D76qeD03gEX X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4d1585f-6209-48a4-5da8-08d5e8b6e28b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:BN6PR03MB3121; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3121; 3:KwixR4I4RY5AJHj4wFweOEt9s0nmWQ3aQvAhsnLOsWMyvPk+m1x42m6THamxXIfgVBmhcAecm45iYY1PJWvqOTh+GFZGfJVuNl8IiDvM0V0Jxt5FNzieA5LBNYKZ9uzDSe3zRV4JDhZkiumbyR8OLsdmziZhvzhVjFDM4SLsrvTgzxgFJZEdFG19OCTOQAo5K//B/0QJvhZLRhsmWl2U7IqyQd6Xy/TKT+nGRR8AiOsHZDpaXkH7XvAOSBVBz69Q04asiLAgrdTr6FtWOQaIAis4xdsS85Ql12TDgcTnMjU/lpdBGXZaGQO9NTshdLUIS+iSHj5tZGhC+qJGfVdJRdlCi6N1cPIIiE/vD6m/hMA=; 25:PGq+0p9BPfutQ/04i7/p3/82ZAz8ybUK1fabyXRR4EAUED9uc+C/TZ76Eflwdtv9/9eELPsBcE/rAPRJ0GfVnZJLKtD+F58c08Z9ilaJCO9Utd3De6s2kVZdKp3G/rYig0BfdcS4rHrF0Kn/LDTSUQ8f0NO9XJwGrR2+6y98rDKkuAFvfQlj8yjnlJ+/ovrzeK9LCEq36+P4i8Zy/vWLvXyxvx/X05vAkjmMBJISeLsUif2k6lan9PGkFwkKviedWys3NVHKv7aylo9jigx94Hcgz9lSZ4gJ93OFpm+biG1fWvptHN7uiqe5WeGXbBYWLEC6Bl+6X1ZxyMOzqqPuCg== X-MS-TrafficTypeDiagnostic: BN6PR03MB3121: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3121; 31:4HkSfv1SocK1NE1nI0/OKRHCPzHbB83GSm4rFMiGaEyJ0a/v2ac0G+uKWeLpzp0Me5qNXbgs5SqKAFp6oBKeu7mgR8gcBDaDQXDE/SqjYRUTQXa90tj9k944C+wqpPSekGZHvEiWX+StFH/Ux0qWKwxUYN3Tyomvh9bhZYG4tChYAC6hMY/qqCXtGZZCjPqxcVqHYq2tJHZZvlHUhEnhqQiuY6Tf1+eSk5dUj26wz0Q=; 20:0jLJk9cGzvSVctfrJICSPm3Sw2KsYhkJCacN3bbQUVoX8GhrIU+fVk15QfDPMc8lY3ivoXlbUwlQ9Ragxez7nxUaMbRx16pPFmqIMl6f0s0gFSQozQOZGHf85Pl3EJsVemLl6cUg7kw1qAandx/7JrBxk5p90VhGMaWKU0PCbCmdc7WZ/PLqZAiAd5LYGg9C630hJUYfs7WoLYtR4xOM1LzrFiPSqByMQXwcN+QMbM1Ffvj2gHCQuwfb8BIDt4HCw11jJGhbaJIyOwhHjCiRmVo4VScdhUnr3mWf0UcDvoKIhKJOIJdHTht+L9sHPsf5Kqoiw7UJEm3biIgpGtC7AD8J7iB910nK8UgwyWUMwEUO0Zsc2AGE+A/7hp6MpF7IaTB5m3bT0KOi222hItT8o25lYYqTYhmd9qwnn12+77YjXak2+d+PcTlU0Gj9dC5rUZKpdOZlWbci4g2S34vT96Oyocgedgfd/GbrPqtbKjAapN7+iepHRBnFmT1JzL4x X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(270121546159015)(232431446821674); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(10201501046)(93006095)(93004095)(3002001)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:BN6PR03MB3121; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB3121; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3121; 4:Nct8Y26hdbkHOBmhtpJOZFfJDn5o8J0qKQ3/5+MAykM3zFfd0n585twyzfYGSevqSilbxR9YpiUkkRHN5oNwLaGkxv1yvxnm6jy/WZom1w9mLehvXgl7M4i7FrcvGelVou+ikZiSfCQ1FosWaMXWbQR8wX6bvGtzqVjJszmjCyknc3qCRNkx0pbfpjZBO41GA6Zlin2hk7MZJ29y97nfxScrvc7oUS+Ugevt3OPyXQ6EoTdJ5nI/LHG5FavM8zus55pkarNgNzU/8X5jG5yV6Jx9LWe11GPmL/nJa2t/BGvOUH/DbeM2MoUgsn4LiY70Vtgg74RZciAzihyABPn5qw== X-Forefront-PRVS: 07326CFBC4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB3121; 23:klhcuCYF37tuwfse5sSy4aF5CLpChoYX54efcGSDN?= =?us-ascii?Q?H7KqxexLeixUVcmR96JR72NHVYrOgdl87TtKqx8hItySyoU6fHp47UC/X6uh?= =?us-ascii?Q?UulC7suV4hg/ZZeESlY6lIBpGQcav5FgqCyGcMWYVHq1BSzcr8Ss2b3WLf89?= =?us-ascii?Q?wlPBNhw9Ec8phsX/EXCvz5S8Tk/qRTxEcM0TOpsu9EkAITk1ybY1mX6kwPCo?= =?us-ascii?Q?NZqVDA7IAguH30tSWNI5UgfBWf6M1J0+krRPHr2Ka+6Op6rVYvWip2lr0TVa?= =?us-ascii?Q?ua4ffQpU7o3zNLdU49QsQhEPF36+m48B65sjGZyGC2O6tO7aM1GbuEB1JWWJ?= =?us-ascii?Q?FqakPKIFsohwLuZs30QdEanWeGz4farjgCQ6KeFOlG+GTKqeyPpwAkXvuNif?= =?us-ascii?Q?Us6FigYUXMpBImJLp9hwXIKMPBqJNU9tdKacHk1YBCS/9mAf2G9vCaWQ496m?= =?us-ascii?Q?pStRbqpxNomTLbUs9X7ZEnHk8uceBDxGI2O/WPFFBMMbf0VE2JG+M1kEZL2W?= =?us-ascii?Q?ViBxW1cBg7w8P7lek0T8WszP3yLE/iRUPbFR4mGvBxxLgeq4pXmOnstUS1hn?= =?us-ascii?Q?T3UIRIDjZIFdAc60Jn3/jzkgQX0bEdqjVp6TofpuZZ8J+eUw56aRfjaNiNws?= =?us-ascii?Q?gDHsdGxiFAUj2wUC8LDlpMc39Ea61pSPUw5ixJlekRzyKPcUOMoEnVN/crsw?= =?us-ascii?Q?q2L7IAlErBe1Iwcnr+jJei04fyblvsbUsIIfKi7kZVTaMrR9y0nUOQ1KTzXP?= =?us-ascii?Q?rFrf2lXc0/zmf4Fo1Y3yvE4Vrr0O4hVlvY3SY2Jzt184AZXgznGOldGOrWCm?= =?us-ascii?Q?Pvr1wQnDN/m3LaAuOeHZgIU6uD7X1Q487KD5TGXSW5ssM8mI43YwjYBO3kkn?= =?us-ascii?Q?V7MYfSyEJK++NLc+WIAbIJDu+i98oNq/XNgZZIgGC5YiM9fF2rZHJv3sEpeF?= =?us-ascii?Q?/U8nXMh7UgigQ7nay703P3mDpuexIxk/uhKQULjaewP3vmkd4t+Z0Pfp82wd?= =?us-ascii?Q?9Gj/BGRuEp21CWGaPRNNi1pRd9VJAHku5PonST0Fu/BIl/7ZYDU1M/a3I4jn?= =?us-ascii?Q?NzKlPZBu+dJRfDTejIOnLJUif0F5k+LPLBpsWvfEqqgOplTCV5YtEypzC19p?= =?us-ascii?Q?oEacswaBXGp4ktFUIAoLW98S5hHjKvLkCcKcqtg4mDb/7PBIus2iK2MxBnfC?= =?us-ascii?Q?NP/DySxRz5fOx8=3D?= X-Microsoft-Antispam-Message-Info: phw/nvn85scv8DEX8ceLXrvg8R6xwOh6OEFf49h6w8hS0aPRZY77qJL6zWSm+xlY/OQ1LLXFzc0V8v8ahR1dc61mozufsFBOlMVs+S+4iWwZpxmuZkWnna0kDvOTNywLtFc2+X0UtldVikQhYsupT6TteVL4vjzBsAbfoqnQgSR5/XGQ5o9DTBFPAIBIkFwNLerNWlidIyFM9LRDJ0I6rWFqnLNbgEqKH3Se2S4c9g5Q4LidL7aH5Drb5OCMlqoZzUyAaJVKif06VWokRg/Vv2FjcGJnQU8ybJVXWZF9lPJDpYmesEc+2/JJLJELTe16XYZbGCblBwFFdvcqo2X8KpShH4v7WS1DpnnNNchzd+c= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3121; 6:obukyPwCuhFg9gS0uGEYwsvRf75Dxa9q3NRlW9YmNCHORjnHGf6ngXVSKE/7FxKiphbw+z6weDIY4S/pJIfKMDWGfDXYjRhlGCyRBJ4AnSZ7KcBTjUA2IBBn7s51+K9Qyby7IjMn5UCnEwd+Z4lTFFPNMEsaV33HBUbIKzZibQNLfq9lEMRVtskqpYy3wp/PK2It+NCv+Tq3kkoFBwT844vByjYQgDrVv+4sBpzpJpXtukE2FNer/4/S1MP60vvebDChj72qc6et/WKzhz+Y+jY2OtlOjJv8MQ3vXKrwBOO2lpmeThW37S8nZLuhE2NUqPQeRMlh3zoxLFWUoHGv7xcv3Ltl3dNgZJkssEjs2PxWY9ExS+eKUAdM+XpFSZfGx3BrDvmZzHsKRQN0gLbDx7gL5imPARaCb5w2hUIiOkPQPlhpagyGP5MlCGU1RBDUflVFQv39kYFxzd7BpVEsiQ==; 5:ra31qf297bDo936c+zzEDz3PO0AeCxo5khvcd7Vh6VMjt3Su+h6cW8onOLHREj4+BZ+3S1vpBQ7V4FLjB+kAaSimry+S0Y8Waa70HgWoy6qo7Vp86uifQEhcbglxzcmkS3VXeJ3pwZduOpavIjio8IgwlvE5O2jKA/mHmlFn0mg=; 24:0oALVDo+8C5ChS9OPembbZhUDEBXNsc1F5yjLITtSwtR6SqvMuDO4P5D2AgLbXIkXAQd4+E7V236KZr7OojE7dViMv9JmCRl1tnGM6lXUm4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB3121; 7:2HSXX9bwLfGEGpqHDtVcJQXFm05Eu0KhL5dCYwxYUgYrZahE9oMOpMKAb9O9rIAOKdMnOOZ0QSSherpcx84nEy5tozwe3ZHg+nD4yfm3T5Q/GF81K+EY1JXdrRBUem9sfVdaSK2x7sQtaVSUjQzGkbFx0KDHOBNKMfN+pO7EU3IBAlANMDkgiO2qIAjtoG+qVrkgs1mz3xywEjeg4OXTBW3NrHTMgbEjJvcgVV7BZZli2EJ/GHsn6HiKf/J2Nk1O X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2018 11:50:52.4331 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4d1585f-6209-48a4-5da8-08d5e8b6e28b X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB3121 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lars-Peter Clausen The ADXL375 is fully register map compatible to the ADXL345 (including the device ID register returning the same value ...). The only difference is the resolution of the acceleration sensor. The ADXL375 can measure up to +-200g of acceleration. Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL375.PDF Signed-off-by: Lars-Peter Clausen Signed-off-by: Mircea Caprioru --- .../devicetree/bindings/iio/accel/adxl345.txt | 5 +++-- drivers/iio/accel/Kconfig | 4 ++-- drivers/iio/accel/adxl345.h | 7 ++++++- drivers/iio/accel/adxl345_core.c | 19 +++++++++++++++++-- drivers/iio/accel/adxl345_i2c.c | 6 ++++-- drivers/iio/accel/adxl345_spi.c | 6 ++++-- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/adxl345.txt b/Documentation/devicetree/bindings/iio/accel/adxl345.txt index e7111b02c02c..ca5761b888ac 100644 --- a/Documentation/devicetree/bindings/iio/accel/adxl345.txt +++ b/Documentation/devicetree/bindings/iio/accel/adxl345.txt @@ -1,9 +1,10 @@ -Analog Devices ADXL345 3-Axis, +/-(2g/4g/8g/16g) Digital Accelerometer +Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers http://www.analog.com/en/products/mems/accelerometers/adxl345.html +http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html Required properties: - - compatible : should be "adi,adxl345" + - compatible : should be one of "adi,adxl345", "adi,adxl375" - reg : the I2C address or SPI chip select number of the sensor Required properties for SPI bus usage: diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 62ae7e5abcfa..829dc96c9dd6 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -40,7 +40,7 @@ config ADXL345_I2C select REGMAP_I2C help Say Y here if you want to build support for the Analog Devices - ADXL345 3-axis digital accelerometer. + ADXL345 or ADXL375 3-axis digital accelerometer. To compile this driver as a module, choose M here: the module will be called adxl345_i2c and you will also get adxl345_core @@ -54,7 +54,7 @@ config ADXL345_SPI select REGMAP_SPI help Say Y here if you want to build support for the Analog Devices - ADXL345 3-axis digital accelerometer. + ADXL345 or ADXL375 3-axis digital accelerometer. To compile this driver as a module, choose M here: the module will be called adxl345_spi and you will also get adxl345_core diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index c1ddf3927c47..ccd63de7a55a 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -11,8 +11,13 @@ #ifndef _ADXL345_H_ #define _ADXL345_H_ +enum adxl345_device_type { + ADXL345, + ADXL375, +}; + int adxl345_core_probe(struct device *dev, struct regmap *regmap, - const char *name); + enum adxl345_device_type type, const char *name); int adxl345_core_remove(struct device *dev); #endif /* _ADXL345_H_ */ diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 7b29ae8375e9..03f5061ee317 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -50,9 +50,16 @@ */ static const int adxl345_uscale = 38300; +/* + * The Datasheet lists a resolution of Resolution is ~49 mg per LSB. That's + * ~480mm/s**2 per LSB. + */ +static const int adxl375_uscale = 480000; + struct adxl345_data { struct regmap *regmap; u8 data_range; + enum adxl345_device_type type; }; #define ADXL345_CHANNEL(index, axis) { \ @@ -97,7 +104,14 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; - *val2 = adxl345_uscale; + switch (data->type) { + case ADXL345: + *val2 = adxl345_uscale; + break; + case ADXL375: + *val2 = adxl375_uscale; + break; + } return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_CALIBBIAS: @@ -143,7 +157,7 @@ static const struct iio_info adxl345_info = { }; int adxl345_core_probe(struct device *dev, struct regmap *regmap, - const char *name) + enum adxl345_device_type type, const char *name) { struct adxl345_data *data; struct iio_dev *indio_dev; @@ -169,6 +183,7 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, data = iio_priv(indio_dev); dev_set_drvdata(dev, indio_dev); data->regmap = regmap; + data->type = type; /* Enable full-resolution mode */ data->data_range = ADXL345_DATA_FORMAT_FULL_RES; diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c index 05e1ec49700c..d24bf81adb95 100644 --- a/drivers/iio/accel/adxl345_i2c.c +++ b/drivers/iio/accel/adxl345_i2c.c @@ -34,7 +34,7 @@ static int adxl345_i2c_probe(struct i2c_client *client, return PTR_ERR(regmap); } - return adxl345_core_probe(&client->dev, regmap, id ? id->name : NULL); + return adxl345_core_probe(&client->dev, regmap, id->driver_data, id ? id->name : NULL); } static int adxl345_i2c_remove(struct i2c_client *client) @@ -43,7 +43,8 @@ static int adxl345_i2c_remove(struct i2c_client *client) } static const struct i2c_device_id adxl345_i2c_id[] = { - { "adxl345", 0 }, + { "adxl345", ADXL345 }, + { "adxl375", ADXL375 }, { } }; @@ -51,6 +52,7 @@ MODULE_DEVICE_TABLE(i2c, adxl345_i2c_id); static const struct of_device_id adxl345_of_match[] = { { .compatible = "adi,adxl345" }, + { .compatible = "adi,adxl375" }, { }, }; diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c index 6d658196f81c..67b7c66a8492 100644 --- a/drivers/iio/accel/adxl345_spi.c +++ b/drivers/iio/accel/adxl345_spi.c @@ -42,7 +42,7 @@ static int adxl345_spi_probe(struct spi_device *spi) return PTR_ERR(regmap); } - return adxl345_core_probe(&spi->dev, regmap, id->name); + return adxl345_core_probe(&spi->dev, regmap, id->driver_data, id->name); } static int adxl345_spi_remove(struct spi_device *spi) @@ -51,7 +51,8 @@ static int adxl345_spi_remove(struct spi_device *spi) } static const struct spi_device_id adxl345_spi_id[] = { - { "adxl345", 0 }, + { "adxl345", ADXL345 }, + { "adxl375", ADXL375 }, { } }; @@ -59,6 +60,7 @@ MODULE_DEVICE_TABLE(spi, adxl345_spi_id); static const struct of_device_id adxl345_of_match[] = { { .compatible = "adi,adxl345" }, + { .compatible = "adi,adxl375" }, { }, };