Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp18444994ybl; Fri, 3 Jan 2020 02:29:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyGHK3IeFwem3x2mwoGWq3QmcmZIJ95EEgR+4QXDJZZ67AeE8VzyymeoAOhUCQQXfXGGqTr X-Received: by 2002:a9d:7410:: with SMTP id n16mr85739285otk.23.1578047356522; Fri, 03 Jan 2020 02:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578047356; cv=none; d=google.com; s=arc-20160816; b=A/dE25JoUby4fnQs/8BZmevjqbF2+TNw0rTVaAU8E9z+W52fKWHwwKHALLy86bp1Xe 3yWHXgaPXqCmv4bQwk5l3XTp1ZjRWvXZBacosvdetTdI6sGXODyxQXxzP3iLD2bX88/9 vpSJJpJennXQW8KzlOw83GYeJmHunDVVSPePqsc/dpHzb7CGObjt+y6xkuHOh4ftlDSS 4VdkLDsDZ2cMpJb9w01iVfC4f/q4PvfUicJi/GVgug3xMLo+M3mFYuZh2hKmCXKr4wC+ 5ILbn4kPQNCC8vyEq4TXe+HocviDBTcyyg8+Yf7uwqRUGkDJA8TwBkKXauLuqmQxvzW3 iFgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from; bh=/ama+sjn/thkUScJx5b8YW9MROnUhZTWTWPySDXwIQ8=; b=wbCr1m86Qdpmncy4AjKpj4R46cM8ab2k9mEQA1UXsitO/cIke044KclN8FyqDHucmH 80xtKd4uvMsDuMRsqowZ6nzctCZv2fBfmpRbYndmKIZFzO9NNNqwRMoFVTFNSGF9vESu 6P9LvVn5tvVW18pcpetGC8kqfoQAGXqIjwh3n/SmGOA5soCJD7UhFXoN7lXxFSvXtDMT qnyYTwzHavUX1IOwNlJODCEpc+KLqoLyjO9zOH9gljL9+61fiwbJ7Pfwv9tsn6ZqLQ4W UXw1ELla5SUXnF4fqYyisNDbYmReYMT6rzFTe+H4hmrkC6eA6O+xxXrExOv8prVmEFFr E75Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si18252823oib.70.2020.01.03.02.29.04; Fri, 03 Jan 2020 02:29:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727489AbgACK1L (ORCPT + 99 others); Fri, 3 Jan 2020 05:27:11 -0500 Received: from comms.puri.sm ([159.203.221.185]:42204 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727350AbgACK1L (ORCPT ); Fri, 3 Jan 2020 05:27:11 -0500 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id DCE6CE031B; Fri, 3 Jan 2020 02:27:10 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BrXUx_jgwVQu; Fri, 3 Jan 2020 02:27:09 -0800 (PST) From: Martin Kepplinger To: lorenzo.bianconi83@gmail.com, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] iio: imu: st_lsm6dsx: add mount matrix support Date: Fri, 3 Jan 2020 11:26:30 +0100 Message-Id: <20200103102630.17109-1-martin.kepplinger@puri.sm> Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow to read the mount-matrix device tree property and provide the mount_matrix file for userspace to read. Signed-off-by: Martin Kepplinger --- tested using the lsm9ds1 on the librem5-devkit (and userspace tools like iio-sensor-proxy) where this will be needed. thanks, martin drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 18 ++++++++++++++++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index a763ff46f596..8483f770b233 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -76,6 +76,7 @@ enum st_lsm6dsx_hw_id { .endianness = IIO_LE, \ }, \ .event_spec = &st_lsm6dsx_event, \ + .ext_info = st_lsm6dsx_accel_ext_info, \ .num_event_specs = 1, \ } @@ -406,6 +407,8 @@ struct st_lsm6dsx_hw { struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX]; const struct st_lsm6dsx_settings *settings; + + struct iio_mount_matrix orientation; }; static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = { @@ -479,4 +482,19 @@ st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr, return err; } +static const struct iio_mount_matrix * +st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev, + const struct iio_chan_spec *chan) +{ + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); + struct st_lsm6dsx_hw *hw = sensor->hw; + + return &hw->orientation; +} + +static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix), + { } +}; + #endif /* ST_LSM6DSX_H */ diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 0c64e35c7599..587e02bb9be9 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2325,6 +2325,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, (pdata && pdata->wakeup_source)) device_init_wakeup(dev, true); + err = iio_read_mount_matrix(hw->dev, "mount-matrix", &hw->orientation); + if (err) + return err; + return 0; } EXPORT_SYMBOL(st_lsm6dsx_probe); -- 2.20.1