From patchwork Mon Aug 2 15:56:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 490439 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 44576C4338F for ; Mon, 2 Aug 2021 15:57:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A10761102 for ; Mon, 2 Aug 2021 15:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234994AbhHBP5b (ORCPT ); Mon, 2 Aug 2021 11:57:31 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.54]:36610 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbhHBP5b (ORCPT ); Mon, 2 Aug 2021 11:57:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1627919825; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=mLmbG7FaZcS5dOyweoPjyoCfYgTIacG4CENTQ8e5dZQ=; b=T3L+d5Uq1lWjooRP/q/DGuIDrQ+n8GMb4c1ZDzVeSQX1OLpF/J0lIPoD+DUbDvW6s1 5bOH70ahywSTgde6PqmY1d5kPlLKHpAtfI/9a9YkYjA3NA9QAQXFD297y7e/i4otuA8h Ou8DZLIHQNxf7U40dwHWKvTvhpO2iYkYjMZZxE77rPcL47gOOUbWN84A0fCtqMnBxXGM 5xD0ExcSzHHN285aFyaKF7/AR1D82D+7Nzazgorbo81z95FWCcV4UzAmsJAVm4GqBvKh n2Em1F0+jeUuzbzs53I0RfcyI/DPC1fW6kZs3aA5HU5Baiz6nrRtBE6oq2uAQGWR1Cqg lXCA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXTbAOHjRHIhr0eF6M4Q==" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.30.0 DYNA|AUTH) with ESMTPSA id e095f1x72Fv52RD (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 2 Aug 2021 17:57:05 +0200 (CEST) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Rob Herring , Linus Walleij , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Hans de Goede , Andy Shevchenko , ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin , Stephan Gerhold Subject: [PATCH v2 1/4] dt-bindings: iio: accel: bma255: Add interrupt-names Date: Mon, 2 Aug 2021 17:56:54 +0200 Message-Id: <20210802155657.102766-2-stephan@gerhold.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802155657.102766-1-stephan@gerhold.net> References: <20210802155657.102766-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The binding already allows specifying both interrupt pins, but there is currently no way to describe a board where (for whatever reason) only INT2 is connected. Make it possible to use "interrupt-names" to make it explicit which interrupt pin is meant in the interrupts. Reviewed-by: Linus Walleij Signed-off-by: Stephan Gerhold Reviewed-by: Rob Herring --- Changes in v2: - Add "Without interrupt-names, ..." to "interrupts" description to clarify that ordering of interrupts can be relaxed if interrupt-names is used. --- .../bindings/iio/accel/bosch,bma255.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml index 5b35856b1942..253b2051d0b1 100644 --- a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml @@ -45,9 +45,18 @@ properties: minItems: 1 maxItems: 2 description: | - The first interrupt listed must be the one connected to the INT1 pin, - the second (optional) interrupt listed must be the one connected to the - INT2 pin (if available). The type should be IRQ_TYPE_EDGE_RISING. + Without interrupt-names, the first interrupt listed must be the one + connected to the INT1 pin, the second (optional) interrupt listed must be + the one connected to the INT2 pin (if available). The type should be + IRQ_TYPE_EDGE_RISING. + + interrupt-names: + minItems: 1 + maxItems: 2 + items: + enum: + - INT1 + - INT2 mount-matrix: description: an optional 3x3 mounting rotation matrix. @@ -73,6 +82,7 @@ examples: vddio-supply = <&vddio>; vdd-supply = <&vdd>; interrupts = <57 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "INT1"; }; }; - | From patchwork Mon Aug 2 15:56:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 490438 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 1AD9AC4320E for ; Mon, 2 Aug 2021 15:57:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F39FA61103 for ; Mon, 2 Aug 2021 15:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235243AbhHBP5d (ORCPT ); Mon, 2 Aug 2021 11:57:33 -0400 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.81]:34595 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235429AbhHBP5d (ORCPT ); Mon, 2 Aug 2021 11:57:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1627919826; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=PBDUzAA2uZL8rx4T0qqlTZQwhvXnyhX6ulO6O6mtELA=; b=DYI9hI9jUINOLNxFQnukJwn5zLmQEUfZTOVhSlTUDUMiOBkGUf6a+db2b7HgYX/XbQ ybVLFqFQZZoJvzNZlZz06Wvx9Y2PyFH5tFr7xyBcGNAvRRulNH+yqlF44jyrGtf7cGUo v40ZZoQFp4W1dFfgwkhzc9KxyJPPFNWsPun3ScZg7oSz2MVfirnEVcugpklfEFlk+/LP YMZyhWe9XqydQQxQLsrRcpe3xIe+2pQMKVull2WdihHyIBFctlXR1bNmhlwdZ0iNL9QN 3dTE46V7J5N5RNTsvDHP8UzNws8kfotWLsTj+jhA4DVSmX8uJzctMRwj64MU+wIVDwlZ Jjxg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXTbAOHjRHIhr0eF6M4Q==" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.30.0 DYNA|AUTH) with ESMTPSA id e095f1x72Fv52RE (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 2 Aug 2021 17:57:05 +0200 (CEST) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Rob Herring , Linus Walleij , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Hans de Goede , Andy Shevchenko , ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin , Stephan Gerhold , Rob Herring Subject: [PATCH v2 2/4] dt-bindings: iio: accel: bma255: Add bosch, bmc156_accel Date: Mon, 2 Aug 2021 17:56:55 +0200 Message-Id: <20210802155657.102766-3-stephan@gerhold.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802155657.102766-1-stephan@gerhold.net> References: <20210802155657.102766-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org BMC156 is very smilar to BMC150, but it has only one accelerometer interrupt pin. It would make sense if only INT1 was exposed but someone at Bosch decided to only have an INT2 pin. In this case, it does not make sense if the first interrupt pin is treated as INT1 (since that pin does not exist). Add a note to the bindings that the first interrupt pin is treated as INT2 for BMC156. Reviewed-by: Linus Walleij Reviewed-by: Rob Herring Signed-off-by: Stephan Gerhold --- .../bindings/iio/accel/bosch,bma255.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml index 253b2051d0b1..478e75ae0885 100644 --- a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml @@ -26,6 +26,7 @@ properties: - bosch,bma255 - bosch,bma280 - bosch,bmc150_accel + - bosch,bmc156_accel - bosch,bmi055_accel # bma180 driver in Linux @@ -50,6 +51,9 @@ properties: the one connected to the INT2 pin (if available). The type should be IRQ_TYPE_EDGE_RISING. + BMC156 does not have an INT1 pin, therefore the first interrupt pin is + always treated as INT2. + interrupt-names: minItems: 1 maxItems: 2 @@ -85,6 +89,20 @@ examples: interrupt-names = "INT1"; }; }; + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + accelerometer@10 { + compatible = "bosch,bmc156_accel"; + reg = <0x10>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + interrupts = <116 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "INT2"; + }; + }; - | # include spi { From patchwork Mon Aug 2 15:56:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 490437 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 4AEA4C4338F for ; Mon, 2 Aug 2021 15:57:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33D2161103 for ; Mon, 2 Aug 2021 15:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235440AbhHBP5e (ORCPT ); Mon, 2 Aug 2021 11:57:34 -0400 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.80]:9631 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235426AbhHBP5d (ORCPT ); Mon, 2 Aug 2021 11:57:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1627919827; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=vjjM9KDhXDv2+5Ew09t9LRbQGsYbUdyEmKNBZzOLl0c=; b=M0zRSa/YDlFCV993+kpcUdu0iaSFUiCaf2m02E0zJVHEVngo2iVFDYy7kpxiuPPRQZ maGTgmpCeqjqleWvBeD2kVwWVByPk+ZR4DXJLhBuKQCQ6imTnj7JmwGH4L4Z0cAqr7lG 3iGg3nUBvZP3APKrCper4revlvRb7LfwqhH4NnX5boQwSzYw72bnb9H4OFKW0IqOGPnA IR7DeAwVYtPscypEQHMUgWKM45koTHXTyQswASx5mrL8dukolQ9IrLr3Y70TrArQt9xb U2kasfJkmxMxLEuZMQ8pRPjpqFuT65OfZ02tEdLBn8vp0+eSeUsQAVyuibm2MxnZ/Cvz /ljg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXTbAOHjRHIhr0eF6M4Q==" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.30.0 DYNA|AUTH) with ESMTPSA id e095f1x72Fv72RG (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 2 Aug 2021 17:57:07 +0200 (CEST) From: Stephan Gerhold To: Jonathan Cameron Cc: Lars-Peter Clausen , Rob Herring , Linus Walleij , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Hans de Goede , Andy Shevchenko , ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin , Stephan Gerhold Subject: [PATCH v2 4/4] iio: accel: bmc150: Add support for BMC156 Date: Mon, 2 Aug 2021 17:56:57 +0200 Message-Id: <20210802155657.102766-5-stephan@gerhold.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802155657.102766-1-stephan@gerhold.net> References: <20210802155657.102766-1-stephan@gerhold.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org BMC156 is another accelerometer that works just fine with the bmc150-accel driver. It's very similar to BMC150 (also a accelerometer + magnetometer combo) but with only one accelerometer interrupt pin. It would make sense if only INT1 was exposed but someone at Bosch decided to only have an INT2 pin. Try to deal with this by making use of the INT2 support introduced in the previous commit and force using INT2 for BMC156. To detect that we need to bring up a simplified version of the previous type IDs. Note that unlike the type IDs removed in commit c06a6aba6835 ("iio: accel: bmc150: Drop misleading/duplicate chip identifiers") here I only add one for the special case of BMC156. Everything else still happens by reading the CHIP_ID register since the chip type information often is not accurate in ACPI tables. Tested-by: Nikita Travkin # BMC156 Reviewed-by: Linus Walleij Signed-off-by: Stephan Gerhold --- Changes in v2: - Wrap line in bmc150_accel_interrupts_setup() for better readability - Clarify reason for BOSCH_UNKNOWN with a comment --- drivers/iio/accel/Kconfig | 5 +++-- drivers/iio/accel/bmc150-accel-core.c | 9 ++++++--- drivers/iio/accel/bmc150-accel-i2c.c | 10 ++++++++-- drivers/iio/accel/bmc150-accel-spi.c | 10 +++++++++- drivers/iio/accel/bmc150-accel.h | 20 +++++++++++++++++++- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 0e56ace61103..2f0c0d512ae7 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -143,10 +143,11 @@ config BMC150_ACCEL select BMC150_ACCEL_SPI if SPI help Say yes here to build support for the following Bosch accelerometers: - BMA222, BMA222E, BMA250E, BMA253, BMA254, BMA255, BMA280, BMC150, BMI055. + BMA222, BMA222E, BMA250E, BMA253, BMA254, BMA255, BMA280, BMC150, BMC156 + BMI055. Note that some of these are combo modules: - - BMC150: accelerometer and magnetometer + - BMC150/BMC156: accelerometer and magnetometer - BMI055: accelerometer and gyroscope This driver is only implementing accelerometer part, which has diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 8d3dd3c2bcc2..e8693a42ad46 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -553,7 +553,8 @@ static void bmc150_accel_interrupts_setup(struct iio_dev *indio_dev, * Without interrupt-names, we assume the irq belongs to INT1. */ irq_info = bmc150_accel_interrupts_int1; - if (irq == of_irq_get_byname(dev->of_node, "INT2")) + if (data->type == BOSCH_BMC156 || + irq == of_irq_get_byname(dev->of_node, "INT2")) irq_info = bmc150_accel_interrupts_int2; for (i = 0; i < BMC150_ACCEL_INTERRUPTS; i++) @@ -1174,7 +1175,7 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {306458, BMC150_ACCEL_DEF_RANGE_16G} }, }, { - .name = "BMA253/BMA254/BMA255/BMC150/BMI055", + .name = "BMA253/BMA254/BMA255/BMC150/BMC156/BMI055", .chip_id = 0xFA, .channels = bmc150_accel_channels, .num_channels = ARRAY_SIZE(bmc150_accel_channels), @@ -1661,7 +1662,8 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) } int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, - const char *name, bool block_supported) + enum bmc150_type type, const char *name, + bool block_supported) { const struct attribute **fifo_attrs; struct bmc150_accel_data *data; @@ -1676,6 +1678,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, dev_set_drvdata(dev, indio_dev); data->regmap = regmap; + data->type = type; if (!bmc150_apply_acpi_orientation(dev, &data->orientation)) { ret = iio_read_mount_matrix(dev, &data->orientation); diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 999495f0669d..88bd8a25f142 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -176,6 +176,7 @@ static int bmc150_accel_probe(struct i2c_client *client, { struct regmap *regmap; const char *name = NULL; + enum bmc150_type type = BOSCH_UNKNOWN; bool block_supported = i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || i2c_check_functionality(client->adapter, @@ -188,10 +189,13 @@ static int bmc150_accel_probe(struct i2c_client *client, return PTR_ERR(regmap); } - if (id) + if (id) { name = id->name; + type = id->driver_data; + } - ret = bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, block_supported); + ret = bmc150_accel_core_probe(&client->dev, regmap, client->irq, + type, name, block_supported); if (ret) return ret; @@ -236,6 +240,7 @@ static const struct i2c_device_id bmc150_accel_id[] = { {"bma255"}, {"bma280"}, {"bmc150_accel"}, + {"bmc156_accel", BOSCH_BMC156}, {"bmi055_accel"}, {} }; @@ -251,6 +256,7 @@ static const struct of_device_id bmc150_accel_of_match[] = { { .compatible = "bosch,bma255" }, { .compatible = "bosch,bma280" }, { .compatible = "bosch,bmc150_accel" }, + { .compatible = "bosch,bmc156_accel" }, { .compatible = "bosch,bmi055_accel" }, { }, }; diff --git a/drivers/iio/accel/bmc150-accel-spi.c b/drivers/iio/accel/bmc150-accel-spi.c index 54b8c9c8068b..191e312dc91a 100644 --- a/drivers/iio/accel/bmc150-accel-spi.c +++ b/drivers/iio/accel/bmc150-accel-spi.c @@ -16,6 +16,8 @@ static int bmc150_accel_probe(struct spi_device *spi) { struct regmap *regmap; + const char *name = NULL; + enum bmc150_type type = BOSCH_UNKNOWN; const struct spi_device_id *id = spi_get_device_id(spi); regmap = devm_regmap_init_spi(spi, &bmc150_regmap_conf); @@ -24,7 +26,12 @@ static int bmc150_accel_probe(struct spi_device *spi) return PTR_ERR(regmap); } - return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, id->name, + if (id) { + name = id->name; + type = id->driver_data; + } + + return bmc150_accel_core_probe(&spi->dev, regmap, spi->irq, type, name, true); } @@ -54,6 +61,7 @@ static const struct spi_device_id bmc150_accel_id[] = { {"bma255"}, {"bma280"}, {"bmc150_accel"}, + {"bmc156_accel", BOSCH_BMC156}, {"bmi055_accel"}, {} }; diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index 47121f070fe9..1bb5023e8ed9 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -13,6 +13,22 @@ struct i2c_client; struct bmc150_accel_chip_info; struct bmc150_accel_interrupt_info; +/* + * We can often guess better than "UNKNOWN" based on the device IDs + * but unfortunately this information is not always accurate. There are some + * devices where ACPI firmware specifies an ID like "BMA250E" when the device + * actually has a BMA222E. The driver attempts to detect those by reading the + * chip ID from the registers but this information is not always enough either. + * + * Therefore, this enum should be only used when the chip ID detection is not + * enough and we can be reasonably sure that the device IDs are reliable + * in practice (e.g. for device tree platforms). + */ +enum bmc150_type { + BOSCH_UNKNOWN, + BOSCH_BMC156, +}; + struct bmc150_accel_interrupt { const struct bmc150_accel_interrupt_info *info; atomic_t users; @@ -62,6 +78,7 @@ struct bmc150_accel_data { int ev_enable_state; int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */ const struct bmc150_accel_chip_info *chip_info; + enum bmc150_type type; struct i2c_client *second_device; void (*resume_callback)(struct device *dev); struct delayed_work resume_work; @@ -69,7 +86,8 @@ struct bmc150_accel_data { }; int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, - const char *name, bool block_supported); + enum bmc150_type type, const char *name, + bool block_supported); int bmc150_accel_core_remove(struct device *dev); extern const struct dev_pm_ops bmc150_accel_pm_ops; extern const struct regmap_config bmc150_regmap_conf;