Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2232308rdb; Wed, 21 Feb 2024 00:47:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9niKqYuxQygz9FGVVP1s3yxAYFWqQ3tX6HCDStPmgMUvZsh3g9RuAdmbnFm+Xn6RfH1uMPvv37cRUGUU2OzbFlXtMjKyPdQFsD4MaJA== X-Google-Smtp-Source: AGHT+IEAZs8/q0ypk1Pbc521oe5dNtG8zq611BwdgEcjxZObWXGrOkY4Aaldvx+6YW527GtUZCgS X-Received: by 2002:a17:90b:8a:b0:299:5d8a:434b with SMTP id bb10-20020a17090b008a00b002995d8a434bmr8756653pjb.40.1708505251510; Wed, 21 Feb 2024 00:47:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708505251; cv=pass; d=google.com; s=arc-20160816; b=T79Td/ALNgiM2AocBb7GDAqbJvw4RGT91N4FjB0RuOS63CgpSHZg3lzhl5x6qQjxNd dIeZ7nZoqIR79wxbfv1nzUC74mY84XRuIgc3QADpq8x4g5A0kOoylDX2Z2UfmwCWKuPm FKduMOohu1lSbtaFk9lvJINh94eEW2HSPN7aNlsbTO9IYtTNJX5MpmXBjYeYigp9jhqX TWnGyjPuuU36aUYVDVo845GoSYwHj19c3dsu/cLQjuifjSZSeMqV9Ieq9JarQZ3KmNtO iZ3nxcPyOa9kT2zlU2VAuZbOzxpE+tyt/YarPwRgO8DWjyfuLPyvr/SkNFnBK1zymI8C wStA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z3Daaw0Dcf2nABbvAMRYqMKPzsgnTCV1QI7V7j1/eIM=; fh=eKMfTwfqFcpmv973+nSgfl4GG/uuCkjIC73bT2f5Dv4=; b=j/4Qfq97wcqT1skOe79tHTBBOaQhvORx8ls2JA3o/pjHr0pRpPP2hMinmwGpsoc4mz PrAZBv95VGEAbbzpFik/VsDGsGmwYv7j3Wj0dZwfD+e8hTWKOrcb3+xvHsQhnGNXo++y 837Ezf3+fouAu85Aw4VvfxdxvLnpWPAKIY6EIEE/tMPHI9JFwUjNpFPcnnWE010TvtUM nIBeIp2YDqWfoF/FD2jeM7hSoDIjMQ8WhGEzd9w8P4giveFZFvRfM24KJft2zVvNjhms E+vHyDPDywo+OZEDmeG4mp/3vsPYSJ7n7s5wAI0sHVPyhByf3LHPisQ8hXURkQU5xgUE 7GIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IN4Evyml; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id nv11-20020a17090b1b4b00b002995be1ac13si1103483pjb.97.2024.02.21.00.47.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:47:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IN4Evyml; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-74252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 82884B238EF for ; Wed, 21 Feb 2024 07:43:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3FD43B1A4; Wed, 21 Feb 2024 07:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IN4Evyml" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C12383A27B; Wed, 21 Feb 2024 07:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708501425; cv=none; b=LSYxKp+X2Aln7+y2tAuD5U846/dZYs2GgYA0juSnbRGtk70QKewQaQtYHDq2qInJ1/vBFd1Fpf7oHjGsRnD4xdfqixIdNbz5rHDdOroGL5E5bsS1i0VGoeIEMO40Sust9ZDPsT0b0uEmd3P7liznbzd1xPEl9G2gzuPRqkqGoXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708501425; c=relaxed/simple; bh=ltTht77zSLOZYTaO34bNZ2vXR72J5XsBwuQr3EcrxMc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ggRw21H5DaIsYUuwptXtx2/1nzbu2pkYObOETXm7dZfHavwk2ubCtbm2GJ3DkFmiRDic0ElzuDZZ1WMojNnHD47rPiA4vIzT7oDNlxBjj4KXqBA5oyjC6k1dMZyOTXgLiIcTjt8ZtxN1BUiiK2K88Ap1BQhmQf1ZyAHg0IkPEDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IN4Evyml; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708501424; x=1740037424; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=ltTht77zSLOZYTaO34bNZ2vXR72J5XsBwuQr3EcrxMc=; b=IN4EvymlP0JQktO7IAo5rzmlKPFPRmf6miSjyG0RhqiRAnajMwRBy8te gRBSnSTROSNu7S5rpQXTP08NeCZEUs5jBGg3M4lOlq5Rx3SJBOwtmSEp7 yQEoTu1CU7qZFSiK64Yn5/TcfsZj2eT2xombxbSo/ss2S0gS0kJSpJ3rf aR7J2hXs3XNHvfETiunp4vTPUty9jGXy2nsB6tGijqVFmhm/4CHQuyhTm KwitqLmc+kPXJTnLYQQ6mzoRnbXLtSB3Qu4u0jEsfKKtGeY2/q8f7klED Lblp1iRuU6ql/RAubWgeFVFeC2uqWGGHBO3DNNDo53FF7EWVAdmtD12qL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="13267305" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="13267305" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 23:43:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="827300778" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="827300778" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 23:43:34 -0800 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id B6E6511F855; Wed, 21 Feb 2024 09:43:31 +0200 (EET) Date: Wed, 21 Feb 2024 07:43:31 +0000 From: "sakari.ailus@linux.intel.com" To: Zhi Mao =?utf-8?B?KOavm+aZuik=?= Cc: "heiko@sntech.de" , "linux-mediatek@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "yunkec@chromium.org" , "robh+dt@kernel.org" , "dan.scally@ideasonboard.com" , Shengnan Wang =?utf-8?B?KOeOi+Wco+eUtyk=?= , "hdegoede@redhat.com" , "linux-media@vger.kernel.org" , "gerald.loacker@wolfvision.net" , "linus.walleij@linaro.org" , "andy.shevchenko@gmail.com" , Yaya Chang =?utf-8?B?KOW8tembhea4hSk=?= , "jacopo.mondi@ideasonboard.com" , "mchehab@kernel.org" , "jernej.skrabec@gmail.com" , Project_Global_Chrome_Upstream_Group , "tomi.valkeinen@ideasonboard.com" , "10572168@qq.com" <10572168@qq.com>, "hverkuil-cisco@xs4all.nl" , "bingbu.cao@intel.com" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "matthias.bgg@gmail.com" , "laurent.pinchart@ideasonboard.com" , "linux-arm-kernel@lists.infradead.org" , "angelogioacchino.delregno@collabora.com" , "devicetree@vger.kernel.org" , "macromorgan@hotmail.com" Subject: Re: [PATCH v4 2/2] media: i2c: Add GC08A3 image sensor driver Message-ID: References: <20240204061538.2105-1-zhi.mao@mediatek.com> <20240204061538.2105-3-zhi.mao@mediatek.com> <20240206184542.GE2827@pendragon.ideasonboard.com> <598f62bbb55157eec1e23dd1dbc307fea3851b21.camel@mediatek.com> <20240220030104.GF20376@pendragon.ideasonboard.com> <115698c0c549e747026cc8841a3bd571533f8e6f.camel@mediatek.com> <063fa9763efb1570295cfef385829714dd5e42cf.camel@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <063fa9763efb1570295cfef385829714dd5e42cf.camel@mediatek.com> Hi Zhi, On Wed, Feb 21, 2024 at 02:37:27AM +0000, Zhi Mao (毛智) wrote: > Hi Laurent & sakari, > > Thanks for your feedback. > > On Tue, 2024-02-20 at 07:25 +0000, sakari.ailus@linux.intel.com wrote: > > > > External email : Please do not click links or open attachments until > > you have verified the sender or the content. > > Hi Zhi, > > > > On Tue, Feb 20, 2024 at 05:45:54AM +0000, Zhi Mao (毛智) wrote: > > > Hi Laurent, > > > > > > Thanks for you reply. > > > I'd like to ask for advice about how to contrl "reset-pin", please > > > check the below comments. > > > > > > On Tue, 2024-02-20 at 05:01 +0200, Laurent Pinchart wrote: > > > > > > > > External email : Please do not click links or open attachments > > until > > > > you have verified the sender or the content. > > > > Hi Zhi, > > > > > > > > On Tue, Feb 20, 2024 at 02:12:26AM +0000, Zhi Mao (毛智) wrote: > > > > > On Tue, 2024-02-06 at 20:45 +0200, Laurent Pinchart wrote: > > > > > > On Sun, Feb 04, 2024 at 02:15:38PM +0800, Zhi Mao wrote: > > > > > > > Add a V4L2 sub-device driver for Galaxycore GC08A3 image > > > > sensor. > > > > > > > > > > > > > > Signed-off-by: Zhi Mao > > > > > > > --- > > > > > > > drivers/media/i2c/Kconfig | 10 + > > > > > > > drivers/media/i2c/Makefile | 1 + > > > > > > > drivers/media/i2c/gc08a3.c | 1448 > > > > ++++++++++++++++++++++++++++++++++++ > > > > > > > 3 files changed, 1459 insertions(+) > > > > > > > create mode 100644 drivers/media/i2c/gc08a3.c > > > > > > > > [snip] > > > > > > > > > > > diff --git a/drivers/media/i2c/gc08a3.c > > > > b/drivers/media/i2c/gc08a3.c > > > > > > > new file mode 100644 > > > > > > > index 000000000000..3fc7fffb815c > > > > > > > --- /dev/null > > > > > > > +++ b/drivers/media/i2c/gc08a3.c > > > > > > > @@ -0,0 +1,1448 @@ > > > > > > > > [snip] > > > > > > > > > > > +static int gc08a3_power_on(struct device *dev) > > > > > > > +{ > > > > > > > +struct i2c_client *client = to_i2c_client(dev); > > > > > > > +struct v4l2_subdev *sd = i2c_get_clientdata(client); > > > > > > > +struct gc08a3 *gc08a3 = to_gc08a3(sd); > > > > > > > +int ret; > > > > > > > + > > > > > > > +ret = > > regulator_bulk_enable(ARRAY_SIZE(gc08a3_supply_name), > > > > > > > + gc08a3->supplies); > > > > > > > +if (ret < 0) { > > > > > > > +dev_err(gc08a3->dev, "failed to enable regulators: %d\n", > > > > ret); > > > > > > > +return ret; > > > > > > > +} > > > > > > > + > > > > > > > +ret = clk_prepare_enable(gc08a3->xclk); > > > > > > > +if (ret < 0) { > > > > > > > +regulator_bulk_disable(ARRAY_SIZE(gc08a3_supply_name), > > > > > > > + gc08a3->supplies); > > > > > > > +dev_err(gc08a3->dev, "clk prepare enable failed\n"); > > > > > > > +return ret; > > > > > > > +} > > > > > > > + > > > > > > > +usleep_range(GC08A3_MIN_SLEEP_US, GC08A3_MAX_SLEEP_US); > > > > > > > + > > > > > > > +gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); > > > > > > > > > > > > Are you asserting reset when powering on ? That sounds wrong, > > you > > > > should > > > > > > de-assert reset here (and acquire the reset gpio in probe() > > with > > > > > > GPIOD_OUT_HIGH). Drivers should use logical levels for GPIOs, > > > > setting a > > > > > > GPIO named "reset" to 1 should assert the reset signal, even > > if > > > > the > > > > > > physical signal is active low. You may have the wrong > > polarity in > > > > the > > > > > > device tree. > > > > > > > > > > According to the sensor power sequence sepc, "reset" pin should > > be > > > > pull > > > > > from low to high after "dovdd/dvdd/avdd" power on, so I follow > > this > > > > > power sequece to pull "reset" pin high in software flow. > > > > > > > > From a hardware point of view that's right, but the Linux kernel > > > > handles > > > > logical level of GPIOs. If a GPIO is named "reset", it is > > expected > > > > that > > > > calling > > > > > > > > gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); > > > > > > > > will "assert" the reset signal, setting it to a logical "reset = > > > > true" > > > > level. This maps to the hardware 0V output level, as the signal > > is > > > > active-low. To achieve this, define the reset GPIO as active low > > in > > > > DT, > > > > and the GPIO framework will invert the signal for you. You should > > > > then > > > > call > > > > > > > > gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); > > > > > > > > in the driver when you want to assert reset (set it to 0V), and > > > > > > > > gpiod_set_value_cansleep(gc08a3->reset_gpio, 0); > > > > > > > > when you want to deassert it (set it to 3.3V, or whatever the I/O > > > > voltage for the signal is). > > > > > > > > This way all driver use logical states, and the inversion is > > handled > > > > in > > > > DT. > > > > > > > > > > Sensor power sequence as below: > > > ------------------ > > > | | | > > > | | | > > > dvdd/avdd/dovdd -------- > > > --------- > > > | > > > | > > > reset-pin ------------- > > > > > > In order to match this power sequece, "reset-pin" contrl flow is > > below: > > > 1. config the "reset-pin" is "active-high" in DTS: > > > reset-gpios = <&pio 19 GPIO_ACTIVE_HIGH>; > > > > > > 2. image sensor driver probe function: > > > gc08a3->reset_gpio = devm_gpiod_get(dev, "reset", > > > GPIOD_OUT_LOW); //init "reset-pin" is low > > > > > > 3. image sensor driver power_on function: > > > gpiod_set_value_cansleep(gc08a3->reset_gpio, 1); //pull "reset-pin" > > > high > > > > > > so, the expect state of "reset-pin" is from low to high. > > > If I am wrong, please correct me. > > > > > > From Documentation/driver-api/gpio/consumer.rst: > > > > As a consumer should not have to care about the physical line > > level, all of the gpiod_set_value_xxx() or > > gpiod_set_array_value_xxx() functions operate with the *logical* > > value. With this they take the active low property into account. > > This means that they check whether the GPIO is configured to be > > active low, and if so, they manipulate the passed value before the > > physical line level is driven. > > > > I.e. when you want to enable reset, you set the value to 1 in the > > driver. I > > think you're now setting the value to 0 in that case. The opposite > > for > > disabling it of course. > > > After checking "Documentation/driver-api/gpio/consumer.rst": > To summarize:: > Function (example) line property physical > line > ... > gpiod_set_value(desc, 1); default (active high) high > gpiod_set_value(desc, 0); active low high > ... > > > From my understanding, it seems that "reset-pin" is using the > following(active_high) case in current code: > "gpiod_set_value(desc, 1); default (active high) high" > > Do you mean, we should use the "active_low" case: > "gpiod_set_value(desc, 0); active low high" > Code should be changed as below: > 1. config the "reset-pin" is "active-low" in DTS: > - reset-gpios = <&pio 19 GPIO_ACTIVE_LOW> > 2. image sensor driver power_on function: > - gpiod_set_value_cansleep(gc08a3->reset_gpio, 0); //pull high > Is that so? Correct. -- Regards, Sakari Ailus