From patchwork Sun Nov 1 12:28:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 314957 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 39AFAC2D0A3 for ; Sun, 1 Nov 2020 12:28:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5FFB20882 for ; Sun, 1 Nov 2020 12:28:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g30qIXbR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgKAM2k (ORCPT ); Sun, 1 Nov 2020 07:28:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbgKAM2j (ORCPT ); Sun, 1 Nov 2020 07:28:39 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36163C0617A6 for ; Sun, 1 Nov 2020 04:28:39 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id a7so13758084lfk.9 for ; Sun, 01 Nov 2020 04:28:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QOXieuuEEbc116u9FS/tLUaOZv79e9gqeLS9/EKUpZ8=; b=g30qIXbRJL5C/nXIrSgCkN0N2zOTkxTPyQtoJgI/5Bs7rNmuiZHb3TRDXdbcU36lLt 9RwLjV102npps2h+YPgU367k/Rn0pSGN7FMiiuHEf4cSBw81k9fLFCqeqxVz8nKCzz3r C+ykdFMM6CxcUhrSaD5g3DpUtdxESdL6I70DFTNScAk0sKExnQnd4Cu+ZqvpD3JW3S6W +NxYG9YqjtGggmB/EXO9wF9XkXyxxdpzz4WD2AEaZ1P51qXQ8iJ2U5b/pLiOBYZRVYkG AYC6uGz228NN8qb85OdO4jqZSgJrQqWMtQIjhZCARRJ/l9Nroc0+qXa60WxuRw97FjEX 7EcQ== 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:mime-version :content-transfer-encoding; bh=QOXieuuEEbc116u9FS/tLUaOZv79e9gqeLS9/EKUpZ8=; b=Byg4iiF7X/Kn2UNkA7qlEKvfSefdBdVUCF6TCfURpr6aloOc3pFvwo/p6NkV9auW3L Qg/ErvGOvppx9Lbuxrpw5KFmalve9G0P2tpXvZ+6rJn1g2BT2gPfLQnivuxmFHiy96Kn X4y3GEXKXTu3O9Bms6XXGZsG5/sL3eEPvmt+fVU1fVVzT+Kh8367lxCF51a2pj5oVhRi eUbq89U0CZ+X9JWM1wk1KuQ/6JbTEcMlHF4Zkc648N/eGJKmvS8jwf7sCJZhe5MEuH5v u91ixhMih1ry8IdbFtdg+tA4j2Z9GUOvUxK52G/8GdwskkRNruUNrfZOAMkPkxfdERMs XeIg== X-Gm-Message-State: AOAM531ugq8BOIapn2x7CSEUBotT0ebIZ5fYnuTxFxIWaoYM4kW2fzpA nZS0QG/+oMIWgNG/5sTMg3GpOg== X-Google-Smtp-Source: ABdhPJzyqdJNEAfRNvG2NWx0qtUEFOzaGXj1bTk+b/YuMCYpAyGYIrwcsmKj5sur8hrKyvNbOzljWg== X-Received: by 2002:ac2:4422:: with SMTP id w2mr3804297lfl.219.1604233717531; Sun, 01 Nov 2020 04:28:37 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id 190sm1480655lfk.238.2020.11.01.04.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:28:36 -0800 (PST) From: Linus Walleij To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-input@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 1/3] iio: accel: bmc150-accel: Add DT bindings Date: Sun, 1 Nov 2020 13:28:31 +0100 Message-Id: <20201101122833.1111424-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org These accelerometers have bindings used in the kernel and several device trees but no proper bindings documentation. Add it. Also add a compatible for the BMA222 that I am right now adding support for in the driver. Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij --- .../bindings/iio/accel/bosch,bmc-bmi-bma.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/accel/bosch,bmc-bmi-bma.yaml diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bmc-bmi-bma.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bmc-bmi-bma.yaml new file mode 100644 index 000000000000..11b8b68aaf3e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bmc-bmi-bma.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/bosch,bmc-bmi-bma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMCxxx, BMIxxx and BMAxxx Accelerometers + +maintainers: + - Linus Walleij + +description: + 3 axis accelerometers with varying range and I2C or SPI + 3-wire interface. + +properties: + compatible: + enum: + - bosch,bmc150 + - bosch,bmi055 + - bosch,bma255 + - bosch,bma250e + - bosch,bma222 + - bosch,bma222e + - bosch,bma280 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + + interrupts: + maxItems: 1 + + mount-matrix: + description: an optional 3x3 mounting rotation matrix. + + spi-max-frequency: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #include + #address-cells = <1>; + #size-cells = <0>; + accelerometer@8 { + compatible = "bosch,bma222"; + reg = <0x08>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + interrupts = <57 IRQ_TYPE_EDGE_FALLING>; + }; + }; + - | + # include + spi { + #address-cells = <1>; + #size-cells = <0>; + accel@0 { + compatible = "bosch,bma222"; + reg = <0>; + spi-max-frequency = <10000000>; + }; + }; +... From patchwork Sun Nov 1 12:28:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 320171 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp2926381ilc; Sun, 1 Nov 2020 04:28:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQ23P+HCOO3ZcT2TVp3mWYvLS+J3Q4poo7tbbgnIbM3vnhVOay/ZkNbdWx2rQymwJviwWT X-Received: by 2002:a50:9993:: with SMTP id m19mr5884365edb.99.1604233725014; Sun, 01 Nov 2020 04:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604233725; cv=none; d=google.com; s=arc-20160816; b=Vuowrs3tzSj8wRwj7yYP/AZprLClHGcrnRMS4Wg2L0coKQ1qtTyKlhj3i0Ns1x4MjJ BteqCQL78WRX+MzjlsKHldoV5Sl2GzliDVSIhWboP/HIuE32Hlv01e4UVmq8eR/+9o5k XSetNCc+Hq7H/Wc1+7jLIJ6y3hn7Oa44SkmEjbenMBF9CF/NIvqgEkCaau9MzcT1t2ld 1pVUzwlrjCRUsYUclQXGWXySlu6H6U9rMXwQEoqsxHy7fixkj6mFAtdZTvhmsqgZQ0AK OVK3t/Oi9YppqeSKgenONC51AuZuZe8BwNorxOzjAFW6R/Xhv3Xl55HyRAGZv1BU15RQ 9OTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C1h7tD4oiBs+mtjedWhyGqQzrspO0zTn8Dim8Rdes2w=; b=GFUXe7CMGlGoYDbqulokFPOTBwvLAFmzezcb+ZDW4fKMVUPjwyCA5h63wnyaq4hp6k 9buBAbGiVJBtdt1ama3YmtqJe5aptR4Bwlm4LcYRuZrdWaidvgyOGqn32RwZa5HK/19K RGud7SBc7K4iTVfyAOnEAyIxdOh0A+B2vbT/Yj5VkVRQiZTdoDXPfneZqtTq5g3/x1S2 EdkjuJFFKbRGY60QkxX3O+UxR3Og1TUQUvxZusC9Gl8rXSaElC65oWwa/IG+jzaio4SF YirodtogdievgQIACC5SS0M4CcTO2BM6gYy1k9EpFb0u1G1QjGmU9AUE2NjZvel9UQxS e0YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OUj2TIp/"; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si9476722ejf.525.2020.11.01.04.28.44; Sun, 01 Nov 2020 04:28:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OUj2TIp/"; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbgKAM2n (ORCPT + 1 other); Sun, 1 Nov 2020 07:28:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbgKAM2m (ORCPT ); Sun, 1 Nov 2020 07:28:42 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E94BDC0617A6 for ; Sun, 1 Nov 2020 04:28:40 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id h6so13786979lfj.3 for ; Sun, 01 Nov 2020 04:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C1h7tD4oiBs+mtjedWhyGqQzrspO0zTn8Dim8Rdes2w=; b=OUj2TIp/ohXcdhyUDwBAYjJoD7jDmxhbZmHC+LCnwQrsu91AmAnoUu8DdQGKswq916 pd4q30RKAWKmHlzkJVX72nt2YWmKgoqDO+ye7efx8vsQjarvgq6tJwniznEgNppiO2gG 1zA22L0ObT9AJcJKCbRXfSGeHRLtfDSD3Mh7IaFjnVSAEBhNToKgIMUKBTyeOPm0lUAq U0zoIdmXsV+eIsCJIOIX554dz43+Hbk4PFH1XNCnhZDVrqNa0gZUbrF9KQJxI1Lp6Nvb hVQykyX97Z6yvcO+k6UNSE8X+f7ld0mNNKqb3b2GveVOjccb6WhgH12geaglyXMwSWll xEbw== 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:mime-version:content-transfer-encoding; bh=C1h7tD4oiBs+mtjedWhyGqQzrspO0zTn8Dim8Rdes2w=; b=sbIQWEuNTSOF3NBhexSsAL9g7Y6WWX3WVKfZ0WjEGw7UL8tg3ESni1pS+yFbuR1SeQ fmnyWLz3lJgNlWk2AlRkmPDZbfL2mT4E58I6OVPfiNwGfN8FmGWFi+jvn+eBsALRC9BK FKX3iNT/QmSECI0UvbHDueaVtk4q29cHzyHJW3YO0FVjJaIsWI6Jct3PfxIRsQ9Ityc0 4zwTMwIy82Me5+F2wIKiOy6/gVN/F88SbGnKxV5bQfDpWaYPth9MTfZmBtKT4E8UVnL7 l3szK1jULgmJvUYP6he08cHlUIcDh6JBxW7Ua0BwvzL4d0BxMEOAi03a4NdkwejXI8E9 7Tgg== X-Gm-Message-State: AOAM533J8OGqkoXFzhvQanoklq93KikBN/6LGQqNA2XB1mJfQ5zrkmVM 4zU2lHg4+HXxQPxLMaYP3dZWjw== X-Received: by 2002:ac2:4d58:: with SMTP id 24mr3908549lfp.32.1604233719423; Sun, 01 Nov 2020 04:28:39 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id 190sm1480655lfk.238.2020.11.01.04.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:28:38 -0800 (PST) From: Linus Walleij To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-input@vger.kernel.org, Linus Walleij Subject: [PATCH 2/3] iio: accel: bmc150-accel: Add support for BMA222 Date: Sun, 1 Nov 2020 13:28:32 +0100 Message-Id: <20201101122833.1111424-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201101122833.1111424-1-linus.walleij@linaro.org> References: <20201101122833.1111424-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This adds support for the BMA222 version of this sensor, found in for example the Samsung GT-I9070 mobile phone. Signed-off-by: Linus Walleij --- drivers/iio/accel/bmc150-accel-core.c | 17 +++++++++++++++++ drivers/iio/accel/bmc150-accel-i2c.c | 4 ++++ drivers/iio/accel/bmc150-accel-spi.c | 2 ++ drivers/iio/accel/bmc150-accel.h | 1 + 4 files changed, 24 insertions(+) -- 2.26.2 diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 48435865fdaf..0dafe4052856 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -5,6 +5,7 @@ * - BMI055 * - BMA255 * - BMA250E + * - BMA222 * - BMA222E * - BMA280 * @@ -1013,6 +1014,8 @@ static const struct iio_event_spec bmc150_accel_event = { IIO_CHAN_SOFT_TIMESTAMP(3), \ } +static const struct iio_chan_spec bma222_accel_channels[] = + BMC150_ACCEL_CHANNELS(8); static const struct iio_chan_spec bma222e_accel_channels[] = BMC150_ACCEL_CHANNELS(8); static const struct iio_chan_spec bma250e_accel_channels[] = @@ -1063,6 +1066,20 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {153277, BMC150_ACCEL_DEF_RANGE_8G}, {306457, BMC150_ACCEL_DEF_RANGE_16G} }, }, + [bma222] = { + .name = "BMA222", + .chip_id = 0x03, + .channels = bma222_accel_channels, + .num_channels = ARRAY_SIZE(bma222_accel_channels), + /* + * The datasheet page 17 says: + * 15.6, 31.3, 62.5 and 125 mg per LSB. + */ + .scale_table = { {156000, BMC150_ACCEL_DEF_RANGE_2G}, + {313000, BMC150_ACCEL_DEF_RANGE_4G}, + {625000, BMC150_ACCEL_DEF_RANGE_8G}, + {1250000, BMC150_ACCEL_DEF_RANGE_16G} }, + }, [bma222e] = { .name = "BMA222E", .chip_id = 0xF8, diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 06021c8685a7..bba92dd33179 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -5,6 +5,7 @@ * - BMI055 * - BMA255 * - BMA250E + * - BMA222 * - BMA222E * - BMA280 * @@ -54,6 +55,7 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMI055A", bmi055}, {"BMA0255", bma255}, {"BMA250E", bma250e}, + {"BMA222", bma222}, {"BMA222E", bma222e}, {"BMA0280", bma280}, {"BOSC0200"}, @@ -66,6 +68,7 @@ static const struct i2c_device_id bmc150_accel_id[] = { {"bmi055_accel", bmi055}, {"bma255", bma255}, {"bma250e", bma250e}, + {"bma222", bma222}, {"bma222e", bma222e}, {"bma280", bma280}, {} @@ -78,6 +81,7 @@ static const struct of_device_id bmc150_accel_of_match[] = { { .compatible = "bosch,bmi055_accel" }, { .compatible = "bosch,bma255" }, { .compatible = "bosch,bma250e" }, + { .compatible = "bosch,bma222" }, { .compatible = "bosch,bma222e" }, { .compatible = "bosch,bma280" }, { }, diff --git a/drivers/iio/accel/bmc150-accel-spi.c b/drivers/iio/accel/bmc150-accel-spi.c index 2a8c311d6f5a..74a8aee4f612 100644 --- a/drivers/iio/accel/bmc150-accel-spi.c +++ b/drivers/iio/accel/bmc150-accel-spi.c @@ -39,6 +39,7 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMI055A", bmi055}, {"BMA0255", bma255}, {"BMA250E", bma250e}, + {"BMA222", bma222}, {"BMA222E", bma222e}, {"BMA0280", bma280}, { }, @@ -50,6 +51,7 @@ static const struct spi_device_id bmc150_accel_id[] = { {"bmi055_accel", bmi055}, {"bma255", bma255}, {"bma250e", bma250e}, + {"bma222", bma222}, {"bma222e", bma222e}, {"bma280", bma280}, {} diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index ae6118ae11b1..f5427103574d 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -9,6 +9,7 @@ enum { bmi055, bma255, bma250e, + bma222, bma222e, bma280, }; From patchwork Sun Nov 1 12:28:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 314956 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 90051C5517A for ; Sun, 1 Nov 2020 12:28:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55A0E2085B for ; Sun, 1 Nov 2020 12:28:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kGIyGZKe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbgKAM2o (ORCPT ); Sun, 1 Nov 2020 07:28:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbgKAM2n (ORCPT ); Sun, 1 Nov 2020 07:28:43 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7746C061A49 for ; Sun, 1 Nov 2020 04:28:42 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id f9so13806209lfq.2 for ; Sun, 01 Nov 2020 04:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D//csSkef/q1fmS2JF6nZIsqRiFshRpn9N22nb8nS5E=; b=kGIyGZKeEweHWzwL+H0LdhP4e14J8KJbxwtqgSIJIUOjduETuvRplH52h5hiVVZZ1q 7pprDNN9o2dzShN7Q+TWr95DB5630naYzfL4JXWNf5jNBo7+hfCxiHGJViTUNdHPyqss +OU0FvSflg/RTZY0khH+ckx2gIh99keG4GYgipQB9wmEgOd/VOBOmyFWh28plZT5i0w8 bI3jrd1YVPjqYExRPvjhvcDYH8tK2UogQd5id5J16E7wjEafGkU+JOPMk4OmkKv4XXC+ wtJdjrWcOI+FLPy8uJ1feTc+9Ps92cvmC9XCMeQ2wpGfwC4wYN2NK3/FdFKAwh4HHTk/ WxwQ== 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:mime-version:content-transfer-encoding; bh=D//csSkef/q1fmS2JF6nZIsqRiFshRpn9N22nb8nS5E=; b=sgstg3z9nvuhQhcwD3mk9fI/zRLVuES9eEr0qWqoHJCoZxEjIowNbAnKvUmzz0kI0C e+ZWfvsbMiJ/MksnLSDFFZYicS641BXAacUpUwMCBB6VsED8Z/J3bdhpTgRE+2aiyKuF /q46P8ZH7Rdz1kz3gYEvvErrvGxzVX/nlP8v5QNHw+PFUWQt4ebno/AfskJLhcR0557E jJgxXGVj1WtWZlyGjUF54HQeqiAv6EFY9grExb//Td4mFFOMtwXBr20XeN7obtZy5t8O X+rNrTGPVQcMtbsAp32heb4VPSwJQjwN63IngpTW9faN41Ln2IXErHyIxmj5khWuO364 d8sw== X-Gm-Message-State: AOAM531tz++RuLCngi88QByweBPCSa4Cjiu/VZtqlwIfVtkClynPgI/w udxB+Hpc+BHcr1rqJTPHZuLMbOT3Dv/OPvw3 X-Google-Smtp-Source: ABdhPJwhuNTY0jV6fjulkvIZnQ1RW5Oq8uFHGKx1pb6i8VdF0X7g3OKU7Xo4KnxH2y4uEhCAQ8uEkw== X-Received: by 2002:ac2:5c4c:: with SMTP id s12mr3756651lfp.174.1604233721157; Sun, 01 Nov 2020 04:28:41 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id 190sm1480655lfk.238.2020.11.01.04.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:28:40 -0800 (PST) From: Linus Walleij To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-input@vger.kernel.org, Linus Walleij Subject: [PATCH 3/3] iio: accel: bmc150-accel: Add rudimentary regulator support Date: Sun, 1 Nov 2020 13:28:33 +0100 Message-Id: <20201101122833.1111424-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201101122833.1111424-1-linus.walleij@linaro.org> References: <20201101122833.1111424-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org These Bosch accelerometers have two supplies, VDD and VDDIO. Add some rudimentary support to obtain and enable these regulators during probe() and disable them during remove() or on the errorpath. Signed-off-by: Linus Walleij --- drivers/iio/accel/bmc150-accel-core.c | 37 +++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 0dafe4052856..a69a4f54d69a 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "bmc150-accel.h" @@ -184,6 +185,7 @@ enum bmc150_accel_trigger_id { struct bmc150_accel_data { struct regmap *regmap; + struct regulator_bulk_data regulators[2]; int irq; struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; @@ -1593,10 +1595,35 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, &data->orientation); if (ret) return ret; + /* + * VDD is the analog and digital domain voltage supply + * VDDIO is the digital I/O voltage supply + */ + data->regulators[0].supply = "vdd"; + data->regulators[1].supply = "vddio"; + ret = devm_regulator_bulk_get(dev, + ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to get regulators %d\n", ret); + return ret; + } + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) { + dev_err(dev, "failed to enable regulators: %d\n", ret); + return ret; + } + /* + * 2ms or 3ms power-on time according to datasheets, let's better + * be safe than sorry and set this delay to 5ms. + */ + msleep(5); ret = bmc150_accel_chip_init(data); if (ret < 0) - return ret; + goto err_disable_regulators; mutex_init(&data->mutex); @@ -1613,7 +1640,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, &bmc150_accel_buffer_ops); if (ret < 0) { dev_err(dev, "Failed: iio triggered buffer setup\n"); - return ret; + goto err_disable_regulators; } if (data->irq > 0) { @@ -1674,6 +1701,9 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); +err_disable_regulators: + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); return ret; } @@ -1698,6 +1728,9 @@ int bmc150_accel_core_remove(struct device *dev) bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0); mutex_unlock(&data->mutex); + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); + return 0; } EXPORT_SYMBOL_GPL(bmc150_accel_core_remove);