From patchwork Mon Sep 9 10:10:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19829 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3031925A57 for ; Mon, 9 Sep 2013 10:10:34 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf6929274vcb.11 for ; Mon, 09 Sep 2013 03:10:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=3jps6hRb9UtzSzNK1oQO/L+mEBTisbcAsQTOR11DauM=; b=aLtMRzbhdxhvb4mam7DmhvZn6jf0APLGCgoRZe4YorrY6W8/Q7jwYljD2rl5mTy7Ev FU2hhdJO1v0chhCC7whzfjGRR1bS4o9iaPdyCw+t7htDH4NCjkeeyFN1P58PvNw2LM7B BnZl6zoWWL2shLnJKINdKEEdUL6uuyDoEKi2Hjvr7LRTnZcnvj4yB6hLq1kA8fhOJMPZ Ke5GCXlrb5Erfk6ThK/6MfF3NDsBJQVSGlD316GVEq3qXcxTUFXcgJBKb3+/4Mo/XwY3 xLSkJoYPmksS8viQOZ9C0eQDJccF+NZ1sdSoswg+8+w7WYfgGOxx1UalHdNfP0zCh/QS sEGA== X-Received: by 10.236.80.42 with SMTP id j30mr5952986yhe.29.1378721434013; Mon, 09 Sep 2013 03:10:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.231 with SMTP id n7ls1613865qen.14.gmail; Mon, 09 Sep 2013 03:10:33 -0700 (PDT) X-Received: by 10.52.165.237 with SMTP id zb13mr567707vdb.28.1378721433904; Mon, 09 Sep 2013 03:10:33 -0700 (PDT) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id cz7si2955580veb.147.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id e12so3917352vbg.29 for ; Mon, 09 Sep 2013 03:10:33 -0700 (PDT) X-Gm-Message-State: ALoCoQnWTj+ir7D3HRRw21XBwGx5BlRLglDJiKMyM6WCbSF3nwBip47ueB45QE6A3in7jdHZYGk5 X-Received: by 10.220.140.69 with SMTP id h5mr16880213vcu.0.1378721433825; Mon, 09 Sep 2013 03:10:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78976vcz; Mon, 9 Sep 2013 03:10:33 -0700 (PDT) X-Received: by 10.15.35.196 with SMTP id g44mr29226948eev.18.1378721432427; Mon, 09 Sep 2013 03:10:32 -0700 (PDT) Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com [74.125.83.47]) by mx.google.com with ESMTPS id o7si9578855eep.48.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:32 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.47 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.47; Received: by mail-ee0-f47.google.com with SMTP id d49so2986037eek.20 for ; Mon, 09 Sep 2013 03:10:32 -0700 (PDT) X-Received: by 10.15.99.72 with SMTP id bk48mr29438875eeb.22.1378721431906; Mon, 09 Sep 2013 03:10:31 -0700 (PDT) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginmedia.com. [92.233.57.238]) by mx.google.com with ESMTPSA id m54sm20768068eex.2.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:31 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jic23@cam.ac.uk Cc: arnd@arndb.de, linus.walleij@linaro.org, denis.ciocca@st.com, linux-iio@vger.kernel.org, Lee Jones Subject: [PATCH 10/14] iio: pressure-core: st: Provide support for the Vdd power supply Date: Mon, 9 Sep 2013 11:10:06 +0100 Message-Id: <1378721410-30937-11-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> References: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The power to some of the sensors are controlled by regulators. In most cases these are 'always on', but if not they will fail to work until the regulator is enabled using the relevant APIs. This patch allows for the Vdd power supply to be specified by either platform data or Device Tree. Signed-off-by: Lee Jones --- drivers/iio/pressure/st_pressure_core.c | 28 ++++++++++++++++++++++++++++ include/linux/iio/common/st_sensors.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index c5fe03f..f11cffc 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -313,6 +314,29 @@ static const struct iio_trigger_ops st_press_trigger_ops = { #define ST_PRESS_TRIGGER_OPS NULL #endif +void st_press_power_enable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *pdata = iio_priv(indio_dev); + int err; + + /* Regulators not mandatory, but if requested we should enable it. */ + pdata->vdd = devm_regulator_get_optional(&indio_dev->dev, "vdd"); + if (!IS_ERR(pdata->vdd)) { + err = regulator_enable(pdata->vdd); + if (err != 0) + dev_warn(&indio_dev->dev, + "Failed to enable specified Vdd supply\n"); + } +} + +void st_press_power_disable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *pdata = iio_priv(indio_dev); + + if (!IS_ERR(pdata->vdd)) + regulator_disable(pdata->vdd); +} + int st_press_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *plat_data) { @@ -323,6 +347,8 @@ int st_press_common_probe(struct iio_dev *indio_dev, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &press_info; + st_press_power_enable(indio_dev); + err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_press_sensors), st_press_sensors); @@ -378,6 +404,8 @@ void st_press_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); + st_press_power_disable(indio_dev); + iio_device_unregister(indio_dev); if (pdata->get_irq_data_ready(indio_dev) > 0) { st_sensors_deallocate_trigger(indio_dev); diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index e732fda..968b84e 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -201,6 +202,7 @@ struct st_sensors { * @trig: The trigger in use by the core driver. * @sensor: Pointer to the current sensor struct in use. * @current_fullscale: Maximum range of measure by the sensor. + * @vdd: Pointer to sensor's Vdd power supply * @enabled: Status of the sensor (false->off, true->on). * @multiread_bit: Use or not particular bit for [I2C/SPI] multiread. * @buffer_data: Data used by buffer part. @@ -216,6 +218,7 @@ struct st_sensor_data { struct iio_trigger *trig; struct st_sensors *sensor; struct st_sensor_fullscale_avl *current_fullscale; + struct regulator *vdd; bool enabled; bool multiread_bit;