From patchwork Fri Feb 3 23:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13128517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A12EC05027 for ; Fri, 3 Feb 2023 23:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=B3kU75JR1cGHOKLY8ctfC0G2UuoTBRdBNyaWTiIgkOo=; b=u8FoTuLNdN/Jpn BJNSVqwE2WbWp4tA+R20WAsRNNOfnvO2hoChkauJ/9ErXpq6bHrjaOPpTWjSwro3pUfxOJMHTqKsZ 1M9EqLGX9EDzQ7tDkC5melT+zrmumDZLQFEX4Ld1vOvS/eIy2m/T1Jrtn5I6Y+QF/Xqfrn5Ou9rjj 5buCcE0tlzz0Df2AXlo3Smey60REcxC794wW5VRlmC+7hnXT3Za7BYWHY16Pfr9YNqKatosS8gkRL MRs6GJZbQivGsxMQZ21fvi1F/fGWRzfpXgXSMSOsgpKWnGx6r+oVRzQo3mlfGZ0VZopMb0I2b06jx BGcaX4hThX2pF0g/e24g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pO5Fn-0040zI-Si; Fri, 03 Feb 2023 23:14:00 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pO5Fj-0040xn-Iv for linux-arm-kernel@lists.infradead.org; Fri, 03 Feb 2023 23:13:57 +0000 Received: by mail-pg1-x533.google.com with SMTP id 7so4667078pgh.7 for ; Fri, 03 Feb 2023 15:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=KHbHNdg7pHAZm+iH1umTf2t8yLyMxQ4O1NYUoM8SKQ4=; b=GH1GgjQZNFEmvuBmSymoXZd3w+dMuweEQssS5Sv0HcRz1X3P4GV6YymXJheadYKSSB 5/bhs3nVBE7BnbD0iGQ9VX+MDfp1oLJldRwcISktoB9IJfM3Xf/dZk4nDLhFAtdLyjZ8 IEPYimOB9brCQJ5fclnP74q+AnER8hOsOHpSRa6D//iM9HA917XbAVXQc8qN0lhcyi2x +doKrQHfVAzgMmaEdbvZmHqQJO0cDBqI1fU+gpMAaanzseDHR2N//dl2A3+8P3PbZ1R+ +wOUgZENewKDlU21i0cubU7YKCCfgUJsp/rgH6mjHsgdu0d4qiz+8on6LHEj5zj2C54y USHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KHbHNdg7pHAZm+iH1umTf2t8yLyMxQ4O1NYUoM8SKQ4=; b=RVDBLdVh4ZZRYSiZsdBM3cK/tBCZu2EGOcAZztGpREuCFwKT0oG2X6MSU1F1qS8HR7 R0AUFb/pKrnGfKQtiep7cNYTz8IWT31xp8jjro5gcD9jAQsREFFsMqdMlPFzlH9o8pZ0 Ku8LjgOFkYiSQkQgm3scapEFFijW6c2HpLs04pxIaPAc/4Cfn8MmLUZaWgpshHRxY1X+ UsDNfQq2OsbedCHu2Dhp+sL5EzqsR0ag+HmeEbe7TkHaxbW0CU0r+PZU4fYrgezkVRdX 0jvoSDtCrbgqZDcNWZZiZx5ld9rMV3UMFqlB6xPuh6HUn2UUQLouxeY5TnVHJk5JJjGm tABA== X-Gm-Message-State: AO0yUKWxufhXcA+nQLMVuWX6/Mordcm38BsH6ZocfUxkXRq6Avd54z+S J5TrpjG+1CDFfmMRvGvBN1o= X-Google-Smtp-Source: AK7set/vkmoUxiQSouNiHnlki72tZjyhwr744ylOZKXLzwrJGtL6LgNiXFtHiBarLCY0WTauLkNiyQ== X-Received: by 2002:a05:6a00:330d:b0:587:8d47:acdd with SMTP id cq13-20020a056a00330d00b005878d47acddmr11019138pfb.34.1675466032436; Fri, 03 Feb 2023 15:13:52 -0800 (PST) Received: from google.com ([2620:15c:9d:2:6e90:bb76:2b36:4df2]) by smtp.gmail.com with ESMTPSA id m26-20020aa78a1a000000b0056b4c5dde61sm2441207pfa.98.2023.02.03.15.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 15:13:51 -0800 (PST) Date: Fri, 3 Feb 2023 15:13:48 -0800 From: Dmitry Torokhov To: Patrice Chotard , Mauro Carvalho Chehab Cc: Arnd Bergmann , Andy Shevchenko , Hans Verkuil , Liang He , Wan Jiabing , Hugues Fruchet , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: c8sectpfe: switch to using gpiod API Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230203_151355_659341_072BF4E8 X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This switches the driver from using legacy gpio API and to the newer gpiod API. Since ordinary gpiod APIs operate on logical and not electrical levels, handling of the reset GPIO is adjusted accordingly. Signed-off-by: Dmitry Torokhov Reviewed-by: Andy Shevchenko --- .../st/sti/c8sectpfe/c8sectpfe-core.c | 31 ++++++++----------- .../st/sti/c8sectpfe/c8sectpfe-core.h | 4 ++- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c index c38b62d4f1ae..dd8141e0828d 100644 --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -812,30 +814,23 @@ static int c8sectpfe_probe(struct platform_device *pdev) } of_node_put(i2c_bus); - tsin->rst_gpio = of_get_named_gpio(child, "reset-gpios", 0); - - ret = gpio_is_valid(tsin->rst_gpio); - if (!ret) { - dev_err(dev, - "reset gpio for tsin%d not valid (gpio=%d)\n", - tsin->tsin_id, tsin->rst_gpio); - ret = -EINVAL; - goto err_node_put; - } - - ret = devm_gpio_request_one(dev, tsin->rst_gpio, - GPIOF_OUT_INIT_LOW, "NIM reset"); + /* Acquire reset GPIO and activate it */ + tsin->rst_gpio = devm_fwnode_gpiod_get(dev, + of_fwnode_handle(child), + "reset", GPIOD_OUT_HIGH, + "NIM reset"); + ret = PTR_ERR_OR_ZERO(tsin->rst_gpio); if (ret && ret != -EBUSY) { - dev_err(dev, "Can't request tsin%d reset gpio\n" - , fei->channel_data[index]->tsin_id); + dev_err(dev, "Can't request tsin%d reset gpio\n", + fei->channel_data[index]->tsin_id); goto err_node_put; } if (!ret) { - /* toggle reset lines */ - gpio_direction_output(tsin->rst_gpio, 0); + /* wait for the chip to reset */ usleep_range(3500, 5000); - gpio_direction_output(tsin->rst_gpio, 1); + /* release the reset line */ + gpiod_set_value_cansleep(tsin->rst_gpio, 0); usleep_range(3000, 5000); } diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h index c9d6021904cd..bf377cc82225 100644 --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.h @@ -16,6 +16,8 @@ #define C8SECTPFE_MAX_TSIN_CHAN 8 +struct gpio_desc; + struct channel_info { int tsin_id; @@ -25,7 +27,7 @@ struct channel_info { int i2c; int dvb_card; - int rst_gpio; + struct gpio_desc *rst_gpio; struct i2c_adapter *i2c_adapter; struct i2c_adapter *tuner_i2c;