From patchwork Tue Sep 4 20:04:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Afonso Bordado X-Patchwork-Id: 10587781 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 39DDB13BB for ; Tue, 4 Sep 2018 19:05:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AB3029826 for ; Tue, 4 Sep 2018 19:05:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28E4B2A004; Tue, 4 Sep 2018 19:05:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B6A7629826 for ; Tue, 4 Sep 2018 19:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727315AbeIDXbh (ORCPT ); Tue, 4 Sep 2018 19:31:37 -0400 Received: from sender-of-o52.zoho.com ([135.84.80.217]:21406 "EHLO sender-of-o52.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726507AbeIDXbg (ORCPT ); Tue, 4 Sep 2018 19:31:36 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1536087886; cv=none; d=zoho.com; s=zohoarc; b=nzgdfEx1mioJBqF6QRH5tjVfh/Jn6RnBwR8yQb0vtsHC+kqO6C+/61evPLhdddn+2c4lQH/b+yMkPqt63eHO0Sw8EvvyfwGdAOLd21fsH8HPoSUDUq5fNe3vLPuUFJ+bs7gyCJyAGEOoCRJvN9NJRO207Nn+o5SYwjyi2niY58c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1536087886; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=YMx5VvmJ8fW6zZHsvaFdHdmEl5xkSGTecAbAMIAh5xM=; b=XG9Tse2VU4p7+gyhksCOMfakmNbnuVs5eCjRgACabjChVkqM82moSBNnMnk2YVxVJ40M0Io4OIzfZnvmjj67VH6GAtnYz4dxIJBjEvdob7hk0qmRKOlee1AQSbtehoHONVy7FcdV9zxiLHhw7I+hsrN4OOTwvnOel3F5WwxVtMU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=az8.co; spf=pass smtp.mailfrom=afonsobordado@az8.co; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1536087886; s=dkimmail; d=az8.co; i=afonsobordado@az8.co; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=2882; bh=YMx5VvmJ8fW6zZHsvaFdHdmEl5xkSGTecAbAMIAh5xM=; b=g7olJaaFgATpb21BdAV/PYMxaJ7LdlaVl8eDCYdfKHePQO8AnLeNJkDu9HQZcKdA Ef4oL7O1xCOCdH9Xc7cJ91ZUsrhD8gGp4M3ItR0+UCn0yrJZiLTCLpq5wvE1onrEErm rVCBkij0YTF68OgG22Mg+fluE/vbvAuwayV6W4eE= Received: from localhost (bl9-77-228.dsl.telepac.pt [85.242.77.228]) by mx.zohomail.com with SMTPS id 1536087883621993.4434342450922; Tue, 4 Sep 2018 12:04:43 -0700 (PDT) From: Afonso Bordado To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 2/4] iio: gyro: add device tree support for fxas21002c Date: Tue, 4 Sep 2018 21:04:32 +0100 Message-Id: <20180904200434.10442-2-afonsobordado@az8.co> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904200434.10442-1-afonsobordado@az8.co> References: <20180904200434.10442-1-afonsobordado@az8.co> X-ZohoMailClient: External 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 adds device tree support for the fxas21002c driver, including bindings. Signed-off-by: Afonso Bordado --- .../bindings/iio/gyroscope/fsl,fxas21002c.txt | 35 +++++++++++++++++++ drivers/iio/gyro/fxas21002c.c | 10 +++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/iio/gyroscope/fsl,fxas21002c.txt diff --git a/Documentation/devicetree/bindings/iio/gyroscope/fsl,fxas21002c.txt b/Documentation/devicetree/bindings/iio/gyroscope/fsl,fxas21002c.txt new file mode 100644 index 000000000000..5f02cfa5ac82 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/gyroscope/fsl,fxas21002c.txt @@ -0,0 +1,35 @@ +* Freescale FXAS21002C Digital Angular Rate Gyroscope + +Required properties: + + - compatible: must be "fsl,fxas21002c" + - reg : the I2C address of the sensor + +Optional properties: + + - interrupt-parent : phandle to the parent interrupt controller. + see interrupt-controller/interrupts.txt + - interrupts : The first interrupt listed must be the one + connected to the INT1 pin, the second interrupt + listed must be the one connected to the INT2 pin. + The interrupts can be triggered on rising or falling + edges alike. + see interrupt-controller/interrupts.txt + - vdd-supply : The main voltage regulator + - iovdd-supply : The IO voltage regulator + see regulator/regulator.txt + - reset-gpios : GPIO used to reset the device. + see gpio/gpio.txt. + - mount-matrix : see iio/mount-matrix.txt + +Example: +gyroscope@20 { + compatible = "fsl,fxas21002c"; + reg = <0x20>; + reset-gpios = <&gpio0 2 0>; + vdd-supply = <&vref>; + iovdd-supply = <&vref2>; + interrupt-parent = <&foo>; + interrupts = <0 IRQ_TYPE_EDGE_RISING>, + <1 (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)>; +}; diff --git a/drivers/iio/gyro/fxas21002c.c b/drivers/iio/gyro/fxas21002c.c index 1668e6f3fe11..18b1f500dd3e 100644 --- a/drivers/iio/gyro/fxas21002c.c +++ b/drivers/iio/gyro/fxas21002c.c @@ -8,7 +8,6 @@ * Datasheet: https://www.nxp.com/docs/en/data-sheet/FXAS21002.pdf * TODO: * ODR / Scale Support - * Devicetree * Power management * GPIO Reset * Power supplies @@ -350,6 +349,14 @@ static int fxas21002c_probe(struct i2c_client *client, return ret; } +#ifdef CONFIG_OF +static const struct of_device_id fxas21002c_of_ids[] = { + {.compatible = "fsl,fxas21002c"}, + {} +}; +MODULE_DEVICE_TABLE(of, fxas21002c_of_ids); +#endif + static const struct i2c_device_id fxas21002c_id[] = { {"fxas21002c", ID_FXAS21002C}, {} @@ -360,6 +367,7 @@ MODULE_DEVICE_TABLE(i2c, fxas21002c_id); static struct i2c_driver fxas21002c_driver = { .driver = { .name = FXAS21002C_DRV_NAME, + .of_match_table = of_match_ptr(fxas21002c_of_ids), }, .probe = fxas21002c_probe, .id_table = fxas21002c_id,