From patchwork Thu Sep 20 18:45:52 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: 10608531 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 645055A4 for ; Thu, 20 Sep 2018 18:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5636E2E3FD for ; Thu, 20 Sep 2018 18:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A9762E505; Thu, 20 Sep 2018 18:46:00 +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 E134A2E3FD for ; Thu, 20 Sep 2018 18:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388069AbeIUAat (ORCPT ); Thu, 20 Sep 2018 20:30:49 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34231 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbeIUAat (ORCPT ); Thu, 20 Sep 2018 20:30:49 -0400 Received: by mail-ed1-f66.google.com with SMTP id e25so256304edv.1; Thu, 20 Sep 2018 11:45:57 -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; bh=HCaEKlZfrKOaIAaRGQkC9jdTapEZ9vbpVpv1ISxlmZg=; b=WT3uVCnbm5sko7hqODtSLYNnLDnGzboi8S7tr8oneQ+0LcVa7N0OoxC3i5/9bYCrvU SVAW97bMgEV71U/frjM4a46jfPC6JIIogCgu7noexGkiM5QbiWKMGN/tKeMn/DSdcOuQ xM7u7FVCRNFIHJnLfYFABmMZIb7s2z82a1QvdRxu/HVPfqbNxLN1FP0jimO1G1AhZAg7 T56kxdcX0bWD1iknWpCaI+unn6+VQx7B59+46ifPy75oCJ8hcx4Ifz53hH9IA9xnbHL9 qGs3aSiBeJLfbZ5uokqIMiSQdXnJaF2yoolZoRLUuHOPtyjZCVYVVLNUFhmVtneCf6xH pXTw== 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; bh=HCaEKlZfrKOaIAaRGQkC9jdTapEZ9vbpVpv1ISxlmZg=; b=WLnvZJoy/zfP+Rhtp/+2Br1srjlvsAzDmUppwXsiJfmGMJOcgpUeO1DexpY1jnfA2p ZzXqD0GtueWROCcqqo9NrQg9ujUrGtuhlqpoAcXwZq0AH9EhMY9SC32rU3/g1RdynU/w 4/4swZF+11qCe7wM6oKc9bnbOQKxLj3vzOPkamZAIn3+GlY8SuSOFPLRs+4iA2bI0Fyk cmSC9kVEyGY07oT12d5ngBHM6/dPkHk6PyerPFPf5xcoMFJOnv2wpW6HQOVKfkxzeTOp bMwIyez0u1SE5j7+j5MpYlHclGrOUssSgPqE/Rgx9WbpraZ56RgQggtH8+RXGsn6k6fb JopA== X-Gm-Message-State: APzg51AFOFZGThmhfbSpBdh7mx/nnMrz/c+41ttt5KVOKJ/CyUKEz7nl FdD79NzapYE/9lzJ/8TvRmV0DEeY X-Google-Smtp-Source: ANB0VdZ4FfKb5/3zlF4IcOVe2mQpy3ysAMe/UTV9PwtpN1qSlgn405onXQImK0+sfqe75nOZD6l37w== X-Received: by 2002:aa7:cb56:: with SMTP id w22-v6mr6195752edt.202.1537469156598; Thu, 20 Sep 2018 11:45:56 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id y27-v6sm1136957edb.20.2018.09.20.11.45.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 11:45:55 -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 v2 2/4] [media] ad5820: Add support for enable pin Date: Thu, 20 Sep 2018 20:45:52 +0200 Message-Id: <20180920184552.4919-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180920161912.17063-2-ricardo.ribalda@gmail.com> References: <20180920161912.17063-2-ricardo.ribalda@gmail.com> 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 --- 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..625867472929 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);