From patchwork Thu Aug 29 15:18:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2044B13B1 for ; Thu, 29 Aug 2019 15:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E91342080F for ; Thu, 29 Aug 2019 15:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="hJHDJBSc"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="gmrN+tgC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfH2PmY (ORCPT ); Thu, 29 Aug 2019 11:42:24 -0400 Received: from mx0b-00328301.pphosted.com ([148.163.141.47]:43336 "EHLO mx0b-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbfH2PmY (ORCPT ); Thu, 29 Aug 2019 11:42:24 -0400 Received: from pps.filterd (m0156136.ppops.net [127.0.0.1]) by mx0b-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9rex002001; Thu, 29 Aug 2019 08:18:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=heClZ0ql3KJUPNRN/egwecUlQGDcyswZL0MpwgZnr2g=; b=hJHDJBSc1ZKURB/LxRPLzuQdhbf3SPZ+/CJDgvunRVbeeZI0bSSRLCVpc6FscX3YL2Hl y2FYB3W5B9yW78DtnzOpMQ0tQW8XPH0iKWQulahLT/ifMtDJvAt5s9stLY1mWvTsNbqR owVwZ0GM085dzHmmqu9I5BKOI6N7MIz08WEoUtLPrZFJ+mYeTZOuBrFfAvLz9X4fz9fu pqDIAfsI+pdl08uyM3o/OYzUyykgAyblBVY2wFGnuyP8JQYTe8roepRWcHITfu3VU0K0 1Xjuj1avZ/EWcAcaGZSoq7EtS68tmdp5smzwKq719FBDlPV6cmmK0wXWDwlzRXbfBcm6 9g== Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2051.outbound.protection.outlook.com [104.47.32.51]) by mx0b-00328301.pphosted.com with ESMTP id 2ukyymt18q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=muVp31hxSvq8ztcR7aBFbrwCMV2hK7sylMolZP1raFzS1T+P4XgbmxdgkbR3ZT+YlMiHYcJVIh0nh63EQunPvUhort0AdjaUpplG4S7h+2ULGgtRZnlhI2jisnNmBhktNLgIEPG5kIN7ON5gW/Uem+OcHNGaKsu2BTY+XjwuF/iKd16uY3ctaa77HVyGa/s3h2UKzOafjjJW60fZqYjdRUMyZ8W9vwDwjnGnge++XLB+a8LAIkRv2IhHz4qYPbKfm//AC3BBROza/n3H6uEjPuIlQ3k+mqZ23FLcsdcI5JpO/RSDTO0RvASRq4Pvxc1410brh4SIwatWYlT0ZKgwjg== 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-SenderADCheck; bh=heClZ0ql3KJUPNRN/egwecUlQGDcyswZL0MpwgZnr2g=; b=iodGpGl57uTp2nkCtllRJ87Y+Sclx5TIkfTR5y+9r5ID39ZXj+fMjagQ7CfTphR1FoCYZNCXAc+YvmY/sMmRtP+R/6HkPJEwI3sygk6INXF2glBjnjMjnFgW7uBV0HvQvwSoW7yBgTiJwAOo9UiF78TVS+mUSSiGYmw/aWbf2ZapER2qRISfqHyQkc4Lg0u+CF8AmWMDgBW/8v9hnXojCFVe2KUCY/oEjP+AyOvGe32XNyfmPyn3qXMlycarmrzrWjeubyYGAngsdeH1+0TS6ToVXgHu8Mtv/VOrnivuD6AhhD8epIm9i1SHWdNVbkOOmvxPsXeP93eHzaTib1wXuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=heClZ0ql3KJUPNRN/egwecUlQGDcyswZL0MpwgZnr2g=; b=gmrN+tgCgiUEs1L+RQ6QOi1Gl8r+rMfOxiwqv5WmDseh5rSFL2vURQV4GtczyM1BAv4BIvZH9t6DkPBkYAxm9VJJ49UMjIsmlCGt+sc+C4YkRnb6/iV9Wb3UBGeGkM8T1vd8EtqqQDKfGVXRJDN1ZxNkGUaPBgGaeDuOO7J1PtI= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB2950.namprd12.prod.outlook.com (20.179.91.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Thu, 29 Aug 2019 15:18:35 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:35 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 1/8] iio: imu: inv_mpu6050: disable i2c mux for 925x under Kconfig Thread-Topic: [PATCH 1/8] iio: imu: inv_mpu6050: disable i2c mux for 925x under Kconfig Thread-Index: AQHVXn0GAso2MZ425k2F5wy9hXdqZA== Date: Thu, 29 Aug 2019 15:18:35 +0000 Message-ID: <20190829151801.13014-2-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d784c327-c40f-4c39-732f-08d72c942901 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB2950; x-ms-traffictypediagnostic: BYAPR12MB2950: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(396003)(39850400004)(376002)(346002)(366004)(189003)(199004)(54906003)(7736002)(8676002)(71190400001)(14454004)(14444005)(386003)(81156014)(71200400001)(66946007)(256004)(66446008)(66476007)(305945005)(64756008)(86362001)(66556008)(81166006)(2906002)(5640700003)(8936002)(478600001)(5660300002)(316002)(80792005)(6506007)(76176011)(1076003)(2501003)(36756003)(26005)(107886003)(3846002)(6116002)(66066001)(6512007)(6916009)(6486002)(476003)(486006)(2616005)(446003)(11346002)(6436002)(52116002)(25786009)(53936002)(2351001)(186003)(99286004)(50226002)(102836004)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB2950;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: WJrXOngXhLAhjI5XJVzXv6lcV+GkU27Fw1UVDez4TTI8uQOE/f2SQ9pQPWMyXAriiCoIG9GDODTodszjxIR+fPFSDs8MMtCbjfwGZdCkEpACM8feTfD6RbQ0jbF+15rVrgTv1svrOpK6Q2G54E2nwtSAm9mb1L2/YshqQoIYOvUYQLD+SShtEhyVs+YKjVCFczDiG38ugcZxRxpIPHaGxVisg5Lz9NFeSH5MvuUC79kIuGAjn6hVOvQPufUSDle9rXAJQsrXhmPdimY2kspsRA5ZcBw5SLvACy4H+6qWxNO5RaIFNzuN0cvDERSJs/a59mFKmumCZ7kPgbSk6ww2dOaaRMohnSaDdvDNOb9afCKhBB5wDu1vRCy59zUI7smkVqkZDWyYjbgcnTaST+3BuTCmCgUKcfgyO13f+3qOQNE= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: d784c327-c40f-4c39-732f-08d72c942901 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:35.4545 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Q4uUSR2Ut6eKCBgCXEaduH2KvVsbubDKoL7sqz1UPrmEPAdrHyZOwoJvsw59QvHJ1bpl+rxJ11ch0+bneYcktcatJKzXEZ9TNx/0eFa42tM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2950 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Disable i2c mux for supported 9xxx chips when a Kconfig option is enabled. Add the new Kconfig option for enabling control of 9xxx magnetometer using the i2c master of the chip. Since it has to be explicitly enabled, we assure retro-compatibility with existing configuration. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/Kconfig | 9 +++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig index e4c4c12236a7..a92b723c6b32 100644 --- a/drivers/iio/imu/inv_mpu6050/Kconfig +++ b/drivers/iio/imu/inv_mpu6050/Kconfig @@ -31,3 +31,12 @@ config INV_MPU6050_SPI over SPI. This driver can be built as a module. The module will be called inv-mpu6050-spi. + +config INV_MPU6050_MAGN + bool "Invensense 9-axis magnetometer support" + depends on INV_MPU6050_IIO + help + For 9xxx chips add support of 9-axis in the driver using chip + i2c master to drive the integrated magnetometer. + Beware that this is disabling access to the i2c auxiliary bus! + Support only MPU925x. diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index 4b8b5a87398c..4c318304f9c6 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -121,6 +121,11 @@ static int inv_mpu_probe(struct i2c_client *client, case INV_ICM20608: case INV_ICM20602: /* no i2c auxiliary bus on the chip */ +#ifdef CONFIG_INV_MPU6050_MAGN + case INV_MPU9250: + case INV_MPU9255: + /* i2c auxiliary bus used for driving magnetometer */ +#endif break; default: /* declare i2c auxiliary bus */ From patchwork Thu Aug 29 15:18:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 771B313B1 for ; Thu, 29 Aug 2019 15:39:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D5A5208C2 for ; Thu, 29 Aug 2019 15:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="TiFrcPfR"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="Nb37Ahzl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbfH2Pju (ORCPT ); Thu, 29 Aug 2019 11:39:50 -0400 Received: from mx0b-00328301.pphosted.com ([148.163.141.47]:2852 "EHLO mx0b-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbfH2Pju (ORCPT ); Thu, 29 Aug 2019 11:39:50 -0400 Received: from pps.filterd (m0156136.ppops.net [127.0.0.1]) by mx0b-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9rf1002001; Thu, 29 Aug 2019 08:18:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=AhuCvMbkwsKTFtXlbk/RBoZgEO4CKCGDd2zDk27CDVg=; b=TiFrcPfRkYMlmmsq/cspMZgw5oFq/930dlZ8CY/3CVqISyZSFTOsLAHR6ttYIg8fRSTZ ItqVUkbyo0lVXjaq7NTNNIokWEqxNP+7C/fCABL5N9W43Bp+y8NXUjedI2pZNhfmTv/c 1lHWvgaVdRvUaEyLrMUTZAPGMlH3QjWyA35b/0djdHmXgoB4y4vXvi1Qhyzp2OvCUAzM m2X0uDMuAJTpyHMLjtLWlzXBXs1M5jkm+BjIZQMu5B1u+m/obZLjwy0ynA9wBn+Xnti/ DXs9a6t6evUURk0Fw+eM+G1do5q1pI4uAFzBbf2tA0MLEgj5L+dvDaHnGp/rEvyCmh/H ZQ== Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2051.outbound.protection.outlook.com [104.47.32.51]) by mx0b-00328301.pphosted.com with ESMTP id 2ukyymt18q-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c5jcn7AJHRqQ1uR04nVxNY8fqudMBEUjiq7MizK7d2R1IJh0zgXFrUTRUW5AVrXTj8kgLIdikSIDv45F7GU8f+tTCg7b+cruC43NQyKblS+AvTvCfGsCOwdc/i2QRAh+GS5orbt64ppqeJO2uiKt4xqutQt7wPxgQgvUeljz002f/xzHzbTr7FnQpiI9280bq/A39IwPZ6tyJTYO8swCW9n9D/wJncXdm7yjnHncfNqfZER5em0RF+1xKtFf3c8BY3aYRzBCXBOtQYPt6Nbpn85GAY9mNS12+4DZ2AeT9y1HYUfR6jX9NHbr5IBA74Aq35zxItv8UAiiBXqr5Jo6mA== 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-SenderADCheck; bh=AhuCvMbkwsKTFtXlbk/RBoZgEO4CKCGDd2zDk27CDVg=; b=V7OFzFBRxDIYarazA5YDK2GGNmIYimVHYUMzDvhoPS2GyQxO1qP2hflCd5na63EHGFVdst8vN4FpXWbHsvBDm5RZHbyF8G4nya/nlO54E0+GgaWqPY1ifVPTzFWSv6F1Ma9USJN5vLyfefV8Ck8ywHxYQBfmxJltUi/UWIU7RAYi+gAz+93qfNauAp6lsECFBkrkwiSxzYT4XvA8s4apxeOGgnGOE6WYPzesFGYcIJt4gdKKVVcbA14dHVCv3z4vzpKmE8JZpyln064SvnlocanJMQwX7t1ehsh1LVfcayX/QI9j0bjFmJndqIjFFKM5Azvddmwx1TZmimFf2quG+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AhuCvMbkwsKTFtXlbk/RBoZgEO4CKCGDd2zDk27CDVg=; b=Nb37AhzlCzmDOzd38dDoQ88QZHtXgQxK+saEif/O6wBMZ0Hixo+7BLspv08cqApwYivyS3NIOVl5MxKaLbtONf2Vv0UeRVd0W7a47r3ZbhtR9WAlAN8z+QgSODZ+GvfQ9y1ygBLDG8m5nEbf73QUAJMWHb2chx8NbOcI+yXyrNA= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB2950.namprd12.prod.outlook.com (20.179.91.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Thu, 29 Aug 2019 15:18:37 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:37 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 2/8] iio: imu: inv_mpu6050: add header include protection macro Thread-Topic: [PATCH 2/8] iio: imu: inv_mpu6050: add header include protection macro Thread-Index: AQHVXn0HbBGjuRZnOkK8ZEkIbCuQrA== Date: Thu, 29 Aug 2019 15:18:37 +0000 Message-ID: <20190829151801.13014-3-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5522b178-f08a-4fb0-4004-08d72c9429fb x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB2950; x-ms-traffictypediagnostic: BYAPR12MB2950: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:296; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(396003)(39850400004)(376002)(346002)(366004)(189003)(199004)(54906003)(7736002)(8676002)(71190400001)(14454004)(14444005)(386003)(81156014)(71200400001)(4744005)(66946007)(256004)(66446008)(66476007)(305945005)(64756008)(86362001)(66556008)(81166006)(2906002)(5640700003)(8936002)(478600001)(5660300002)(316002)(80792005)(6506007)(76176011)(1076003)(2501003)(36756003)(26005)(107886003)(3846002)(6116002)(66066001)(6512007)(6916009)(6486002)(476003)(486006)(2616005)(446003)(11346002)(6436002)(52116002)(25786009)(53936002)(2351001)(186003)(99286004)(50226002)(102836004)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB2950;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: r+5Kps0ETj3hSb5eG1Idwsr3NhyvZ7/92xqHD9Z7glIB8kGYU03Wfh9VByh3e0MkCsKeFVEAkqTPhF7QP7kEs9qUKKpVIKmj76p1ECJGqmuNzAmMlmEm/idMsKIXV8OdPV6W//FW7fU/w91TpzYRojicYGTQQycduV+yMSIAfJxy+7IluDM4VtBJH2Bf2MBHQCUWNBe4tuPSszFyCHjzsrI5FT862mhvIlwyEOyM3DwsRs+naaVsgoX1T0DblMDBiysNWZx1Ra2NmRlTVMKB3aIbn1dfkGDDLPQoysKC+BdgFsXhbEfe+3FSSg20fVQYVVXOeKOemP4UkoYSsNVujuDpB/xVPwFbd0unuJL2Q1M+D4HxSOR3WAmLrVIYqAcj8EE6vLPAeGu+Cx2cL9fSeUTxu+fZ8FWbHyNQZw1ZMyc= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5522b178-f08a-4fb0-4004-08d72c9429fb X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:37.1875 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SWgzmq6myg2gsiIR/3IxdwYM1erDP9JJ3OW+Adj9mB95hlRT3bjq6h4yHAX02PwIDgPaLsqwlYVOWxJOVSpVblD+WzunZGQZtqi/H16HvU0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2950 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index db1c6904388b..e64eb978e810 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -2,6 +2,10 @@ /* * Copyright (C) 2012 Invensense, Inc. */ + +#ifndef INV_MPU_IIO_H_ +#define INV_MPU_IIO_H_ + #include #include #include @@ -342,3 +346,5 @@ void inv_mpu_acpi_delete_mux_client(struct i2c_client *client); int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type); extern const struct dev_pm_ops inv_mpu_pmops; + +#endif From patchwork Thu Aug 29 15:18:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ADA614F7 for ; Thu, 29 Aug 2019 15:18:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5673C22CED for ; Thu, 29 Aug 2019 15:18:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="fHmesJPP"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="WA5LJGjb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbfH2PSn (ORCPT ); Thu, 29 Aug 2019 11:18:43 -0400 Received: from mx0a-00328301.pphosted.com ([148.163.145.46]:30760 "EHLO mx0a-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfH2PSn (ORCPT ); Thu, 29 Aug 2019 11:18:43 -0400 Received: from pps.filterd (m0156134.ppops.net [127.0.0.1]) by mx0a-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9qr9024048; Thu, 29 Aug 2019 08:18:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=VyS37ZNowLyKTstbciYHFo2MfPB7Kn/zrUWZHaPMV5g=; b=fHmesJPPCLqVP0crAxQp39oxvbovv686rLhxFz7wR8tfVMNJ0ZfjB8AJCPDaDq8IBEO3 LXabNwyaA6QY9XrkQYIvI6Xac7lCJhBAyuF8QWwQpSL4g2d25YFsdC+zHWrHZJ4rTtPF w4IMws/lDHRTNEu9Hb/QJOm5B0jwc0WqjyZ96yAGoilK627dyX02uWq+kRljhnhV6gNz EDp54+rp+5DQmgL205dFkskMZGL77Vw8nXV+wDysDB4mMz1+jIZ0peqnRnffzZe3MkFC vfAuPZXY1MOlAAY9cONpaOYWjUQnY7+arDPnH1GXPOd1HVWvsAgqqh+dpHbIULaWdOkz XQ== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2055.outbound.protection.outlook.com [104.47.48.55]) by mx0a-00328301.pphosted.com with ESMTP id 2up71c88kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dNxKBzKEGkn1kEw524iMWpJnGDHbtVZJ2aZXwRiaA4gBVN/Oxr/SToE/3QmZZbR9srldOeJmwf5x6uMr/EQ1wsfzEGIBoKF+GSBJ8N4H4VKCYAgYsUcvqiLTfOvgCYEeQzwJJuEO/+TRLW6EbpugvstOQuyrgRu3JmvLo/1/LUZF6Kquhudy/r7aQEwF7gaJjnnmAqIm/NQcB884geowAs53w389tbPqOFE/hr3cTjSKbCS5/2PGsne8sHqi4PGVQGCJAxdqG/bsJPm9bcoSDw5/XyE3fyqctC2L2DIfdU6kJQw5I6Qr9FNYK43tAiATTx9eeIT8eZRy3cckrjg71w== 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-SenderADCheck; bh=VyS37ZNowLyKTstbciYHFo2MfPB7Kn/zrUWZHaPMV5g=; b=kePmlOgh8aarJAgXmBa5VAdP9TE8lb33zKuR95ubzCSCaX81z31/Y7DVrZoAo6Z0TY3k3QT87nnVewGSzef0JLRywPcqs0LEyvtVdrmOdNhoDBX6oLMDGzK/MqRKnsoUuKY0VUqEO8UJ33sJD3RaUX6f6kqPOdvASTTYktTRo2/q7coIQgvI7vCXNotQ5TMUw8aPsAXoyTqdXmqn5RYR8LqCGrlk0i0FXYWwUV+e/SuaUAS39Ya2bFw/x7W4HesLPWVVXpzNAv2e0XAcM8SIapVJAmIKH0e2vdAs1pWC75KDUm+LAB2WFx2LHMSc4yEUt8Y0ESKrfPY8RfCLlquy6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VyS37ZNowLyKTstbciYHFo2MfPB7Kn/zrUWZHaPMV5g=; b=WA5LJGjbfuiaKBqzNdQxkiV9WcqWC7uHZGnHuxCc911CTWF+fJiDg082wulPEa+gXa0XJppA2wmzqV8Q3ara82qVnOYUNFcn4iIxjlRZaHjMQOHD+v8HVpYIvZdfJcn6u3Znsfs8+9A10pRz+nQRei6jaLwGtOc06ixStopHMJw= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:39 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:38 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 3/8] iio: imu: inv_mpu6050: add defines for supporting 9-axis chips Thread-Topic: [PATCH 3/8] iio: imu: inv_mpu6050: add defines for supporting 9-axis chips Thread-Index: AQHVXn0IoHuQuPiY50GrnsE0SJyHHw== Date: Thu, 29 Aug 2019 15:18:38 +0000 Message-ID: <20190829151801.13014-4-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 459d75ce-9c8a-4fc9-c54a-08d72c942b14 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2276; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(14444005)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 7kD+MrSZqA9aTOl2a7UcA6mL0CF0qpaQwZK6eQpr9pngYO2gRYf0H3lAgf6FW0Tolxt1iB5+piJxkP4+EyVD8U3pdtIS2kkb2fEwn7AxgA/tEJQDGH213/bfMFKq+1ZTddHY8ZSH090Oywldk7AevRKDFS02oNqi7B3VJ172UOQ6D17HS75kFEcgahjAb36MZpb5tbonTqf8wIqEDcSlyzVaRxgZys1ktG0a2MfYDCAgAt6RtcUt3VYyxWWFPvmyHCSxFBSP/+l99UmrNeFcSWCKz4ShZVuktfYFP2WA9y/zSDTU1yPHulz9yhEVMezDGCmNQ/mnGNkNw2gr/Hzq8l2IzDIEBK3MB5Lz7Q1qwZa3ZZVRgxd95pY4LQIjBNoy6c+n4DgnTCIAItGahWejsPD+MZyP7FU/c4c/Egws2U4= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: 459d75ce-9c8a-4fc9-c54a-08d72c942b14 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:38.8286 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f1kxJ9ch3C1Y9d7O0qBSJyZTYMOKfL1jNGYM/NIRJ41IVVrOC+aF3GX/oM1tLf0rJF8LONmxFKBZH+cxRg+sjz2vsdx7qwLpl9UFWPZHUxY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add registers defines required for driving chip i2c master ip. Add MPU9xxx magnetometer scan elements and update data bytes size. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 65 ++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index e64eb978e810..82669ecb4735 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -162,9 +162,41 @@ struct inv_mpu6050_state { #define INV_MPU6050_REG_ACCEL_CONFIG 0x1C #define INV_MPU6050_REG_FIFO_EN 0x23 +#define INV_MPU6050_BIT_SLAVE_0 0x01 +#define INV_MPU6050_BIT_SLAVE_1 0x02 +#define INV_MPU6050_BIT_SLAVE_2 0x04 #define INV_MPU6050_BIT_ACCEL_OUT 0x08 #define INV_MPU6050_BITS_GYRO_OUT 0x70 +#define INV_MPU6050_REG_I2C_MST_CTRL 0x24 +#define INV_MPU6050_BITS_I2C_MST_CLK_400KHZ 0x0D +#define INV_MPU6050_BIT_I2C_MST_P_NSR 0x10 +#define INV_MPU6050_BIT_SLV3_FIFO_EN 0x20 +#define INV_MPU6050_BIT_WAIT_FOR_ES 0x40 +#define INV_MPU6050_BIT_MULT_MST_EN 0x80 + +/* control I2C slaves from 0 to 3 */ +#define INV_MPU6050_REG_I2C_SLV_ADDR(_x) (0x25 + 3 * (_x)) +#define INV_MPU6050_BIT_I2C_SLV_RNW 0x80 + +#define INV_MPU6050_REG_I2C_SLV_REG(_x) (0x26 + 3 * (_x)) + +#define INV_MPU6050_REG_I2C_SLV_CTRL(_x) (0x27 + 3 * (_x)) +#define INV_MPU6050_BIT_SLV_GRP 0x10 +#define INV_MPU6050_BIT_SLV_REG_DIS 0x20 +#define INV_MPU6050_BIT_SLV_BYTE_SW 0x40 +#define INV_MPU6050_BIT_SLV_EN 0x80 + +/* I2C master delay register */ +#define INV_MPU6050_REG_I2C_SLV4_CTRL 0x34 +#define INV_MPU6050_BITS_I2C_MST_DLY(_x) ((_x) & 0x1F) + +#define INV_MPU6050_REG_I2C_MST_STATUS 0x36 +#define INV_MPU6050_BIT_I2C_SLV0_NACK 0x01 +#define INV_MPU6050_BIT_I2C_SLV1_NACK 0x02 +#define INV_MPU6050_BIT_I2C_SLV2_NACK 0x04 +#define INV_MPU6050_BIT_I2C_SLV3_NACK 0x08 + #define INV_MPU6050_REG_INT_ENABLE 0x38 #define INV_MPU6050_BIT_DATA_RDY_EN 0x01 #define INV_MPU6050_BIT_DMP_INT_EN 0x02 @@ -177,6 +209,18 @@ struct inv_mpu6050_state { #define INV_MPU6050_BIT_FIFO_OVERFLOW_INT 0x10 #define INV_MPU6050_BIT_RAW_DATA_RDY_INT 0x01 +#define INV_MPU6050_REG_EXT_SENS_DATA 0x49 + +/* I2C slaves data output from 0 to 3 */ +#define INV_MPU6050_REG_I2C_SLV_DO(_x) (0x63 + (_x)) + +#define INV_MPU6050_REG_I2C_MST_DELAY_CTRL 0x67 +#define INV_MPU6050_BIT_I2C_SLV0_DLY_EN 0x01 +#define INV_MPU6050_BIT_I2C_SLV1_DLY_EN 0x02 +#define INV_MPU6050_BIT_I2C_SLV2_DLY_EN 0x04 +#define INV_MPU6050_BIT_I2C_SLV3_DLY_EN 0x08 +#define INV_MPU6050_BIT_DELAY_ES_SHADOW 0x80 + #define INV_MPU6050_REG_USER_CTRL 0x6A #define INV_MPU6050_BIT_FIFO_RST 0x04 #define INV_MPU6050_BIT_DMP_RST 0x08 @@ -204,6 +248,9 @@ struct inv_mpu6050_state { #define INV_MPU6050_BYTES_PER_3AXIS_SENSOR 6 #define INV_MPU6050_FIFO_COUNT_BYTE 2 +/* MPU9X50 9-axis magnetometer */ +#define INV_MPU9X50_BYTES_MAGN 7 + /* ICM20602 FIFO samples include temperature readings */ #define INV_ICM20602_BYTES_PER_TEMP_SENSOR 2 @@ -231,8 +278,8 @@ struct inv_mpu6050_state { #define INV_ICM20602_TEMP_OFFSET 8170 #define INV_ICM20602_TEMP_SCALE 3060 -/* 6 + 6 round up and plus 8 */ -#define INV_MPU6050_OUTPUT_DATA_SIZE 24 +/* 6 + 6 + 7 (for MPU9x50) round up and plus 8 */ +#define INV_MPU6050_OUTPUT_DATA_SIZE 32 #define INV_MPU6050_REG_INT_PIN_CFG 0x37 #define INV_MPU6050_ACTIVE_HIGH 0x00 @@ -283,6 +330,20 @@ enum inv_mpu6050_scan { INV_MPU6050_SCAN_TIMESTAMP, }; +/* scan element definition for MPU9x50 devices */ +enum inv_mpu9x50_scan { + INV_MPU9X50_SCAN_ACCL_X, + INV_MPU9X50_SCAN_ACCL_Y, + INV_MPU9X50_SCAN_ACCL_Z, + INV_MPU9X50_SCAN_GYRO_X, + INV_MPU9X50_SCAN_GYRO_Y, + INV_MPU9X50_SCAN_GYRO_Z, + INV_MPU9X50_SCAN_MAGN_X, + INV_MPU9X50_SCAN_MAGN_Y, + INV_MPU9X50_SCAN_MAGN_Z, + INV_MPU9X50_SCAN_TIMESTAMP, +}; + /* scan element definition for ICM20602, which includes temperature */ enum inv_icm20602_scan { INV_ICM20602_SCAN_ACCL_X, From patchwork Thu Aug 29 15:18:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B66B7184E for ; Thu, 29 Aug 2019 15:18:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94C012339E for ; Thu, 29 Aug 2019 15:18:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="b/pDKAEx"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="ULcQvgPm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfH2PSn (ORCPT ); Thu, 29 Aug 2019 11:18:43 -0400 Received: from mx0a-00328301.pphosted.com ([148.163.145.46]:31054 "EHLO mx0a-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfH2PSn (ORCPT ); Thu, 29 Aug 2019 11:18:43 -0400 Received: from pps.filterd (m0156134.ppops.net [127.0.0.1]) by mx0a-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9qrA024048; Thu, 29 Aug 2019 08:18:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=5mSFPzjXvF2DWpr+b2NK78N6s6olmW8sHyGEuxIcapE=; b=b/pDKAEx2L92HgnaoVXDjFPut36pAObsGrdKVtPK3oYH3+Ag2xjoQ/28Rg65iC436OVz 1OoEmUKYtUxn4DL0OdGcI0nQGSRwUp2npcfnTYm3a+pZmmvh3LHDg0+Bs8tTGnskYLnP EBWh1gbQlixx3+v+hMC5Tbx70Y4zXi5RePp3ZR5Wak8I4tIqy5wDgmILBmLHSZ/8w6hu adD7V7EYvFDna7OcjEiiVedo2j4qmBTFoxnO017lYEgFgj1owDLBavEaFSg9V0BJIbgk +STZ20/izl3+jkyC+IGxBgq/B93XHOpRUNmzUneXMgkZFb+dGn9QkI6ONr6Tx9gbWRud Cw== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2055.outbound.protection.outlook.com [104.47.48.55]) by mx0a-00328301.pphosted.com with ESMTP id 2up71c88kn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iFbTRC4h9eQfgMXeP0+jMZsbV1e+frIOeMSc7IK7TLKBywVarHPtChLrFRb7rFhLuV6QhZKrcF/vhS05PdcNEfFc26d1h4L9CzGy9apf2Heuobq2fyiIL6nCPaTO5ujQaVVxsOOTZVG/KvDrXNvjbFjFy4T8MjdyqSYdx3p1TKXOE/b/ol/l4PNemRrhTtvdptSTWvQVMIqnJWPIM29YvdvG5qHZ+ivRK1lxtNTAGQvEcYpqg+4tCSizXYCTiU2TG8WjvmeMeb230sKcB6qyvDLMtKVxN92pPkxzk6I5Au7UMJT/8tdGlO2nykiQU2UjgJOo4LT4EK1HbqW4l47s+A== 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-SenderADCheck; bh=5mSFPzjXvF2DWpr+b2NK78N6s6olmW8sHyGEuxIcapE=; b=nKNN1qWguBbLlf+T/k3+fQO9CzGVrWd8m46pGDZ7heNEynrLU2jcePB9pog7ADKdK9cXB43mFMgtL3zXk6Fpme57zc9s23PLUSRlNlzXkPFBEnzlR75QiqVbDpfFcDR6xfzZO9yEn7/Jr7RJzRUnfF2wsqRJ9d7L0lfvRIJOfJRS0nd41sgF+RTwuoS6Gw+1pU3px7FVONd61DLyKg461WZJsJ9T+6QCMiD/ORA7bmthQBgkf9M5JcQRDikSfHWnIqms18hLtDzXD7vsq8WlyJd+la9cFTgz8cLe2TFsvxGDjJWn/bt4q7M8DopIU4sWFPb5cDVhy4078Ya3qBCB3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5mSFPzjXvF2DWpr+b2NK78N6s6olmW8sHyGEuxIcapE=; b=ULcQvgPm9zjuqEyRpvz68h5Iz4RZRVMWhhqEpNg87kmC2GLB8XKRqJlMHBBFWcxRNUhb1VOZtbzd/WVVN9ltG/sv+ll6LAJw2S4KEIYpbmKw5kKiMNazN5tIfWyvcL96j5AJ9/8yGYWUXtX0SsMqc3ppi2eRha0GvhlAkdFMvFU= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:40 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:40 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 4/8] iio: imu: inv_mpu6050: fix objects syntax in Makefile Thread-Topic: [PATCH 4/8] iio: imu: inv_mpu6050: fix objects syntax in Makefile Thread-Index: AQHVXn0J3XHvKnFT3k628HJHYxH76A== Date: Thu, 29 Aug 2019 15:18:40 +0000 Message-ID: <20190829151801.13014-5-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0bee700b-780c-4b15-b163-08d72c942c00 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(4744005)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: KWXwiJwVSOF452oOcgpk+s1jdxK1j9cVPnWr8XjeYSsrUeE+AdyciD5RIoJgnu7INuFJD7GeL8KuBVtS84BqXRTKxa1XVO8nkKLfZwa/9Cs5qAtQeLmFibeWI4a93rEwuBY0derChwx7udqPz8xh9pJe/sGet/e2vMGTf2Y3sYC7iKsQLadBcFwrUxArt4k2cbfoGPkgzFoOzaduJWw8GuR9jzrcgbGrMzi3E6cR/46gGd0DKqcbkN0G+GSDpuJwjflyxzo8xHaKPzGv5aPfa7dUEYEEP1khElcJsIATHPyBRbCWn/h8NoksVboiJWGF5zuOrjdji9lOdFOU9HpbkBmSBNZ0VlUcjovJkhtCRoOon2vHO22X7OXt3x4btSn0qf4e60yT7htUrKEdS3TLcnORr27z9YpDy4h8j6Bahss= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bee700b-780c-4b15-b163-08d72c942c00 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:40.5786 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2Ib+XCE6Jk7V/ajVcICRhesgPmwERx4RRPEidLR3uUJE2txDq74HSp/YEcsNEf8s8NeDe2ecU/fh6Q1f3JelLvqkOorn1KB80idDmfK7G5U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 mlxlogscore=889 mlxscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use the correct syntax *-y for declaring object files. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/Makefile b/drivers/iio/imu/inv_mpu6050/Makefile index 70ffe0d13d8c..33bec09fee9b 100644 --- a/drivers/iio/imu/inv_mpu6050/Makefile +++ b/drivers/iio/imu/inv_mpu6050/Makefile @@ -4,10 +4,10 @@ # obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o -inv-mpu6050-objs := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o +inv-mpu6050-y := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o obj-$(CONFIG_INV_MPU6050_I2C) += inv-mpu6050-i2c.o -inv-mpu6050-i2c-objs := inv_mpu_i2c.o inv_mpu_acpi.o +inv-mpu6050-i2c-y := inv_mpu_i2c.o inv_mpu_acpi.o obj-$(CONFIG_INV_MPU6050_SPI) += inv-mpu6050-spi.o -inv-mpu6050-spi-objs := inv_mpu_spi.o +inv-mpu6050-spi-y := inv_mpu_spi.o From patchwork Thu Aug 29 15:18:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19AD216B1 for ; Thu, 29 Aug 2019 15:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D993122CED for ; Thu, 29 Aug 2019 15:18:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="toFJMzmE"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="ATQgDjlZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfH2PSp (ORCPT ); Thu, 29 Aug 2019 11:18:45 -0400 Received: from mx0a-00328301.pphosted.com ([148.163.145.46]:33528 "EHLO mx0a-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfH2PSp (ORCPT ); Thu, 29 Aug 2019 11:18:45 -0400 Received: from pps.filterd (m0156134.ppops.net [127.0.0.1]) by mx0a-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9tst024063; Thu, 29 Aug 2019 08:18:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=KufskYDzb4SYFi/x95CIozryUIEqGs9hb5qYF2fn/F4=; b=toFJMzmE8xYKDH/a0CY1RVyJoVHLMWy4McDlydJ7lmK/uT9TQzYi21ioJsjT4nNBwU10 tUpr17+N/uuilyrey5yXbknMwHx/HeeyCoIGK8kznoMt4U0qwI81ooziDm6BkeM392b4 Rfe9KN8owMVmMghYN81vaMPKDIFdUTxM3zqfC9dK6DFLOtUbgSx/ch74uTpV6C6E6rJm QkZbwjOHT/yR/NE68QPKkgnPr9Hf6yYl1NSIecAGDHffQGGuBuwewwbVH620Bclms6D3 fGdSkXMars9qJTSQMCqJlPp5NDB+bRB7QdICs1KwrUYOHJUXwL/EgVWVV4jf7uLALyni RA== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2050.outbound.protection.outlook.com [104.47.48.50]) by mx0a-00328301.pphosted.com with ESMTP id 2up71c88kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XGgxk4oJPaNTMmwgzDjFESgdEM7fKkOl6U3CykruPMv64slVfsM9JtPNq1SQ1J3J8cltvkhbMr5Rf6d1Bp32aAwQLcyXAWaetRrcvvrqb0tTk1e9MJYSx/XOwyIA2IGE0lnAIhGpuxNpVGciOcs07pO+4Yt4N15QOcyhnsfvs01Pi2ddTqzF6c3tofyhPgMZxN4Eyvi+tGDGSYsN8b280HoWrQqpsTrcpKzhsRx3kgQHi595uK8moulZANQo++0dJkD/1cl3sOds6pzT981ff7KYCreBZh5L+eV5aYJcKE05SVooZakhEe2KcnLFQoUl8BVpCrwUzSvBkCilP85O6A== 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-SenderADCheck; bh=KufskYDzb4SYFi/x95CIozryUIEqGs9hb5qYF2fn/F4=; b=RWV+7PTja+D0NgYzgnufOwI+ujHrku1NxNpQrXk1FCsQjxMvrmz0dQeklr3bCpwCNZQKinJQwdGW2vpvU841JwGB330TEVNL8pe77QOH/z7NZGUzYGQTWbabrKJ0Y6ZV0Um57NtMVZSzgEmw5g3NZ6VDJzCQcR4IiqRieEvihSYpGPz4OhT4AMZ5lDjCtCU8H8Lsi6f+9ALnFjtiTSDAm3SCIIQxw7m5H3N9EgpRSBnWO3RichErXoh83JMi6KquIKJvmWj3bP9OkkHxyzC0P5tYwXPHdcZZ8JivDC/Nf8wye07Hzgb3J1L1fM5I6OG4QVtFU3MwnaUgXR7NmifOxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KufskYDzb4SYFi/x95CIozryUIEqGs9hb5qYF2fn/F4=; b=ATQgDjlZuV7d6gDQai+g4P38wB4CjqD+DMMkslb441ty1d4rAb2eIZSe+KespzV9MEjUUxE8WcVp+jiqXalK5UvAwcA5UDX6QUFnsuE+7sXiYoMPWKhhzc+oUnbCuWArTSGvTZ4eBsiJrMXqzagni6MF1NWsVpcDk2JXib9bXzk= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:42 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:42 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 5/8] iio: imu: inv_mpu6050: helpers for using i2c master on auxiliary bus Thread-Topic: [PATCH 5/8] iio: imu: inv_mpu6050: helpers for using i2c master on auxiliary bus Thread-Index: AQHVXn0KZSl3P1+jXUG7UhFKyFF9/w== Date: Thu, 29 Aug 2019 15:18:42 +0000 Message-ID: <20190829151801.13014-6-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e7d6bef6-7a81-4a81-ee39-08d72c942d05 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(14444005)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: pNla3uWieCxjKeU/tYROxQHIRp2DNW+MT3g9M7KY1LUMtVpAQa4zHFAbnHjhiuMK37bSAqdcvCN3RYwhQNbMSXNin4ufZMh/1FGlA3WncJs5HpUWwmO53lRZgYzayUJ2NlWB1rG1IE6/6HK8dvzk0stF/ovn0KdB5osWuholRVuUlCy1UVr1btwTvuu7xCUfvW3Yq63yDy9JMONYdS++U0/6c0TNW2dqYge+N+jWw7gX5rwHhaWkGS8DlOFV6d69SqkkEpzH1km0hphF3keeGQZPZqnLrSBvICqniqree50TT/qyd56m+T4iCSHRKC5dPVzZLiRN2I45tbbGxWcg3+V/KARRDC6ElXB5qYgSGPxz9Gkc+Ds+i8UOYFx/SZ68yZeMkYSZ2QyWZxPu9QTrJdV15JeE3rxN2/kfr/OOYKc= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7d6bef6-7a81-4a81-ee39-08d72c942d05 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:42.0918 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rLisoAzUlTXm4jYz5bFnI6VU6Vqz939d4cSu9S2WRba39eBsjcm7O86zffsR2WwOM+eo6PYWrB5r3jBkZzXuLtPqnNMNio7S06sepiyMCtA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add helper functions to use the i2c auxiliary bus with the MPU i2c master block. Support only register based chip, reading and 1 byte writing. These will be useful for initializing magnetometers inside MPU9x50 chips. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/Makefile | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c | 191 ++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_aux.h | 46 ++++++ 3 files changed, 238 insertions(+) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_aux.h diff --git a/drivers/iio/imu/inv_mpu6050/Makefile b/drivers/iio/imu/inv_mpu6050/Makefile index 33bec09fee9b..187f003c81f2 100644 --- a/drivers/iio/imu/inv_mpu6050/Makefile +++ b/drivers/iio/imu/inv_mpu6050/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o inv-mpu6050-y := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o +inv-mpu6050-$(CONFIG_INV_MPU6050_MAGN) += inv_mpu_aux.o obj-$(CONFIG_INV_MPU6050_I2C) += inv-mpu6050-i2c.o inv-mpu6050-i2c-y := inv_mpu_i2c.o inv_mpu_acpi.o diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c new file mode 100644 index 000000000000..afb957567c12 --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.c @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#include +#include +#include +#include + +#include "inv_mpu_iio.h" + +/* + * i2c master auxiliary bus transfer function. + * Requires the i2c operations to be correctly setup before. + */ +static int inv_mpu_i2c_master_xfer(const struct inv_mpu6050_state *st) +{ + /* use 50hz frequency for xfer */ + const unsigned int freq = 50; + const unsigned int period_ms = 1000 / freq; + uint8_t d; + unsigned int user_ctrl; + int ret; + + /* set sample rate */ + d = INV_MPU6050_FIFO_RATE_TO_DIVIDER(freq); + ret = regmap_write(st->map, st->reg->sample_rate_div, d); + if (ret) + return ret; + + /* start i2c master */ + user_ctrl = st->chip_config.user_ctrl | INV_MPU6050_BIT_I2C_MST_EN; + ret = regmap_write(st->map, st->reg->user_ctrl, user_ctrl); + if (ret) + goto error_restore_rate; + + /* wait for xfer: 1 period + half-period margin */ + msleep(period_ms + period_ms / 2); + + /* stop i2c master */ + user_ctrl = st->chip_config.user_ctrl; + ret = regmap_write(st->map, st->reg->user_ctrl, user_ctrl); + if (ret) + goto error_stop_i2c; + + /* restore sample rate */ + d = st->chip_config.divider; + ret = regmap_write(st->map, st->reg->sample_rate_div, d); + if (ret) + goto error_restore_rate; + + return 0; + +error_stop_i2c: + regmap_write(st->map, st->reg->user_ctrl, st->chip_config.user_ctrl); +error_restore_rate: + regmap_write(st->map, st->reg->sample_rate_div, st->chip_config.divider); + return ret; +} + +int inv_mpu_aux_init(const struct inv_mpu6050_state *st) +{ + unsigned int val; + int ret; + + /* configure i2c master */ + val = INV_MPU6050_BITS_I2C_MST_CLK_400KHZ | + INV_MPU6050_BIT_WAIT_FOR_ES; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_MST_CTRL, val); + if (ret) + return ret; + + /* configure i2c master delay */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV4_CTRL, 0); + if (ret) + return ret; + val = INV_MPU6050_BIT_I2C_SLV0_DLY_EN | + INV_MPU6050_BIT_I2C_SLV1_DLY_EN | + INV_MPU6050_BIT_I2C_SLV2_DLY_EN | + INV_MPU6050_BIT_I2C_SLV3_DLY_EN | + INV_MPU6050_BIT_DELAY_ES_SHADOW; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_MST_DELAY_CTRL, val); + if (ret) + return ret; + + return 0; +} + +/* + * i2c slave reading using SLV0 + */ +int inv_mpu_aux_read(const struct inv_mpu6050_state *st, uint8_t addr, + uint8_t reg, uint8_t *val, size_t size) +{ + unsigned int status; + int ret; + + if (size > 0x0F) + return -EINVAL; + + /* setup i2c SLV0 control: i2c addr, register, enable + size */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(0), + INV_MPU6050_BIT_I2C_SLV_RNW | addr); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(0), reg); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), + INV_MPU6050_BIT_SLV_EN | size); + if (ret) + return ret; + + /* do i2c xfer */ + ret = inv_mpu_i2c_master_xfer(st); + if (ret) + goto error_disable_i2c; + + /* disable i2c slave */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), 0); + if (ret) + goto error_disable_i2c; + + /* check i2c status */ + ret = regmap_read(st->map, INV_MPU6050_REG_I2C_MST_STATUS, &status); + if (ret) + return ret; + if (status & INV_MPU6050_BIT_I2C_SLV0_NACK) + return -EIO; + + /* read data in registers */ + ret = regmap_bulk_read(st->map, INV_MPU6050_REG_EXT_SENS_DATA, + val, size); + if (ret) + return ret; + + return 0; + +error_disable_i2c: + regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), 0); + return ret; +} + +/* + * i2c slave writing 1 byte using SLV0 + */ +int inv_mpu_aux_write(const struct inv_mpu6050_state *st, uint8_t addr, + uint8_t reg, uint8_t val) +{ + unsigned int status; + int ret; + + /* setup i2c SLV0 control: i2c addr, register, value, enable + size */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(0), addr); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(0), reg); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_DO(0), val); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), + INV_MPU6050_BIT_SLV_EN | 1); + if (ret) + return ret; + + /* do i2c xfer */ + ret = inv_mpu_i2c_master_xfer(st); + if (ret) + goto error_disable_i2c; + + /* disable i2c slave */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), 0); + if (ret) + goto error_disable_i2c; + + /* check i2c status */ + ret = regmap_read(st->map, INV_MPU6050_REG_I2C_MST_STATUS, &status); + if (ret) + return ret; + if (status & INV_MPU6050_BIT_I2C_SLV0_NACK) + return -EIO; + + return 0; + +error_disable_i2c: + regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), 0); + return ret; +} diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.h new file mode 100644 index 000000000000..bae4eab58e6c --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_aux.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#ifndef INV_MPU_AUX_H_ +#define INV_MPU_AUX_H_ + +#include + +#include "inv_mpu_iio.h" + +/** + * inv_mpu_aux_init() - init i2c auxiliary bus + * @st: driver internal state + * + * Returns 0 on success, a negative error code otherwise. + */ +int inv_mpu_aux_init(const struct inv_mpu6050_state *st); + +/** + * inv_mpu_aux_read() - read register function for i2c auxiliary bus + * @st: driver internal state. + * @addr: chip i2c Address + * @reg: chip register address + * @val: buffer for storing read bytes + * @size: number of bytes to read + * + * Returns 0 on success, a negative error code otherwise. + */ +int inv_mpu_aux_read(const struct inv_mpu6050_state *st, uint8_t addr, + uint8_t reg, uint8_t *val, size_t size); + +/** + * inv_mpu_aux_write() - write register function for i2c auxiliary bus + * @st: driver internal state. + * @addr: chip i2c Address + * @reg: chip register address + * @val: 1 byte value to write + * + * Returns 0 on success, a negative error code otherwise. + */ +int inv_mpu_aux_write(const struct inv_mpu6050_state *st, uint8_t addr, + uint8_t reg, uint8_t val); + +#endif /* INV_MPU_AUX_H_ */ From patchwork Thu Aug 29 15:18:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ADFF13B1 for ; Thu, 29 Aug 2019 16:13:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4980F2189D for ; Thu, 29 Aug 2019 16:13:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="we4eTrIV"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="T2hC2V36" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbfH2QNu (ORCPT ); Thu, 29 Aug 2019 12:13:50 -0400 Received: from mx0b-00328301.pphosted.com ([148.163.141.47]:53062 "EHLO mx0b-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727426AbfH2QNt (ORCPT ); Thu, 29 Aug 2019 12:13:49 -0400 Received: from pps.filterd (m0156136.ppops.net [127.0.0.1]) by mx0b-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9rem001995; Thu, 29 Aug 2019 08:18:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=xC3iDkO/dOKCHduCofvu69oSiAk6FHMSt92ahBaO+/w=; b=we4eTrIVCJf+ZNZ/36EtCQkZ9ehZ+y2e7tQX3/06YXcX8UmzKyn8F1446Y/JFPFw+XEU VLXQG0930Bm65owqrJZmB1XCMc/bAadJWtKjtq2L3qalbp/Xzv/9vJ3b45SMUHrMtA7t UWrlI5OpyKi3t80GzGDQ4frglRsY2dh7eLmoq4UA/EBk+WhyV9lqQRRUycYzIjsxxhZa 13LS0o24ttEHFMqypwhziYGJLf/5nWqIWB2XHcqb8I1s+XBFLlhFcqWVWLTxdQNCaiHV FgogkgOUzIND9FWS2hK+qLQ1TvA26onwto/1Xw+pg+H33aTuHVIS4HHsrIvdsPOEBjfZ ug== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2050.outbound.protection.outlook.com [104.47.48.50]) by mx0b-00328301.pphosted.com with ESMTP id 2ukyymt18t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKkp4faoAHiGk+wiL9wRa/99wZislw/HfxNTc5+jxb3jexV16SimO/ZsSY9ltirfoTYxpAjlhGR01PKcQNqYaiYN8su93g67PziHN1N+Gi5l/6jZw2vsj7QAp1HE0ZTONmCGKmhXUpEEnMrAD+/dL80E4Ed3p8R2sDpNPUK5xac2WLC4QxRaGRlI8QLkl74i9MU/u/2qtw1q4DLe0XGFYbXyjQcuts0cf14Lkr1nvNl5CqV4SPayAFyN4pDpkmCroQTTvJ1fn8oe3Fv1riM5UoUK8mBLwv8XY3aWIA/kWlQ4lgtF3aSJ4UA2VrHJz2M5DI+JhjvhkiX9WVtqhBXyDw== 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-SenderADCheck; bh=xC3iDkO/dOKCHduCofvu69oSiAk6FHMSt92ahBaO+/w=; b=DcG+Cw3SG3US2WEtbo0B0iFxjma2ShPBkhJLheyX2dLZo17v2Sqt8EqL5GWY0XFFG8zk1EZ3gPtNa7EjAzVlF8m/bmjiqCbI6qyFiH694t5zXnA9/ZlsoLMeMen3ewXsfoG9o1inFLW8apVRym6C3Gpn5j8DDg1LvNkxkVMrITMBzwCzLlpsETFjXy9PDWl+XZ4k7O5Hbuynz27L6HJuQt9w6+Jr6pGZG4LaQk4rzWpBTKieunae8yLnYbcPJ9mHrdLYkZrXrGsummh3SUpHnwNWbaNAgnIJar+R1jgnkB/c0jnuhPztcHcaykYuWTvTDzyLeuPFY5pQD2c9Q2xnJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xC3iDkO/dOKCHduCofvu69oSiAk6FHMSt92ahBaO+/w=; b=T2hC2V36Wag2WXDQeIbEmw3cNKN83yXPtyJB5sfatpm2uV9acNQzKQvEJUfAh7DAyu8x+3YYfWJFso/sL3v1FdX7MiDKRPGHsK2gZbWWkPXVdIm170j7dqoe8+cicqg4feZCG93HMUgLVSu3CmtPVptnXyznNYrUlTLDmYW+Oqw= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:43 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:43 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 6/8] iio: imu: inv_mpu6050: add magnetometer implementation for MPU925x Thread-Topic: [PATCH 6/8] iio: imu: inv_mpu6050: add magnetometer implementation for MPU925x Thread-Index: AQHVXn0LDCBuZOA8OkStPvzl+JKzSQ== Date: Thu, 29 Aug 2019 15:18:43 +0000 Message-ID: <20190829151801.13014-7-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1a836b19-c710-4f35-6e1f-08d72c942ded x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(14444005)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: NYb/mlEWMSZw1VDOch4Rfg5N4LXtVELmgGoVgQ+eYkfoqV1xopiOVmoe9eAjB59Hto2muBxQ4oBe6PzKafmJ5NeS9CbHInQsk+UowNm2ZtVp9FLxLFdZEss3BQ2/TBEy80CcSNDQYZuoaGp4TqhFPW3xdzE+LDOrHUtVjcgBtx1Taz5fg4/FcnySiDKylA8n8f1CFoC09y3fnFgebMbb0X7UYTjz6/Gbc7DRFd9fLQaSMZmxaaM7r+hvPhPZSOqPbPzGc27Ei6r+uw4dM83DsAmunwr7qVZ6taqWQoBvt0zMncdmfX+mdBx3j7JKaADENJJ850lfaqRfKLWHXViyc411w7YplUf22IxbJNZd8X1XrfunP0tZkDFwka2XMKxZ/iuRBGXJCzcnBW75H998xz1tm8YpQiDQKIutbn+nIPQ= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a836b19-c710-4f35-6e1f-08d72c942ded X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:43.6050 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BV5YLSeDyRMQZP4VVkI5hlsLb4h46E1H/7fHIAlzDaMCnhYtGLXUjV2mv/OtD6/UTvvBsiNVL/iX7e0UYdKiiFAnemt3rpOJQ29l6DKsojA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add implementation for driving MPU9250 magnetometer connected on i2c auxiliary bus using the MPU i2c master. This is currently not wired inside the main mpu driver. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/Makefile | 2 +- .../iio/imu/inv_mpu6050/inv_mpu9250_magn.c | 239 ++++++++++++++++++ .../iio/imu/inv_mpu6050/inv_mpu9250_magn.h | 27 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 4 + 4 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.c create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.h diff --git a/drivers/iio/imu/inv_mpu6050/Makefile b/drivers/iio/imu/inv_mpu6050/Makefile index 187f003c81f2..fee41415ebdb 100644 --- a/drivers/iio/imu/inv_mpu6050/Makefile +++ b/drivers/iio/imu/inv_mpu6050/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o inv-mpu6050-y := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o -inv-mpu6050-$(CONFIG_INV_MPU6050_MAGN) += inv_mpu_aux.o +inv-mpu6050-$(CONFIG_INV_MPU6050_MAGN) += inv_mpu_aux.o inv_mpu9250_magn.o obj-$(CONFIG_INV_MPU6050_I2C) += inv-mpu6050-i2c.o inv-mpu6050-i2c-y := inv_mpu_i2c.o inv_mpu_acpi.o diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.c b/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.c new file mode 100644 index 000000000000..0c2230247557 --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.c @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#include +#include +#include +#include +#include +#include + +#include "inv_mpu_iio.h" +#include "inv_mpu_aux.h" +#include "inv_mpu9250_magn.h" + +/* + * MPU9250 magnetometer is an AKM AK8963 chip on I2C aux bus + */ +#define INV_MPU9250_MAGN_I2C_ADDR 0x0C + +#define INV_MPU9250_MAGN_REG_WIA 0x00 +#define INV_MPU9250_MAGN_BITS_WIA 0x48 + +#define INV_MPU9250_MAGN_REG_ST1 0x02 +#define INV_MPU9250_MAGN_BIT_DRDY 0x01 +#define INV_MPU9250_MAGN_BIT_DOR 0x02 + +#define INV_MPU9250_MAGN_REG_DATA 0x03 + +#define INV_MPU9250_MAGN_REG_ST2 0x09 +#define INV_MPU9250_MAGN_BIT_HOFL 0x08 +#define INV_MPU9250_MAGN_BIT_BITM 0x10 + +#define INV_MPU9250_MAGN_REG_CNTL1 0x0A +#define INV_MPU9250_MAGN_BITS_MODE_PWDN 0x00 +#define INV_MPU9250_MAGN_BITS_MODE_SINGLE 0x01 +#define INV_MPU9250_MAGN_BITS_MODE_FUSE 0x0F +#define INV_MPU9250_MAGN_BIT_OUTPUT_BIT 0x10 + +#define INV_MPU9250_MAGN_REG_CNTL2 0x0B +#define INV_MPU9250_MAGN_BIT_SRST 0x01 + +#define INV_MPU9250_MAGN_REG_ASAX 0x10 +#define INV_MPU9250_MAGN_REG_ASAY 0x11 +#define INV_MPU9250_MAGN_REG_ASAZ 0x12 + +/* init magnetometer chip */ +static int inv_magn_init(struct inv_mpu6050_state *st) +{ + uint8_t val; + uint8_t asa[3]; + int ret; + + /* check whoami */ + ret = inv_mpu_aux_read(st, INV_MPU9250_MAGN_I2C_ADDR, + INV_MPU9250_MAGN_REG_WIA, &val, sizeof(val)); + if (ret) + return ret; + if (val != INV_MPU9250_MAGN_BITS_WIA) + return -ENODEV; + + /* reset chip */ + ret = inv_mpu_aux_write(st, INV_MPU9250_MAGN_I2C_ADDR, + INV_MPU9250_MAGN_REG_CNTL2, + INV_MPU9250_MAGN_BIT_SRST); + if (ret) + return ret; + + /* read fuse ROM data */ + ret = inv_mpu_aux_write(st, INV_MPU9250_MAGN_I2C_ADDR, + INV_MPU9250_MAGN_REG_CNTL1, + INV_MPU9250_MAGN_BITS_MODE_FUSE); + if (ret) + return ret; + ret = inv_mpu_aux_read(st, INV_MPU9250_MAGN_I2C_ADDR, + INV_MPU9250_MAGN_REG_ASAX, asa, sizeof(asa)); + if (ret) + return ret; + + /* switch back to power-down */ + ret = inv_mpu_aux_write(st, INV_MPU9250_MAGN_I2C_ADDR, + INV_MPU9250_MAGN_REG_CNTL1, + INV_MPU9250_MAGN_BITS_MODE_PWDN); + if (ret) + return ret; + + /* + * Sensitivity adjustement and scale to Gauss + * + * Hadj = H * (((ASA - 128) * 0.5 / 128) + 1) + * Factor simplification: + * Hadj = H * ((ASA + 128) / 256) + * + * sensor sensitivity: 0.15 uT (16 bits) + * 1 uT = 0.01 G and value is in micron (1e6) + * + * Hadj = H * ((ASA + 128) / 256) * 0.15 * 0.01 * 1e6 + * Hadj = H * ((ASA + 128) / 256) * 1500 + */ + st->magn_raw_to_gauss[0] = (((int32_t)asa[0] + 128) * 1500) / 256; + st->magn_raw_to_gauss[1] = (((int32_t)asa[1] + 128) * 1500) / 256; + st->magn_raw_to_gauss[2] = (((int32_t)asa[2] + 128) * 1500) / 256; + + return 0; +} + +/** + * Probe magnetometer chip and setup all i2c transfers. + * SLV0: read sensor data + * SLV1: launch sensor single measurement + * + * Sampling data requires 2 cycles to read after measurement. + * A measurement can take up to ~10ms. + */ +int inv_mpu9250_magn_probe(struct inv_mpu6050_state *st) +{ + int ret; + + /* check and init mag chip */ + ret = inv_magn_init(st); + if (ret) + return ret; + + /* + * configure mpu i2c master accesses + * i2c SLV0: read sensor data, 7 bytes data(6)-ST2 + * Byte swap data to store them in big-endian in impair address groups + */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(0), + INV_MPU6050_BIT_I2C_SLV_RNW | + INV_MPU9250_MAGN_I2C_ADDR); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(0), + INV_MPU9250_MAGN_REG_DATA); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), + INV_MPU6050_BIT_SLV_EN | + INV_MPU6050_BIT_SLV_BYTE_SW | + INV_MPU6050_BIT_SLV_GRP | + INV_MPU9X50_BYTES_MAGN); + if (ret) + return ret; + + /* i2c SLV1: launch single measurement */ + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(1), + INV_MPU9250_MAGN_I2C_ADDR); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(1), + INV_MPU9250_MAGN_REG_CNTL1); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_DO(1), + INV_MPU9250_MAGN_BITS_MODE_SINGLE | + INV_MPU9250_MAGN_BIT_OUTPUT_BIT); + if (ret) + return ret; + ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(1), + INV_MPU6050_BIT_SLV_EN | 1); + if (ret) + return ret; + + return 0; +} + +/** + * Read magnetometer data from MPU fifo. + * Sampling data requires running the i2c master for 2 cycles. + * Use magnetometer maximal supported frequency. + */ +int inv_mpu9250_magn_read(const struct inv_mpu6050_state *st, int axis, + int *val) +{ + unsigned int user_ctrl, status; + __be16 data[3]; + uint8_t addr; + uint8_t d; + unsigned int period_ms; + int ret; + + /* Mag data: X - Y - Z */ + switch (axis) { + case IIO_MOD_X: + addr = 0; + break; + case IIO_MOD_Y: + addr = 1; + break; + case IIO_MOD_Z: + addr = 2; + break; + default: + return -EINVAL; + } + + /* set sample rate to max mag freq */ + d = INV_MPU6050_FIFO_RATE_TO_DIVIDER(INV_MPU9250_MAGN_FREQ_HZ_MAX); + ret = regmap_write(st->map, st->reg->sample_rate_div, d); + if (ret) + return ret; + + /* start i2c master, wait for xfer, stop */ + user_ctrl = st->chip_config.user_ctrl | INV_MPU6050_BIT_I2C_MST_EN; + ret = regmap_write(st->map, st->reg->user_ctrl, user_ctrl); + if (ret) + return ret; + /* need to wait 2 periods + half-period margin */ + period_ms = 1000 / INV_MPU9250_MAGN_FREQ_HZ_MAX; + msleep(period_ms * 2 + period_ms / 2); + user_ctrl = st->chip_config.user_ctrl; + ret = regmap_write(st->map, st->reg->user_ctrl, user_ctrl); + if (ret) + return ret; + + /* restore sample rate */ + d = st->chip_config.divider; + ret = regmap_write(st->map, st->reg->sample_rate_div, d); + if (ret) + return ret; + + /* check i2c status and read raw data */ + ret = regmap_read(st->map, INV_MPU6050_REG_I2C_MST_STATUS, &status); + if (ret) + return ret; + if (status & INV_MPU6050_BIT_I2C_SLV0_NACK || + status & INV_MPU6050_BIT_I2C_SLV1_NACK) + return -EIO; + ret = regmap_bulk_read(st->map, INV_MPU6050_REG_EXT_SENS_DATA, + data, sizeof(data)); + if (ret) + return ret; + + *val = (int16_t)be16_to_cpu(data[addr]); + + return IIO_VAL_INT; +} diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.h b/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.h new file mode 100644 index 000000000000..9899dd6c560c --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu9250_magn.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#ifndef INV_MPU9250_MAGN_H_ +#define INV_MPU9250_MAGN_H_ + +#include + +#include "inv_mpu_iio.h" + +/* Magnetometer maximum frequency */ +#define INV_MPU9250_MAGN_FREQ_HZ_MAX 50 + +/** + * inv_mpu9250_magn_probe() - MPU9250 implementation + */ +int inv_mpu9250_magn_probe(struct inv_mpu6050_state *st); + +/** + * inv_mpu9250_magn_read() - MPU9250 implementation + */ +int inv_mpu9250_magn_read(const struct inv_mpu6050_state *st, int axis, + int *val); + +#endif diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 82669ecb4735..5b462672bbcb 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -129,6 +129,7 @@ struct inv_mpu6050_hw { * @it_timestamp: timestamp from previous interrupt. * @data_timestamp: timestamp for next data sample. * @vddio_supply voltage regulator for the chip. + * @magn_raw_to_gauss: coefficient to convert mag raw value to Gauss. */ struct inv_mpu6050_state { struct mutex lock; @@ -150,6 +151,9 @@ struct inv_mpu6050_state { s64 it_timestamp; s64 data_timestamp; struct regulator *vddio_supply; +#ifdef CONFIG_INV_MPU6050_MAGN + s32 magn_raw_to_gauss[3]; +#endif }; /*register and associated bit definition*/ From patchwork Thu Aug 29 15:18:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14B7714D5 for ; Thu, 29 Aug 2019 15:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C852A20828 for ; Thu, 29 Aug 2019 15:37:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="xwmXgVOQ"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="gFqGZSZe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbfH2Ph1 (ORCPT ); Thu, 29 Aug 2019 11:37:27 -0400 Received: from mx0b-00328301.pphosted.com ([148.163.141.47]:56170 "EHLO mx0b-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbfH2Ph1 (ORCPT ); Thu, 29 Aug 2019 11:37:27 -0400 Received: from pps.filterd (m0156136.ppops.net [127.0.0.1]) by mx0b-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9ren001995; Thu, 29 Aug 2019 08:18:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=udsw7c3C+8DqbLgrH6g/o7PRZLWKMoCB96VTql8/46c=; b=xwmXgVOQlA1oZjc99Itft6jWVUyOLtxPzKiNJNsaxm5fl87ZZABjvWREGVGo25YRWKxn OKJpdGCs94tXaF/gKu+jC1S5VT/xcS3+C5v0e+90pOMXlXfVb4oFJXWCUKXjA05ynIYW G8QSFfKaLLxekgrAVuS5thQXP1UOpwitArPb8ACDxyvh5tnmt+bK2MYTBcxzHqtkevY4 VW/QLRzrV7AEJpt4/lixbSTXp3nK9x0FPBgyTmjPFTMaIZEzbqtITY+vKDUX48mfxJlF AnT5rcFEfgASLckgio9kRZRHvchk2KFhuXUdZbMGVVZ3wZZbWzvEqErtvahZiNYOGLaQ 8g== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2050.outbound.protection.outlook.com [104.47.48.50]) by mx0b-00328301.pphosted.com with ESMTP id 2ukyymt18t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AD+BASoyx+3WI5kaQNY6nodtGqIdvl50D3BVpRnHa0KYbmt7v7z601UVkunMBvggvMCiaz93feDzwgHFJVRxhRSjtZqAZyF9jzPCHg2gB2cOVk42/kVNpCa8h0U62hZmno8Q1vSxmZcc513M7FQA065IJXJJ2RUkQskEF6jjhOjlxd5rG0xPL7oPYMx4BQ+BlcPJOVjA5NaJlC1U/XnkAs8ouM6x1FUoVrNAg+2QOVrrWfxc8F3fVSof+gXXBjdI4jdGAyB4U1y4kXUghgiEZXu37BNvcdU9A8F0YrtGGKSuZcC6gnHV4yn4ZFgt6zMKa6dNHbFSRKSAQA/BnRsQfg== 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-SenderADCheck; bh=udsw7c3C+8DqbLgrH6g/o7PRZLWKMoCB96VTql8/46c=; b=lxwk/H/V2DjeAQUX4b69tzFBCrfDWmkvi4etG2X0q4neH7P4J2VZGWLbldu1h/v9ye0woZhSbFs6lw9oU0AjNtadW7zO3qUa+OnpSdFuFzYUIQFs+GNm11OWvbXeJkaZ1dyFVFWxEZrvSA4AyQ/w2L2JMJToGfGPGsaI+YgZ8K72QYUHGFgo3Zq7ieQunyx8rriQHI8ncHam4M1wU5FDFdD33zaHt41tPsqZmdCB1aiDGRDFwpWGtTrLgVpGZu5ukVUeih86zjcRVo8UfSTIXHz3y1wp8fcD2J7k3WfJud47ufAwU/kNACDdikLz8OKxkxpy8MRT7c6poS2B5dR6QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=udsw7c3C+8DqbLgrH6g/o7PRZLWKMoCB96VTql8/46c=; b=gFqGZSZeFKQyTaarP5V62/tLVZx+Eu4Kr1f/0qoh3J1mmUNJeeEfxb8g/E2x1bpx8jUPkq0H++fAKGhhJYF1nrtfmnaZHtFkJPEYWvbOyMvh5WfQTenmoONQB3cVc6ej1bN0ASidw2bF4AEfXgnsylztLbTZZfJYbf4Z3A2ZL4M= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:45 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:45 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 7/8] iio: imu: inv_mpu6050: add magnetometer support inside mpu driver Thread-Topic: [PATCH 7/8] iio: imu: inv_mpu6050: add magnetometer support inside mpu driver Thread-Index: AQHVXn0MYpJzl4x+WUecu/G2bHQLjw== Date: Thu, 29 Aug 2019 15:18:45 +0000 Message-ID: <20190829151801.13014-8-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cd3601aa-ed6a-4cbd-03cc-08d72c942ed4 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(14444005)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(30864003)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: b5F2U2X+Wcz+6xACixEUGlwgt/lAu6pxxHUJ255C6MVAQd+c0T12fzgTJ5dfSlVjyzZK/r6BrgR2gaBR2Pz2p2G9nGH+9dPfICZZC/2mw/YUiKjY4Q9RqyrLouN7CeUKiaockaMTj60ZJ/nJO2pfuu0cG96v7oRQIcrYKusH1a+HkiwnSawzg5i1q3JxXundTWhbmHEZo40pUlAvOVAzFVGaCrgwg6p1a+njmFBUb1JdhyFJwPZRLDsCa5sCqKRoXghSNa+kEfZ7LXNNRDxer9o+uiICoC/Zu6az88KME5H3eu72oIYg1A7qWkq1suNDpHHEt29eXc7wxYPgLRuvJQdlak5sGIpV/V1Ln25wO+zr6DcsUAZrhMSeG+mKcmk6bojCXelJ/u1uNjb9FwguCsSTllHfJ/p7bGuNXfYKKgU= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd3601aa-ed6a-4cbd-03cc-08d72c942ed4 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:45.2660 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zetAYztGTdbgIfLcitZDsjKxS0rEB/ForIr9OF7zaNRrauOWguCfonbAHvHLQexHL4uk8vYN2Wbx87yGSr9dZvkGSvIDeGQzSJGtLWKS3ZM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add inv_mpu_magn layer to manage several chip specific implementations and be noop when Kconfig option is not set. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/Makefile | 3 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 140 ++++++++++++++++++++- drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 + drivers/iio/imu/inv_mpu6050/inv_mpu_magn.c | 120 ++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h | 107 ++++++++++++++++ 5 files changed, 368 insertions(+), 4 deletions(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_magn.c create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h diff --git a/drivers/iio/imu/inv_mpu6050/Makefile b/drivers/iio/imu/inv_mpu6050/Makefile index fee41415ebdb..6f5baac29f81 100644 --- a/drivers/iio/imu/inv_mpu6050/Makefile +++ b/drivers/iio/imu/inv_mpu6050/Makefile @@ -5,7 +5,8 @@ obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o inv-mpu6050-y := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o -inv-mpu6050-$(CONFIG_INV_MPU6050_MAGN) += inv_mpu_aux.o inv_mpu9250_magn.o +inv-mpu6050-$(CONFIG_INV_MPU6050_MAGN) += inv_mpu_aux.o inv_mpu_magn.o \ + inv_mpu9250_magn.o obj-$(CONFIG_INV_MPU6050_I2C) += inv-mpu6050-i2c.o inv-mpu6050-i2c-y := inv_mpu_i2c.o inv_mpu_acpi.o diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index b17f060b52fc..d08cec6a8a7a 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -16,7 +16,9 @@ #include #include #include + #include "inv_mpu_iio.h" +#include "inv_mpu_magn.h" /* * this is the gyro scale translated from dynamic range plus/minus @@ -332,6 +334,11 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev) */ st->chip_period = NSEC_PER_MSEC; + /* magn chip init, noop if not present in the chip */ + result = inv_mpu_magn_probe(st); + if (result) + goto error_power_off; + return inv_mpu6050_set_power_itg(st, false); error_power_off: @@ -411,6 +418,9 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev, ret = inv_mpu6050_sensor_show(st, st->reg->temperature, IIO_MOD_X, val); break; + case IIO_MAGN: + ret = inv_mpu_magn_read(st, chan->channel2, val); + break; default: ret = -EINVAL; break; @@ -469,6 +479,8 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev, *val2 = INV_MPU6050_TEMP_SCALE; return IIO_VAL_INT_PLUS_MICRO; + case IIO_MAGN: + return inv_mpu_magn_get_scale(st, chan, val, val2); default: return -EINVAL; } @@ -710,6 +722,11 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr, if (result) goto fifo_rate_fail_power_off; + /* update rate for magn, noop if not present in chip */ + result = inv_mpu_magn_set_rate(st, fifo_rate); + if (result) + goto fifo_rate_fail_power_off; + fifo_rate_fail_power_off: result |= inv_mpu6050_set_power_itg(st, false); fifo_rate_fail_unlock: @@ -795,8 +812,13 @@ inv_get_mount_matrix(const struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { struct inv_mpu6050_state *data = iio_priv(indio_dev); + const struct iio_mount_matrix *matrix = &data->orientation; - return &data->orientation; +#ifdef CONFIG_INV_MPU6050_MAGN + if (chan->type == IIO_MAGN) + matrix = &data->magn_orient; +#endif + return matrix; } static const struct iio_chan_spec_ext_info inv_ext_info[] = { @@ -864,6 +886,102 @@ static const unsigned long inv_mpu_scan_masks[] = { 0, }; +#ifdef CONFIG_INV_MPU6050_MAGN + +#define INV_MPU9X50_MAGN_CHAN(_chan2, _bits, _index) \ + { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = _chan2, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_RAW), \ + .scan_index = _index, \ + .scan_type = { \ + .sign = 's', \ + .realbits = _bits, \ + .storagebits = 16, \ + .shift = 0, \ + .endianness = IIO_BE, \ + }, \ + .ext_info = inv_ext_info, \ + } + +static const struct iio_chan_spec inv_mpu9250_channels[] = { + IIO_CHAN_SOFT_TIMESTAMP(INV_MPU9X50_SCAN_TIMESTAMP), + /* + * Note that temperature should only be via polled reading only, + * not the final scan elements output. + */ + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) + | BIT(IIO_CHAN_INFO_OFFSET) + | BIT(IIO_CHAN_INFO_SCALE), + .scan_index = -1, + }, + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_MPU9X50_SCAN_GYRO_X), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_MPU9X50_SCAN_GYRO_Y), + INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_MPU9X50_SCAN_GYRO_Z), + + INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_X, INV_MPU9X50_SCAN_ACCL_X), + INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Y, INV_MPU9X50_SCAN_ACCL_Y), + INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU9X50_SCAN_ACCL_Z), + + /* Magnetometer resolution is 16 bits */ + INV_MPU9X50_MAGN_CHAN(IIO_MOD_X, 16, INV_MPU9X50_SCAN_MAGN_X), + INV_MPU9X50_MAGN_CHAN(IIO_MOD_Y, 16, INV_MPU9X50_SCAN_MAGN_Y), + INV_MPU9X50_MAGN_CHAN(IIO_MOD_Z, 16, INV_MPU9X50_SCAN_MAGN_Z), +}; + +static const unsigned long inv_mpu9x50_scan_masks[] = { + /* 3-axis accel */ + BIT(INV_MPU9X50_SCAN_ACCL_X) + | BIT(INV_MPU9X50_SCAN_ACCL_Y) + | BIT(INV_MPU9X50_SCAN_ACCL_Z), + /* 3-axis gyro */ + BIT(INV_MPU9X50_SCAN_GYRO_X) + | BIT(INV_MPU9X50_SCAN_GYRO_Y) + | BIT(INV_MPU9X50_SCAN_GYRO_Z), + /* 3-axis magn */ + BIT(INV_MPU9X50_SCAN_MAGN_X) + | BIT(INV_MPU9X50_SCAN_MAGN_Y) + | BIT(INV_MPU9X50_SCAN_MAGN_Z), + /* 6-axis accel + gyro */ + BIT(INV_MPU9X50_SCAN_ACCL_X) + | BIT(INV_MPU9X50_SCAN_ACCL_Y) + | BIT(INV_MPU9X50_SCAN_ACCL_Z) + | BIT(INV_MPU9X50_SCAN_GYRO_X) + | BIT(INV_MPU9X50_SCAN_GYRO_Y) + | BIT(INV_MPU9X50_SCAN_GYRO_Z), + /* 6-axis accel + magn */ + BIT(INV_MPU9X50_SCAN_ACCL_X) + | BIT(INV_MPU9X50_SCAN_ACCL_Y) + | BIT(INV_MPU9X50_SCAN_ACCL_Z) + | BIT(INV_MPU9X50_SCAN_MAGN_X) + | BIT(INV_MPU9X50_SCAN_MAGN_Y) + | BIT(INV_MPU9X50_SCAN_MAGN_Z), + /* 6-axis gyro + magn */ + BIT(INV_MPU9X50_SCAN_GYRO_X) + | BIT(INV_MPU9X50_SCAN_GYRO_Y) + | BIT(INV_MPU9X50_SCAN_GYRO_Z) + | BIT(INV_MPU9X50_SCAN_MAGN_X) + | BIT(INV_MPU9X50_SCAN_MAGN_Y) + | BIT(INV_MPU9X50_SCAN_MAGN_Z), + /* 9-axis accel + gyro + magn */ + BIT(INV_MPU9X50_SCAN_ACCL_X) + | BIT(INV_MPU9X50_SCAN_ACCL_Y) + | BIT(INV_MPU9X50_SCAN_ACCL_Z) + | BIT(INV_MPU9X50_SCAN_GYRO_X) + | BIT(INV_MPU9X50_SCAN_GYRO_Y) + | BIT(INV_MPU9X50_SCAN_GYRO_Z) + | BIT(INV_MPU9X50_SCAN_MAGN_X) + | BIT(INV_MPU9X50_SCAN_MAGN_Y) + | BIT(INV_MPU9X50_SCAN_MAGN_Z), + 0, +}; + +#endif + static const struct iio_chan_spec inv_icm20602_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(INV_ICM20602_SCAN_TIMESTAMP), { @@ -1145,6 +1263,11 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, return result; } + /* fill magnetometer orientation */ + result = inv_mpu_magn_set_orient(st); + if (result) + return result; + /* power is turned on inside check chip type*/ result = inv_check_and_setup_chip(st); if (result) @@ -1167,14 +1290,25 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, else indio_dev->name = dev_name(dev); - if (chip_type == INV_ICM20602) { + switch (chip_type) { +#ifdef CONFIG_INV_MPU6050_MAGN + case INV_MPU9250: + case INV_MPU9255: + indio_dev->channels = inv_mpu9250_channels; + indio_dev->num_channels = ARRAY_SIZE(inv_mpu9250_channels); + indio_dev->available_scan_masks = inv_mpu9x50_scan_masks; + break; +#endif + case INV_ICM20602: indio_dev->channels = inv_icm20602_channels; indio_dev->num_channels = ARRAY_SIZE(inv_icm20602_channels); indio_dev->available_scan_masks = inv_icm20602_scan_masks; - } else { + break; + default: indio_dev->channels = inv_mpu_channels; indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels); indio_dev->available_scan_masks = inv_mpu_scan_masks; + break; } indio_dev->info = &mpu_info; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 5b462672bbcb..cfc11cb0a36c 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -130,6 +130,7 @@ struct inv_mpu6050_hw { * @data_timestamp: timestamp for next data sample. * @vddio_supply voltage regulator for the chip. * @magn_raw_to_gauss: coefficient to convert mag raw value to Gauss. + * @magn_orient: magnetometer sensor chip orientation if available. */ struct inv_mpu6050_state { struct mutex lock; @@ -153,6 +154,7 @@ struct inv_mpu6050_state { struct regulator *vddio_supply; #ifdef CONFIG_INV_MPU6050_MAGN s32 magn_raw_to_gauss[3]; + struct iio_mount_matrix magn_orient; #endif }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.c new file mode 100644 index 000000000000..2bb40dae0429 --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#include +#include +#include + +#include "inv_mpu_iio.h" +#include "inv_mpu_aux.h" +#include "inv_mpu9250_magn.h" + +int inv_mpu_magn_probe(struct inv_mpu6050_state *st) +{ + int ret; + + /* probe and init mag chip */ + switch (st->chip_type) { + case INV_MPU9250: + case INV_MPU9255: + /* configure i2c master aux port */ + ret = inv_mpu_aux_init(st); + if (ret) + return ret; + return inv_mpu9250_magn_probe(st); + default: + break; + } + + return 0; +} + +int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, int fifo_rate) +{ + int max_freq; + uint8_t d; + + switch (st->chip_type) { + case INV_MPU9250: + case INV_MPU9255: + max_freq = INV_MPU9250_MAGN_FREQ_HZ_MAX; + break; + default: + return 0; + } + + /* + * update i2c master delay to limit mag sampling to max frequency + * compute fifo_rate divider d: rate = fifo_rate / (d + 1) + */ + if (fifo_rate > max_freq) + d = fifo_rate / max_freq - 1; + else + d = 0; + + return regmap_write(st->map, INV_MPU6050_REG_I2C_SLV4_CTRL, d); +} + +int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st) +{ + const char *orient; + char *str; + int i; + + /* fill magnetometer orientation */ + switch (st->chip_type) { + case INV_MPU9250: + case INV_MPU9255: + /* x <- y */ + st->magn_orient.rotation[0] = st->orientation.rotation[3]; + st->magn_orient.rotation[1] = st->orientation.rotation[4]; + st->magn_orient.rotation[2] = st->orientation.rotation[5]; + /* y <- x */ + st->magn_orient.rotation[3] = st->orientation.rotation[0]; + st->magn_orient.rotation[4] = st->orientation.rotation[1]; + st->magn_orient.rotation[5] = st->orientation.rotation[2]; + /* z <- -z */ + for (i = 0; i < 3; ++i) { + orient = st->orientation.rotation[6 + i]; + /* use length + 2 for adding minus sign if needed */ + str = devm_kzalloc(regmap_get_device(st->map), + strlen(orient) + 2, GFP_KERNEL); + if (str == NULL) + return -ENOMEM; + if (strcmp(orient, "0") == 0) { + strcpy(str, orient); + } else if (orient[0] == '-') { + strcpy(str, &orient[1]); + } else { + str[0] = '-'; + strcpy(&str[1], orient); + } + st->magn_orient.rotation[6 + i] = str; + } + break; + default: + st->magn_orient = st->orientation; + break; + } + + return 0; +} + +int inv_mpu_magn_read(const struct inv_mpu6050_state *st, int axis, int *val) +{ + int ret; + + switch (st->chip_type) { + case INV_MPU9250: + case INV_MPU9255: + ret = inv_mpu9250_magn_read(st, axis, val); + break; + default: + ret = -ENODEV; + break; + } + + return ret; +} diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h new file mode 100644 index 000000000000..efa2ec1b3b2f --- /dev/null +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 TDK-InvenSense, Inc. + */ + +#ifndef INV_MPU_MAGN_H_ +#define INV_MPU_MAGN_H_ + +#include + +#include "inv_mpu_iio.h" + +#ifdef CONFIG_INV_MPU6050_MAGN + +/** + * inv_mpu_magn_probe() - probe and setup magnetometer chip + * @st: driver internal state + * + * Returns 0 on success, a negative error code otherwise + * + * It is probing the chip and setting up all needed i2c transfers. + * Noop if there is no magnetometer in the chip. + */ +int inv_mpu_magn_probe(struct inv_mpu6050_state *st); + +/** + * inv_mpu_magn_get_scale() - get magnetometer scale value + * @st: driver internal state + * + * Returns IIO data format. + */ +static inline int inv_mpu_magn_get_scale(const struct inv_mpu6050_state *st, + const struct iio_chan_spec *chan, + int *val, int *val2) +{ + *val = 0; + *val2 = st->magn_raw_to_gauss[chan->address]; + return IIO_VAL_INT_PLUS_MICRO; +} + +/** + * inv_mpu_magn_set_rate() - set magnetometer sampling rate + * @st: driver internal state + * @fifo_rate: mpu set fifo rate + * + * Returns 0 on success, a negative error code otherwise + * + * Limit sampling frequency to the maximum value supported by the + * magnetometer chip. Resulting in duplicated data for higher frequencies. + * Noop if there is no magnetometer in the chip. + */ +int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, int fifo_rate); + +/** + * inv_mpu_magn_set_orient() - fill magnetometer mounting matrix + * @st: driver internal state + * + * Returns 0 on success, a negative error code otherwise + * + * Fill magnetometer mounting matrix using the provided chip matrix. + */ +int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st); + +/** + * inv_mpu_magn_read() - read magnetometer data + * @st: driver internal state + * @axis: IIO modifier axis value + * @val: store corresponding axis value + * + * Returns 0 on success, a negative error code otherwise + */ +int inv_mpu_magn_read(const struct inv_mpu6050_state *st, int axis, int *val); + +#else /* CONFIG_INV_MPU6050_MAGN */ + +static inline int inv_mpu_magn_probe(struct inv_mpu6050_state *st) +{ + return 0; +} + +static inline int inv_mpu_magn_get_scale(const struct inv_mpu6050_state *st, + const struct iio_chan_spec *chan, + int *val, int *val2) +{ + return -EINVAL; +} + +static inline int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, + int fifo_rate) +{ + return 0; +} + +static inline int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st) +{ + return 0; +} + +static inline int inv_mpu_magn_read(const struct inv_mpu6050_state *st, int axis, + int *val) +{ + return 0; +} + +#endif /* CONFIG_INV_MPU6050_MAGN */ + +#endif /* INV_MPU_MAGN_H_ */ From patchwork Thu Aug 29 15:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 11121737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE16813B1 for ; Thu, 29 Aug 2019 15:36:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5DD22073F for ; Thu, 29 Aug 2019 15:36:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=invensense.com header.i=@invensense.com header.b="AyIAolWK"; dkim=pass (1024-bit key) header.d=invensense.onmicrosoft.com header.i=@invensense.onmicrosoft.com header.b="K3CYOuVg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbfH2Pgs (ORCPT ); Thu, 29 Aug 2019 11:36:48 -0400 Received: from mx0b-00328301.pphosted.com ([148.163.141.47]:7816 "EHLO mx0b-00328301.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbfH2Pgs (ORCPT ); Thu, 29 Aug 2019 11:36:48 -0400 X-Greylist: delayed 1087 seconds by postgrey-1.27 at vger.kernel.org; Thu, 29 Aug 2019 11:36:46 EDT Received: from pps.filterd (m0156136.ppops.net [127.0.0.1]) by mx0b-00328301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7TF9reo001995; Thu, 29 Aug 2019 08:18:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt1; bh=eKJpu0FAG3xTlEJyaTt5j7RpzxzHKBb6JyV+n1KauIE=; b=AyIAolWKfPs7vA375sDowh4BgbcVQyG3lJAlKgzmsYLlZhHaPtw54fJYMr+hn8pLy5oy pS91bzWZsZwr5L02ttiY9xZboLtImPRrrg83hC1sgH46SiJviD0BKWgPnllPDokv2jfE k+WybbmURgYiO2J4N/Q/UrxGMYtohDVobvCJ/tyX0xzyYYYVavDAMnLLbIaHbkO71zXx xI/dx/HzZlHmio1BNd1k0pUcolRSAa6DGdQsHY8IdeEGTo1i1V6SOrHWiVDqJSuaSZDp Iiemoe7bDeiKYcOqqjP7reVZ9O+kFa+MmRlvtM/dxWbQRvsemqWGjuMN9e4vjFajkvs/ dg== Received: from nam05-co1-obe.outbound.protection.outlook.com (mail-co1nam05lp2050.outbound.protection.outlook.com [104.47.48.50]) by mx0b-00328301.pphosted.com with ESMTP id 2ukyymt18t-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 08:18:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GgXhtJIk8DRNRKWvo97Xn/4RCTvie8RMSUpul4WnbhwDudwI0EFJuaZs1EoKKhYcrBBq547SobwetXwJhyN3X4cU46iDoFFvuIPih20ZYolHn2kjS49Rr+Dp+DuLt/B8oO3ndwmKg6B04hWI+Nq9OP5HPfPiwmiFOU4SI71zjaSSR/jAthXtTQpkz3MTSiJPi9SQUrkrK38wC/EEw1lcudLWWm/Xz8yste6z9oKnduOYs3Kgi99GIzOdRXbIY86XWhtOJKsUCjx/u0uFXZDPEyOaSHyiOu5q1ENNi0vwS6AsaiUKWAwTvP9nzal8w0zPgFCD2zdD6xFjUjVMI+g0kw== 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-SenderADCheck; bh=eKJpu0FAG3xTlEJyaTt5j7RpzxzHKBb6JyV+n1KauIE=; b=mA6lop09cHAFCpbQkWQC8W6mX7o/Q7ExuRpZYi4idswPVutySeEug1Q+3s7YuDurTsEYPfmfb7TQry0CkAByRH8bhTgUue8szj5L/A5uC+c7KGJGdO5ioCM7DSfPxDRkv3AnYDUA4jvCMWHU7Gu8eP1RfX1+HqTP7DLeJll2ZDq2nMyy+vnnnLdUOd8o7oXkDTLEn41fQMN5A1H+iZDiaJckQwgFsnoqr5cw0YGqQo69WbmWkojjMmyc17XE1cdYXSzAH9LgbItfSBxglpz9mvqxtk0y8W6p9gDwr1UdykSOZ3TvoBIJeadCT4Mps8My2frVg7aCE+UWUYnUCFy8ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=invensense.com; dmarc=pass action=none header.from=invensense.com; dkim=pass header.d=invensense.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector2-invensense-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eKJpu0FAG3xTlEJyaTt5j7RpzxzHKBb6JyV+n1KauIE=; b=K3CYOuVg+PUr/gVi1nMYZLlALk5imQD9u4o0iMpieqI1gZ6/NcT6M19GtZj8Z9aoCM59G8YXWfsjbxsRJ8rpv7eikcXw9EIpyvyOyT9C/sO/F+a5Md7Tlf69JwYVHJGPcBCY1SvckK5Ehsu8LkSG44++qUruvlLlMKlJTD2mKMY= Received: from BYAPR12MB3366.namprd12.prod.outlook.com (20.178.55.207) by BYAPR12MB3638.namprd12.prod.outlook.com (20.178.54.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.16; Thu, 29 Aug 2019 15:18:47 +0000 Received: from BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861]) by BYAPR12MB3366.namprd12.prod.outlook.com ([fe80::24a1:e93b:cc7:5861%7]) with mapi id 15.20.2199.021; Thu, 29 Aug 2019 15:18:46 +0000 From: Jean-Baptiste Maneyrol To: "jic23@kernel.org" CC: "linux-iio@vger.kernel.org" , Jean-Baptiste Maneyrol Subject: [PATCH 8/8] iio: imu: inv_mpu6050: add fifo support for magnetometer data Thread-Topic: [PATCH 8/8] iio: imu: inv_mpu6050: add fifo support for magnetometer data Thread-Index: AQHVXn0N9geTb3i1l0qss4zhN1di9Q== Date: Thu, 29 Aug 2019 15:18:46 +0000 Message-ID: <20190829151801.13014-9-jmaneyrol@invensense.com> References: <20190829151801.13014-1-jmaneyrol@invensense.com> In-Reply-To: <20190829151801.13014-1-jmaneyrol@invensense.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0137.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::29) To BYAPR12MB3366.namprd12.prod.outlook.com (2603:10b6:a03:a9::15) x-originating-ip: [77.157.193.39] x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ce490043-6b12-4977-a097-08d72c942fd1 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR12MB3638; x-ms-traffictypediagnostic: BYAPR12MB3638: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2331; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(376002)(346002)(39850400004)(136003)(199004)(189003)(4326008)(6486002)(256004)(14454004)(1076003)(14444005)(316002)(26005)(102836004)(81166006)(66066001)(81156014)(386003)(6506007)(305945005)(86362001)(2351001)(6916009)(186003)(2501003)(80792005)(7736002)(36756003)(50226002)(2616005)(6512007)(8676002)(478600001)(71190400001)(71200400001)(64756008)(54906003)(66946007)(2906002)(66446008)(6116002)(52116002)(76176011)(66476007)(99286004)(66556008)(8936002)(446003)(486006)(107886003)(5640700003)(53936002)(11346002)(476003)(6436002)(5660300002)(3846002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3638;H:BYAPR12MB3366.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: /Sg1Wc33raqTqXrno/jQdawpZZ2RbvHtQWWPoN0ThW6v0oIDwDp4zziN0XoepcCXgcJaSwZkB6Pn2IP9XkY4bbSAQf9BJo+nk1Co31uIeKky1hePSctJLGaRX3DpvSrcENhv2KTPD61AOTQeK450W78VFaDjz5pCM3akkFiQ8iIcXYGdjzS8un7sobcXJJtgnHUfiqP0ewW6Q+ATAPOxYQtRkAy3en+/AE+2XmjsetaRFGMboHCc7frIgnvzvkv3lgEo2tKyj6ZOkd25D2d/Ro5VY8ChBmqF3cnOrZ6N+6kamd6DIj+ko64nddMwsmLjiIsb3lqG8xuPFR7JMh4S5jyfApHfgDCTlnlyg57sZ3Dty49aXNmai/spAJ4hhNrLV7YmNja3zcsBcy2xFqEk28uKdhwHAAw4m76PhFaivwk= MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce490043-6b12-4977-a097-08d72c942fd1 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2019 15:18:46.8262 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3aGOKhD2ftsmeMUR2g+UGvj7rVeb8T690LNiVLhaZSoH/4ts2zoRgZyf9zOb2ufH7vkTdT7ZF2pavWjNPc9v+0UTBH1dbOxtskBaFGCUb2Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3638 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-08-29_07:2019-08-29,2019-08-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908290164 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Put read magnetometer data by mpu inside the fifo. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 + drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 14 ++- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 90 +++++++++++++++++-- 4 files changed, 94 insertions(+), 13 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index d08cec6a8a7a..d4a321fd03a9 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -105,6 +105,7 @@ static const struct inv_mpu6050_chip_config chip_config_6050 = { .divider = INV_MPU6050_FIFO_RATE_TO_DIVIDER(INV_MPU6050_INIT_FIFO_RATE), .gyro_fifo_enable = false, .accl_fifo_enable = false, + .magn_fifo_enable = false, .accl_fs = INV_MPU6050_FS_02G, .user_ctrl = 0, }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index cfc11cb0a36c..48ed66e39cda 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -86,6 +86,7 @@ enum inv_devices { * @accl_fs: accel full scale range. * @accl_fifo_enable: enable accel data output * @gyro_fifo_enable: enable gyro data output + * @magn_fifo_enable: enable magn data output * @divider: chip sample rate divider (sample rate divider - 1) */ struct inv_mpu6050_chip_config { @@ -94,6 +95,7 @@ struct inv_mpu6050_chip_config { unsigned int accl_fs:2; unsigned int accl_fifo_enable:1; unsigned int gyro_fifo_enable:1; + unsigned int magn_fifo_enable:1; u8 divider; u8 user_ctrl; }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 5f9a5de0bab4..f0a5350c1848 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -14,6 +14,7 @@ #include #include #include + #include "inv_mpu_iio.h" /** @@ -124,7 +125,8 @@ int inv_reset_fifo(struct iio_dev *indio_dev) /* enable interrupt */ if (st->chip_config.accl_fifo_enable || - st->chip_config.gyro_fifo_enable) { + st->chip_config.gyro_fifo_enable || + st->chip_config.magn_fifo_enable) { result = regmap_write(st->map, st->reg->int_enable, INV_MPU6050_BIT_DATA_RDY_EN); if (result) @@ -141,6 +143,8 @@ int inv_reset_fifo(struct iio_dev *indio_dev) d |= INV_MPU6050_BITS_GYRO_OUT; if (st->chip_config.accl_fifo_enable) d |= INV_MPU6050_BIT_ACCEL_OUT; + if (st->chip_config.magn_fifo_enable) + d |= INV_MPU6050_BIT_SLAVE_0; result = regmap_write(st->map, st->reg->fifo_en, d); if (result) goto reset_fifo_fail; @@ -190,17 +194,19 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) } if (!(st->chip_config.accl_fifo_enable | - st->chip_config.gyro_fifo_enable)) + st->chip_config.gyro_fifo_enable | + st->chip_config.magn_fifo_enable)) goto end_session; + bytes_per_datum = 0; if (st->chip_config.accl_fifo_enable) bytes_per_datum += INV_MPU6050_BYTES_PER_3AXIS_SENSOR; - if (st->chip_config.gyro_fifo_enable) bytes_per_datum += INV_MPU6050_BYTES_PER_3AXIS_SENSOR; - if (st->chip_type == INV_ICM20602) bytes_per_datum += INV_ICM20602_BYTES_PER_TEMP_SENSOR; + if (st->chip_config.magn_fifo_enable) + bytes_per_datum += INV_MPU9X50_BYTES_MAGN; /* * read fifo_count register to know how many bytes are inside the FIFO diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c index dd55e70b6f77..fa4928e589b9 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c @@ -5,7 +5,7 @@ #include "inv_mpu_iio.h" -static void inv_scan_query(struct iio_dev *indio_dev) +static void inv_scan_query_mpu6050(struct iio_dev *indio_dev) { struct inv_mpu6050_state *st = iio_priv(indio_dev); @@ -26,6 +26,52 @@ static void inv_scan_query(struct iio_dev *indio_dev) indio_dev->active_scan_mask); } +#ifdef CONFIG_INV_MPU6050_MAGN +static void inv_scan_query_mpu9x50(struct iio_dev *indio_dev) +{ + struct inv_mpu6050_state *st = iio_priv(indio_dev); + + st->chip_config.gyro_fifo_enable = + test_bit(INV_MPU9X50_SCAN_GYRO_X, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_GYRO_Y, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_GYRO_Z, + indio_dev->active_scan_mask); + + st->chip_config.accl_fifo_enable = + test_bit(INV_MPU9X50_SCAN_ACCL_X, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_ACCL_Y, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_ACCL_Z, + indio_dev->active_scan_mask); + + st->chip_config.magn_fifo_enable = + test_bit(INV_MPU9X50_SCAN_MAGN_X, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_MAGN_Y, + indio_dev->active_scan_mask) || + test_bit(INV_MPU9X50_SCAN_MAGN_Z, + indio_dev->active_scan_mask); +} +#endif + +static void inv_scan_query(struct iio_dev *indio_dev) +{ + struct inv_mpu6050_state *st = iio_priv(indio_dev); + + switch (st->chip_type) { +#ifdef CONFIG_INV_MPU6050_MAGN + case INV_MPU9250: + case INV_MPU9255: + return inv_scan_query_mpu9x50(indio_dev); +#endif + default: + return inv_scan_query_mpu6050(indio_dev); + } +} + /** * inv_mpu6050_set_enable() - enable chip functions. * @indio_dev: Device driver instance. @@ -34,6 +80,11 @@ static void inv_scan_query(struct iio_dev *indio_dev) static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) { struct inv_mpu6050_state *st = iio_priv(indio_dev); + uint8_t d; + unsigned int gyro_skip = 0; + unsigned int accl_skip = 0; + unsigned int magn_skip = 0; + unsigned int skip_samples; int result; if (enable) { @@ -41,14 +92,13 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) if (result) return result; inv_scan_query(indio_dev); - st->skip_samples = 0; if (st->chip_config.gyro_fifo_enable) { result = inv_mpu6050_switch_engine(st, true, INV_MPU6050_BIT_PWR_GYRO_STBY); if (result) goto error_power_off; /* gyro first sample is out of specs, skip it */ - st->skip_samples = 1; + gyro_skip = 1; } if (st->chip_config.accl_fifo_enable) { result = inv_mpu6050_switch_engine(st, true, @@ -56,22 +106,40 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) if (result) goto error_gyro_off; } + if (st->chip_config.magn_fifo_enable) { + d = st->chip_config.user_ctrl | + INV_MPU6050_BIT_I2C_MST_EN; + result = regmap_write(st->map, st->reg->user_ctrl, d); + if (result) + goto error_accl_off; + st->chip_config.user_ctrl = d; + /* mag first sample is always not ready, skip it */ + magn_skip = 1; + } + /* compute first samples to skip */ + skip_samples = gyro_skip; + if (accl_skip > skip_samples) + skip_samples = accl_skip; + if (magn_skip > skip_samples) + skip_samples = magn_skip; + st->skip_samples = skip_samples; result = inv_reset_fifo(indio_dev); if (result) - goto error_accl_off; + goto error_magn_off; } else { result = regmap_write(st->map, st->reg->fifo_en, 0); if (result) - goto error_accl_off; + goto error_magn_off; result = regmap_write(st->map, st->reg->int_enable, 0); if (result) - goto error_accl_off; + goto error_magn_off; - result = regmap_write(st->map, st->reg->user_ctrl, - st->chip_config.user_ctrl); + d = st->chip_config.user_ctrl & ~INV_MPU6050_BIT_I2C_MST_EN; + result = regmap_write(st->map, st->reg->user_ctrl, d); if (result) - goto error_accl_off; + goto error_magn_off; + st->chip_config.user_ctrl = d; result = inv_mpu6050_switch_engine(st, false, INV_MPU6050_BIT_PWR_ACCL_STBY); @@ -90,6 +158,10 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) return 0; +error_magn_off: + /* always restore user_ctrl to disable fifo properly */ + st->chip_config.user_ctrl &= ~INV_MPU6050_BIT_I2C_MST_EN; + regmap_write(st->map, st->reg->user_ctrl, st->chip_config.user_ctrl); error_accl_off: if (st->chip_config.accl_fifo_enable) inv_mpu6050_switch_engine(st, false,