From patchwork Wed Sep 4 09:31:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19751 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f200.google.com (mail-ye0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C51924869 for ; Wed, 4 Sep 2013 09:32:12 +0000 (UTC) Received: by mail-ye0-f200.google.com with SMTP id r3sf45655yen.11 for ; Wed, 04 Sep 2013 02:32:12 -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=48PtrGbKaN43fO5Dtpr0jN01PS1yBscxtJEDSf0CTZo=; b=KiHh4mcrYkel9ONxLWHR/I0/t9tuCzQQ/fQW8+A+ps8k50xd4GjD5aSgLIgZb91bvM PRkhY9kq6ktA/z7DVrVt1vF3LbENvdtKo7qQTSgR7go7nBSNme7JaHyBfmh9WTHSGMRD 4yeJhxD0H4sI4GE043sKXa9sOyql6DLQ55SycAl9L4OODpw5vjXGh2+YvGfiukOyyFrL 1VavwdORKzc0IPZ+Wtl0iFOQuaP0uZTnU9yoMv+16lobBYkel5RyI2w5317qvSuHgrwf Kc/Ulbl3gWYxCUmmNpY4UQFsJhIV5QhbdMUQa1dla3F695UYvhGHfO03dpvgvae2hoI2 AyMA== X-Received: by 10.236.45.102 with SMTP id o66mr696106yhb.47.1378287132402; Wed, 04 Sep 2013 02:32:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.228 with SMTP id p4ls25175qeu.43.gmail; Wed, 04 Sep 2013 02:32:12 -0700 (PDT) X-Received: by 10.58.108.74 with SMTP id hi10mr1837129veb.14.1378287132288; Wed, 04 Sep 2013 02:32:12 -0700 (PDT) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by mx.google.com with ESMTPS id 10si5642539vcs.30.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:12 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.48 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.48; Received: by mail-vb0-f48.google.com with SMTP id w16so37737vbf.35 for ; Wed, 04 Sep 2013 02:32:12 -0700 (PDT) X-Gm-Message-State: ALoCoQkUUgqT3+bZP8z4yr/VHLxhNsts+ukGh4HHgikGVaGfeotEfcMkOSiovlIfTP8gnaUnECNp X-Received: by 10.52.173.165 with SMTP id bl5mr1563578vdc.18.1378287132198; Wed, 04 Sep 2013 02:32:12 -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 u4csp223895vcz; Wed, 4 Sep 2013 02:32:11 -0700 (PDT) X-Received: by 10.15.83.2 with SMTP id b2mr3330653eez.28.1378287131041; Wed, 04 Sep 2013 02:32:11 -0700 (PDT) Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by mx.google.com with ESMTPS id h8si18343321eeo.186.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.176; Received: by mail-ea0-f176.google.com with SMTP id q16so32582ead.35 for ; Wed, 04 Sep 2013 02:32:10 -0700 (PDT) X-Received: by 10.14.178.66 with SMTP id e42mr1302860eem.67.1378287130394; Wed, 04 Sep 2013 02:32:10 -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 p5sm38475700eeg.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:09 -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 11/11] iio: pressure-core: st: Provide correct regulator support Date: Wed, 4 Sep 2013 10:31:43 +0100 Message-Id: <1378287103-21765-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378287103-21765-1-git-send-email-lee.jones@linaro.org> References: <1378287103-21765-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.48 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. Signed-off-by: Lee Jones --- drivers/iio/pressure/st_pressure_core.c | 13 +++++++++++++ include/linux/iio/common/st_sensors.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index f452417..7beed89 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 @@ -315,6 +316,15 @@ int st_press_common_probe(struct iio_dev *indio_dev) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &press_info; + /* Regulator not mandatory, but if requested we should enable it. */ + pdata->regulator = regulator_get(&indio_dev->dev, "vdd"); + if (!IS_ERR_OR_NULL(pdata->regulator)) { + err = regulator_enable(pdata->regulator); + if (err != 0) + dev_warn(&indio_dev->dev, + "Failed to enable specified vdd regulator\n"); + } + err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_press_sensors), st_press_sensors); @@ -363,6 +373,9 @@ void st_press_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); + if (!IS_ERR_OR_NULL(pdata->regulator)) + regulator_disable(pdata->regulator); + 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 4aef925..eb6ef3f 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 #define ST_SENSORS_TX_MAX_LENGTH 2 #define ST_SENSORS_RX_MAX_LENGTH 6 @@ -197,6 +198,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. + * @regulator: Pointer to sensor's 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. @@ -211,6 +213,7 @@ struct st_sensor_data { struct iio_trigger *trig; struct st_sensors *sensor; struct st_sensor_fullscale_avl *current_fullscale; + struct regulator *regulator; bool enabled; bool multiread_bit;