Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2138410rdh; Tue, 26 Sep 2023 13:49:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG77ybpMRDLC9gyl9WGAjuN3yfknUsd6zj8hQ96rwQna/JHB3FuYYFwtIrLx/ke1R27iMdg X-Received: by 2002:a17:90b:4d90:b0:259:466:940f with SMTP id oj16-20020a17090b4d9000b002590466940fmr7448674pjb.22.1695761353412; Tue, 26 Sep 2023 13:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695761353; cv=none; d=google.com; s=arc-20160816; b=AxH89O+HNXSwjxr83D8+o37CVzwvTVcXkCkr6EMCHWECnTgYv5llSGW91HmaVgR0dm sWOdsFPZv0V6rVSv4GZe39txoM1ftgk40KAuxPYdDTMzPENTMre4PutTIjToeWFY9b67 hWD+5TPwZm+MmlTPmRxh42pBe1LnILccqe0z4a/mLzmSrSTDeibpGeFDnfYI0HQiOHtc D70u0LZgxjsys2+vPCQdAfLEHhtfNJg2s+unMnIuQUxfObyDdDsy3A9BC+osHilGbAD2 FGxGKUTMRuPeSFl3xpzgyQpUY0jrAXLg2wIM0ZpshsqM+7PuQkpi4T25a88lj/9cbsZ4 TGjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=g+YK6lrwoo5PS1PbwoYs4cua1OZYf0WJQH4v9P83A2w=; fh=WAyu9NuhnG8NHsIS9bVNJ1j0r77W9n0xwF/YeArNuwY=; b=zhXsva4+SNfaV+ts7NCnPN2lJFzn1Imvehdtcvdj81obYJC78N6qTtJTRgRqleHCu8 irbInR7kemzsRK7y9dndwbt1pYCVy0pn4RcVSzOeljyzMifaraLoemJnHh+Rox67b2L9 13vfsps9b6LjtT4IiL0CUwKzpmBF1kAfwdQU6/Amx4zY2iN2xzGCoSvioLlWZmK7TJq/ 3Hd7nMzbZVhyO7dTqYR+dUYxPBSk5pObyNRjvdSzrH6V1i4Ksa6LUnShJ3Xh3OqNVhhs azuWEj39BP8ZHsMBkTltY+bmuDGHvnNHJXWasxy+iIEX79pvYGaM1J/6Xpm+xjPz//Sm +DPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id jx2-20020a17090b46c200b002773294d636si7731426pjb.103.2023.09.26.13.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 13:49:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5368981BFA86; Tue, 26 Sep 2023 13:38:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235898AbjIZUiP (ORCPT + 99 others); Tue, 26 Sep 2023 16:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235879AbjIZUiL (ORCPT ); Tue, 26 Sep 2023 16:38:11 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a02:c205:3004:2154::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D1412A; Tue, 26 Sep 2023 13:38:04 -0700 (PDT) Received: from p200300ccff2a5b001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff2a:5b00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlEoY-004D58-9q; Tue, 26 Sep 2023 22:37:49 +0200 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1qlEoX-008tVQ-1u; Tue, 26 Sep 2023 22:37:49 +0200 From: Andreas Kemnade To: jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, bcousson@baylibre.com, tony@atomide.com, jean-baptiste.maneyrol@tdk.com, andreas@kemnade.info, chenhuiz@axis.com, andy.shevchenko@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v2 2/3] iio: imu: mpu6050: add level shifter flag Date: Tue, 26 Sep 2023 22:37:38 +0200 Message-Id: <20230926203739.2119963-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230926203739.2119963-1-andreas@kemnade.info> References: <20230926203739.2119963-1-andreas@kemnade.info> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 13:38:25 -0700 (PDT) Some boards fail in magnetometer probe if level shifter flag is not set, definition was found in a 3.0 vendor kernel. Signed-off-by: Andreas Kemnade --- drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c | 10 ++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 3 +++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 + 3 files changed, 14 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c index 7327e5723f961..1d30360f1d482 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c @@ -71,6 +71,16 @@ int inv_mpu_aux_init(const struct inv_mpu6050_state *st) unsigned int val; int ret; + /* code based on a 3.0 vendor kernel, the exact meaning is unknown */ + if (st->chip_type == INV_MPU9150) { + unsigned int mask = BIT(7); + + val = st->level_shifter ? mask : 0; + ret = regmap_update_bits(st->map, 0x1, mask, val); + if (ret) + return ret; + } + /* configure i2c master */ val = INV_MPU6050_BITS_I2C_MST_CLK_400KHZ | INV_MPU6050_BIT_WAIT_FOR_ES; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 29f906c884bd8..3fbeef1a70186 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -1495,6 +1496,8 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, st->irq = irq; st->map = regmap; + st->level_shifter = device_property_read_bool(dev, + "invensense,level-shifter"); pdata = dev_get_platdata(dev); if (!pdata) { result = iio_read_mount_matrix(dev, &st->orientation); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index ed5a96e78df05..7eba1439c8093 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -203,6 +203,7 @@ struct inv_mpu6050_state { s32 magn_raw_to_gauss[3]; struct iio_mount_matrix magn_orient; unsigned int suspended_sensors; + bool level_shifter; u8 *data; }; -- 2.39.2