From patchwork Thu Jun 21 06:34:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10479197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 040EE60230 for ; Thu, 21 Jun 2018 06:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8B5628D08 for ; Thu, 21 Jun 2018 06:35:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC6A428D28; Thu, 21 Jun 2018 06:35:10 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB,T_DKIM_INVALID 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 7E6AF28D08 for ; Thu, 21 Jun 2018 06:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754137AbeFUGfJ (ORCPT ); Thu, 21 Jun 2018 02:35:09 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36769 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbeFUGfH (ORCPT ); Thu, 21 Jun 2018 02:35:07 -0400 Received: by mail-pf0-f193.google.com with SMTP id a12-v6so1017018pfi.3 for ; Wed, 20 Jun 2018 23:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W0xBedclQ7LJDlzoBFeAQ1puC3mh3p1itSqH8gBbMBc=; b=HTufsbcSiOXETuRKlE5uQaFPm7Q1kR9pHBlGpCCNQcDSWOO7fuPboAS9cUX18y6GrE vCNOIW4thcjYnxmnfRFP9DltYbpAQPE7p2rAd1VtbguNaUCWVCoBtsUr0o6B78CD+B+p 3HF5r/j1Hg+j7QE4QpA9qTAjB8PqIFyNCDcXOmxn9ofELBaZ7VFlgHnU2QuUDjv7Fpkc l/jpWQCXTRkYinCY07VfIhd7t+MKss7XKPRgoMXEGhBWybdullu16RyfDfOq+51QMuh3 G1kYbSWBmxxuEbXBeUU2h+RPXLkuHr58OFL7ApsIKZNzFRuJTMX9zWlPde4NUVk4OB1H WkdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W0xBedclQ7LJDlzoBFeAQ1puC3mh3p1itSqH8gBbMBc=; b=P5AuTvjUKhqi6I8+opJqEywvGSrcZGgwhnhM00xi/6/A3UQt6HDax1/7z4mLlfYKoc euu1i6vsBDDXJ7eeDpQXK/UY8qt8uv5vzwFeVJiK0AXTy4TsCIL4lpfrtPgVRbMJ/N8i 8OJGkJrUTSQvAi+aL7rCshEkPIH+ZJyMmyLJY9h3isDpjZ+LqP47+hcUst2eY92FjlpW s9iKg91oY5XL3FGdvkpLz+x4amtoyzkFzgs4hhlgzJJpWU8sV1aaRwf82q1iECrTXPnz Bwd3a3S40zmq0TRYk0D1y5OoaksCR0OHALlgXw1c4925WnMqWAgv60utT+xQm2TUk9fJ /MQw== X-Gm-Message-State: APt69E1JsBShWJHwReqbCkawHsxSSKrifmZK8hyanMttrOnjkEgXqegW qqwyxc0us8oCcYOuRnMqnlQ= X-Google-Smtp-Source: ADUXVKI9F/xVFq40payh7lyqMOg9VcXwglxOYjenUXGoDbh464yfTr5N/jjyFARPnJHMI82KJC2oNg== X-Received: by 2002:a63:b505:: with SMTP id y5-v6mr21894123pge.213.1529562907034; Wed, 20 Jun 2018 23:35:07 -0700 (PDT) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id n83-v6sm9406527pfi.147.2018.06.20.23.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jun 2018 23:35:06 -0700 (PDT) From: Himanshu Jha To: jic23@kernel.org, linux-iio@vger.kernel.org Cc: lars@metafoo.de, pmeerw@pmeerw.net, daniel.baluta@gmail.com, Himanshu Jha Subject: [RFC 3/3] iio: imu: bme680: Add ACPI support Date: Thu, 21 Jun 2018 12:04:37 +0530 Message-Id: <1529562877-9357-4-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529562877-9357-1-git-send-email-himanshujha199640@gmail.com> References: <1529562877-9357-1-git-send-email-himanshujha199640@gmail.com> 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 Add support to probe the bme680 sensor on the i2c bus using ACPI. Cc: Daniel Baluta Signed-off-by: Himanshu Jha --- drivers/iio/imu/bme680/bme680_core.c | 15 +++++++++++++++ drivers/iio/imu/bme680/bme680_i2c.c | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/iio/imu/bme680/bme680_core.c b/drivers/iio/imu/bme680/bme680_core.c index 05712de..a891b1f 100644 --- a/drivers/iio/imu/bme680/bme680_core.c +++ b/drivers/iio/imu/bme680/bme680_core.c @@ -3,6 +3,7 @@ * * IIO core driver - I2C & SPI bus support */ +#include #include #include #include @@ -445,6 +446,17 @@ static int bme680_chip_init(struct bme680_data *data, bool use_spi) return 0; } +static const char *bme680_match_acpi_device(struct device *dev) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + + return dev_name(dev); +} + static const struct bme680_chip_info bme680_chip_info = { .oversampling_temp_avail = bme680_oversampling_avail, .num_oversampling_temp_avail = ARRAY_SIZE(bme680_oversampling_avail), @@ -480,6 +492,9 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, if (ret < 0) return ret; + if (!name && ACPI_HANDLE(dev)) + name = bme680_match_acpi_device(dev); + indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->channels = bme680_channels; diff --git a/drivers/iio/imu/bme680/bme680_i2c.c b/drivers/iio/imu/bme680/bme680_i2c.c index 1c8223e..2807085 100644 --- a/drivers/iio/imu/bme680/bme680_i2c.c +++ b/drivers/iio/imu/bme680/bme680_i2c.c @@ -3,6 +3,7 @@ * - 0x76 if SDO is pulled to GND * - 0x77 if SDO is pulled to VDDIO */ +#include #include #include #include @@ -41,6 +42,11 @@ static const struct i2c_device_id bme680_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, bme680_i2c_id); +static const struct acpi_device_id bme680_acpi_match[] = { + {"BME0680", 0}, + {}, +}; + static struct i2c_driver bme680_i2c_driver = { .driver = { .name = "bme680_i2c",