From patchwork Fri Aug 23 10:27:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13774936 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 2293C1607AA for ; Fri, 23 Aug 2024 10:27:41 +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=1724408864; cv=none; b=ltd6eKuMzaBWdogbN8ZHoq/23unpAW+nt1pUdKwxYWWbX+9yAUJuXcRI2hDxgpBNzeiBIka6x2wgD4I7qLq+xsoT5I88LAnX8z1xZjOb92g5mf5phKpoBjPeLeWm8AlEnHjUp75JYylFoD0ftoOKZWBSELDy1Hb43N+adHa823U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408864; c=relaxed/simple; bh=7jtO45iwJAAgfmHOZWPXSXPTcsdPCcn8YU4bEjvnJpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C93CkfYahkxoFp4H+aFc7+U3FZcPW/dXh3HFUEx4tFm8TrHWvM10QZPAH4305fgYlJkx2FzE8wop7/eekAzSMHUgFVJGW9qcWOo4l8dHbcNKSQ0bNFfvX39kxdrT0aQVNyn3JnDgUngDKNKuAREDateKsCNbTWKjIkBg9pF4lQ4= 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=uU+MzmJw; 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="uU+MzmJw" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2f402830d19so2961811fa.0 for ; Fri, 23 Aug 2024 03:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408859; x=1725013659; 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=FZqDlZ0/ZGM06KWmfesFZAE+M+CUqOBy+QMXwudGFcY=; b=uU+MzmJwuyPmI+Wxqt4z1vwKdCwrlEU8gT3awvMNMGm5tcoBKepqV4+aP18FQIqg/s j91jeViQUhVss9oKdnjvzkIFT9oTxIfCqdv2J6+KWXmkJz/tkqV9kK1Uon1WayIDzAts p6uO/NQtrUrf4d2dmMtRd4BJLrIG9WgYLvvh9h5yFI+kR06Ldol+0yhpGUhuZQibTRCF y43o9U5BfkmH4upUHgw6PUMnssKNxJppRbI/x2PVX3uwbtvjDmzUsHZsFQrc0oDaOZ2U 7Tl6NV8px+2OsTZJVVOKSuVhg4l/a8zk+aOXOUx/oqIfNjIeY3fjhGHpeS/0sXvmPDR1 6nBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408859; x=1725013659; 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=FZqDlZ0/ZGM06KWmfesFZAE+M+CUqOBy+QMXwudGFcY=; b=UCdAjuYxJATSTNiYVwQ6sraCi1s+bL+tFfd2udDpppjSbMrNV8a1cS/cDaI0p79KZt /d+zlYRCbV1+BTu4ohVUHvaCbv+gCaQ+A+RS1C9F603rzjZUxfVRcpt/HDBtZpOOP1e4 MJBQU7YoHicAkfBkfGYhatK/4hEY+ADvQOsfGzfZQI9MVIBjVDw3d5p3CZ3amRdKiOlP pI7sb8L9SrzUrWK8VG4UyM5+opOHjhYIsN1Klwpu2340m+R0a2nE71Ra6qZKJDvKTyLF LNB8i0+X+0Efz08u+GHTNpbx4SatA3q19G2BKE2zLfPFdGdy0UR4eSgQQrTOPc5pysn9 uXKg== X-Forwarded-Encrypted: i=1; AJvYcCWLD7aQ4rmR/3B7IbEYRDT+muQD8gfi94USvvMS1SZbo4dWdfYL8odGn3VAE+OOgl1b+g0JjY3bGSn0XA==@vger.kernel.org X-Gm-Message-State: AOJu0YzDbMs5wYL3b1gj3rFv5JriW+HDvQQEXYxzqVBl84/qFVaBI1Ir RTnuda1du3ZPWaWVAsLe0J9D+9GgdQkz+rjDFdyG0rp2wF4WkTI515tCT5Cg16I= X-Google-Smtp-Source: AGHT+IGnbSm5104EwX1aNcAsLt0GTw54/sEIe6+bmsLuIXLRM2An5z1lDSzxzykfIyFwaEGEvPWisQ== X-Received: by 2002:a05:6512:2814:b0:52e:ccf5:7c3e with SMTP id 2adb3069b0e04-534387be271mr563339e87.7.1724408859253; Fri, 23 Aug 2024 03:27:39 -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-5334ea5d220sm504669e87.183.2024.08.23.03.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:38 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org, Conor Dooley Subject: [PATCH v3 1/6] media: dt-bindings: Add OmniVision OG01A1B image sensor Date: Fri, 23 Aug 2024 13:27:26 +0300 Message-ID: <20240823102731.2240857-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 8766f3e5e87e..10d3c510314b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16792,6 +16792,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 23 10:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13774935 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 24017165EFC for ; Fri, 23 Aug 2024 10:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408863; cv=none; b=BLm4rOMCkjKbZvCrUkNkd2pPo9TxPnMpydlrGrSEBkkmw9u/e2Z/C1xx5fJfm+H1jUs9j0t7qZelFbPD1QkPgjQcudyXafk26g/qTGwS2PGc5Zpaz3sjRKCxY1lzbbqlbQQ3lRdYyeUrGNXAFMPn/WMFWNw1BGDVvnJlNKIysmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408863; c=relaxed/simple; bh=dHPvVFMF9oE/Smq/fAVh/jP8Xok6qZTN+5FpM5SDwrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MAhogYlni2WcdObQCDwef8zZCBuq3sTxaER5SqDX+0eYSO+DysAKpOA7ADN7YYAK612iOZ11C/VBAVJE7jpRiQznmo05w8fyN/sg6Y/tWG3JcPvGzppJrYNRCPR/6OSEgB8BlUPNcVCO5XSIGOxUnMAfjHqmoWMQZE/fATG3Pys= 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=wPjXe/Fa; arc=none smtp.client-ip=209.85.167.47 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="wPjXe/Fa" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5334b61b6beso345977e87.3 for ; Fri, 23 Aug 2024 03:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408860; x=1725013660; 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=wPjXe/FaO0xZhYY+jx1aJZHM9BCjg78ZG8d89tcJ4JF1cIIa/NKxr4Cuw4a4DS1+2f lafev4PRW4iOeAdKRNUyEEP5yPcmwsPg9/fTaLqf2WojpDOm6noANbzks4topXcyRicP kTUcsYzs5PkyWhGvDpjfG5jaoOK0h1JrlGPFLKmIvhy9Vu/AHMZcduqx7g9T9AAJzf6B GXVA2iDW2kLw4n2DGEfgT49rOkqxcMASXep/EZ7wgjQylUV7QYFficy9XoIiAxaI5Tk8 oix6Op5syPbeCYC7B0WoMHLc0Hm8NrzSH0IFdi5Qk+FYoyq/XkTpJhwWCNOHmFy34YKR apBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408860; x=1725013660; 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=JaG5WSVSGSgFQ7v0pDSYbId7yF+c1Hn2BZis9XBcDh0OptoUglM2AhIIdkFw7xpMbC x2liNrm5EWljT6L9/TY350eDamUjgEH/Wzv+a74HqrSoxRYhUj0gzGac2YdJD7ApF+P1 pLoUFjIQcuL4tPYtC/SXGv3Ac3XSPb6CCqj6hL6K0VhfgjDTVa/Q0VkME+nOdrv1uHjX lgvqfCl26vQCzqiJGSQ2YFFRCRUIYAcDNhaIky6en/u824n5K7s7jXD/CL9ZTLXXzq8b qc8opROs6c8U84tBzVkgUm4MeXnPUOmOjKGqc5nYIioNZW0iB9Bs1Xz/MLKXtbtnGzYz fbTA== X-Forwarded-Encrypted: i=1; AJvYcCUuAAKbyng+1zv96SWMJTRuOTzVjKcRclCafIB9cmClDBtm9316toh/N2LdKE1blcLEai1ghCIgjiMRGg==@vger.kernel.org X-Gm-Message-State: AOJu0YwM9ZdM8dPm3t06fGBVZ9qlQ7G2PQ+2KF20tiwlG/M21OVBv3S0 Iz+DkkAPVNsyo9h4vKOEAesdFWbKGpylcCR0Y/+oyLdEK6l/hRzRQxXb8piy+cg= X-Google-Smtp-Source: AGHT+IHj6u1YSXOraviPtV63DYC7MbZqPcUgArDQQsE+WD3jUawG7j23x9GYsLGIIsYZQuTzoNAQwg== X-Received: by 2002:a05:6512:2391:b0:530:baec:3975 with SMTP id 2adb3069b0e04-53438757440mr731455e87.1.1724408860163; Fri, 23 Aug 2024 03:27:40 -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-5334ea5d220sm504669e87.183.2024.08.23.03.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:39 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org Subject: [PATCH v3 2/6] media: i2c: og01a1b: Add OF support to the image sensor driver Date: Fri, 23 Aug 2024 13:27:27 +0300 Message-ID: <20240823102731.2240857-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 Fri Aug 23 10:27:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13774937 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 EC6301474D7 for ; Fri, 23 Aug 2024 10:27:42 +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=1724408864; cv=none; b=Smoynq4A5otJH0uTa3twW+1OY0xnpfNzhQ83brJDaabLCiuwtokARZVTm0+qFdDzvek8Gqmgf2bmtvMPpDcixVwXsxZshB2PoeG0bxU3Kpg60GTBJW7hKyCQTT3W/NkY9dXi7jES2fxpBZW3DZggi6I5DkHngbr0xZWcRcN+TU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408864; c=relaxed/simple; bh=kIV0F91IXvXUKzpvDFHxNVojmJGwADBZn1C2iDFr0hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bHt8EpxXivK8Ek6x7KqSGtotaOI4TAhObUP2VxG2zmCHSd49P/4YnyrC2wpzG7yH29PYfsfdKNzFe/0tEk4RVnVcecvA3Ce4IFInGiKBMSQIXW2PuW3ptchyE/4Bm1lHR4KA8RPt30H4+YhtyBaP/YXdi9Mj5on91w+ZFmBnW/k= 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=J1Dx9/G4; 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="J1Dx9/G4" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52ef9714673so330596e87.0 for ; Fri, 23 Aug 2024 03:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408861; x=1725013661; 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=J1Dx9/G4Vo9+18g3Bpf8FeHy2YGgEIPKpn44Z4okFue3o+uoOSkqyR9X8XGcdhcX+x IMZlbNV14rtW7bXdO4UgAq/ZYVFZ/iYF1c2hMXbCaChuNkr51xcg07LB4GstTisl9FGJ 9B7vVBjBZyFAPlBGhV4u6tK2EtxUYKRhMOX4lE7gQ51EML+q3GggiDTD20A7QlZIVXPr mUpSaK9L4S3XcdB5Ju9V0X5WdCWM7KxXxsFu+akQbT7inF66++/tZSoYL+08PskIuPLg KlLvpJkfTY+bhMp9ZvhRwnLDu8acAT/AiMqK5eTlysSjdBB6wCY32Eyo2uBESXmjJ7iB R5gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408861; x=1725013661; 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=k87S8OXIb8AWJplavOUMlA/SvluqRqddOI2kz134Qp19Qc+R425vN2W1dN/1nDRvo9 +hx7wqfZpE0su9RjKtkfZrPNwSpcIXhuHeaFOedGqHIOK3wB3FJ+VQXAm/GRgNz+tV9m RXk6DA+hclw3K1lYIH7kEcRSxbtZow1xajdzl2Ss5in2ftRnBZ1iB0GI26AljU+U2O/X vPJ5zq0Awbl7/hztTjMmbkPr2f/IRzRMPQ5BvBZDqqxxQAuTWS5v6S6fwS1vdcjDDHe7 J7cEJSa0JL5HFWeW6wpwIRCAt0vy2gUd5uOFQ4IUs6TOH0MCGmkNn2iBIuFje17eVA+q MQdQ== X-Forwarded-Encrypted: i=1; AJvYcCWPdcXj03cJTI2/ji0zxPJWy6PPtDJ0vZiaEfyXbNSgUHcpo8aXEWZ6SafButB/wUdT9ju463A9zwL2gg==@vger.kernel.org X-Gm-Message-State: AOJu0YxCSckt15m0PnQGDO+c2sOaC92DX0Z+NyiPvIBxR1M6mWaDUQtz Wag9gvW2mSXgSGpHGahbTfe6ALNAJzSv+U3NgByDe5+3qgWmsjxgKhBqdgCveuY= X-Google-Smtp-Source: AGHT+IH4TL1ZXoDhWNLr+Lh/z+iV+vwHBgCcEZuSIqYsOPCqcsvImsC++yuqxqyQwfIhLByC2nXQNA== X-Received: by 2002:a05:6512:10c6:b0:52e:fd7c:8b9b with SMTP id 2adb3069b0e04-534387bf0c6mr647460e87.7.1724408860912; Fri, 23 Aug 2024 03:27:40 -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-5334ea5d220sm504669e87.183.2024.08.23.03.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:40 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org Subject: [PATCH v3 3/6] media: i2c: og01a1b: Add stubs of runtime power management functions Date: Fri, 23 Aug 2024 13:27:28 +0300 Message-ID: <20240823102731.2240857-4-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 23 10:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13774938 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 B02D217C7DC for ; Fri, 23 Aug 2024 10:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408865; cv=none; b=tYe71o/6ZWksvaoRg0ktK3AIR27/d95ZgflzeOO0V7UZbyg4LPEW82g9Bfob7AgDUkHfC0B2N830sLZgtE4rWGW3tC+hNwhSgPfMrv34QK7Jiow6OgW1JsN++kFu5j81VdEiKjPIogp2QljTa/ni//PVbpQlbiqZCmVE7mhmcOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408865; c=relaxed/simple; bh=zFeRD1dubZTlUw2Tr8sTwatKL5cUhpCf5nRuXAjei3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4X7R9dy++h5+xGOF7QD+OQwQ8N7Rss2XAPgYxYxEtsR3/1GQ6TwT91o8YDfrBc12tNg26Q3Wf/oAbYy4AOCH8m0YdoZXDizmY0ZpzbJhBiORigL5Yis/acrD3OL2NLtwwhuBMryQMI+OopBIWN25GpjZTaUZ7u0nBccLpQqxrs= 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=LfBtpnFh; arc=none smtp.client-ip=209.85.208.179 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="LfBtpnFh" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f3f2b86b2dso2307871fa.3 for ; Fri, 23 Aug 2024 03:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408862; x=1725013662; 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=LfBtpnFhXuH5pcRlimFlDlCroKdycTP6yITicgAPCvojSVdlMEpc1lYMC5ubHGUNQW nfsRbajQAtldXrN5aYLigUeDobVQLH/fnzPHiCOPzuNv6W+kiSRjKj4/jASCXEYKqLv3 K2Fei6Agb2ntElCTHXbWsnX5MTKGNpqD0nvvM+Sbtfo35oRGLBPMvd8MHmfS/wNkRmPi 10ghUzWuXeWmMXS6WEMdduw/anyHv2JMXnt5Hdcdyn9o6ptBhSnJIE1mVnG2ljrz8/Mm hXuIni5nqZ0Tgee7rwDpSp0RlW7kL8HP5F6nngeVAVB/ldudhbD0ItnWK7xDLBnjiaKb u3Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408862; x=1725013662; 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=U9njE70+yFmRNxmjMvKH/zlp/HtXb1ha2nc08nh5eWwzcrAh+ug+a1Y/D9adZ9oVtP PyyAK+Nf/tK/FiB+nXLW4y1H9urRFgB2oOfEQzgJUO0hbvJyRLY1buuv+/8Ev7CFvhF0 vbhosB8lRnA/ASFklBvZGbZg+nbqxTHoVYWXqYY91MzECDgOErwIGS4SnRtNWbpJ/NjR g/8KA0Zi78jbfM1uFL6Y98u74GDAvV2bPFzini76sVL6zqjBTdPoWJ5QVs2gDSs0DQwa qiX0CB1HmVKNnogwXfrhBncnSSQAi5bV5ZeI9YsfSIrfaGpuf6hj5fZtQr18sI2Frs68 6ecQ== X-Forwarded-Encrypted: i=1; AJvYcCWQmVRJG5c+kzZY0MFLxaTs9tS2+uoyQIKkQuzfZyUXbvUe0/9DMeAsHTlovjUiX9hqozRaxrcOgwVmDA==@vger.kernel.org X-Gm-Message-State: AOJu0YwVwSq/5JqCoMNsSWagaRi+2QjQOqe3qc1cUC3VpLRGWuhz1zWx pr9UH+1TUNS5PCxD1d15YTupIvf6HJG228rkV6AwTnYZvD24udAprR4cxjY65l8= X-Google-Smtp-Source: AGHT+IE+1+8eRFLGdhtll5p2rIecUHj9u7LHRyeW0jm+/ekgPTBRYJ8/dJcusYYe6NZl4x7efnvUlw== X-Received: by 2002:a05:6512:3e1b:b0:52f:c285:323d with SMTP id 2adb3069b0e04-534387bb090mr676570e87.5.1724408861821; Fri, 23 Aug 2024 03:27:41 -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-5334ea5d220sm504669e87.183.2024.08.23.03.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:41 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org Subject: [PATCH v3 4/6] media: i2c: og01a1b: Add support of xvclk supply clock in power management Date: Fri, 23 Aug 2024 13:27:29 +0300 Message-ID: <20240823102731.2240857-5-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 Fri Aug 23 10:27: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: 13774939 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 82F43185B62 for ; Fri, 23 Aug 2024 10:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408866; cv=none; b=bRjDw5g7N8vOK2E9OQZW7Nti5hFyLjUpuLlm4/c1VDLXEtGxucwixVFwlBYb4/2QQ1xJ012kHHdiOZX1UrVDH19aXg3fmQhcYMZt5b0eFsD1l7gQCDiodlVMs88H0zrLvGUhdiNXAf1ku8m2LV8RMmJWARFKLVOljMLt8r+pbyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408866; c=relaxed/simple; bh=GCZa41LBUHJwi/6V+Gjr/aZ/mKBaKvgPNKryTB40qo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ipf56Pw6JrBK4zFr1LN0wn1wYX2TtWKDlIRWhU7SyH3yPuTG5vR9qbhSQrX1LbSinK5Vc7BhEPIr0IcrokQMLXwxYci/q8iQTZEmpN7MAHUV7c9pjBHSj5kgZwFrJbkMAkuXeBM8g8fIi2nBHnz1WaB/J/lEW64SPTt4EW1LBGY= 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=LGvYAvPH; arc=none smtp.client-ip=209.85.208.174 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="LGvYAvPH" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2f402830d19so2961911fa.0 for ; Fri, 23 Aug 2024 03:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408863; x=1725013663; 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=LGvYAvPHeyNSh1NHzUq+TV3mH8bf5fgVwMqlMMJOlgOZI97+itDTLmlnXms2tZvD3j chIYqFz2V/j6EtgxclZakOHwZJJSHY6qsPsq2JNnvUyCayhte99ACiazwn2QCMuN557z kNwe+jxpaxMF2vjCPxteOHu0rkE1j1vs10GL6fYBk23gIOiKxW7JK2l1zNCpTdcaMeLv Ff1BCmHEpereXdsZGP4yMlmrQ7o0Y3BRNJgmQzHsjw8TlOXpbaLmymCB44lFILbIcXLQ FtmmAQ/1TmcRfITZQrwVHKj6jozumEHuCuTo/SxH8F40vl3xsBssR04h20NDJvdZOBi/ mCQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408863; x=1725013663; 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=vC0zcneFQsvS3+VhM/lERUuSBr0isNgoucqk+EeGQz4goKO3rhlqt9nyOGdepcNoCC tysmgpBj4uPHITw2XySDC7uUFYXuicHG0A4VNKDHwGNxdzkn48Y0BMl82+p3E4DRCpTC npY7O+G7uGaOzTAr34TL/DFTm1oL7oPAk0w8w7syuLz5bYXtvAZwhCK9CK7J+mbeHyI3 rdZXaXz1xjKaJ5If7ltJuczXGvPy4Amvpidd3C6LS9sxv5ZQg6kgpiT/pD/AjEDZNLf5 WIn46fBOxEf/6f64oPjoaxB1i3DHieLTOydLe9cd5xq5VgHZ/sviLnbn46Be1PLSpxBm PyPQ== X-Forwarded-Encrypted: i=1; AJvYcCVoB+4c1+dy6bvNUBBTUyGXHVK1tfVmVCIsbEzIIouvhmKXRJoB+0k6Gx0I7wbHQR9gGHDhwBATrkaMPw==@vger.kernel.org X-Gm-Message-State: AOJu0Yx2xA8ie+t22FYEX0a2I3wsb9zazlZcwHLtp24+CpOWwa1J7uJC /Vq5yuMkrqje0R6GGOF+/erRUgFkL8Vjg7u7lWFin3z+1JaX2yBFeuW4PTuDGsZ/Us+ojC3Q1Wm G4C0= X-Google-Smtp-Source: AGHT+IHi4gWkeo6N+GlWFmMIkV/0UQJbJ+PFkaW5dUMWp8wa2Fa+Ci8FiQc6/0jqjsd3e3DDPhkrOA== X-Received: by 2002:a05:6512:3ba7:b0:52e:9b87:2340 with SMTP id 2adb3069b0e04-534387be0d3mr640917e87.6.1724408862641; Fri, 23 Aug 2024 03:27: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-5334ea5d220sm504669e87.183.2024.08.23.03.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:42 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org Subject: [PATCH v3 5/6] media: i2c: og01a1b: Add management of optional reset GPIO Date: Fri, 23 Aug 2024 13:27:30 +0300 Message-ID: <20240823102731.2240857-6-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 Fri Aug 23 10:27: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: 13774940 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 8918C186E5D for ; Fri, 23 Aug 2024 10:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408867; cv=none; b=ix3dt8u1YyzbcqjxXlBWjiuRCG6wIytTbivQ8HnBYAONFNcWOYwg8L4HrN1kDySNWUWc3V+DRigTXzl4pSigKJwDrwgP1HP946Y7yjAgryFJWrgV+LnnGh0sf3OHj80zhRN+CNnWQFyfPj7qN8XJKo9DMTdAM6qt/rfokpQ0RI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724408867; c=relaxed/simple; bh=TLxSz++/7M97PUkNT2/Br7+oya34SVBySx4WaXTnWXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NVBU7WXqIb7CfyRv8JrzzjNMhvjk8basZVFzsCI2Q4JnfeqF5cwy/ldnB/WH66e4FSBj5lwJ3ZUHO6w2Jv4M1FZ2yuYQfhk152i6s0d5Nwyo09sdHqHxaFkMwwg7ubX9tb9kWPxEPXSyTuRKO7QW80jLRsEbgMbkzGBgdeqGf6E= 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=HoHmUX7t; arc=none smtp.client-ip=209.85.167.49 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="HoHmUX7t" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-53346424061so380187e87.2 for ; Fri, 23 Aug 2024 03:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724408863; x=1725013663; 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=fs0wiahdfO6Fz40mXpiMOeMkXjf8sxyUVit18FlZ5o4=; b=HoHmUX7toacGoEM/L9HFVRoWbImDEXbORG6baKGi3nWrwhpLvwUGwaF+uM97aZZDyq N3fh+oKjDiZ0j+a0BWogIs7chpBFEMBIIkS0Q9d4r86aJxu+TSsXdu0MoF8nMJI8jRjs +34YYi11DkzEf/x9lJNBGm//aJvTL1i3tq7fmrPMR3SuYGc7rPpknplt5PD9yBxq75tr fClKaWP3NJHRpbsPGL4nvID0ZNaOpAwhLLwgIUZ7r18gU+lkr1KjE/5NLxOldR0M0Cpf iNDZZS1Hiym+C7Y0Y5KfzAeS+XVM09sLzKsUrwiGbnK9+Tfu0GXqLgnGIiSj+4qBHo82 SBFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724408863; x=1725013663; 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=fs0wiahdfO6Fz40mXpiMOeMkXjf8sxyUVit18FlZ5o4=; b=WNdtNVE2hOAaKIcv2LqbJe+9K6g7CHJyH5z/Ytlskp0BVoDlhPKHvxBdsYNgdox7vg zJFtQxRj3D12YeqL4UQq1fkilYROZWO5D2Y2YyJBlq/By5m6w2Ai1e3CUE3SYmbpf0Wk 4m9PEZezA/+UNuvM8QRH8hc3k4LZm/NLFVim4w9CkPyUq/p1pqTso0bt/MV07m8zpsNa /rJuRyr4kISoqkMUcg0nTpyIyKk70l7Bimee4Mk0wveZdETsPAP6meBidPvbH6JoyKQh V0y/FGKmS9X/AVsD1ZWpPgDv/jrlrpa+3+xiA0NpU07awicTqPMZXiTcC+fsyPvjGwVI USQA== X-Forwarded-Encrypted: i=1; AJvYcCXxzTcEOVH9rLGqrkk0Tt3gSuxVh7fb+3Zuko3IHOtr86aM5fEkj4bVni3DnxrEbu7NV4flhiCsuKW7Ig==@vger.kernel.org X-Gm-Message-State: AOJu0YwGW5P9TLwru3Qcuf7/bUM2kDl5q8c5krnUAkxp8Y2OG+OqlpJD O9K9k0XCyv5qpSx/Lo103DaAXMCMVlmzjFuTxZoJo1pfTFqn3V14LlclgXcfoKw= X-Google-Smtp-Source: AGHT+IG1Ng+0IppKUCkwNvF7DM6tkj2HyfqHpfD5QWzj68seAvf1svSYrqh79zw+tkk3509heTNnlQ== X-Received: by 2002:a05:6512:b8d:b0:52e:ccf4:c222 with SMTP id 2adb3069b0e04-534387c4d10mr806570e87.9.1724408863470; Fri, 23 Aug 2024 03:27: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-5334ea5d220sm504669e87.183.2024.08.23.03.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 03:27:43 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus , Mauro Carvalho Chehab Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-media@vger.kernel.org Subject: [PATCH v3 6/6] media: i2c: og01a1b: Add management of optional sensor supply lines Date: Fri, 23 Aug 2024 13:27:31 +0300 Message-ID: <20240823102731.2240857-7-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240823102731.2240857-1-vladimir.zapolskiy@linaro.org> References: <20240823102731.2240857-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 three power rails, if supplies are present as device properties, include them into the 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)