From patchwork Fri Jul 31 16:48:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Campello X-Patchwork-Id: 11695229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46153722 for ; Fri, 31 Jul 2020 16:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BCD622B3F for ; Fri, 31 Jul 2020 16:49:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mauPgZkR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387455AbgGaQtX (ORCPT ); Fri, 31 Jul 2020 12:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732542AbgGaQtP (ORCPT ); Fri, 31 Jul 2020 12:49:15 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB7CC06138E for ; Fri, 31 Jul 2020 09:49:12 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id r12so25851487ilh.4 for ; Fri, 31 Jul 2020 09:49:12 -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=iPeLJC5RmTN6zDPmUvW9ZmlL+f5oIqstFwOQkWarKhY=; b=mauPgZkR3yYh8jMCKGBfhJgq+IYZTD+hGEW8hqlsiaoHIDa0vLMFwZe4WfYVuZomqY jtRGoYgexlntCTpWBbHsCfNbM/gtMxMzcby/7U7qFV4QHjFfBeLy1uS1nbHKtvPAcszc U2e+TmFMkQcSkVnL1xYWl+W/FGUXTZwaFp4OY= 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=iPeLJC5RmTN6zDPmUvW9ZmlL+f5oIqstFwOQkWarKhY=; b=cHu93NBJoy3nPQNeWTji9Y3pCn08Iz3H7NBNiZYsLO8JCQp3XNSsMWlFlSOHE98MxF +WDMfJdGqF5N8II00F8FskZl0eFH3928Ek9rHWsS+fhd73af4EFZfuSxhpEhMeLPQOak 3nl0p6804MWKeDea83/GG8ukN+ssdKCXMo4zw+TbEi+jeCb4FxSXeUiW9lIje5sGZdpm 70yNu5swAWJETvqVWnMfnn8wAT+DvbuYeWQBqJhgpJr0VrJLy9F9GW6AiInamgnwcplK ROVaQ/MBVWsrx2NAFt6EyFT27z0cMfSNfPIQ6EB3C3BmcoKBYK4eWtNVVXZcV8xA+4Sk 8R5A== X-Gm-Message-State: AOAM531SJDJXpScfck0DEbmVnB0AkOum1sTazDJIRaQZaat0k+ko3m6M 9HkJGuQHY4Bdy5OkY9FkexIn3A== X-Google-Smtp-Source: ABdhPJwKKkMUhHTHs8liqqiZEw6QbqKsR0VH1EETQ++13b9+/gCqkxAPhTie6BCSmDUT+IdW8uzOrQ== X-Received: by 2002:a92:8b51:: with SMTP id i78mr4391748ild.179.1596214151902; Fri, 31 Jul 2020 09:49:11 -0700 (PDT) Received: from derch.Home (97-122-92-59.hlrn.qwest.net. [97.122.92.59]) by smtp.gmail.com with ESMTPSA id e84sm5122083ill.60.2020.07.31.09.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:49:11 -0700 (PDT) From: Daniel Campello To: LKML , LKML Cc: Jonathan Cameron , Stephen Boyd , Douglas Anderson , Daniel Campello , Andy Shevchenko , Gwendal Grignou , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org Subject: [PATCH v3 14/15] iio: sx9310: Enable vdd and svdd regulators at probe Date: Fri, 31 Jul 2020 10:48:51 -0600 Message-Id: <20200731104555.v3.14.Ib7bdc8340021d8515b430498fb6686eedf22c9f2@changeid> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog In-Reply-To: <20200731164853.3020946-1-campello@chromium.org> References: <20200731164853.3020946-1-campello@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Stephen Boyd 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. Signed-off-by: Stephen Boyd Reviewed-by: Douglas Anderson Signed-off-by: Daniel Campello Reviewed-by: Andy Shevchenko --- Changes in v3: None Changes in v2: None drivers/iio/proximity/sx9310.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index aa21f6f1a58e3c..a20cd6a4dad729 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -120,6 +121,7 @@ struct sx9310_data { struct i2c_client *client; struct iio_trigger *trig; struct regmap *regmap; + struct regulator_bulk_data supplies[2]; /* * Last reading of the proximity status for each channel. * We only send an event to user space when this changes. @@ -879,6 +881,13 @@ static int sx9310_set_indio_dev_name(struct device *dev, return 0; } +static void sx9310_regulator_disable(void *_data) +{ + struct sx9310_data *data = _data; + + regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies); +} + static int sx9310_probe(struct i2c_client *client) { int ret; @@ -892,6 +901,8 @@ static int sx9310_probe(struct i2c_client *client) data = iio_priv(indio_dev); data->client = client; + data->supplies[0].supply = "vdd"; + data->supplies[1].supply = "svdd"; mutex_init(&data->mutex); init_completion(&data->completion); @@ -899,6 +910,21 @@ static int sx9310_probe(struct i2c_client *client) if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), + data->supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(data->supplies), data->supplies); + if (ret) + return ret; + /* Must wait for Tpor time after initial power up */ + usleep_range(1000, 1100); + + ret = devm_add_action_or_reset(dev, sx9310_regulator_disable, data); + if (ret) + return ret; + ret = regmap_read(data->regmap, SX9310_REG_WHOAMI, &data->whoami); if (ret) { dev_err(dev, "error in reading WHOAMI register: %d\n", ret);