From patchwork Tue Oct 2 07:32:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 10623143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA49815E8 for ; Tue, 2 Oct 2018 07:33:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD0162074F for ; Tue, 2 Oct 2018 07:33:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B15A520952; Tue, 2 Oct 2018 07:33:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469BB20950 for ; Tue, 2 Oct 2018 07:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727273AbeJBOOW (ORCPT ); Tue, 2 Oct 2018 10:14:22 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40346 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbeJBOOV (ORCPT ); Tue, 2 Oct 2018 10:14:21 -0400 Received: by mail-lj1-f194.google.com with SMTP id r83-v6so818827ljr.7; Tue, 02 Oct 2018 00:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RmTshnoq0D1caFdQ57INpjfkRgxEBWXE7yXtkeuvd6Q=; b=ku5lTBjOKYHLkBfY1EZkm9e/e+mmu4cgzTK0QJyh5AVLnHtS+UkJPBjtLoBTVCAES4 cJ0+lyf0qXBiD7cQOxX0jly35YpcA84KAGw5Amp7x91bD1lIcs9DlivS9XkeM6xlbOnt oU82tJ86eL86qQy18qU/cdgrwATdLv+gRMWek6UNNcUFCXtHsuzi1Pjybb7yGxZlovq0 dSHBnjZ0v6ldXVyodqhZe7vOhd8PFUdnYuuEnmfnxuYp4zsujbJhfOzqM8JGSSKP11TB z4Mpn3n2a0X054elWnB+atnfOLT+EY4DlNWpT2aYO+U10DyCxjt4orXpZOiMbYlpfkyi e8uQ== 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=RmTshnoq0D1caFdQ57INpjfkRgxEBWXE7yXtkeuvd6Q=; b=NVl9+c4GAKXc9j97nVp0sWNL8ffWSjtITnriu/zG0gj7CxlcRR8ZGNg1QOgUDDN7pL BmIS7LSirB29dtnStmANpyCSLXXKEMLcC3aDsiHGu7gXfMmCRYmMBt5J0k5YEZ3qorZ0 O4AWP8P0S0uGhjrLQT3F8rEq6HhlfMu59gfU+ZfsPwfMiZsudZlo7tmejAcjbP0l0cHk n6Nw4YgssSvxk7Lbpa37UAHFFffjAVvdFFQynaxhan+1scBUovtw9EhyeAw2oXyJHAIH iCMwb6gxQZnJFLHEolIgB+vUfEJ5nq58EBeYg2TupfMHaRoulOrHLJeOBIxxGF6s2LKc ndfw== X-Gm-Message-State: ABuFfojKbqqi7VLVulkyxW7kXjY8mTU4O6Sypr9zoxopzy7H5m7P6rtp pddb7ADyHur9QulwM+KVwqY= X-Google-Smtp-Source: ACcGV63rWqiv6FHr3B4rC+JDPLhhb2tPx/siHb2bIX0k4a1X4rNaDf3A5oXijiNzVYdhHg5qlWvpqg== X-Received: by 2002:a2e:5686:: with SMTP id k6-v6mr874451lje.105.1538465548259; Tue, 02 Oct 2018 00:32:28 -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 d17-v6sm1242246lfj.9.2018.10.02.00.32.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 00:32:27 -0700 (PDT) From: Ricardo Ribalda Delgado To: Pavel Machek , Sakari Ailus , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Laurent Pinchart Cc: Ricardo Ribalda Delgado Subject: [PATCH v5 3/6] [media] ad5820: Add support for enable pin Date: Tue, 2 Oct 2018 09:32:19 +0200 Message-Id: <20181002073222.11368-3-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002073222.11368-1-ricardo.ribalda@gmail.com> References: <20181002073222.11368-1-ricardo.ribalda@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 bfdb494686bf..1ba6eaaf58fb 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -321,7 +321,7 @@ config VIDEO_ML86V7667 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 22759aaa2dba..97eb05e65833 100644 --- a/drivers/media/i2c/ad5820.c +++ b/drivers/media/i2c/ad5820.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,8 @@ struct ad5820_device { u32 focus_ramp_time; u32 focus_ramp_mode; + struct gpio_desc *enable_gpio; + struct mutex power_lock; int power_count; @@ -122,6 +125,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; @@ -136,6 +141,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; @@ -146,6 +153,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); @@ -312,6 +320,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);