From patchwork Mon Sep 16 16:02:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 20365 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E4BD277F1 for ; Mon, 16 Sep 2013 16:02:55 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id x20sf4477836qcv.11 for ; Mon, 16 Sep 2013 09:02:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=3LC7uZBnceGtCkgWBm0feQHqqt+6oRGXgt3KlQCbotE=; b=aPLgbQcMsB3F4QC33WAcZLBT5KLGWPAyMYdsSSyiPndUILjKWtppc7AOCsTDH77Ml1 TyUJz7eGzczZ3Lq295tE/0NeodEJuzqqFJ4dM6tD9lORMkZrYIa4+AnRB+ZT8JOYnnac B3AHLJSmOyvTiChDyEWXHpHTcUQM7Ko7irCVyLYrS4dGR/aAN7o6HFVmvAAViM0QjGse ZOQQHNGL10F1aGexJxpzf4gy0ORb+LSZvHOqkllAPp8NQrHiXZ5mQaBfZbgKzHSU2nmK HzXSgtd8fZpvjhXgZVMksNJMMP7RW8AG/Qcdk6NiBPwiS5/sQvw/z366cu0jeq3jfolt Lbow== X-Gm-Message-State: ALoCoQmONS2RY/V9aX1U59riiLofLqmvX3M1uhgK2DEi99HLFH9lczixVbDW5Pv73KW4wOaYJ62c X-Received: by 10.236.73.164 with SMTP id v24mr10404598yhd.24.1379347374881; Mon, 16 Sep 2013 09:02:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.134.74 with SMTP id pi10ls2196906qeb.35.gmail; Mon, 16 Sep 2013 09:02:54 -0700 (PDT) X-Received: by 10.52.98.131 with SMTP id ei3mr23220145vdb.4.1379347374792; Mon, 16 Sep 2013 09:02:54 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id b5si7257992vcf.129.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jy13so3082641veb.5 for ; Mon, 16 Sep 2013 09:02:54 -0700 (PDT) X-Received: by 10.58.75.131 with SMTP id c3mr24397922vew.12.1379347374693; Mon, 16 Sep 2013 09:02:54 -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 u4csp104947vcz; Mon, 16 Sep 2013 09:02:53 -0700 (PDT) X-Received: by 10.15.32.136 with SMTP id a8mr2798149eev.71.1379347373531; Mon, 16 Sep 2013 09:02:53 -0700 (PDT) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) by mx.google.com with ESMTPS id h5si16794632eeg.290.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.181 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.181; Received: by mail-ea0-f181.google.com with SMTP id d10so2123878eaj.40 for ; Mon, 16 Sep 2013 09:02:52 -0700 (PDT) X-Received: by 10.15.34.135 with SMTP id e7mr3426165eev.63.1379347372871; Mon, 16 Sep 2013 09:02:52 -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 z12sm43061275eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:52 -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 16/20] iio: pressure-core: st: Provide support for the Vdd power supply Date: Mon, 16 Sep 2013 17:02:22 +0100 Message-Id: <1379347346-823-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1379347346-823-1-git-send-email-lee.jones@linaro.org> References: <1379347346-823-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.128.174 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 e879542..c801c80 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); @@ -381,6 +407,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;