From patchwork Mon Oct 7 13:20:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 11177471 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 06819112B for ; Mon, 7 Oct 2019 13:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D96EE218AC for ; Mon, 7 Oct 2019 13:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570454511; bh=/ew1iTFSPFJl1GZ94sCBI0f4pcTvUs1Ne8ccMb1v1Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QnUWlWF0VeUPhKXkvMHRs0Afd6frzpDci7vl1ayaAzrY0YXt4ReITJGn8733K+F7M lkKS2w0BAaCN4Cbaqk4K/vEy8WTKJbiXbojfXDPCR/MuvWrxTsJ1G73c+krUgpnL85 3c7hxJTE433eEvfRjH/PzeYRZ0i1O7c4woOyiyc4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbfJGNVN (ORCPT ); Mon, 7 Oct 2019 09:21:13 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37014 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728235AbfJGNVM (ORCPT ); Mon, 7 Oct 2019 09:21:12 -0400 Received: by mail-lf1-f68.google.com with SMTP id w67so9267555lff.4; Mon, 07 Oct 2019 06:21:11 -0700 (PDT) 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=GX+ni17mNRYs8d+zDraCFt5XjyO8QrKC7e0GjBCgxpI=; b=CHYrG2G8fWBGdJvgo67uDoIed/9CPtwZPTYTNmjRF9kZFAu2rdIFyrO9ixoD1IcKkQ kscz1pUoiQxOtb6Cf2hgDC4GEx1X1FENNT7kcdpQpua3+bWbhADJfBCkWizWtzqVko1l iMiC+jkj3j++4/Hp3GLOCe145LAefo9txz3HF8RO1iD0up8c1/2mgx+w6fVRxoPvQFeN feqCDHrrcSEycsRn0yMjNFqaIVivh8F2Jczw5PfS789CdElZYHk1kK5ekwn14jUvD95W DkcA1Vl9p0Bc9k0g5kAI6eKbvRkQkw2L06VIsySsg+5ubrLjXch2QjzzKOYhzN43iBJM 3wFg== X-Gm-Message-State: APjAAAV1OPAeKq7h/bhc6hlhHqEsXr4noHt+TorhWL11ZICvPnabg6F4 +bNxpfWdS0hllHK706GqYKI= X-Google-Smtp-Source: APXvYqwlE8mz5IqyFoGHNe1iuu0hWCBGRHHravGVWOyYThgV5dMLWivqXmj1Cc/4oxMSs0RrQq+SSg== X-Received: by 2002:ac2:48af:: with SMTP id u15mr17147302lfg.75.1570454470551; Mon, 07 Oct 2019 06:21:10 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id z14sm2687360lfh.30.2019.10.07.06.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 06:21:09 -0700 (PDT) From: Ricardo Ribalda Delgado To: Pavel Machek , Sakari Ailus , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v7 3/6] media: ad5820: Add support for enable pin Date: Mon, 7 Oct 2019 15:20:44 +0200 Message-Id: <20191007132050.27298-7-ribalda@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191007132050.27298-1-ribalda@kernel.org> References: <20191007132050.27298-1-ribalda@kernel.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch adds support for a programmable enable pin. It can be used in situations where the ANA-vcc is not configurable (dummy-regulator), or just to have a more fine control of the power saving. The use of the enable pin is optional. Signed-off-by: Ricardo Ribalda Delgado Acked-by: Pavel Machek --- drivers/media/i2c/Kconfig | 2 +- drivers/media/i2c/ad5820.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 78dc64d7b0e7..30d460844dff 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -975,7 +975,7 @@ if MEDIA_CAMERA_SUPPORT config VIDEO_AD5820 tristate "AD5820 lens voice coil support" - depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER + depends on GPIOLIB && I2C && VIDEO_V4L2 && MEDIA_CONTROLLER help This is a driver for the AD5820 camera lens voice coil. It is used for example in Nokia N900 (RX-51). diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c index 7a49651f4d1f..76aab651f217 100644 --- a/drivers/media/i2c/ad5820.c +++ b/drivers/media/i2c/ad5820.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,8 @@ struct ad5820_device { u32 focus_ramp_time; u32 focus_ramp_mode; + struct gpio_desc *enable_gpio; + struct mutex power_lock; int power_count; @@ -114,6 +117,8 @@ static int ad5820_power_off(struct ad5820_device *coil, bool standby) ret = ad5820_update_hw(coil); } + gpiod_set_value_cansleep(coil->enable_gpio, 0); + ret2 = regulator_disable(coil->vana); if (ret) return ret; @@ -128,6 +133,8 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore) if (ret < 0) return ret; + gpiod_set_value_cansleep(coil->enable_gpio, 1); + if (restore) { /* Restore the hardware settings. */ coil->standby = false; @@ -138,6 +145,7 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore) return 0; fail: + gpiod_set_value_cansleep(coil->enable_gpio, 0); coil->standby = true; regulator_disable(coil->vana); @@ -304,6 +312,15 @@ static int ad5820_probe(struct i2c_client *client, return ret; } + coil->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(coil->enable_gpio)) { + ret = PTR_ERR(coil->enable_gpio); + if (ret != -EPROBE_DEFER) + dev_err(&client->dev, "could not get enable gpio\n"); + return ret; + } + mutex_init(&coil->power_lock); v4l2_i2c_subdev_init(&coil->subdev, client, &ad5820_ops);