From patchwork Tue Sep 10 12:49:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19884 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E01B25EA3 for ; Tue, 10 Sep 2013 12:50:21 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id k10sf9538336iea.7 for ; Tue, 10 Sep 2013 05:50:20 -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=LhQEVtRFvPj3ecGhARd617Rs9qGRA/IWUBsQlhmpKhY=; b=dptETAOfs6IYGovVpTNu1bQrGint33HWYdHT/NWYCxkuJDD5oL3zoiHdIIZYEMa1Fh rCD9j+H0KG79NWNjVJuGEb2nK5E6oVgoeNdKpTXaROBmU3suQVk62rhQJGuodKymMNyC XXF+xw449MpqCGSmnbAAucw4lHtm0Ka40c7sV4PukJc7ZnGHWQUh9eqJzV9uV8Uge7By YOB+LQz5IhVZJePJS341SoR/zZ2gfXVgaCks7qsnuHN3ShTLkvmVVxJQN1oMArKnNwlx Phc7KoQrkvyTgXohPjwWAIvno4q6ebyTQo3ybuSbWbAQpaXYjw/3Nt97Sx2JVt2msFnb +pcA== X-Received: by 10.182.133.38 with SMTP id oz6mr491303obb.45.1378817420665; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.15.198 with SMTP id z6ls2095169qec.63.gmail; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) X-Received: by 10.58.73.202 with SMTP id n10mr22917051vev.7.1378817420291; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id tj1si4393503vdc.53.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.46 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.46; Received: by mail-vb0-f46.google.com with SMTP id p13so4809256vbe.19 for ; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) X-Gm-Message-State: ALoCoQkTp4f6+L0pp2nuCU95nt5bKaHVuhiOUDUs0hU4Jd7gEuLc8aHUFlL1MCH2flhddedEFd6j X-Received: by 10.220.186.202 with SMTP id ct10mr23310168vcb.14.1378817420197; Tue, 10 Sep 2013 05:50:20 -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 u4csp19410vcz; Tue, 10 Sep 2013 05:50:19 -0700 (PDT) X-Received: by 10.14.10.2 with SMTP id 2mr3022224eeu.63.1378817416617; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by mx.google.com with ESMTPS id h46si14873778eex.13.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.177 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.177; Received: by mail-ea0-f177.google.com with SMTP id f15so3773932eak.8 for ; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Received: by 10.14.10.2 with SMTP id 2mr3022159eeu.63.1378817416044; Tue, 10 Sep 2013 05:50:16 -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 z12sm31123277eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:15 -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 29/38] iio: pressure-core: st: Provide support for the Vdd power supply Date: Tue, 10 Sep 2013 13:49:30 +0100 Message-Id: <1378817379-8238-30-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378817379-8238-1-git-send-email-lee.jones@linaro.org> References: <1378817379-8238-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.46 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 b42614a..d52b487 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); @@ -382,6 +408,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;