Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp41281imm; Thu, 20 Sep 2018 13:46:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY+MgMoxXhcj86by/xkI79KbEui2qrqk9hKZs7JA8JM03WADZ52sdo4L9iaifVt9O/ks34P X-Received: by 2002:a17:902:4124:: with SMTP id e33-v6mr41292428pld.48.1537476373911; Thu, 20 Sep 2018 13:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537476373; cv=none; d=google.com; s=arc-20160816; b=fA1R8bVJGmck3XkKNxCfmWt3poLXiJCMloo3itQDZ9Mi3kVLjxCTFcAu4KexTHj+JB /iHbPFu6mi85mdWP9c8UiWu2HHyB8Z8D8u4e+26VDOa/WlKnyPkUasGPk1gIPLDWnvnI 737eYiXwIoG2UBD7k5TstREqP1GpOMc42NBt0MyLV+op2I/MSNj8Dyha66NdYGEdwFoR DnXH1Qmr/vMiAV6xxSjoQuO7ChMMGybGkpfiEqZtViIjymLfREMbL8rUgFXrlk7ThUpi BVC1SPw8NZ64uRatJ3BCUHNYmDFBDfDM98mkw2iV/GIeV/DCeF1XGtS8ttJQpt9SnriY Ibvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=H9daVNGO5OptY0IYg0urEvmo0f2MhZ+T6kMd4xhx4iY=; b=RBwbjTi5Lz8r4sd48GMjG7s8MSBD2jflsDgEveQXKzc0YE6m1QX23nAQeHz53GvLJg Om0KHk+/x3m9yH+xC3E9nbTozJ9+BxQk08rH2WHVwEWNP7MlrAJZDaUVv59CegE+tmDj If1EB0TOzo+PSKbNQQ88d3ObCaKacSfywZObFlG1vv1dp7jrjduab0KWTjRJvKITPAcT ZdezsX5IiKTJEFlsQDWuwoPtvtcOouzD834yRU0mIDOYR91OmjATcT3Ha1nkfMbpfa5N djTH379ULv/mUeFPtURC3UoSjCkPOWW2CyTBJ5XH6m7iXSwS/vITfdZvWB5PApS1Hzgq 3tsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X3FMPHLX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6-v6si24087518plk.31.2018.09.20.13.45.58; Thu, 20 Sep 2018 13:46:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X3FMPHLX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388386AbeIUCbF (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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); -- 2.18.0