From patchwork Mon May 31 11:22:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 451648 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 2889DC47082 for ; Mon, 31 May 2021 11:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06C656135C for ; Mon, 31 May 2021 11:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhEaLYk (ORCPT ); Mon, 31 May 2021 07:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbhEaLYj (ORCPT ); Mon, 31 May 2021 07:24:39 -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 4D4DBC061574; Mon, 31 May 2021 04:22:59 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id c124so6091037qkd.8; Mon, 31 May 2021 04:22:59 -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=QdxY2TSl0gwzlhyshpBXtvrmDyNfej//+830SK0uF3E=; b=QB5MyuA0jJGqzpxu+ZEJsVG7xpKGL5beDN4U5l4eceeiKD+gJ6HZXrIbJOVXhmmotX DrhcxE2XWIaSnUV9o1UzuJpC/KzPfabOicscs59/h7W/Uemiei5L+/FcqVOLoOln6V7r NpFuGN+OQbziaUxKk4774vTVLAL/dV8BVHmx5j2lRok8kLYjYUC9gpDNkpEY9sck4Uox TLYpGhuIZDwrtRB+KDd2FkoV/pY4ooECedwGi+PdaGwEOrHuCfpUyUI3Sx/Wgq522hBF YQbjmrl1gqWXOYfaWQITmgKYQYMg9vXNZI8XdqdZKs4yXCT2NGKsP7mhG061R5cDfKpC E6wA== 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=QdxY2TSl0gwzlhyshpBXtvrmDyNfej//+830SK0uF3E=; b=CBIh5tzJI7D1I6KdqmniBTazm7wC1uZEUMHegXA63HiQ8FnAJkqfOctU7kyYiHbY6X wjmADBzvL5uW+zhUxSM44jZLCpXcNOGv8+AeShgTu2FiU5KmYbQlg7NTW3/efhtDc+Ii IrqrJB5BFhZwjL9VjbmWETum67wCpu6XV6GTe78elmIL04XT1x+6cXWUdzjcpwIWC63x mPDgypjdXIj9ebm81F8rM2mIKhAySxiB+lDi8UqB0DYrhHYasG4hyleWlJFlNUAIMIY5 7NyCn6QIXAHpdWZj86Xl/3AojoUkePYzyjmmsT5GOR5Hi2VV65+5nnT2+JEzM7sOZuqf mRzQ== X-Gm-Message-State: AOAM532Tqs+rs2z9MMJDsop2EVgOLVk72TBZQNdWDEretBIH0J8xYKYa J2+ylo+4kf/pYqKxK0c5n5zDpo6fZ8KRKQ== X-Google-Smtp-Source: ABdhPJxinxg32/xaSP8/JVn93NBl6Uh3GlIRFfwRr90KhHH2vm8S5vJ2gT/OLy5CkYUrNuaLfFGj7Q== X-Received: by 2002:ae9:f310:: with SMTP id p16mr15703396qkg.267.1622460178449; Mon, 31 May 2021 04:22:58 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:df45:f91c:ea2e:9334]) by smtp.gmail.com with ESMTPSA id h5sm9105480qkg.122.2021.05.31.04.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 04:22:58 -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 v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Date: Mon, 31 May 2021 08:22:35 -0300 Message-Id: <20210531112237.706063-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 --- Changes since v1: - None 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 Mon May 31 11:22:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 450637 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.7 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, URIBL_BLOCKED, 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 4136EC47082 for ; Mon, 31 May 2021 11:23:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2561B61090 for ; Mon, 31 May 2021 11:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231315AbhEaLYn (ORCPT ); Mon, 31 May 2021 07:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbhEaLYl (ORCPT ); Mon, 31 May 2021 07:24:41 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC32C061574; Mon, 31 May 2021 04:23:02 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id h21so7678310qtu.5; Mon, 31 May 2021 04:23:02 -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=xrfxJ0vUNlyHJx75Ay206N50rBJDEg6+qdqzHboImHE=; b=fZMt9EaARWg7ten4vYUQJP4EW1nnBbv3E0tEwalPotIUJfbWZ0EYgj8Tku50Jk835s 3t/va79wqBMrClGS/K8h0dqfm+FgbrCTNDDNbvd2lU5AOhnpIuPjmX8XevWntVWmfY2r khcDxYZ8H000+yfAsreDkTUhUN3BVQgCBPvwLHH5UcKufxcpF+X+DAX621/+LsgMY9IM 2gbwfk/irgxEgqLz8ixIlclzhG4/b8ERfOBT5O67W+uNXskczV4mDbPdk6WY21ktBCVF mVNHOrHlIIB0hhD8rSHRDZpwum/uOjWR6wqMf4r+ew1wWVr0B6JeGt2UjWw4osGzwr+R IaTg== 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=xrfxJ0vUNlyHJx75Ay206N50rBJDEg6+qdqzHboImHE=; b=fWbb+Ghyk0MA1CquQpVWqGm0AXTKdsyIgY8u0nq9bgq9X11qsJzPMI9cf0l8wddICs mKaoODoY7SRHzxEIGmoHaQpSOXqJ0vGkAW7498VIfr/I1UxHFuLsCosfCZARsBEPRKiz 9THzPudFNP49NUuPl/7gW/G/BSu8upGtrK2LZZsXG0kcsRSWqc+tmOMBbwLmMi6ikoNe Nq0Ub/PAP2/hfpV6SqUI8JTFnfV3M122nz2Zr9By+fpdLRj6w13NAHjYhC0wTw5A/T1h o183MBo7uLXAOOoin7MWWTgmmboBtN1GfYEgJ9MOXsPc7FLT5mX6LkRK1taN9iZ7juRv whgQ== X-Gm-Message-State: AOAM530FHYDkuBoXE03tqGQEurPT2UIx6rZeslON3dsRBOuDiw4vP/Wq s/qrjecXZbxfxt9ocD4ekr8= X-Google-Smtp-Source: ABdhPJwre6+S9/iuADIyu3vZjblwYPYFlJIGUEQpe6jpyuLVb63qfp2WrWrOfQPTJgcVRwgY7MbLQQ== X-Received: by 2002:ac8:1188:: with SMTP id d8mr14180945qtj.218.1622460181439; Mon, 31 May 2021 04:23:01 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:df45:f91c:ea2e:9334]) by smtp.gmail.com with ESMTPSA id h5sm9105480qkg.122.2021.05.31.04.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 04:23:01 -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 v2 2/3] media: adv7180: Add optional reset GPIO Date: Mon, 31 May 2021 08:22:36 -0300 Message-Id: <20210531112237.706063-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210531112237.706063-1-festevam@gmail.com> References: <20210531112237.706063-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Frieder Schrempf There is a reset input that can be controlled by GPIO. Let's add it to let the driver control it if required. Signed-off-by: Frieder Schrempf Signed-off-by: Fabio Estevam --- Changes since v1: - Used Frieder's version of the patch. drivers/media/i2c/adv7180.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 44bb6fe85644..2890041cc231 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 *rst_gpio; v4l2_std_id curr_norm; bool powered; bool streaming; @@ -484,6 +485,19 @@ static void adv7180_set_power_pin(struct adv7180_state *state, bool on) } } +static void adv7180_set_reset_pin(struct adv7180_state *state, bool on) +{ + if (!state->rst_gpio) + return; + + if (on) { + gpiod_set_value_cansleep(state->rst_gpio, 1); + } else { + gpiod_set_value_cansleep(state->rst_gpio, 0); + usleep_range(5000, 10000); + } +} + static int adv7180_set_power(struct adv7180_state *state, bool on) { u8 val; @@ -1263,6 +1277,7 @@ static int init_device(struct adv7180_state *state) mutex_lock(&state->mutex); adv7180_set_power_pin(state, true); + adv7180_set_reset_pin(state, false); adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES); usleep_range(5000, 10000); @@ -1338,6 +1353,14 @@ static int adv7180_probe(struct i2c_client *client, return ret; } + state->rst_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(state->rst_gpio)) { + ret = PTR_ERR(state->rst_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); @@ -1428,6 +1451,7 @@ static int adv7180_remove(struct i2c_client *client) i2c_unregister_device(state->vpp_client); i2c_unregister_device(state->csi_client); + adv7180_set_reset_pin(state, true); adv7180_set_power_pin(state, false); mutex_destroy(&state->mutex); From patchwork Mon May 31 11:22:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 451647 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.7 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, URIBL_BLOCKED, 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 EFABAC47082 for ; Mon, 31 May 2021 11:23:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C875661090 for ; Mon, 31 May 2021 11:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhEaLYr (ORCPT ); Mon, 31 May 2021 07:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbhEaLYo (ORCPT ); Mon, 31 May 2021 07:24:44 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33CC6C06174A; Mon, 31 May 2021 04:23:05 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id c10so7654871qtx.10; Mon, 31 May 2021 04:23:05 -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=Mt7POv9PaCwKFvdwIODXsLJlyClKZZS8dpjMNwC08Rk=; b=FpkAUxBHyO6WxH6MjvrfYwHqOShz/gWIonA+Zb6HgAqE7r/GxLuo7uPfudu/hlT4Cz EvoMTXEi8geOdv0lx/bn7vQDJIXeSoBupCGmZZfQ1sCCzNIMy/+0X7zU2kt+KNqGIhp3 MhVs2rNyUU5oP+zHJG6kfWdlOMrj/HN83OAK3AKPzG25FDxOF4TkZitdjQ+UVjXVxpTi 5KKji0u8fvXeyel7lUPyDgyCvXztM0CfChX2TKFs8zLMM4lhB2C6wnkICSmNRZYtpZjA F0/RajNllgXEK6ftJ4FaprWp+O8at6YCo46gLDFWaUZPbGIzSUnMTNCqJrifVIWyfyN1 qB2g== 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=Mt7POv9PaCwKFvdwIODXsLJlyClKZZS8dpjMNwC08Rk=; b=RQCwh0SDrwNJQ5HzMLuB/He2QnXNk5MtKtoFjY5cWZOCGOBnCw/6fjgl3j0mCOrogc R1rcjqxrFRGxlfn7d+MeCZbrpUFr+mFiJA7bnhBYokZ0WTa4RgskgXxJu9+hWZWF+vpz fsbYctFWnQ7Kjdfc/FCNgfjhVcL151OEM/pIThDvBMpsmTmOAOPLyghLVjlELdVObaX1 nQ1kRyv0vb3dQNhrBphZ6BNdyX4Jxl/374uXnDn5yFrzfsai0vHWCR08pjo11mNrpnmF TWZUMbqBJpJKzpVa14yFy1JsHf1Uzm2yU8G9mVS1OePRcWAaLVTF3xh5uBihplm3aigT UrSQ== X-Gm-Message-State: AOAM533vEJ+YVAs9RO6wqNkKvdulKFiu5m79Ho4no3cOX3JZ1lXUeo+Z xJL+/0Lc2AhKnCjnbJaAXBY= X-Google-Smtp-Source: ABdhPJxzSZAUeVtEqtOK6G/lO950T7d9LNRDEcB1h+2IPLpRndsKnrbArB4s83shNBHe9LfY3fRZOw== X-Received: by 2002:ac8:51c4:: with SMTP id d4mr14458594qtn.186.1622460184409; Mon, 31 May 2021 04:23:04 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:df45:f91c:ea2e:9334]) by smtp.gmail.com with ESMTPSA id h5sm9105480qkg.122.2021.05.31.04.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 04:23:04 -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 v2 3/3] media: i2c: adv7180: Print the chip ID on probe Date: Mon, 31 May 2021 08:22:37 -0300 Message-Id: <20210531112237.706063-3-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210531112237.706063-1-festevam@gmail.com> References: <20210531112237.706063-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 --- Changes since v1: - Added Frieder's Reviewed-by tag. 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 2890041cc231..4f99b46e7eaa 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1415,11 +1415,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);