From patchwork Fri Aug 30 06:34:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 824296 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8A1014F13A for ; Fri, 30 Aug 2024 06:35:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999707; cv=none; b=J/VRJVUOMUA2nJxNan2dku9bg5OD1l/hOCGKqwC8MTrDTIMF3A6X9HA65dFkF/M+i8j/8ZhygOJm8/JW5y44SNqAjKw3KSjb63iz9rP0q9k3jmk5fSj6p3wvKO5pF70ZuPcsp4T31FYmZu2sMTs4xq4+rCSrwfZj00v1iqEmqpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999707; c=relaxed/simple; bh=yYQ6acehCyW1zLMUki14le2kpNm27i0RtoBcCYQ15Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lsltIGa3pideSwa9mLdsLFQ4FqkKB2v5xLjMtCIFuktnDb6k11TRe8IuNN1Q7S+pFaqjIPW0+KEYNmsZPAEwtrQCsaiqyUqrwuQnN1R8gcvBDxMPUXzYi/bqeLcUX1nNZ8nXjjDL5z4gnp6YhZ854clh+j7yc+w6Omewph2bcyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=urphI+MH; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="urphI+MH" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f401c20b48so961411fa.1 for ; Thu, 29 Aug 2024 23:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724999704; x=1725604504; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SDnDU3kgVwS7LsssVzzQefO3+iiD2Zk1z7JTxz0bJKQ=; b=urphI+MH3FfZe6MLYbCloWgjOsWDVsnfzttyqs+UElSvOA/M6hbslnsO8j7GFXK0RF QXJZLU/mLTPX1Kev2MrLiX/HbZv48aggX3O0RSVza9NTU4IB/tjDb7F08ZRLBGoQwcTX ggrAv1H642gU7xf3Ekd1bRvRTZDfsPx5ch1a2zHUq5G2XFVIMfg5tUJYt+5zVxF1kQT7 hE9bhI7idD8IFOU94Z2WsDpUyR+/yXTyiiaOlPBaKrwm2pkDO4h49bZXVTv0w9WXts38 KvS8SjJqO7wjgqJfAoTvuwHoeR/uXQ1lAg9mPTHzS2XBOIOMuQfL8NTzBcNP27v3vOFg vwQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724999704; x=1725604504; 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:message-id:reply-to; bh=SDnDU3kgVwS7LsssVzzQefO3+iiD2Zk1z7JTxz0bJKQ=; b=Y+XquhnBNJnLtCHsx/lvS5MGp/LRc5da1T+3eOIUVMBXN/LzReFeccb1smoWkDDsG7 8/b5GXs/aJaUQBVM2/tZL3IOGa9YLfOltjKQxxvXst+hYG8lh7c4Ehy0wOz+ZbVQ0arT AFpbYPZzoD2IWpJAIAFMC8u9jdS3vL3OpXZ9JFgIyQfrAAi2++yqbydKdYwELopGiSUd 049rwfSU4xUFJMg4UXOfNg7vlCufgAy2YCQGujfamAsJZ+GbQYHlaB9t9DX0x2b1shLt o27E2tEDQIh4o1LbTfGk/qoIBi1WbuyGf59gJF+BTdb7Zs9DhiPIWmF07/ys4oIJPHNg oxtw== X-Forwarded-Encrypted: i=1; AJvYcCXB5aBit7v5+MX5PmZ657Hd09TNQ80LSAkNHlhbgyEwh+3N40d7vljtEWPncvyl9ARcoU5IM/GNeRNiqA==@vger.kernel.org X-Gm-Message-State: AOJu0YyDu9hUvDUo1m2iax5YR3ZvpA/yfGSFKmenLqClre6gT6t/MCCa B8We3pv+YtYg8cj8L+jYdOzCYtwfD01QatUIDFIierGxkHIT5nJoqIAsQz8Mu7U= X-Google-Smtp-Source: AGHT+IHUyvr8pXivZtsQv1J3akeFVxkHJVKRhZ/KiVVOTyEeBR306kHbWJatGH85ERomac9zgh9sqQ== X-Received: by 2002:a2e:bc0b:0:b0:2ef:226e:bc6d with SMTP id 38308e7fff4ca-2f61e023cf2mr4806181fa.2.1724999703575; Thu, 29 Aug 2024 23:35:03 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f614f00860sm4879441fa.45.2024.08.29.23.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 23:35:03 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Conor Dooley Subject: [PATCH v4 1/6] media: dt-bindings: Add OmniVision OG01A1B image sensor Date: Fri, 30 Aug 2024 09:34:54 +0300 Message-ID: <20240830063459.3088895-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> References: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add device tree bindings documentation for OmniVision OG01A1B image sensor. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Conor Dooley --- .../bindings/media/i2c/ovti,og01a1b.yaml | 107 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 108 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml new file mode 100644 index 000000000000..ca57c01739d2 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml @@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2023-2024 Linaro Ltd. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/ovti,og01a1b.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: OmniVision OG01A1B Image Sensor + +maintainers: + - Vladimir Zapolskiy + +description: + The OmniVision OG01A1B is black and white CMOS 1.3 Megapixel (1280x1024) + image sensor controlled over an I2C-compatible SCCB bus. + The sensor transmits images on a MIPI CSI-2 output interface with one or + two data lanes. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: ovti,og01a1b + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + reset-gpios: + description: Active low GPIO connected to XSHUTDOWN pad of the sensor. + maxItems: 1 + + strobe-gpios: + description: Input GPIO connected to strobe pad of the sensor. + maxItems: 1 + + avdd-supply: + description: Analogue circuit voltage supply. + + dovdd-supply: + description: I/O circuit voltage supply. + + dvdd-supply: + description: Digital circuit voltage supply. + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + description: + Output port node, single endpoint describing the CSI-2 transmitter. + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + minItems: 1 + maxItems: 2 + items: + enum: [1, 2] + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + +required: + - compatible + - reg + - clocks + - port + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@60 { + compatible = "ovti,og01a1b"; + reg = <0x60>; + clocks = <&clk 0>; + reset-gpios = <&gpio 117 GPIO_ACTIVE_LOW>; + avdd-supply = <&vreg_3v3>; + dovdd-supply = <&vreg_1p8>; + dvdd-supply = <&vreg_1p2>; + + port { + og01a1b_ep: endpoint { + remote-endpoint = <&csiphy_ep>; + data-lanes = <1 2>; + link-frequencies = /bits/ 64 <500000000>; + }; + }; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index cf9c9221c388..9b0d1db35b7d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16507,6 +16507,7 @@ OMNIVISION OG01A1B SENSOR DRIVER M: Sakari Ailus L: linux-media@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml F: drivers/media/i2c/og01a1b.c OMNIVISION OV01A10 SENSOR DRIVER From patchwork Fri Aug 30 06:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 824295 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C9621531D5 for ; Fri, 30 Aug 2024 06:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999709; cv=none; b=j5P9THOUIXZFYwstLFKrTBV0ocwwDY0KCXrg9ySuSrJZjmxziBYD2mA0FtxrERZ5l+XWEd7MpIv+FmStwGK2eqxSf4hBEkSLTkYlZeJ1XsyuEIQms8Wdp4PNhvgwSNLVcOwq/NABhrUxQpulGilGGE2jicMR7qWGIBx+XXoioYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999709; c=relaxed/simple; bh=kIV0F91IXvXUKzpvDFHxNVojmJGwADBZn1C2iDFr0hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=saWYIaRkWi0CZGV6TTY8ubYxZGU2GnTZC2d8g0apXWmiJykySqoMndSYzK46bgO3+9YFitFF3xqbAz+VUDRurV2l5DriR6cCFTqt9K04n5Hg8v5nlyMvRgVLxKZxi3Fft9YYoTowzqxw7qJ7IIcrx1ohce7pFZaoMxse3ihyOKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=F7cSB899; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F7cSB899" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2f3f99ccb76so968491fa.0 for ; Thu, 29 Aug 2024 23:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724999705; x=1725604505; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wsv5X2BcXiIj52Q3nX5m9Zd42JJpX6eUx2njNNBJGRU=; b=F7cSB8996cjaloIuHe9CBD8H+AqTLAmh4r88RJkqb9NLafGTdt+yWgIGX5lBY1gozA KJgdJ5QGFa1wcK9ZXzF/Ur4q2NYEVQ50oTBLYNRGgTGRZYOIZUQIvoX6d60k7zpNdO82 3odjR13YEWj+URllJ0d1vUAwIcQuM+dN2iFEo/ibGNmgTpJBQQaCgK0ipf2S8m9+sY4i AFamusayvVNDA5pgx/2VUX8SxW+ykON/VlL+Nk0QoxqOo6z0WnPn/ZLBYo37FGOapMED BcbJv2MkmdAJkcyth68Tp0shaOejb1hDTL4909hSlYLputAjMwotgkjSwFO9F+JQcl+3 MgSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724999705; x=1725604505; 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:message-id:reply-to; bh=wsv5X2BcXiIj52Q3nX5m9Zd42JJpX6eUx2njNNBJGRU=; b=Vv+szphqKAzQJf7g9lVmrDJBFVizEPcoQ19cIENBH65PnTCyGUFJu9QM6Gy77dZszf 5WE7MdVMEwTpXmzhgiu/KF3YTtp4gdvDZUsOubhQhT3gNY8v+4GDCQeVnzBeqnl6cDK+ Vo3GbdJK9MdkpEsd5h/NI64cO7RwVgZKNem3jcxjg9WqVPP2YWwapErEli7bajJGKfIT D+oOntg1bcV4lVGC3EzRC4YCqBORnPhmH6tjqhP6qTrt6PBi1TDurvfs0+AYchSXre8j uJSPpB8kx+CrOpA1uiPnQGYxG4tHeu6l/yJGVJHoHLjavQiqUNNhx2Xcl0xgcV+lx4/y Y71w== X-Forwarded-Encrypted: i=1; AJvYcCVTEI3xv6ThoFWHF9SwY3buRT04NjY0Xghw50bPnnMNX3k48gqOAoTggKCZnKLjeV3UoeU3vPTyRevmRQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzUFrJaBDp0x9+mG/j6dFy6MDFFouIMUf9TOzLeK7kT/2guQK9i VvtC5AO3vmOCGKppeyLVmzsxgiiRbiRdYbnXRTIgNdmwrrrsmitMkZdxrwoEo3Y= X-Google-Smtp-Source: AGHT+IHrkn7X8r1BezpfgrvJ9H3MdnM6LLa+YY9J5l1LnwUSt2AZ77rXeLwXmw7DSaQQCNWtORcSjg== X-Received: by 2002:a2e:be09:0:b0:2ef:17df:62f9 with SMTP id 38308e7fff4ca-2f61e09b105mr4011121fa.7.1724999705423; Thu, 29 Aug 2024 23:35:05 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f614f00860sm4879441fa.45.2024.08.29.23.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 23:35:05 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 3/6] media: i2c: og01a1b: Add stubs of runtime power management functions Date: Fri, 30 Aug 2024 09:34:56 +0300 Message-ID: <20240830063459.3088895-4-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> References: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rearrange initializations and checks in probe before population of the power management functions. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 42 +++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index 9e756c1c47df..d993ef4bad46 100644 --- a/drivers/media/i2c/og01a1b.c +++ b/drivers/media/i2c/og01a1b.c @@ -967,6 +967,19 @@ static int og01a1b_check_hwcfg(struct device *dev) return ret; } +/* Power/clock management functions */ +static int og01a1b_power_on(struct device *dev) +{ + /* Device is already turned on by i2c-core with ACPI domain PM. */ + + return 0; +} + +static int og01a1b_power_off(struct device *dev) +{ + return 0; +} + static void og01a1b_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); @@ -984,6 +997,12 @@ static int og01a1b_probe(struct i2c_client *client) struct og01a1b *og01a1b; int ret; + og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL); + if (!og01a1b) + return -ENOMEM; + + v4l2_i2c_subdev_init(&og01a1b->sd, client, &og01a1b_subdev_ops); + ret = og01a1b_check_hwcfg(&client->dev); if (ret) { dev_err(&client->dev, "failed to check HW configuration: %d", @@ -991,15 +1010,15 @@ static int og01a1b_probe(struct i2c_client *client) return ret; } - og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL); - if (!og01a1b) - return -ENOMEM; + /* The sensor must be powered on to read the CHIP_ID register */ + ret = og01a1b_power_on(&client->dev); + if (ret) + return ret; - v4l2_i2c_subdev_init(&og01a1b->sd, client, &og01a1b_subdev_ops); ret = og01a1b_identify_module(og01a1b); if (ret) { dev_err(&client->dev, "failed to find sensor: %d", ret); - return ret; + goto power_off; } mutex_init(&og01a1b->mutex); @@ -1028,10 +1047,7 @@ static int og01a1b_probe(struct i2c_client *client) goto probe_error_media_entity_cleanup; } - /* - * Device is already turned on by i2c-core with ACPI domain PM. - * Enable runtime PM and turn off the device. - */ + /* Enable runtime PM and turn off the device */ pm_runtime_set_active(&client->dev); pm_runtime_enable(&client->dev); pm_runtime_idle(&client->dev); @@ -1045,9 +1061,16 @@ static int og01a1b_probe(struct i2c_client *client) v4l2_ctrl_handler_free(og01a1b->sd.ctrl_handler); mutex_destroy(&og01a1b->mutex); +power_off: + og01a1b_power_off(&client->dev); + return ret; } +static const struct dev_pm_ops og01a1b_pm_ops = { + SET_RUNTIME_PM_OPS(og01a1b_power_off, og01a1b_power_on, NULL) +}; + #ifdef CONFIG_ACPI static const struct acpi_device_id og01a1b_acpi_ids[] = { {"OVTI01AC"}, @@ -1066,6 +1089,7 @@ MODULE_DEVICE_TABLE(of, og01a1b_of_match); static struct i2c_driver og01a1b_i2c_driver = { .driver = { .name = "og01a1b", + .pm = &og01a1b_pm_ops, .acpi_match_table = ACPI_PTR(og01a1b_acpi_ids), .of_match_table = og01a1b_of_match, }, From patchwork Fri Aug 30 06:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 824294 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 511D61531F6 for ; Fri, 30 Aug 2024 06:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999711; cv=none; b=W0jKyqVQCPH8Z3D/5hzq76hAa4Bz9NiCjUwgQcrhXZJ5mrBByTCvFf2o1BPl7DDdXvi0rySw+CXM5u1Gg50xeJ3r7EU/GEMLkQ++jV6AL3W7F9E/110fBMQerxYp33iZJFKrGYNi1TiesFuWb1pezfAKiIGuKVrJcMhga9qkEz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724999711; c=relaxed/simple; bh=qwacd3v8db7ChZ+WZMKSWez3bE4sxEYchYaETEsSQXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zx5EzdwJ2/uVF/InxUMK3zHMiIoAsHFJ7yD50onHMkorBKfKTi48uV7ZUV1im2spwBmywvtqroMih2bKe8EwsNnMozsoqPHWFy8dskfbDwyD8KrtznH60XHTjOkYplYla87ueO//mQYvK6pNeZzgMnb+C6mvJ2IaSuoKnweQ3DM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ukgDzcjL; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ukgDzcjL" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2f3fcdfa099so1130091fa.2 for ; Thu, 29 Aug 2024 23:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724999707; x=1725604507; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nsKfnicCMY52tHbvGBlR5SwuuGZIL8kCBaXTYqhfZaY=; b=ukgDzcjL4oUatJbZRfSJTiJxvu8dbpfFAG2HWy3bwrStgIGr2tL9U6+rrJW7UYsGOI 5ApfHT/GzopNP2Cw3x0Or0ETqOJFVDoiMjHEL8CGRDq1AJZi59kshY3hts+8m8DUJVx1 10uMnBkTLn/gqbFQstROeGilQVPe1sdLogDYaLstgOQHFwFZi6yXzRvsrQgsMbH9/GAa mxpcQc7OJ5AEig1W8YB4mnsMk6pr9aruKOdRn82E+c5ggwkKtZ2DUgXcZlWHA3H887Fj cphD1682LsBh9m0W6/1pGzm8dgiFxZLGpH66DYGPZvMfM1Hq6QHAiqcMSlEezKnGcTx6 UKGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724999707; x=1725604507; 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:message-id:reply-to; bh=nsKfnicCMY52tHbvGBlR5SwuuGZIL8kCBaXTYqhfZaY=; b=E/e+oJutrDSpYoKtyOVZeQZGJsAC/sRG8upXjTL3GYsPX+OGNL6znh4gJh2Oeoz35a 3IT9Xd4AqQizL+xRJHcLsh9OyRX8toMSjIFLUmnVpNHVANWufy6u98TvLHJHslF6nC9j jG1jXOMopTgI/v36Y/hz2PRaySq6Jt/W8IqjkiD4fV8KtUOMNWCReuY7YIBF40vDe/Fe SJ7invw3OSM5GtW0wauTplZN9P5PmvidL5CXwFa4ouS3auJwcYNUMg8iYokskQmAJiN0 4oErPrO1wTpkS3ONpPSdtYiwwWxdYMPmKZ+S6O4osQz3uwKLCtqGzQik9tCIRdiLmBls ZIZg== X-Forwarded-Encrypted: i=1; AJvYcCUGQPCaQ6OWrUxWA8sOp6vpZzO2t/WgsY7O19J5L2W3qvKtKW/Se0CGzYsq9HYxYG1j+eBhD60xVqJqkg==@vger.kernel.org X-Gm-Message-State: AOJu0YxkkRmJRxGDfq1MncFtqZAIOkAnZ7eUtALo3JcWB5AzRf3pew27 3z6POCcQlQaCdRE1bCvFEY3rGNfTIAItTqWoxk60oqmJLjPBN4FjgC8CVvJB1jI= X-Google-Smtp-Source: AGHT+IFlrPfvFMPyPcuwacinKJMUXIogt+p/bJI5w0NNx6sTLh5gP4vbYfAWS56ojG5vMJG7B6aOMg== X-Received: by 2002:a05:651c:198c:b0:2f3:e2f0:5140 with SMTP id 38308e7fff4ca-2f61e0266e7mr3981021fa.2.1724999707456; Thu, 29 Aug 2024 23:35:07 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2f614f00860sm4879441fa.45.2024.08.29.23.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 23:35:07 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 5/6] media: i2c: og01a1b: Add management of optional reset GPIO Date: Fri, 30 Aug 2024 09:34:58 +0300 Message-ID: <20240830063459.3088895-6-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> References: <20240830063459.3088895-1-vladimir.zapolskiy@linaro.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Omnivision OG01A1B camera sensor may have a connected active low GPIO to XSHUTDOWN pad, and if so, include it into sensor power up sequence. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index 406847d18062..95716c234cd5 100644 --- a/drivers/media/i2c/og01a1b.c +++ b/drivers/media/i2c/og01a1b.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -420,6 +421,7 @@ static const struct og01a1b_mode supported_modes[] = { struct og01a1b { struct clk *xvclk; + struct gpio_desc *reset_gpio; struct v4l2_subdev sd; struct media_pad pad; @@ -987,7 +989,11 @@ static int og01a1b_power_on(struct device *dev) if (ret) return ret; - if (og01a1b->xvclk) + gpiod_set_value_cansleep(og01a1b->reset_gpio, 0); + + if (og01a1b->reset_gpio) + usleep_range(5 * USEC_PER_MSEC, 6 * USEC_PER_MSEC); + else if (og01a1b->xvclk) usleep_range(delay, 2 * delay); return 0; @@ -1004,6 +1010,8 @@ static int og01a1b_power_off(struct device *dev) clk_disable_unprepare(og01a1b->xvclk); + gpiod_set_value_cansleep(og01a1b->reset_gpio, 1); + return 0; } @@ -1044,6 +1052,13 @@ static int og01a1b_probe(struct i2c_client *client) return ret; } + og01a1b->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(og01a1b->reset_gpio)) { + dev_err(&client->dev, "cannot get reset GPIO\n"); + return PTR_ERR(og01a1b->reset_gpio); + } + /* The sensor must be powered on to read the CHIP_ID register */ ret = og01a1b_power_on(&client->dev); if (ret)