From patchwork Wed Feb 20 14:00:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 10822181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0374B17FB for ; Wed, 20 Feb 2019 14:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0FEC2DE0F for ; Wed, 20 Feb 2019 14:07:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFACF2E36B; Wed, 20 Feb 2019 14:07:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DA142DE0F for ; Wed, 20 Feb 2019 14:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbfBTOHQ (ORCPT ); Wed, 20 Feb 2019 09:07:16 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([81.169.146.175]:22722 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfBTOHQ (ORCPT ); Wed, 20 Feb 2019 09:07:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550671634; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=+rQcdnByN85IlKxFe3UXL2+usgDxL4sMCHhdK2LMnFI=; b=PiYF7MVjkRgb7S0VKf6kvVU6FdMlm1ccM/DrXwj61ey2bvtmoBKVXCdEpopKDBtFwU 20N4Rc7A9SUd/Owd81FXbZGy6QJDK8p6MZhYVWvtiZrAeLsddMc/SHsyNs+JNCD0aMS2 CR0vUcWVPU6C97lKtKB2FMi/suV6uomwCSG8ngamW3l1lsZ2jyYmFqbv6FhxjqnTGOAD /9hisKsOvUo9zQV08fDYziSf91wgoYfmkH4FGEDD8fznWH/97g4xhcuyHdtcaO0dXkST fhTvaZD9a9XyMHYLwAnYOPQafB23zPLHXbCZtqYmWtJAQyrWuUiWgFgQCdynpRn6vRGW x2TA== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1OAA2UNf2M0OzzrKQ==" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id 608499v1KE10EqY (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 20 Feb 2019 15:01:00 +0100 (CET) From: "H. Nikolaus Schaller" To: Linus Walleij , Jonathan Cameron , Rob Herring , Mark Rutland , "H. Nikolaus Schaller" , Andy Shevchenko , Charles Keepax , Song Qiang Cc: letux-kernel@openphoenux.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] iio: gyro: bmg160: add mount matrix support Date: Wed, 20 Feb 2019 15:00:53 +0100 Message-Id: <56495e0c2fe1b943430c26e14924a436718af9b9.1550671256.git.hns@goldelico.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows to read a mount-matrix device tree property and report to user-space or in-kernel iio clients. Signed-off-by: H. Nikolaus Schaller --- drivers/iio/gyro/bmg160_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 63ca31628a93..7ae59be9a5ef 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -102,6 +102,7 @@ struct bmg160_data { struct regmap *regmap; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; + struct iio_mount_matrix orientation; struct mutex mutex; s16 buffer[8]; u32 dps_range; @@ -794,6 +795,18 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev, return 0; } +static const struct iio_mount_matrix * +bmg160_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + return &((struct bmg160_data *)iio_priv(indio_dev))->orientation; +} + +static const struct iio_chan_spec_ext_info bmg160_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmg160_get_mount_matrix), + { }, +}; + static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 400 1000 2000"); static IIO_CONST_ATTR(in_anglvel_scale_available, @@ -831,6 +844,7 @@ static const struct iio_event_spec bmg160_event = { .storagebits = 16, \ .endianness = IIO_LE, \ }, \ + .ext_info = bmg160_ext_info, \ .event_spec = &bmg160_event, \ .num_event_specs = 1 \ } @@ -1075,6 +1089,11 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, data->irq = irq; data->regmap = regmap; + ret = of_iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + ret = bmg160_chip_init(data); if (ret < 0) return ret;