From patchwork Wed Apr 14 19:54:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 421926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00C4DC43460 for ; Wed, 14 Apr 2021 19:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D600A611B0 for ; Wed, 14 Apr 2021 19:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353552AbhDNTzU (ORCPT ); Wed, 14 Apr 2021 15:55:20 -0400 Received: from mga12.intel.com ([192.55.52.136]:14799 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234221AbhDNTzS (ORCPT ); Wed, 14 Apr 2021 15:55:18 -0400 IronPort-SDR: /fxuuKkazkpa2rtgmWsRig1SNOQI4y+ik3Z8mZzcIroWHEWSoGJ+R9M937hFqV/jVwWdEAqGWv 2+606XTno94g== X-IronPort-AV: E=McAfee;i="6200,9189,9954"; a="174221165" X-IronPort-AV: E=Sophos;i="5.82,223,1613462400"; d="scan'208";a="174221165" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2021 12:54:55 -0700 IronPort-SDR: iLzKHbDYxDY/qOMg+QfF3V+gEWyCDN3qxL3XDicwBuR28h+UuWNGVOCdirKxvkxDHENi6TuW5p WBf+xlJXSX2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,223,1613462400"; d="scan'208";a="450893111" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 14 Apr 2021 12:54:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BA8DD142; Wed, 14 Apr 2021 22:55:09 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , =?utf-8?b?R2HDq3RhbiBB?= =?utf-8?b?bmRyw6k=?= , Andy Shevchenko , =?utf-8?q?Nuno_S=C3=A1?= , Denis Ciocca , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring Subject: [PATCH v1 3/7] iio: magnetometer: st_magn: Provide default platform data Date: Wed, 14 Apr 2021 22:54:50 +0300 Message-Id: <20210414195454.84183-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414195454.84183-1-andriy.shevchenko@linux.intel.com> References: <20210414195454.84183-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Provide default platform data for magnetometer in case it supports DRDY. One case is LSM9DS0 IMU, on which it is the case. Since accelerometer is using INT1, default magnetometer to INT2. While at it, update description of the drdy_int_pin field. Signed-off-by: Andy Shevchenko --- drivers/iio/magnetometer/st_magn_core.c | 11 ++++++++++- include/linux/platform_data/st_sensors_pdata.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 79de721e6015..cf3722e42419 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -382,6 +382,11 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { }, }; +/* Default magn DRDY is available on INT2 pin */ +static const struct st_sensors_platform_data default_magn_pdata = { + .drdy_int_pin = 2, +}; + static int st_magn_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *ch, int *val, int *val2, long mask) @@ -489,6 +494,7 @@ EXPORT_SYMBOL(st_magn_get_settings); int st_magn_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *mdata = iio_priv(indio_dev); + struct st_sensors_platform_data *pdata = dev_get_platdata(mdata->dev); int err; indio_dev->modes = INDIO_DIRECT_MODE; @@ -509,7 +515,10 @@ int st_magn_common_probe(struct iio_dev *indio_dev) mdata->current_fullscale = &mdata->sensor_settings->fs.fs_avl[0]; mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev, NULL); + if (!pdata) + pdata = (struct st_sensors_platform_data *)&default_magn_pdata; + + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_magn_power_off; diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index e40b28ca892e..897051e51b78 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -13,8 +13,9 @@ /** * struct st_sensors_platform_data - Platform data for the ST sensors * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). - * Available only for accelerometer and pressure sensors. + * Available only for accelerometer, magnetometer and pressure sensors. * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). + * Magnetometer DRDY is supported only on LSM9DS0. * @open_drain: set the interrupt line to be open drain if possible. * @spi_3wire: enable spi-3wire mode. * @pullups: enable/disable i2c controller pullup resistors.