Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2392324ybe; Sat, 14 Sep 2019 14:05:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDSehI1IMnkE/QVVuF/TwHBYLrBZ6pcQoedj9dyIwd8HsW4jtUHbr0v7Ef0eX3C1gMzZ3W X-Received: by 2002:a05:6402:1549:: with SMTP id p9mr5078454edx.221.1568495140243; Sat, 14 Sep 2019 14:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568495140; cv=none; d=google.com; s=arc-20160816; b=GzxQtgGdb2GsMwEBqpTrMLebBEZWbGY+DVDP2isnyQCGgCKlK7Yn4Wq2o2QwKGHxVa bOTwikqvrqqJia8XRVgUUeggmUq0QxwzysC3/f68Lt7el2xEDr28rdRngZp87G1/sXCl 7l5a00u5TgBqHohTwmWdJc3C0hliQ58C1mAIYK1bcgzzXpdKoli094vrDrVDyFTwmaWX uul7ZYrLwYPCrgDlgwheIoQbuOfHqHlrjJ+I/NJTaGpKg7SmD1ldv++09vqYtp0iAK1m cP6bCY3WMzvlFV2Ur4AtTg38Yn/3kYHznjDS2ohWggnA4/2JmCbLr+RgTAgXV1jCV4lj MB7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Mbl+TqU1RDnoByFgw6YTBN5hIBAakcwGG9n4xIXKC+c=; b=f412fR+rRMnDiNO7xKU41brDhBBhpJVP5u+HVRepRkVCnZUjuc4dhD89jazWPv0vQy SXxUlwV530BZyzgxWJIwr98tDc7Y5HnlgsuJzJOmywz8CcKbexA2c1dxH82m/tDu7EKH 1S3BJQ9AT5ddb68OgHek0NaW78Ale6YSuwFM7fXhDgJqR3XuggTrBA5bqiu7uQsId559 DjrAfCqIia3fTmjY1IfBB1q6g+2c1JkLaCgtx/ZSW43uaDMYHN7N1CUZhXvWEnjD2oCE MGlfKrb2r+9LXmHgqdIZcXPEuaqd9/oxVCn2BYaW4EtoliSA5CwYFnpDyTIMBxMNE/Ba bfyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tA7nWU3l; 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 h42si19647595eda.90.2019.09.14.14.04.43; Sat, 14 Sep 2019 14:05:40 -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=tA7nWU3l; 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 S1729569AbfINKeK (ORCPT + 99 others); Sat, 14 Sep 2019 06:34:10 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36899 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbfINKeK (ORCPT ); Sat, 14 Sep 2019 06:34:10 -0400 Received: by mail-ot1-f66.google.com with SMTP id s28so31700871otd.4; Sat, 14 Sep 2019 03:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mbl+TqU1RDnoByFgw6YTBN5hIBAakcwGG9n4xIXKC+c=; b=tA7nWU3lXGqX+JpHOfUpDNhRLNRrl/cI6sGJCiUggydaE/S6ZkSqxtdt5kCmPqZMES NWDPdSvDHfUXDYew5WaGZAB7Xgmkvnjd29YNbEyR9axnVffmmchZ/BHsojl/H3Z12TG0 XQvksO1xLsz334htc8qviaKaTmeepDRWOkuGIiE8lhwG1q6MjoN7H+GFt3auQark5aoz Gxpd1aPzqrGpBi+7VoQM0claaW8LeONmt+9gOZPgpQVmF+gXQGodcLz1yp6XUaomdFOb U2o12BGdODfqkuSAdRt+IiKwrWjhCc65AhAeHwkHalTA4/yEUKN3tn3mm2tUaqmL2+Pz IwMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mbl+TqU1RDnoByFgw6YTBN5hIBAakcwGG9n4xIXKC+c=; b=M5e+//XNlm8GKV+74TZtb7+2uPv5TgUVwnR0vbZR8WqtKGr3fQfdOb+264ukHCDoLc aqBTHyy3Nq84L5xSp8Zmn4wljPasctCxpI85Zj8J7X2jUP4RmiMB6JHDdVJkhRPkUzOX rAhLYGSzCRvpNRKBkW74EYW3gUOfZkPy+VkLRCGeg5dRvVU7AxYKbQLgIG4/rnLipiRA cW4OjVsI90yHI8NCq6bH8oIAhzJnRzXIS4LDrPJ+xT09lsDJNf/He+PVKDkAz87+3s89 3pXW29eBWwRPFK92GkbgzkjGb7kCFdR6oe86nxTK4LYI5ihExfcwWQLIBHFrl+C2FGsB RkBA== X-Gm-Message-State: APjAAAVRzUy9aJ/2xnQg9Gd/ouCAk/cXlEVxRPHTsct9/hElUk88G6Zq KmVMmdsOHpT9J8ykZpmNq9bA8C0491HA49p6pLI= X-Received: by 2002:a9d:744c:: with SMTP id p12mr38958898otk.198.1568457249060; Sat, 14 Sep 2019 03:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20190912130007.4469-1-bparrot@ti.com> <20190912130007.4469-5-bparrot@ti.com> In-Reply-To: <20190912130007.4469-5-bparrot@ti.com> From: "Lad, Prabhakar" Date: Sat, 14 Sep 2019 11:33:42 +0100 Message-ID: Subject: Re: [Patch 4/6] media: i2c: ov2659: Add optional powerdown gpio handling To: Benoit Parrot Cc: Hans Verkuil , Sakari Ailus , linux-media , devicetree@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Benoit, On Thu, Sep 12, 2019 at 1:58 PM Benoit Parrot wrote: > > On some board it is possible that the sensor 'powerdown' > pin might be controlled with a gpio instead of being > tied to always powered. > > This patch add support to specify an optional gpio > which will be set at probe time and remained on. > > Signed-off-by: Benoit Parrot > --- > drivers/media/i2c/Kconfig | 2 +- > drivers/media/i2c/ov2659.c | 13 +++++++++++++ > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > index 7eee1812bba3..315c1d8bdb7b 100644 > --- a/drivers/media/i2c/Kconfig > +++ b/drivers/media/i2c/Kconfig > @@ -634,7 +634,7 @@ config VIDEO_OV2640 > config VIDEO_OV2659 > tristate "OmniVision OV2659 sensor support" > depends on VIDEO_V4L2 && I2C > - depends on MEDIA_CAMERA_SUPPORT > + depends on MEDIA_CAMERA_SUPPORT && GPIOLIB > select V4L2_FWNODE > help > This is a Video4Linux2 sensor driver for the OmniVision > diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c > index efbe6dc720e2..c64f73bef336 100644 > --- a/drivers/media/i2c/ov2659.c > +++ b/drivers/media/i2c/ov2659.c > @@ -32,6 +32,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > @@ -232,6 +234,8 @@ struct ov2659 { > struct sensor_register *format_ctrl_regs; > struct ov2659_pll_ctrl pll; > int streaming; > + /* used to control the sensor powerdownN pin */ > + struct gpio_desc *pwrdn_gpio; > }; > > static const struct sensor_register ov2659_init_regs[] = { > @@ -1391,6 +1395,7 @@ static int ov2659_probe(struct i2c_client *client) > struct v4l2_subdev *sd; > struct ov2659 *ov2659; > struct clk *clk; > + struct gpio_desc *gpio; you don't need the local var here you can just assign it directly to pwrdn_gpio. > int ret; > > if (!pdata) { > @@ -1414,6 +1419,14 @@ static int ov2659_probe(struct i2c_client *client) > ov2659->xvclk_frequency > 27000000) > return -EINVAL; > > + /* Optional gpio don't fail if not present */ > + gpio = devm_gpiod_get_optional(&client->dev, "powerdown", > + GPIOD_OUT_HIGH); > + if (IS_ERR(gpio)) > + return PTR_ERR(gpio); > + > + ov2659->pwrdn_gpio = gpio; > + apart from assigning it you don't actually use it. you will also have to read the reset gpio pin and implement ov2659_set_power() and call it in appropriate places/ s_power ? Cheers, --Prabhakar Lad