From patchwork Tue Sep 13 16:41:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12974983 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 6FFE3C54EE9 for ; Tue, 13 Sep 2022 16:46:31 +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:Date:Subject:Cc :To:From: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=PeBflY0urff+O+MOx9WaQU2uXWMEGnUihs3F4TXaNmE=; b=sk4HVGz5VkoRee d3eU1ARR6GyzwJ/XmKXxOrLSVFAlFCKPkUGJVCcpTmZXn4Pl6Am0fVEI4xIXuRcjdO4i7z5eXuTph c0PJKJ8ds9FJwJQG26WIHMM0C4mA7hpQCqRkLrxq1TCoPghoDiM2ZljQ49TAAmZhh6AEeYJF/xWEj dUB90T3WdhPWSoJ61surnYUuCYVjBlyomBqZi2qtt/xLgtl+rdfRBKsCD9ODzmP1Li0ECLT6+nkR1 qwB6+og3q0Q51++M5pdFQLlnwv9QhxLi4J67DXa33sX7nKx5t3n+XLGzGUlf8I/98wUP+7kpQ90J0 VNyX/DFoWZLIzxfA794Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY91w-00DWf6-Qq; Tue, 13 Sep 2022 16:45:01 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY8yF-00DU2Q-8b for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2022 16:41:12 +0000 Received: by mail-pj1-x102d.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so16182335pjq.3 for ; Tue, 13 Sep 2022 09:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=A2Rj9sS1Fjs/+fiIRS4OKQZgMWnN/d2vmPGQj8QoUOc=; b=JoxbvLwkdMyeGanYCTnaRBN2DRM/rPM8P6QeFl2hBucjmx5QFD+IBAOb5AlnDmCVWZ 2mrTN3uilrdOUaEUHxWOxkPLJD32AGcC8WTtVbxtbbB/JgwczNJoF6JohCYAq+Qog00B UKl9dy+sY/mAhgB+CG0h/G1dpMLKvVKfMTvNKWm9LpWjz+bGce/Wf1SShTCo8vXAg8iJ 5yl8Jxe02gHo5XL8P5fP2fFXgKvsQWAZ6KhIxUFrjozvb+TWWrnfTNH9YljiEnhpip8u EoEMc83Zeu9CKRPTG5X6Ll0dCKlH9HGrUxV9y1/krNA11TARNDE39MHs9sPiNXOM9TBv EJUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=A2Rj9sS1Fjs/+fiIRS4OKQZgMWnN/d2vmPGQj8QoUOc=; b=qTpKbLg1/juoLA50NkOt0V+FicxkPsCh5esOrL1sfv0N6ZNrB13/NvS2kaxe8gi7x2 tECNKoi3fSBJQbYou+mWO6lzzjqTqzfDjDA/Shf8xpxGelfMbp6AmiComIJEqHB6+2zd xBJ40Vq+JvqfW6yB6SJK/7U5/AAmNJ+7PemYjDuVsMWIzioHiL05LoS9x2dHFrXc+JKG 44OUIvO3PjAhDMMJfjqoZQE3iU8ZLWrlaffgN2EK6hySci1z+iq81A5VwKHKVYA5rm8h kC6Zax7CWEUUgRRVVebmH0mniQ9QXvAfvWNCwcQbVWf68GYhGNgvrlCbonO7eGK4Ndtg z4qg== X-Gm-Message-State: ACgBeo1UYQV6annlC/AdYYKPc+D0MS4WFVO4wJ69mdrDrVG3vd/EE032 Z0hgXc+22pEhJrjQXdHOGzA= X-Google-Smtp-Source: AA6agR5F+IVKnrECVDn3p+yIBcUysGjy3zydDPF8816rl1m7DIno6uJ83cFOyLfmocT/NP3Gff/JGA== X-Received: by 2002:a17:902:8d8a:b0:16f:21fb:b97a with SMTP id v10-20020a1709028d8a00b0016f21fbb97amr32266273plo.160.1663087268831; Tue, 13 Sep 2022 09:41:08 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:b126:15e1:55ae:d9eb]) by smtp.gmail.com with ESMTPSA id g3-20020aa79f03000000b005465ffaa89dsm1798449pfr.184.2022.09.13.09.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 09:41:08 -0700 (PDT) From: Dmitry Torokhov To: Mauro Carvalho Chehab , Alim Akhtar , Krzysztof Kozlowski , Linus Walleij Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ARM: dts: exynos: correct s5k6a3 reset polarity on Midas family Date: Tue, 13 Sep 2022 09:41:03 -0700 Message-Id: <20220913164104.203957-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_094111_493691_72A528F7 X-CRM114-Status: GOOD ( 15.64 ) 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 According to s5k6a3 driver code, the reset line for the chip appears to be active low. This also matches the typical polarity of reset lines in general. Let's fix it up as having correct polarity in DTS is important when the driver will be switched over to gpiod API. Fixes: b4fec64758ab ("ARM: dts: Add camera device nodes for Exynos4412 TRATS2 board") Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- arch/arm/boot/dts/exynos4412-midas.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/exynos4412-midas.dtsi b/arch/arm/boot/dts/exynos4412-midas.dtsi index b967397a46c5..8e1c19a8ad06 100644 --- a/arch/arm/boot/dts/exynos4412-midas.dtsi +++ b/arch/arm/boot/dts/exynos4412-midas.dtsi @@ -586,7 +586,7 @@ image-sensor@10 { clocks = <&camera 1>; clock-names = "extclk"; samsung,camclk-out = <1>; - gpios = <&gpm1 6 GPIO_ACTIVE_HIGH>; + gpios = <&gpm1 6 GPIO_ACTIVE_LOW>; port { is_s5k6a3_ep: endpoint { From patchwork Tue Sep 13 16:41:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12974984 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 93D6AC54EE9 for ; Tue, 13 Sep 2022 16:47:12 +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:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YJus5r1P5OxlcS6LgHIBBLkO+jRs1iNEMvJsieP6Buc=; b=KmR1OxlD4BaL48 iDRy9wyWvB9a6OJJuYq8XPf43xXZY4Y6lFHOjCHFNjeanWcJFrCWFK3KbffJYvUsi77cmkrNJl0mc 1f05+Q7BQNtRYvd+PmjF1sCvh7Gpmt4K8BDhekE50KSU0hkhcelEK42HzUF2GKAcRiA6joXz1KbqX LDkFZO7R9upoJX6AVpzEd9CbJ24RTqBrINZtZ5EuZjnqheDON6liO7+PhVhju4+AZul/lA4Q0zq/x Gfir5Ew52aA+yQAjTbalk2pu3CFGLFd7ok5hgkKU7kx43JOsXEaeNevvyEQmD8qfoSHynWkaxOPOf 6mcLCyDYBgSiiAZGTyQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY92X-00DX3V-Ug; Tue, 13 Sep 2022 16:45:38 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oY8yF-00DU3i-St for linux-arm-kernel@lists.infradead.org; Tue, 13 Sep 2022 16:41:13 +0000 Received: by mail-pf1-x42e.google.com with SMTP id c198so12281155pfc.13 for ; Tue, 13 Sep 2022 09:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=flmsIEbMJVaOU2duL6ZI4DormffxlXc3pT4gpX1YVyY=; b=oJJympb8sMAda6Xe65RluPDRWqjg1x6o7LcFrt9uHz2+NW1k1V7RYr9YoGKRBv/wSu ++W8Jl1WsbjgihEENvCBk9QIYRkkw7h0HXk+9+1gNzwpQG9BkcIcnPVMGlNCkG8UdJ9X 5O36eSqVORvrezGRv4/Y0AzpPIrHU52FgALIqjzPZ7K67QHalZmod9pUv2PTxuTOD1yQ aMmRNoHjp5CP9sukegIrzpZ7r3hjQz8NWyVafL6+QimJNU35XMT/XR1FCi6XA1uDOn72 bowo1DfGyVp10HIpqeit4l0X5Hf2KfsAmmc5eCVPMx7EHH8G2/1r1K57uBj91ubRgDbK zb2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=flmsIEbMJVaOU2duL6ZI4DormffxlXc3pT4gpX1YVyY=; b=L8x7RSJfGT61NfqgkA9Ujp3nl5hhoug7KAANF3U/6mfzdpsHUqS14VMJ/rSVZfUqMV 51oLOStaEVL+tM3SDFlxSz6SVRfUj2QbPMY3M3p5Ti5Du0BRUaoikIWL3wV7Ike0+AvB seYtrzwYn62JyEhxri7+dlBEeLVbU1PAIdBucsMfscHCGqwAN4SnoQ2Fyy2bCs1AyyvA 7a7HTzKgoGumPFkMskmwShQPTK4CR/kvD7dISsB15aQ3F2tRXlu84eCocsihGDRDE2TB Jllgu1W73Tyy0TCzGNXGfaScOZjH+BIaNiOY1xozp8k6aUGAxSOFOvWu57+xmvmxvKQq BIiw== X-Gm-Message-State: ACgBeo1C9UJCttlh/6sQwSWbEZMub9Gvkerp+ao0Oc6vavep9w07Loeh 4m2/XYOEWes6lyhJKtgZVZ0= X-Google-Smtp-Source: AA6agR7dbwTHN0hiiTca6RAq94QQYffu8spociGapyfiLX7vgcK24At969jRtTFzo15NXaz20VfOOA== X-Received: by 2002:a63:2c4c:0:b0:434:e001:89fd with SMTP id s73-20020a632c4c000000b00434e00189fdmr28188426pgs.444.1663087270291; Tue, 13 Sep 2022 09:41:10 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:b126:15e1:55ae:d9eb]) by smtp.gmail.com with ESMTPSA id g3-20020aa79f03000000b005465ffaa89dsm1798449pfr.184.2022.09.13.09.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 09:41:09 -0700 (PDT) From: Dmitry Torokhov To: Mauro Carvalho Chehab , Alim Akhtar , Krzysztof Kozlowski , Linus Walleij Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] media: i2c: s5k6a3: switch to using gpiod API Date: Tue, 13 Sep 2022 09:41:04 -0700 Message-Id: <20220913164104.203957-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220913164104.203957-1-dmitry.torokhov@gmail.com> References: <20220913164104.203957-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_094111_978868_737EC948 X-CRM114-Status: GOOD ( 17.87 ) 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 patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes one of the last uses of of_get_gpio_flags(). Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij Tested-by: Marek Szyprowski --- drivers/media/i2c/s5k6a3.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index a4efd6d10b43..ef6673b10580 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -9,12 +9,12 @@ #include #include #include +#include #include -#include +#include #include #include #include -#include #include #include #include @@ -59,7 +59,7 @@ struct s5k6a3 { struct v4l2_subdev subdev; struct media_pad pad; struct regulator_bulk_data supplies[S5K6A3_NUM_SUPPLIES]; - int gpio_reset; + struct gpio_desc *gpio_reset; struct mutex lock; struct v4l2_mbus_framefmt format; struct clk *clock; @@ -216,11 +216,11 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor) goto error_clk; } - gpio_set_value(sensor->gpio_reset, 1); + gpiod_set_value_cansleep(sensor->gpio_reset, 0); usleep_range(600, 800); - gpio_set_value(sensor->gpio_reset, 0); + gpiod_set_value_cansleep(sensor->gpio_reset, 1); usleep_range(600, 800); - gpio_set_value(sensor->gpio_reset, 1); + gpiod_set_value_cansleep(sensor->gpio_reset, 0); /* Delay needed for the sensor initialization */ msleep(20); @@ -240,7 +240,7 @@ static int __s5k6a3_power_off(struct s5k6a3 *sensor) { int i; - gpio_set_value(sensor->gpio_reset, 0); + gpiod_set_value_cansleep(sensor->gpio_reset, 1); for (i = S5K6A3_NUM_SUPPLIES - 1; i >= 0; i--) regulator_disable(sensor->supplies[i].consumer); @@ -285,32 +285,24 @@ static int s5k6a3_probe(struct i2c_client *client) struct device *dev = &client->dev; struct s5k6a3 *sensor; struct v4l2_subdev *sd; - int gpio, i, ret; + int i, ret; sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); if (!sensor) return -ENOMEM; mutex_init(&sensor->lock); - sensor->gpio_reset = -EINVAL; - sensor->clock = ERR_PTR(-EINVAL); sensor->dev = dev; sensor->clock = devm_clk_get(sensor->dev, S5K6A3_CLK_NAME); if (IS_ERR(sensor->clock)) return PTR_ERR(sensor->clock); - gpio = of_get_gpio_flags(dev->of_node, 0, NULL); - if (!gpio_is_valid(gpio)) - return gpio; - - ret = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_LOW, - S5K6A3_DRV_NAME); - if (ret < 0) + sensor->gpio_reset = devm_gpiod_get(dev, NULL, GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(sensor->gpio_reset); + if (ret) return ret; - sensor->gpio_reset = gpio; - if (of_property_read_u32(dev->of_node, "clock-frequency", &sensor->clock_frequency)) { sensor->clock_frequency = S5K6A3_DEFAULT_CLK_FREQ;