Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2187820ybe; Thu, 12 Sep 2019 06:00:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/nw9EcpzVR+dJSq+4ZBLxLE9B0ytpaFCwuDljFDEwj2O6ehjl1oYTn5ZPMityxiGB+ENT X-Received: by 2002:a05:6402:7d1:: with SMTP id u17mr41730036edy.132.1568293233456; Thu, 12 Sep 2019 06:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568293233; cv=none; d=google.com; s=arc-20160816; b=zlhhfIX/c4Mw501qRbpoJmioNIXkRh/TtNUOTDkCEjILCKXKQTcVmimxHKkQpr37rw LmTrXJ0iLqTcaotaKmHJBXxGYXNBYhcgiF6jLYZHCYsECvFcfgmT96SS8OI7xVDRh1jv 7bNO1YlQMYidiTrxLmkeQdaXj8n5e69705TPJ6FnQUDM+sEw4K4b1js+nycZZnnc1tHu Pg+WqbHa3WkYeQ/LX84K3Yulztu82SavM/whMlSTXx3YuuDzM0xcHMx3T11GvYXvuBqG Q6RwJm9n5gtS3C8eIllIkEBvtD+CgUv3wIK4PfqlV5CNQhYgVx7OZn/sGElSqSdsvsEA gtLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=0nKBHKh658w9Px5pzqwSjEqC1c/Rx5bK6Y6t/EfyzZQ=; b=YpyrPlTyJLWdbo73Da8OH5Wp2mj+w4MXzz2MWNRJKw4hzzbAo24TdliZI8TcTVfr0F OepaNStGniXqQRiTtDCdKZR5CoG+koMRLwiKQTxN6gEp2xLYhr0sZEd6iNBbtzyTnfK8 cgCSvEqidGEuGEXJjHouqIJfoUoZbEua0Cz5lhJLylCBrKS8LwVFD2CcP1tYvujltD4s hbpqU3X1CuYnHyfdxwAOF8p4rkiA9ly1nkkPy0rpJtbBl4VDeZInwW6rkRdVlehlgD+F tghkofFOZcEulmYjOIHh0oDGzPSueE2MMsgjod/iSanDSAbQlOoKMN+5P8dcKx1ndL3B 2d5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UBeyn4Yk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z43si15075229edc.389.2019.09.12.06.00.10; Thu, 12 Sep 2019 06:00:33 -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=@ti.com header.s=ti-com-17Q1 header.b=UBeyn4Yk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731953AbfILM6P (ORCPT + 99 others); Thu, 12 Sep 2019 08:58:15 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:55764 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731927AbfILM6N (ORCPT ); Thu, 12 Sep 2019 08:58:13 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8CCw8Xj092114; Thu, 12 Sep 2019 07:58:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568293089; bh=0nKBHKh658w9Px5pzqwSjEqC1c/Rx5bK6Y6t/EfyzZQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UBeyn4YkgxIYm1x55j+fsSMCdunBZOiA1Os8hNurQcNgpMYFF2OuEzLqPFlY7MPbr BO0XKlMQfmAMjznEEL9/WZ4U+YX9okUsyPUEDtEFjVIG/5V7sPJpiViY7ZNcJgdG0v nTzYBCr7LFTtlHNEhg+6V1m/cPrJB7MIrYso1xCo= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8CCw8Q2105924 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Sep 2019 07:58:08 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 12 Sep 2019 07:58:08 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 12 Sep 2019 07:58:08 -0500 Received: from uda0869644b.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8CCw4Zi095654; Thu, 12 Sep 2019 07:58:08 -0500 From: Benoit Parrot To: Hans Verkuil , Sakari Ailus CC: Prabhakar Lad , , , , Benoit Parrot Subject: [Patch 4/6] media: i2c: ov2659: Add optional powerdown gpio handling Date: Thu, 12 Sep 2019 08:00:05 -0500 Message-ID: <20190912130007.4469-5-bparrot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190912130007.4469-1-bparrot@ti.com> References: <20190912130007.4469-1-bparrot@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; 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; + v4l2_ctrl_handler_init(&ov2659->ctrls, 2); ov2659->link_frequency = v4l2_ctrl_new_std(&ov2659->ctrls, &ov2659_ctrl_ops, -- 2.17.1