From patchwork Thu Sep 20 20:45:35 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: 10608743 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 E3F18157B for ; Thu, 20 Sep 2018 20:46:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6DDB2E2AE for ; Thu, 20 Sep 2018 20:46:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAECA2E2BC; Thu, 20 Sep 2018 20:46:30 +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 696C72E2AE for ; Thu, 20 Sep 2018 20:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388331AbeIUCbF (ORCPT ); Thu, 20 Sep 2018 22:31:05 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38525 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbeIUCbF (ORCPT ); Thu, 20 Sep 2018 22:31:05 -0400 Received: by mail-lj1-f193.google.com with SMTP id p6-v6so9653578ljc.5; Thu, 20 Sep 2018 13:45:45 -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; bh=H9daVNGO5OptY0IYg0urEvmo0f2MhZ+T6kMd4xhx4iY=; b=X3FMPHLXrcZwssy8ZFkHC4JmrtoI+G4NwTarRF/ueMHCjGCcAn53shRwSBapA9Rkux /LiywC8eN7ru4I1vYLVbXlFbNhb+7wH4GWjpEEn0aRWyHYRhnuvxwnSrrN7MU7djrVMI nMmXR0MkdzufFPhM+Q79dMFGLd8U50aWHROEWVbn5LQxWfAr/AdtsfepuV8FTy1YFGl/ wU0iGrTxgmPM16zAuEXCcX2A52dCOWM7SM2VWvBoI5T8UCFvj1GiBem74vhaEYIQI9Ha WhSfRjCeZrYtlBu899KsZqh+Qq1g0WJqVO9BGXpX0i+/8DAzYbu7i2EJj4gZOG3bA5el CTzQ== 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; bh=H9daVNGO5OptY0IYg0urEvmo0f2MhZ+T6kMd4xhx4iY=; b=oFUUfZw/womGZoI+FGz3FZHl+JE9UON4IHzqvDQYzxq5jNPno3J0iMTmp9/ojrpc6Y pX1OV4Hxen0xR+LA5lfacvlt4MKIdKApiWigyc1L0ondcjZi42AVOsHH8rj3RRXVTVRR pcDgJPTWzRBx3czhiAphrqGh1cvYiXWBxJVKIWc1G+2yI8bxoGidEk4+X1J9Nk/7nddx G76bGa8lm42zp1ynzKGzEFoDWVsPz8r0SdjAysh9rc/ES1otHj7U1tGwmDPeRPAZrFdt sxMNpAnajcOkQyYnn1zYISjSXLDdUXbqH+7wJHxywjzocccYLuV0saxWwGAej8DDTmPL P77w== X-Gm-Message-State: APzg51DBiMMW31tT28c2BLtl+2FYDWbuQUeRuu7uPu2dEq/HqvEeccjy JiwLrnECF8l6wxH7i/gwKfM= X-Google-Smtp-Source: ANB0VdYOZcBgMD3w/UUYw+cjReiB4uRkxj2wbHDoEoBopaq71+khYpH8KelT/Lt3ygIarXuRVJAXFQ== X-Received: by 2002:a2e:3313:: with SMTP id d19-v6mr6917926ljc.25.1537476344666; Thu, 20 Sep 2018 13:45:44 -0700 (PDT) Received: from piling.lan (80-71-134-83.u.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id r23-v6sm4470355ljc.15.2018.09.20.13.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 13:45:43 -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 v3] 1/6] [media] ad5820: Add support for enable pin Date: Thu, 20 Sep 2018 22:45:35 +0200 Message-Id: <20180920204540.28832-1-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.18.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..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);