From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 8B2EAC433EA for ; Fri, 24 Jul 2020 21:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63B502070E for ; Fri, 24 Jul 2020 21:33:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="STyOXqoW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbgGXVdn (ORCPT ); Fri, 24 Jul 2020 17:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbgGXVdh (ORCPT ); Fri, 24 Jul 2020 17:33:37 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB16AC0619D3 for ; Fri, 24 Jul 2020 14:33:36 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d1so5291647plr.8 for ; Fri, 24 Jul 2020 14:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7r5P7yY97nIyh5VEzHl8IWXtXY0874kQ28pbPaAX6qA=; b=STyOXqoW5ATgPELLwQQ+htug+4PwoBB7dhN8Zr+us4YTpwo6KWpaLdQ9vA7dvEmTn0 OoDH/1U/qklppbzvfH52Cfcws+RcgFNHewY9GvymoxFT8cogRC8mj1SpAmA/RBfam/an DEZlRBCGTseP5LiJfhi5DcDMVLOW/5iFsrkMk= 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=7r5P7yY97nIyh5VEzHl8IWXtXY0874kQ28pbPaAX6qA=; b=stlnIeY0yJ/7cJK/BY6wwNQBNsNDrDSrgnEFp4jl6Oddm6OIgpB8od6jJUrrZhwzjg RxQHNn8HW+mmKUMWFwpk96cnVv2Akx6S6lZghb308d9Gyp73IJ7xNsbMSFeCK4STY6xp eaFGUfSoTc8S29PQG/U96+eFcxSxh3yD8C2eAPEIF2gJF4qHPDymwHsBKQXcv6aS2BqK kz6HBD4g8kPU/j3Tks/+AKH4LKBSxJi8j/i6WdA25JZ5P5YKdzEv6+k9WA7u6COR78D/ 9rBfkloSe8wsviauUNrVmAv1xcxF7IwhUUZ01ZaxDpxSdmo9IfXM9FS+WTPCWNU+XuVR oWEQ== X-Gm-Message-State: AOAM5330skdGc5wnAxzVgWWO9IwODldGLjCAfrU+XRFAQcHj2wDO4zv2 l5Cgqc3nNKnINbQSODvqLNco6A== X-Google-Smtp-Source: ABdhPJypUULXnzt+wfn35DBVEVvoWc6T57rYbQ4sYcNEUCnquL9y0upEE6DaTrBVpCMFf8Iw+DUYBQ== X-Received: by 2002:a17:90b:30d7:: with SMTP id hi23mr7703975pjb.69.1595626416540; Fri, 24 Jul 2020 14:33:36 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id z6sm7312919pfn.173.2020.07.24.14.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 14:33:36 -0700 (PDT) From: Stephen Boyd To: Jonathan Cameron Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Gwendal Grignou , Daniel Campello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Douglas Anderson Subject: [PATCH v2 5/5] iio: sx9310: Enable vdd and svdd regulators at probe Date: Fri, 24 Jul 2020 14:33:29 -0700 Message-Id: <20200724213329.899216-6-swboyd@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200724213329.899216-1-swboyd@chromium.org> References: <20200724213329.899216-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable the main power supply (vdd) and digital IO power supply (svdd) during probe so that the i2c communication and device works properly on boards that aggressively power gate these supplies. Cc: Gwendal Grignou Cc: Daniel Campello Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Douglas Anderson Signed-off-by: Stephen Boyd --- drivers/iio/proximity/sx9310.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 1e1f6bba50f6..ad6ed100c7a6 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -899,12 +900,21 @@ static int sx9310_set_indio_dev_name(struct device *dev, return 0; } +static void sx9310_regulator_disable(void *supplies) +{ + regulator_bulk_disable(2, supplies); +} + static int sx9310_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct iio_dev *indio_dev; struct sx9310_data *data; + struct regulator_bulk_data supplies[] = { + { .supply = "vdd" }, + { .supply = "svdd" }, + }; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (indio_dev == NULL) @@ -919,6 +929,23 @@ static int sx9310_probe(struct i2c_client *client, if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); + ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies); + if (ret) + return ret; + /* Must wait for Tpor time after initial power up */ + usleep_range(1000, 1100); + + /* Update sx9310_regulator_disable() size if this bug is hit */ + BUILD_BUG_ON(ARRAY_SIZE(supplies) != 2); + ret = devm_add_action_or_reset(&client->dev, sx9310_regulator_disable, + supplies); + if (ret) + return ret; + ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret < 0) { dev_err(&client->dev, "error in reading WHOAMI register: %d\n", -- Sent by a computer, using git, on the internet