From patchwork Sun May 30 20:44:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12288439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCDEFC47093 for ; Sun, 30 May 2021 20:44:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B31E66120F for ; Sun, 30 May 2021 20:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbhE3UqR (ORCPT ); Sun, 30 May 2021 16:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbhE3UqQ (ORCPT ); Sun, 30 May 2021 16:46:16 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5066AC061574; Sun, 30 May 2021 13:44:38 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id k19so6682985qta.2; Sun, 30 May 2021 13:44:38 -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:mime-version :content-transfer-encoding; bh=RQuLdzF/GeC8fi6lsIXUBhkIwnI4byxBee++wZ1+mZ0=; b=tBj4xHbprXC899hu5uK8xS1ah3CUV0tIYjvbnPya+N3a1VZvQsZdpRzpBrbNI/4app PvveuCAycTIJa4p3p6o5SxBCsiEEukJYO8lVO9Ys+EBnu3oQSn8vPEbUgT8WIq+jhGgV FrHttgXtQp/jj5Cfx+8KojSQbUzh/WqdZIG4kHRuDE9B5h3RG0EnncCLjy2gXcRRqo4I nfXW2NSfii6tsnr5selfN1eH6MTVTR3jzxMsk7DnB/WgcC+U7GPG+N969xO/hJZMrF79 jvcY1MR9GLzdqk6/+5xRVOp++Un1wYZ6urNmORLF4dlVvBGalR2/ZmnA5Oo0F64/oXpd Q+eA== 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:mime-version :content-transfer-encoding; bh=RQuLdzF/GeC8fi6lsIXUBhkIwnI4byxBee++wZ1+mZ0=; b=fpHwXTZc8CctlFKA/HfIayaU1lBMwdApofG22MKOMyqYYTBhoIP7/VkK2oZRM5DEjM i0ANVa8uQAWXyq71NV3aRFYsuDTL8+j2IGDZ/avF7nTaEWF3KVtA7bfYitk+oBPSUZ7H chcS3XZO42RYYOxpl88v6ljTB000jIiVBh0R5YnovHB72QS75mCVEMb+Hr4dWPYRwh3O o6BTw2XPIKHX1uvAGs/8UGCqtktz/IaGoaziNmO7oRdZPS4wIpUi9VbXlx3fv7iZJUyf 2loWyTwSQauhfFKJzJSyos2EfS7XCOpcD9ZC3yLQIlO30my2kssHKji7476ijIW0qNQA wfKg== X-Gm-Message-State: AOAM5321KBwBww/SdD/HB6RHQEXQJ48SPLf3z3BxBnLGs1p25kHF2aR6 8u3hHK6YsW1/p+2vMwGt7aQ= X-Google-Smtp-Source: ABdhPJydf2i98PwZj/Q55xvkS6r/N78cfxlfuHSz1WBDS2zOonM0t1L9R+OBsUxMuanr8p3nVkqOnw== X-Received: by 2002:a05:622a:89:: with SMTP id o9mr12011224qtw.339.1622407477499; Sun, 30 May 2021 13:44:37 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:3dc6:a286:1b00:8f0a]) by smtp.gmail.com with ESMTPSA id m14sm7192666qti.12.2021.05.30.13.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 13:44:36 -0700 (PDT) From: Fabio Estevam To: hverkuil-cisco@xs4all.nl Cc: lars@metafoo.de, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, tharvey@gateworks.com, frieder.schrempf@kontron.de, niklas.soderlund@ragnatech.se, Fabio Estevam Subject: [PATCH 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Date: Sun, 30 May 2021 17:44:08 -0300 Message-Id: <20210530204410.676831-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Introduce the 'reset-gpios' property to describe the GPIO that connects to the ADV7180 reset pin. Signed-off-by: Fabio Estevam --- Documentation/devicetree/bindings/media/i2c/adv7180.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml index bcfd93739b4f..1f1aa46f5724 100644 --- a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml +++ b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml @@ -35,6 +35,9 @@ properties: powerdown-gpios: maxItems: 1 + reset-gpios: + maxItems: 1 + port: $ref: /schemas/graph.yaml#/properties/port From patchwork Sun May 30 20:44:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12288441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F7BFC47092 for ; Sun, 30 May 2021 20:44:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D19B6120D for ; Sun, 30 May 2021 20:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbhE3UqV (ORCPT ); Sun, 30 May 2021 16:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbhE3UqT (ORCPT ); Sun, 30 May 2021 16:46:19 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B0AC061574; Sun, 30 May 2021 13:44:41 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id v8so9531414qkv.1; Sun, 30 May 2021 13:44:41 -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 :mime-version:content-transfer-encoding; bh=Qi3JBoSf3Tk8csxBRbacqjWH+rHIvvgIqkyXT5xbRxE=; b=kcbMbsWbjNZeEO9u1f9oPAMKyi/jwOvJPdY3+2td0LWGuredtKLlxiW1FAj4mDAnCI 1Qn6lBrnFTu0ECw4eh1rwwBth1DoYj/yA4yCxhhSoy2iLbdwm2N9qVBGHur9nrHcZcWo NjKZaC8WB/OALPH+7nzaFgBID43yw2/eG3cK9JGCe4YOblKJAlRYxybNNqnNqbQHddMW YBrM2iDKl9HCR7AgkgaL1XeFoauoPRxO+OQvcS0Gz16bEx5847RJ+PmHJRNkgDOFu3Oh oJci70GLDMizzk7VtUVTmJUo2HS/VCQL3v6JALdeKSAjYY2UNABwXRm7IDZxxFw/0hMG /CYw== 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:mime-version:content-transfer-encoding; bh=Qi3JBoSf3Tk8csxBRbacqjWH+rHIvvgIqkyXT5xbRxE=; b=LGLLano2PNrjNjW7WJHo3tl9TbRUMczf0Kd6JPLhd/Qyg82ExXhOmqCg2KVyLh+MFU ZIaLEZoV8wb07O2GDxkKtIkJ0/4FIPpstZ6zEMgvimEGQosOGABOj0qzntlh1eoaGUrV Dtam4xNqN+euPgLw3F9RfwO0DcLnPDg+mo2V8I1gUGiVLq7OW8PxArw087r4lGVyz1LR TPd80QRmWOVrRm/FrMOxPDNmoWAlZ+qmhNyjN7v9kEm3UhSsghnZJ1vLchrbYTAW2Gg3 ZHiFCwmZfTtW8pn0yVHyUMcnL0yTBHLdpAB+hHoaq959ywAVc8rCpsYRsjEwiZjs5nuW z53g== X-Gm-Message-State: AOAM532EDZkENaMghi0JtD3EG69t8Skxje408+YNRSRL0RZkC+heQYyG rmGqXmgU2sXSU5H8q5POOPiOtkYjrvY3bA== X-Google-Smtp-Source: ABdhPJzYzynUHw4wChRfN5l1k6bCpXUjHdE11ng/yYoh4iNyrSBZ7ECTNk45kM2FWp0ZMX8IPR7QOg== X-Received: by 2002:a37:4386:: with SMTP id q128mr13776817qka.76.1622407480453; Sun, 30 May 2021 13:44:40 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:3dc6:a286:1b00:8f0a]) by smtp.gmail.com with ESMTPSA id m14sm7192666qti.12.2021.05.30.13.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 13:44:40 -0700 (PDT) From: Fabio Estevam To: hverkuil-cisco@xs4all.nl Cc: lars@metafoo.de, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, tharvey@gateworks.com, frieder.schrempf@kontron.de, niklas.soderlund@ragnatech.se, Fabio Estevam Subject: [PATCH 2/3] media: i2c: adv7180: Allow the control of the reset pin Date: Sun, 30 May 2021 17:44:09 -0300 Message-Id: <20210530204410.676831-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210530204410.676831-1-festevam@gmail.com> References: <20210530204410.676831-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On a design where the ADV7180 pin is pulled down, it is not possible to make it functional unless the GPIO connected to this pin goes high. Add support for the reset GPIO by introducing an optional property called 'reset-gpios'. Note: the reset operation is still performed via software as recommended by the Analog Devices, but the reset GPIO still needs to go high to make the chip operational. Signed-off-by: Fabio Estevam --- drivers/media/i2c/adv7180.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 44bb6fe85644..2811f2c337fa 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -205,6 +205,7 @@ struct adv7180_state { struct mutex mutex; /* mutual excl. when accessing chip */ int irq; struct gpio_desc *pwdn_gpio; + struct gpio_desc *reset_gpio; v4l2_std_id curr_norm; bool powered; bool streaming; @@ -473,13 +474,15 @@ static int adv7180_g_frame_interval(struct v4l2_subdev *sd, static void adv7180_set_power_pin(struct adv7180_state *state, bool on) { - if (!state->pwdn_gpio) + if (!state->pwdn_gpio && !state->reset_gpio) return; if (on) { + gpiod_set_value_cansleep(state->reset_gpio, 0); gpiod_set_value_cansleep(state->pwdn_gpio, 0); usleep_range(5000, 10000); } else { + gpiod_set_value_cansleep(state->reset_gpio, 1); gpiod_set_value_cansleep(state->pwdn_gpio, 1); } } @@ -1338,6 +1341,15 @@ static int adv7180_probe(struct i2c_client *client, return ret; } + state->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(state->reset_gpio)) { + ret = PTR_ERR(state->reset_gpio); + v4l_err(client, "request for reset pin failed: %d\n", ret); + return ret; + } + + if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) { state->csi_client = i2c_new_dummy_device(client->adapter, ADV7180_DEFAULT_CSI_I2C_ADDR); From patchwork Sun May 30 20:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12288443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF149C47092 for ; Sun, 30 May 2021 20:44:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FC18600D3 for ; Sun, 30 May 2021 20:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhE3UqX (ORCPT ); Sun, 30 May 2021 16:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbhE3UqW (ORCPT ); Sun, 30 May 2021 16:46:22 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4326BC061574; Sun, 30 May 2021 13:44:44 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id o27so9500051qkj.9; Sun, 30 May 2021 13:44:44 -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 :mime-version:content-transfer-encoding; bh=RL6cDeAlG0LBZMl6xb0WVuFtskFVdK/P7eLeI1c+lN0=; b=g5//hAT9Bss8X1RCcPDH7nH9hCTSaqv2DK4vQrz8cGkLk7CiN0HLCFVnn3Uu37PwVW h9uvpndX4cGh6gpytAtnvJQGNdHLDbTtvRmQf+sIBorXXFgsQadpDYc3HBCzXHKejUlj rvpIrw4fQ0GMSh1U2/9xXYXxSIUdYONdPGjY2HEWJG7A3pZJvp5KY7spNLh7Nwd37LkD KDycQGDe/FFOeeFd03DXXYCF/z9jf8k9031tPL9yydQfmuDEMy2WCQ/UkYyzxy2cak5o wfvFPQQpgtnwjpwKsiRkAlw98DiqxWgrALxsEUzKtsOL3Iux6/IHezH14sNuybiinBuj yp2w== 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:mime-version:content-transfer-encoding; bh=RL6cDeAlG0LBZMl6xb0WVuFtskFVdK/P7eLeI1c+lN0=; b=pTZ2puxySqmiQHsVtKHadF7byt2ZbY+Jao66l/dvTpVt6LggLo/yTloDixldwefvdd J7P9RACDLrvYchdEu8lfnmjBXSe5j+CVcAZjaP1228T9samjDsQWF+IAgCLksukv7ub4 Tt2hMmpnamoKsZ75SzMK4jBUtmCmWVNlKGSEg/0xgDaDczZFXDQI+dnd6keRRLuYJBeO u1nSVXagwDWNmnvFnI8c499X2tYN05k39PaCytiAxRbtPI7++/A8fcre5ZNxacFetgdD m3WU3mECi0HyLm88HVztqTr/Cz666XaxI6iuj1CYKYLgczJB9FwY2QiIoPiLYXPyVqha bXrA== X-Gm-Message-State: AOAM531LPhikF+XZnQf9IOMtfBXHC1Qhchrr/vEsaLJ88NKR3JDeFYgg 2LC0LfbGwoIvKsVw/TlbKg0= X-Google-Smtp-Source: ABdhPJzUyKvLZ+PY0OMnWqctO3qvtMjyuCpz8On1AqREQYq7g99INlx7zjhuObPF/yCahpJKgnXR0Q== X-Received: by 2002:a37:a9d3:: with SMTP id s202mr13693405qke.246.1622407483400; Sun, 30 May 2021 13:44:43 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:3dc6:a286:1b00:8f0a]) by smtp.gmail.com with ESMTPSA id m14sm7192666qti.12.2021.05.30.13.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 13:44:42 -0700 (PDT) From: Fabio Estevam To: hverkuil-cisco@xs4all.nl Cc: lars@metafoo.de, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, tharvey@gateworks.com, frieder.schrempf@kontron.de, niklas.soderlund@ragnatech.se, Fabio Estevam Subject: [PATCH 3/3] media: i2c: adv7180: Print the chip ID on probe Date: Sun, 30 May 2021 17:44:10 -0300 Message-Id: <20210530204410.676831-3-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210530204410.676831-1-festevam@gmail.com> References: <20210530204410.676831-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Improve the probe message by printing the chip ID version. Signed-off-by: Fabio Estevam Reviewed-by: Frieder Schrempf --- drivers/media/i2c/adv7180.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 2811f2c337fa..e5ef99f0460c 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1404,11 +1404,19 @@ static int adv7180_probe(struct i2c_client *client, if (ret) goto err_free_irq; - v4l_info(client, "chip found @ 0x%02x (%s)\n", - client->addr, client->adapter->name); + mutex_lock(&state->mutex); + ret = adv7180_read(state, ADV7180_REG_IDENT); + mutex_unlock(&state->mutex); + if (ret < 0) + goto err_v4l2_async_unregister; + + v4l_info(client, "chip id 0x%x found @ 0x%02x (%s)\n", + ret, client->addr, client->adapter->name); return 0; +err_v4l2_async_unregister: + v4l2_async_unregister_subdev(sd); err_free_irq: if (state->irq > 0) free_irq(client->irq, state);