From patchwork Tue Aug 13 10:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819027 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 010A9187349 for ; Tue, 13 Aug 2024 10:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544446; cv=none; b=MKw6VarWcB3UDTN7cNNIOtCl17v0OpjpbvHA/xcio7BzAh8w/W9JTPKkrqpJqupPV5X31aU0SHxW+wFC4y05aZdVlJ0sd1/+uGTUB0/X5eAh2DF5LBwrhVg1rn1Mr/rgqdZXk8o8noTDE9x1lcZFCpwxxcKBF/2fwh/FRt08SMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544446; c=relaxed/simple; bh=aqhpo7wrTeZIF4C7nPe7XF9JisDqdIYeaeCsgW4QNb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LenIV41NofWS35aFf3B85IE41xxcWYdFlnZLKJOwoHQiett4VxidgVDfRbu+v7Ia+PWQ14bWFSmUcJSPxpgo8mvC9gabetrzpI1KG4S8JlQhOkZzZfdrLoW0K7RMDAgs9FTD/MK4TMLLz9xGCLSmBBG2w15BOJTED/jWh35G+UA= 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=Z3+w1Z1w; arc=none smtp.client-ip=209.85.167.42 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="Z3+w1Z1w" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-52f00427236so879261e87.0 for ; Tue, 13 Aug 2024 03:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544443; x=1724149243; 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=10cT3V7GvRdqqMfeVs6CaqnKxabDpRzyanXk8MSpT+I=; b=Z3+w1Z1wD02k40aK3F6LNl8UzmG8hj/a7D5CkuuG/i117cDsJb5GYHrHO5ErxaY6y5 g2HKuNANp0bjcX1+UYKBLd50yPkmC/6SxlUdEARtTipLW4KhJ8uOZPI+a8uUa4bPItxY RncniehoC6TGXeZcGyeBqs/OOo15GMboCdsc5YF+Yc3LgqFpX56WXZ2hZT5CUL3T0458 vT0A7AT9XjbKiC2Txua853XiGS+bQ1SHqBCmK69F/WU3e8aEiB67xjrpcWYN4Hw/iKHV 1UZ7IMSjcr8NmUGUbikZ/RjP6l4klElHlHUT72g7jUblTeauTXzIGDUuubxzpA5RKrIm KGng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544443; x=1724149243; 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=10cT3V7GvRdqqMfeVs6CaqnKxabDpRzyanXk8MSpT+I=; b=EN84SwSsykUZ2kPwxW40cNJaWUke+3D2UVTLZLq5YGzTO4yW9uACtoaip6hBRyae0a KYLr2F/CZ4CiqwFurdMB1f3JWoswchaEFv+SXqtrjKOO4T+Tm24fGEQGqOBwFnvUqZJm N7g2Zehzz96qV34Ycqbq4VSK0NY1ogbzbFv41n5X97cx163h8z/QnzUv2P2Pr34f1aDX QB0Sk1X+0QNP3yVQ0WqwoZ8w5DgoxIrqctx1EflT5BulhTVhwYj3hGaRAw3KJ71kplyY A1JVV6d1G/yS7ilnlFVoWZzzCbysD/c+R4DVjwtNbqaqeDKAQBhC2tk7OMz0fVT3ssIB mgaA== X-Forwarded-Encrypted: i=1; AJvYcCUAWP5j04TMV0VevHie1fJOajvwswSwxOkN9omJuxvBzRrHb1KxMyuJJ09GioSHiFfqETZVhs04uJnt1w==@vger.kernel.org X-Gm-Message-State: AOJu0YxBTiywyXrEfCTu1nm05bRLiSa1nwiBklVQ2cEdCALPlx3bjU/F +CXr97OoGpG5UMeHPjPhjkzamU3bqhfRAMwsSjnMhQP5jsvw+deFfY6fsVfVWPA= X-Google-Smtp-Source: AGHT+IFFYofkEGPy9fDH4aPbhPmN1XkXRqAgEgwS/2XLZjh1TqzjZD0cm1AH8Ks6HjC55CcFIKe4ag== X-Received: by 2002:a05:6512:3e22:b0:52f:413:30de with SMTP id 2adb3069b0e04-53215d4597bmr498726e87.7.1723544442985; Tue, 13 Aug 2024 03:20:42 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:42 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 1/6] media: dt-bindings: Add description of OmniVision OG01A1B image sensor Date: Tue, 13 Aug 2024 13:20:30 +0300 Message-ID: <20240813102035.1763559-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 Tue Aug 13 10:20:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819924 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 F3C0118A6CF for ; Tue, 13 Aug 2024 10:20:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544447; cv=none; b=Z80Iu75ttPs0xloTvGg/oV6M7z7UaEIiqmbbLkoYa5XRVF8IjSPBWPnyPlbTrGeTHtea5t4qdsuUY4dVKV+cj9NTuihsfLNcICMODFaIar/aTsvuVYpOw3eJ+Wd/8AHpj0CfoI4hpKdvoeN1u659gvoDNbxHTTKNXvf/Hv0K29w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544447; c=relaxed/simple; bh=dHPvVFMF9oE/Smq/fAVh/jP8Xok6qZTN+5FpM5SDwrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KbK9GjtiRhdgsze5safT+8es3Stw4449B9y5Yr+/2PHV3PZ9GgTUzD8uz31DeFE8b1pytHvXW12XUhZtYt20T+OX59n0tVPpCEjGqvEx510pI7K7vJ8c3xvSFxsUsSu7wdDuFI80Ngewe1iK+7F6MxB2cDp509MA3uohh6io4pc= 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=TxyES8lN; arc=none smtp.client-ip=209.85.208.171 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="TxyES8lN" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2ef2c2dfaf9so10906561fa.1 for ; Tue, 13 Aug 2024 03:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544444; x=1724149244; 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=h0tdmBT53w5VNdz5QchETAoTh/+fSs3HRvsgOCGHU8w=; b=TxyES8lNzAa6Fh0b6U4njf5VE/UUueSRabNgsf5RrDDpIdtjy8Ho2Kw8gZmWJFO2E/ pyKU4YGm2naqoQCmMjXxuwEtYWktQA7langyxJAM+baQIJjK7ek8THXyU0+oyxCtVDPX Yeg4ZJav7SVaO/ZadPhh2GgWkiOULEpK8EYVztzxzfFRuv8pKTqM9muSRLk5taDqB5Kw Mf7QWvJA7uY37ZW2X7t6ZMdBVsC1Hngtrf0ensbjpC+UVHxPQeEC2j7YIRLy/wYnHnxJ 3kt2jcOE8IgJGVmOcNidXmGQSkaHxayTvCddzyOvOAqAN1aiglUnKTXz2qcmWDPPLLTS DsOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544444; x=1724149244; 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=h0tdmBT53w5VNdz5QchETAoTh/+fSs3HRvsgOCGHU8w=; b=Tm4W+ha3WxJz6//tInBLUnUan9wRxchPJ6CIPas+Ls2HGsjypxTTNRkb2TB2/55o1A UuOk1w659DAv8RYWWCSENvW44BSsk+2fbr2dCBPIlOtEEkMSXrlUZM2Rb2wxP+4is6Qc 55Lpf/TXc45/wzc6C+tO3usSHTLGil8LGsrmRmDnYbGXIYppWTAydaYfSW/w3p+6qcyd h/kv4YfXn451VEBa/QiErjWXjqlequPajEcu1xnyoV/yN+owziHRuoHNUp/3YFRhbema gDFBscJ8zm+Jw1zS/LwPlDfCnDfbPYfV+sgmnwSaurR1Xuo9k6Pum9LaSg36wXhy6e2R SFYg== X-Forwarded-Encrypted: i=1; AJvYcCU1JOXlCV37e8W+EeN2UmYskO2N57GWmTiiLfQPAJLTQDHrZurnLYmDQZKwMRNxnSauLTJ6pM8hiBzqwQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzbY5IaLuVaKDAk1zSP4vOYIDliKCEUyJSmvRkqGDZVlMBX5Qdr oj4CTVtCIlGJy8t5EsH6FwzINFbgfnWQ847RvxiKU/VI/QHx3Zeu5IR8sxXrULc= X-Google-Smtp-Source: AGHT+IF/VZHJu41gzR8nQXdexwyEmRIlg2m8Yeyw1PWa7amgKeESRU4q3p+273JLfIvLwOLrftt9gQ== X-Received: by 2002:a05:6512:3c8a:b0:530:b78c:445c with SMTP id 2adb3069b0e04-5321502ccf4mr765677e87.8.1723544443830; Tue, 13 Aug 2024 03:20:43 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:43 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 2/6] media: i2c: og01a1b: Add OF support to the image sensor driver Date: Tue, 13 Aug 2024 13:20:31 +0300 Message-ID: <20240813102035.1763559-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 The OmniVision OG01A1B image sensor driver currently supports probing only on ACPI platforms, the changes adds support of OF platforms to the driver. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index bac9597faf68..9e756c1c47df 100644 --- a/drivers/media/i2c/og01a1b.c +++ b/drivers/media/i2c/og01a1b.c @@ -1057,10 +1057,17 @@ static const struct acpi_device_id og01a1b_acpi_ids[] = { MODULE_DEVICE_TABLE(acpi, og01a1b_acpi_ids); #endif +static const struct of_device_id og01a1b_of_match[] = { + { .compatible = "ovti,og01a1b" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, og01a1b_of_match); + static struct i2c_driver og01a1b_i2c_driver = { .driver = { .name = "og01a1b", .acpi_match_table = ACPI_PTR(og01a1b_acpi_ids), + .of_match_table = og01a1b_of_match, }, .probe = og01a1b_probe, .remove = og01a1b_remove, From patchwork Tue Aug 13 10:20:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819026 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 A15A7208AD for ; Tue, 13 Aug 2024 10:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544448; cv=none; b=PSA1KjNYh/ImNhpykI5vaKNB1whZzcMkZRNKkiH3975mg4bCtYLpedKXv9pbefBcelFg50qc+ZitB7Wu+VbkE3mzi/R0/16l8gzncxMJQiCZaFAMdK0YNPQaio0ryvk5cqbVqqLYus/G94/TY8VbD3guaqRijif6sH+EkSAZhL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544448; c=relaxed/simple; bh=kIV0F91IXvXUKzpvDFHxNVojmJGwADBZn1C2iDFr0hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t2z1Xuuj9/isL4lZ+QM5AiUDIjKffSxX8Dg+YevoLn0kjH727STx1ng6azA622zRfD5QT1QE3ucTZNXDCivzHsKvATavb5NYydnicVLTIvSt9xqq6TH41HSlMESXHwYJvNjPARe/ZX4+Bk8mYINH+MqZ6t6wOsffiZ3+Bbokm6E= 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=SwgGkj5p; arc=none smtp.client-ip=209.85.167.53 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="SwgGkj5p" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-530ad984f2dso496366e87.1 for ; Tue, 13 Aug 2024 03:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544445; x=1724149245; 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=SwgGkj5pr7YajKV9SOtf58rhBh0PtEzPBfJzdQ3v3Ld/vmUFK5QyXOILGzP9YEO6y4 P8q2MbMTIWVrTuFWogUO7C6R0xuAiRC6l0H1ipP9Y2aES560qYS0LvU0NhrZAVp7C6GC 7FpHd10AQ98daGiwI/696w7RULYOVgjfkcfgLvoMbOw2WS+iyl7wp0a/ktMz+4MV9atH Ry6j1ReBCmRpxyQ1VNosW1+9FzAINq1f4ckZ8TqGym6QgyFHtdHjvvcJ46yQfiwcrnkh DuGfV+Py7wq0ycJxaGzdWZGkRAq3ijJgAzckYulKIZgFr+ywfrGlXGLdrpnxDN+1Hje7 8kFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544445; x=1724149245; 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=WKH/LoF5WBX/Q9U5DFC0YmVuzGIjJW/M4R26EVCxSki0kJXM/nETkiZZ7AA3GsRtFr sYa7CpRPxYDsTcP2/iV3N5Juz55x3pul26oH7/VDtYBYcOXNinSb+//kpGBNgTyR6UfP m01J2qFh0dNji+ce2wW4A6HXQD5SGizqE2yR8nDYg53hMO0hhr9y9USXta5Xif8Bti6v LpnfPEO9ojcOLRCOBTDaccmSJb5J2URlSRWvR0D4vyq5fppEMlxA91RY3Kf9oWl3PgAV JIWW44neXVWzpUEu29VfxqpTa4Sg+QJ/1kqxLxeS8ldcZZTX5PSsmpGt/kFYUarenYxl 8TlQ== X-Forwarded-Encrypted: i=1; AJvYcCWHiV5TcLbRFRufr1cyh0Rh77AgLoQcaeGSe44e9VfCEvU/UDCFmXDO3vovkoLTOXvyM2dzo3TR5ytN1jxfZc581it6354xV74BYnw= X-Gm-Message-State: AOJu0YyoCoDRFoMRmj1qjd9nH1X9wo+o0DeLee05sErrmRpmyuh7bDrS QEkwagjFltIf6XDtq9OiUSEfdzrXOHTYuQcWTQeSRCoaq+QVNIEYBjv1rA5F4vU= X-Google-Smtp-Source: AGHT+IGNyXNcWaYVf0rGafFn/puOzTSkTz9BwDiy0iJXuA6J/c7TqdQjttIrcFPbgWoWX7Ii83xHCw== X-Received: by 2002:a05:6512:3a93:b0:530:e0fd:4a85 with SMTP id 2adb3069b0e04-5321501af69mr747431e87.4.1723544444558; Tue, 13 Aug 2024 03:20:44 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:44 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 3/6] media: i2c: og01a1b: Add stubs of runtime power management functions Date: Tue, 13 Aug 2024 13:20:32 +0300 Message-ID: <20240813102035.1763559-4-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 Tue Aug 13 10:20:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819923 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 8E44B18CC0F for ; Tue, 13 Aug 2024 10:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544449; cv=none; b=cTCkusaof4ZY1fodk310buRq6FlvbHwEJ5XjQwwZBkpRMdrF08flCNWA/8R+LnZbKJJxJb9akTSp+Q9iPscMMLBN2x7/SvK8gwPv1rkGn6u/8pv1UIzIcySlvReEj16pdq1fWi0GuVyfOmy8ZwJPpotscyUKoIeeQPhfQZkRP8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544449; c=relaxed/simple; bh=zFeRD1dubZTlUw2Tr8sTwatKL5cUhpCf5nRuXAjei3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wyvwoq0T5kBvbMZ0RUPfcq0tN2V9GWPVTZQjieJdIA9YrdW7JhlVit1XALLlw2gkDkR3qQCwyc1fe6NIn5vSfkiyzrtx5xTAErtq0Gf1aE/rbmGbVVDNyQHWM1osfUFnaHWj3+xjhO9Bh1h2+1bRtjDtTg3cr9T+8zUOR/aT+7g= 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=WpOct45u; arc=none smtp.client-ip=209.85.208.182 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="WpOct45u" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2ef18ca13f2so8573001fa.3 for ; Tue, 13 Aug 2024 03:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544446; x=1724149246; 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=AauUhOtdcxefr/CJ3rnixUCq6aw4Uq29mzp5fPuYe10=; b=WpOct45udlADXeNKZAg9RqnLo9z9ks6INkAsfnflV99IIjYmTO9jwT09PohJainHEe YxoAduAh1RleMLF1Dhu3IaBbvJ0yr6P61j4A9Y0r9BxnroFfw5BRC7CBbqG6B6xDpJtu vNi9ORMGpQhZAMZRj9gxBz+va8TBa+g2bzIeK+WfuL1262to3iDfo+b1USJXqvQio9yC v2zRSDrKcYI4oBDHztr4bnwViLj3xCsQTszCSQh+bHREcNJOkAoEUo3cJU0TScCwwD5n NYAZ632I5Xc/+4KQcj7wDoO95bkgfx6Pwy4H+rCAr7rUlEx7WEizcUrfBgci3g33CQki ijxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544446; x=1724149246; 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=AauUhOtdcxefr/CJ3rnixUCq6aw4Uq29mzp5fPuYe10=; b=UkFX1MPsR23WFc04xQ4TXm/PQcMtA17hxf6eDhD7rOZ0NnHagD7L2cIAbwMnPJoqlU rUaUYs/kjlqSvjXiwA/aGd9CiSFGcv9FK/pRpxd0bak59JhjmBsZvpNgeE+vpDkiX4vb gb41OBFR7uxUldHrcnG/q7SROLYdjlinNn9o1O9Q/c6rPChA5lpLSHctpheqIwYpi+zu GoZgvB6iNWqSHh9rjLHJjmyeS6nFPfvwfmV71/3SV2zEr4zc9jqzdNJcTOGfywm5fJGy zv/bvauon/JV7291mc6biwUp6IKzJtSGCo6jSdmxIXbX3DqD4V3rw+ATCX+NWTHb/Ttg khcg== X-Forwarded-Encrypted: i=1; AJvYcCWLJ8PbA4msNX565YBfoPdytySuf5+tqv8GsJZcUnLcaUMic7In3f1MHN3gyIwy7oqyJyP25jRw9lLXnzF3KSfJSVY9PX73b5RSdHo= X-Gm-Message-State: AOJu0YwbmMX6fFtFp5w6gU9b5QeWlm5/CBm2hSa+Xz8+W3WjMFUga7J4 TwHlnHhMZBsfYGxU1GNY7iYnYKJKh4rSvZuAbz8gRGl2Pcg5gCb1cKDrG830CD4= X-Google-Smtp-Source: AGHT+IET57EJTfirEQuvPVEG1X/QJazPFFJZy606wLkFdO+/LZ8fEv9a16ZPYASYP6IFODxwCMrFTw== X-Received: by 2002:a05:6512:687:b0:52f:cf27:69f3 with SMTP id 2adb3069b0e04-53214fdaf44mr738338e87.2.1723544445615; Tue, 13 Aug 2024 03:20:45 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:45 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 4/6] media: i2c: og01a1b: Add support of xvclk supply clock in power management Date: Tue, 13 Aug 2024 13:20:33 +0300 Message-ID: <20240813102035.1763559-5-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 The OmniVision OG01A1B camera sensor has an xvclk supply clock, which could be described and then explicitly controlled on OF platforms. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index d993ef4bad46..766740bd04c1 100644 --- a/drivers/media/i2c/og01a1b.c +++ b/drivers/media/i2c/og01a1b.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -418,6 +419,8 @@ static const struct og01a1b_mode supported_modes[] = { }; struct og01a1b { + struct clk *xvclk; + struct v4l2_subdev sd; struct media_pad pad; struct v4l2_ctrl_handler ctrl_handler; @@ -898,8 +901,10 @@ static int og01a1b_identify_module(struct og01a1b *og01a1b) return 0; } -static int og01a1b_check_hwcfg(struct device *dev) +static int og01a1b_check_hwcfg(struct og01a1b *og01a1b) { + struct i2c_client *client = v4l2_get_subdevdata(&og01a1b->sd); + struct device *dev = &client->dev; struct fwnode_handle *ep; struct fwnode_handle *fwnode = dev_fwnode(dev); struct v4l2_fwnode_endpoint bus_cfg = { @@ -913,10 +918,13 @@ static int og01a1b_check_hwcfg(struct device *dev) return -ENXIO; ret = fwnode_property_read_u32(fwnode, "clock-frequency", &mclk); - if (ret) { - dev_err(dev, "can't get clock frequency"); - return ret; + if (!og01a1b->xvclk) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + mclk = clk_get_rate(og01a1b->xvclk); } if (mclk != OG01A1B_MCLK) { @@ -970,13 +978,19 @@ static int og01a1b_check_hwcfg(struct device *dev) /* Power/clock management functions */ static int og01a1b_power_on(struct device *dev) { - /* Device is already turned on by i2c-core with ACPI domain PM. */ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct og01a1b *og01a1b = to_og01a1b(sd); - return 0; + return clk_prepare_enable(og01a1b->xvclk); } static int og01a1b_power_off(struct device *dev) { + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct og01a1b *og01a1b = to_og01a1b(sd); + + clk_disable_unprepare(og01a1b->xvclk); + return 0; } @@ -1003,7 +1017,14 @@ static int og01a1b_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&og01a1b->sd, client, &og01a1b_subdev_ops); - ret = og01a1b_check_hwcfg(&client->dev); + og01a1b->xvclk = devm_clk_get_optional(&client->dev, NULL); + if (IS_ERR(og01a1b->xvclk)) { + ret = PTR_ERR(og01a1b->xvclk); + dev_err(&client->dev, "failed to get xvclk clock: %d\n", ret); + return ret; + } + + ret = og01a1b_check_hwcfg(og01a1b); if (ret) { dev_err(&client->dev, "failed to check HW configuration: %d", ret); From patchwork Tue Aug 13 10:20:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819025 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 902DD18A6CF for ; Tue, 13 Aug 2024 10:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544450; cv=none; b=PUNMW1mNylbSZKWlU/6CSVZmFRTiuuypJFEBAU66zFA+HDD0KmvLQS7fQGGu156cdVyKk6BZpqynJZ8mOkI0y1wFTC2TeBQ8YLFN3Wcr+xsrLuiRF9pT7SFwgrGk+OKlTT/9Hp39UMafyoUIsFb8QsreQBOGbRPznq8hJreksvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544450; c=relaxed/simple; bh=GCZa41LBUHJwi/6V+Gjr/aZ/mKBaKvgPNKryTB40qo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Md6g/yyBZ7c6xJpiQ4W0ziT/72dbdf4oue5R+KEZ7iIt/SJTRg9zCKdUXfkSjnnUNqQi/5jFHtIxAEcBzH4nEvCUx+FU42jTORzriQtolyfjEF7UwGqpuQOQJof6ekfZ9xtsfNS/x168FHujqO/JvedpXhnAzw+7NjpcO9tUi3k= 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=Q0EBzu/L; arc=none smtp.client-ip=209.85.167.45 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="Q0EBzu/L" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-52fd0904243so525669e87.3 for ; Tue, 13 Aug 2024 03:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544447; x=1724149247; 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=OCeplELLLeiitcqgFPRs5GSflnURqy8in4V3Us1wY+w=; b=Q0EBzu/LyeTT/aMG0Yd8tq46mVDsiPqJ09ljzVfwbZyudQ3pLrqzyNIugYzE4UmTud fb0NxqKe+tRZf7yGdYt3w9UeiT+j+jUBMpbVaQC0R3i0p1SsD3etdZ7VrQssgf3O6pBA S9HE8YR+7wr1XgzahqMYtHB3JFT5ATRuqXSGPJRXEMVXoNJLHS74sCfQMN9/PPZu2bu1 cN9FOUpiY4QbqsEve/KqsGUqMen4RVXqYlJsj8gwr2WYYUo64Hn9kBOkTdGZPvj1xIlj C6894au1y+NtgmT2vzGfUhYNSkyLUmHDHUArKdDL3sDrSIupxH/RwvEsNv5ayRl3KzhM nIqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544447; x=1724149247; 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=OCeplELLLeiitcqgFPRs5GSflnURqy8in4V3Us1wY+w=; b=LDYajrWRa/c9twTHVXv+wA17XY0J18DsBqCro0bvn0ih0j9rYckqShsOct7DY36Gvw 36I72/s1spdJqalSeP+ncnoOBYXHTqtIumUkaI9um6aZGu4qBYFWS0qSn5s4JskOY9AJ r9ZVogyqs2YfZcScQRRCpVVMv6rE5XZCCdTTWVZXLEYfejz05sQlDAVfv4FJ4LXxSvJL w5hezFtl5QFdwKn+97oNhPyFz+UgsFpWcZjhV526yOVQC5kqaUuH3k2bpD2R/Fzk5uux EEzIxE8ELIgATnvcnP/FmJveHz+UbcFio35HeL0ZOXbhYdT7ibYfeeXEuDO9P2IJE68W Dg7g== X-Forwarded-Encrypted: i=1; AJvYcCVnY5Yi3PmUi+C2Y14tBCP0bJeYon/X++X1IcYQwHpcY92EKUh0Miu/oGhgmHi8OmTwX2OE0HvxjNctpoBaA/UU2Ql7h1+zrQo+xo0= X-Gm-Message-State: AOJu0Ywu2DdqvViwJ+of6b4EJTTi75yFu/Ns1j8tSIciGvineB3NS/7L GVrneIa6TATs40Qa7dfPJBovafjKGQLo7BqOX7m5tkeA5gMAWTl6kdTtOvyxpVg= X-Google-Smtp-Source: AGHT+IFgVwF41KQ75i3T0DwK4BU0kkW5oi/pZQP5Yc9cpLSVxHpBIa1TDSXpkCVXuYT9LYoNUpi8YQ== X-Received: by 2002:a05:6512:acb:b0:52f:cad0:2d4a with SMTP id 2adb3069b0e04-53215031142mr696682e87.9.1723544446585; Tue, 13 Aug 2024 03:20:46 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:46 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 5/6] media: i2c: og01a1b: Add management of optional reset GPIO Date: Tue, 13 Aug 2024 13:20:34 +0300 Message-ID: <20240813102035.1763559-6-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index 766740bd04c1..90a68201f43f 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; @@ -981,6 +983,9 @@ static int og01a1b_power_on(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct og01a1b *og01a1b = to_og01a1b(sd); + gpiod_set_value_cansleep(og01a1b->reset_gpio, 0); + usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); + return clk_prepare_enable(og01a1b->xvclk); } @@ -991,6 +996,8 @@ static int og01a1b_power_off(struct device *dev) clk_disable_unprepare(og01a1b->xvclk); + gpiod_set_value_cansleep(og01a1b->reset_gpio, 1); + return 0; } @@ -1031,6 +1038,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) From patchwork Tue Aug 13 10:20:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 819922 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 EFC96194C73 for ; Tue, 13 Aug 2024 10:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544451; cv=none; b=lQ+DwsldcOUdJ0TCq4Gj5inCL465YYsDxrgImPqIzCXQUOcDJWMswp0f+Fs0KBTdSn3XPvgJVvGbmUs5/beZPfava4yAeYq7Ki2vSt0WVuP3v2gdK9JNvkbXHWHkb88M9nr+SehgyKFbTMuv5FvoTrOpv4MGYiQ4GlaZDd3r7AA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723544451; c=relaxed/simple; bh=ptI+1cnf+u4VBn9bOwvEfCwCXmKV4oBoAMfSgsrVIoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QEUGOQsMykW/mkydA9+ULPlAwayj94kLzZ7bBdkSMznLozWcPBmtTVuathqaOAd5FXQQBD3dewm4y6TywV5hKN6yc8ioUoBxers2KzI4DGFiUp9ewBgBfLh+lOPHzFbcC/ji/Ijly+qKM2oMpL70Wd9mlNMFcThmPTEcx6YukUo= 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=LEPjag7e; arc=none smtp.client-ip=209.85.167.53 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="LEPjag7e" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52f015ea784so849915e87.1 for ; Tue, 13 Aug 2024 03:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723544448; x=1724149248; 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=x1GjYwT1PAjue3OAqw3OwrRMNr28kZG4xX7v3BOKWZ4=; b=LEPjag7emQgVZh7UYizmZr03diKcgtEJ1gHERPu9hDb7PCHLpbpGq9aVcH/pQ7nDXY zsEt/acBfTrr5Fsi0wvK+ZSxaneQJjs0tijJb9XwmvYUgrDCsBv7gnD0Woj2cyb2Qwfx XJtgUaxK7HNiQ6fP/uvqyft3MpdNXa90UDR3HfP0354wRnj/MpPNgSX4io9bQX7dU/11 KowqHaPKd66eeA3rJCG2tYr0Ux5wOx3RBbJzedeLS/5YqVOB5GKLfqpQOFJmNbNTXO0/ zVmM/ttTdwda3I5mU6seVCa72DV3WDG7qH5moWCDky1VP5pegZNf1LthL+2mRjNn0ik2 1YSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723544448; x=1724149248; 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=x1GjYwT1PAjue3OAqw3OwrRMNr28kZG4xX7v3BOKWZ4=; b=l+2GST5r5DIGwePqouWjg1PC5TTqcbhFyIE5M6PftTa5R9kufNCFfdWs0csE0W3ctG T2Mu2cXGOcOFAhGkuZuP8QNPBhTnVL1P7w09MTq/QZeqnOv434mRK6AH0Q7iyg/lIa80 7KuznqH6s9gPBtRU1UIvfNzjWbg6zlgF+dNZcb8y9MKndLPNhe6nD8xsm0YXfLPnEZ4y hRojEd4z7zdLjoIj+RE1tEpCvkoF/FpQYrMd3ABrVgbpFBizaLSrDq/tLT0y4prVBMUK zVlOx2QHg+O4/hiJEZLP1peNpEbsjpCnssfuahNPFk2GN5wvEFw4xw4U/I8vHjNTPsqP 2okA== X-Forwarded-Encrypted: i=1; AJvYcCXBn8bbwqc0YcYNGNoUCOaNAdlRBucRToRrf856RMwj02Jq54nUXqn5XEyA7CSQ/GBpz4rMjn+hwDb4mmRzz31Iv14meOG+ZCBuLJU= X-Gm-Message-State: AOJu0YxTqg1/M9n9w0QIQQqBDROxFx3FwtBeXeDjhBnH3jtEYzrUPDDN ejwk2cGzM/J6IOPKnIhCyuIeJ4/T6a4lVK8hOA7KLAtPtbDb0uAJWqLYyD6pl+A= X-Google-Smtp-Source: AGHT+IEpQaqLGz7U6Da0y6hc4YcA3+PMH+jf2GZAO7uQ5ABFL5HDJvQPqGBMGfQZ84FsK4To9SrDIQ== X-Received: by 2002:a05:6512:1589:b0:52e:fd7c:8b9b with SMTP id 2adb3069b0e04-5321502b50fmr791566e87.7.1723544448067; Tue, 13 Aug 2024 03:20:48 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53200eb3ca5sm965917e87.55.2024.08.13.03.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 03:20:47 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab , Krzysztof Kozlowski Cc: Rob Herring , Conor Dooley , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 6/6] media: i2c: og01a1b: Add management of optional sensor supply lines Date: Tue, 13 Aug 2024 13:20:35 +0300 Message-ID: <20240813102035.1763559-7-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240813102035.1763559-1-vladimir.zapolskiy@linaro.org> References: <20240813102035.1763559-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 is supplied by tree power rails, if supplies are present as device properties, include them into sensor power up sequence. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 86 ++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index 90a68201f43f..0150fdd2f424 100644 --- a/drivers/media/i2c/og01a1b.c +++ b/drivers/media/i2c/og01a1b.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -422,6 +423,9 @@ static const struct og01a1b_mode supported_modes[] = { struct og01a1b { struct clk *xvclk; struct gpio_desc *reset_gpio; + struct regulator *avdd; + struct regulator *dovdd; + struct regulator *dvdd; struct v4l2_subdev sd; struct media_pad pad; @@ -982,11 +986,46 @@ static int og01a1b_power_on(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct og01a1b *og01a1b = to_og01a1b(sd); + int ret; + + if (og01a1b->avdd) { + ret = regulator_enable(og01a1b->avdd); + if (ret) + return ret; + } + + if (og01a1b->dovdd) { + ret = regulator_enable(og01a1b->dovdd); + if (ret) + goto avdd_disable; + } + + if (og01a1b->dvdd) { + ret = regulator_enable(og01a1b->dvdd); + if (ret) + goto dovdd_disable; + } gpiod_set_value_cansleep(og01a1b->reset_gpio, 0); usleep_range(USEC_PER_MSEC, 2 * USEC_PER_MSEC); - return clk_prepare_enable(og01a1b->xvclk); + ret = clk_prepare_enable(og01a1b->xvclk); + if (ret) + goto dvdd_disable; + + return 0; + +dvdd_disable: + if (og01a1b->dvdd) + regulator_disable(og01a1b->dvdd); +dovdd_disable: + if (og01a1b->dovdd) + regulator_disable(og01a1b->dovdd); +avdd_disable: + if (og01a1b->avdd) + regulator_disable(og01a1b->avdd); + + return ret; } static int og01a1b_power_off(struct device *dev) @@ -998,6 +1037,15 @@ static int og01a1b_power_off(struct device *dev) gpiod_set_value_cansleep(og01a1b->reset_gpio, 1); + if (og01a1b->dvdd) + regulator_disable(og01a1b->dvdd); + + if (og01a1b->dovdd) + regulator_disable(og01a1b->dovdd); + + if (og01a1b->avdd) + regulator_disable(og01a1b->avdd); + return 0; } @@ -1045,6 +1093,42 @@ static int og01a1b_probe(struct i2c_client *client) return PTR_ERR(og01a1b->reset_gpio); } + og01a1b->avdd = devm_regulator_get_optional(&client->dev, "avdd"); + if (IS_ERR(og01a1b->avdd)) { + ret = PTR_ERR(og01a1b->avdd); + if (ret != -ENODEV) { + dev_err_probe(&client->dev, ret, + "Failed to get 'avdd' regulator\n"); + return ret; + } + + og01a1b->avdd = NULL; + } + + og01a1b->dovdd = devm_regulator_get_optional(&client->dev, "dovdd"); + if (IS_ERR(og01a1b->dovdd)) { + ret = PTR_ERR(og01a1b->dovdd); + if (ret != -ENODEV) { + dev_err_probe(&client->dev, ret, + "Failed to get 'dovdd' regulator\n"); + return ret; + } + + og01a1b->dovdd = NULL; + } + + og01a1b->dvdd = devm_regulator_get_optional(&client->dev, "dvdd"); + if (IS_ERR(og01a1b->dvdd)) { + ret = PTR_ERR(og01a1b->dvdd); + if (ret != -ENODEV) { + dev_err_probe(&client->dev, ret, + "Failed to get 'dvdd' regulator\n"); + return ret; + } + + og01a1b->dvdd = NULL; + } + /* The sensor must be powered on to read the CHIP_ID register */ ret = og01a1b_power_on(&client->dev); if (ret)