From patchwork Thu Jun 20 12:47:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13705353 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (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 BDB9C1ABCB2 for ; Thu, 20 Jun 2024 12:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887674; cv=none; b=jfxVn9LRQ1+RL61McAqYazmkPJxbv7ps1H0XE90nQPMWbe1hkSD5ELkQx1z+lfzEvmBSWxR0zVuFyX2Du+nD1uzb+sFdfn7tEz2rdjz0oAeyIcUZs/2/3iOeidNFMZIY3igokPvul4th9Zxvx/zE9fgknokYJJdZ/PPBnl6ZoQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887674; c=relaxed/simple; bh=P41aa7WDElOn4XJZBkUGownDE7+B+k/xhDJi2TpSQfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HLflfh23MdyTlypNSyp5I0HmPmfXTjs5PwxVibvtyZWVzl+m/FKIYe1+TKbg55pFydwY0Aymd2Ri/Kkp8y5LcwuHLgpGIyrsSA522llz7s08xyIFnxqAe9ukgL2jBH+35ZPhtl7t7ZEi8oiSNpLCfH3F/RvbYj0FU5g1nfFDt44= 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=k2W0HM1j; arc=none smtp.client-ip=209.85.208.193 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="k2W0HM1j" Received: by mail-lj1-f193.google.com with SMTP id 38308e7fff4ca-2ebf5987909so936051fa.0 for ; Thu, 20 Jun 2024 05:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718887671; x=1719492471; 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=/8u0U2kPrmfNx7ufbqQxQVsCfOifpaLBvfvEUHbGXwI=; b=k2W0HM1jtekAyEq+CwWXhtji0OIgS9o58PI4juVK2eU+nH6jiR/o8BLvUzogtXMX08 Fl76+EF3R04uLjf5p7LkQmNqvLs6xSkaZjf495Whuq4UBbNLFachakkJQEzLpiGwMJw6 ZYXR3CW8PqnjTv4nG1s32BeE6GxIfUo3+Wcm0w/Vf4sHoqI1tMIIZNypiE23WQSY8V8V 5JcdN6LO9aDfTU718boJBLMhR1L0i4cKJ+haDZ3zDcwDMiNe1KzStbPQXgx6UZpqRKJu Uj3+Whsj2eQuzO3nGjTDZemPGpR+h3l1Dyf9OW0Vny27Iw3LRtZEWarZYGX9yLEOE4N2 F7AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718887671; x=1719492471; 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=/8u0U2kPrmfNx7ufbqQxQVsCfOifpaLBvfvEUHbGXwI=; b=N6Z6XpyHhpfs8k3e2IBiSzO0eQF1pihNYszle052sur7aAkfrUXIEdyM7sGFAM3K4N UTYiXCGhDpGCm6WXAgxf7W6CNWGg2tDrNTKi9atms9+v4Rvb2BTaBC+i5rOSlNvGHBAK SMenzcJTJmxFvKyJ855paiAZY95k6K1pJkNkcCrJSEYK59/ODdaAU2EVjC0oECzN5k5b 92+ZCavEDk7Hx87gr1P3VaU9PiglPMEXxzNTODfvGC4kzTCUJpJi/wI8SAVQ3p2if8w8 I3bGkohBhFr2q/MBge5odGLMOFJqi67Lk6TKni2KuuOfh4cv7dAcHXykBU4vCR1UgjFM L22w== X-Forwarded-Encrypted: i=1; AJvYcCVff6BdZVETmPzp82LDRP+/sXTJs2dwkMQx8OJcCAwMpG6Dy/x8OFXU/1ealNhSyXLyEeHXcK2W5PY8wQHd9rWfe8Jng8KFrpK1WkA= X-Gm-Message-State: AOJu0Yz/OdLLGTGVbfTtIhLUYD8tIP0MQFGhKDY1B1iUuB1UGq2iW0vR dAO9MiQ/NvPMAp1ItyTmqwg2C1F/2KHHP1OWfBc5VEupsONop2KKuk/HaPMQMQQ= X-Google-Smtp-Source: AGHT+IE4KTRBYTjWtTkJ5PdDFsgGZk5wt6fJvBCyFqaRhLvhQ4C4Y1Ext0P0TROYuT2OfAiMyH6r+w== X-Received: by 2002:a05:651c:1255:b0:2ec:31d9:16e1 with SMTP id 38308e7fff4ca-2ec3cff8f63mr24714151fa.5.1718887671027; Thu, 20 Jun 2024 05:47:51 -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-2ec05c17ba8sm22421411fa.72.2024.06.20.05.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 05:47:50 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus Cc: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Mauro Carvalho Chehab , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/3] media: dt-bindings: Add description of OmniVision OG01A1B image sensor Date: Thu, 20 Jun 2024 15:47:43 +0300 Message-ID: <20240620124745.1265011-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620124745.1265011-1-vladimir.zapolskiy@linaro.org> References: <20240620124745.1265011-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 --- .../bindings/media/i2c/ovti,og01a1b.yaml | 108 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 109 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..5f4c9c4c1ee5 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/ovti,og01a1b.yaml @@ -0,0 +1,108 @@ +# 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: + description: External clock connected to the sensor system clock. + maxItems: 1 + + clock-frequency: + description: Frequency of the external clock to the sensor in Hz. + + reset-gpios: + description: Active low signal GPIO to control sensor. + maxItems: 1 + + strobe-gpios: + description: GPIO connected to the sensor strobe pad. + 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 + + link-frequencies: true + + required: + - data-lanes + +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 d6c90161c7bf..eff16776a287 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16509,6 +16509,7 @@ OMNIVISION OG01A1B SENSOR DRIVER M: Sakari Ailus L: linux-media@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/media/i2c/og01a1b.yaml F: drivers/media/i2c/og01a1b.c OMNIVISION OV01A10 SENSOR DRIVER From patchwork Thu Jun 20 12:47:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13705354 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 0583C1AC789 for ; Thu, 20 Jun 2024 12:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887675; cv=none; b=fms8AagA0khkpQpIpYhBmCSicvuzW9a2hy5vXocqg5SqMy18aZRfp/sKAVBujpZFAbU3NWV5Gd0twwpR+yyH8yIShgySH3geahnWy6FHYRM/+40oIV6HqUiE49Kme9uFzF0PziAV0+FC/EX8kJTtU+aS7mVxUgdPWiZzNbCFf5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887675; c=relaxed/simple; bh=dHPvVFMF9oE/Smq/fAVh/jP8Xok6qZTN+5FpM5SDwrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p0m9zIwscHLhaMMQXfvBPPXqyL0w0ur3yWG02W83be/GBJsT195I2aAUkw/LngegDZprlHGEC+unu7ss+JWEIRqbYd3BhaGR7r4O1230AA1W19rZRCKJtY+Be8nr2ZgCpebXtWZ8PCFftyO3uEX/7R86MQ7WdWdGWoA58NjBtwQ= 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=d6Cc2p/i; arc=none smtp.client-ip=209.85.208.175 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="d6Cc2p/i" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2ec3b282fedso702091fa.3 for ; Thu, 20 Jun 2024 05:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718887672; x=1719492472; 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=d6Cc2p/iP2FjdNIjRf/TnML0rpH1+uaIwDWdKYqTZVgK4F3Q8fqY1fChT2QoeUnACJ P73Vuwx5jeDBpZEUoxLTVEMmkv02/AmQwvNYY5Pv3r6n4p+H9LJ9EA4ryhT2vtRUMshU zZfsOnoezT8ZphsFnmrY7MBXSp/yeq44n/pfqgEGIWh2IPV31/le7JTp+6C2+024YpbD 4xBa97a9BNbIFB+8jx0107buO2fsAlYOuLdWKasbm4Ij4V9EUN4AkHdPEs8CcAGa5jeX utM63aMLi5OHoe+Y5T1bUmCKgmLGsP9KTGdP2K/e4q2tv4aNMM1n9/MXxtXx7R3v7u8P j9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718887672; x=1719492472; 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=GVeJQsM7cn/miUivfyofaUaQHfExbQVONEOVw2QcKSOZAzNCGhycoUHxOAz/NQ4lqv LZUtFD7dyfvCReU8d/S7aH+iIXYYBMW7hSIdU4yImbYVw/3+wvefG31npkF+AX3lBmLg 5D0Yr1230nXKeGHsrY/3ubiDVGUMAqAsL2x6ZOMSagtfwCUBg69Hf68TIlMOWvK8Sobt z/XTDvsPtEyKAKQusatvV/myBUhRh5tmXajUGnbDgw8n7kZOKlepf7JF85viIIyApEYM n92liKEixW3PEnDPwvSyImas0lxCWxi/84cV/Hz2z55dvBB2kn+xtJQQazW2Mj4fQXsh GGZQ== X-Forwarded-Encrypted: i=1; AJvYcCWQJmHziIBJ8HbVROXFmQzod3d2L71cp3VOYbftlV8SYtiaH4Sb0bUNQCqv6hF9hSUW3rL+g5flHoAkGaWG/2w5lVQPeUhM004WIB8= X-Gm-Message-State: AOJu0YwgLyePTYi6V9zk4XVjiSIjHkvZPSaEA8yy9hOxQhGyYy2q3t4W Bi4Zd+QhoxQE1ztSQtaTIBKC9J0XIykXOpIicgd9676wHuNzT4nqPMSjX+wNYSQ= X-Google-Smtp-Source: AGHT+IEu3CNj3wxHw25qkYF3Hp7xRIet6vorYXgQz8TEQ32UIzaBUyMkVV7G19KsiyqkVCDvk17muA== X-Received: by 2002:a2e:9b57:0:b0:2ec:40d1:fb4 with SMTP id 38308e7fff4ca-2ec40d11208mr20518151fa.1.1718887672367; Thu, 20 Jun 2024 05:47:52 -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-2ec05c17ba8sm22421411fa.72.2024.06.20.05.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 05:47:51 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus Cc: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Mauro Carvalho Chehab , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/3] media: i2c: og01a1b: Add OF support to the image sensor driver Date: Thu, 20 Jun 2024 15:47:44 +0300 Message-ID: <20240620124745.1265011-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620124745.1265011-1-vladimir.zapolskiy@linaro.org> References: <20240620124745.1265011-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 Thu Jun 20 12:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 13705355 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 E525B1ACE61 for ; Thu, 20 Jun 2024 12:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887676; cv=none; b=oO4ZbSPrNl8Ccz8lgV03CbcIvOECOcJ0aGJGwRXFi9k97N/t1R8urweBQHpNQxfPt7fmM6M+Bi3NHHKP5KuHRgr7tR5ZAi5xAJD0mc7J8uen44AcS+/a/c9jxALxiGR0XxP9uVOKBygMt3cfBbW1VmOq/DMa51WUpxqqTZWQwmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718887676; c=relaxed/simple; bh=XrspX98ISckG3Sj6/BzKitPRpRn8XaSj2KqHKFT+dR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DjrOGD79mn1JOZoeh9uWksMlAsM21PV1yb0zMBrfwGhB6gA1pZR1ZoieFKnF8s7zh9+Q2OJOiNtXAchdzusAonmd4LU8SiaiSeQAGrDZOox/ex+gEgmxCTd9ba3Fcnktumu5RnM8IrGpVAfDwuSzwqQyQVgrPzHIJpGcU0CG2lI= 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=TShp/ttk; arc=none smtp.client-ip=209.85.208.172 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="TShp/ttk" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ec3432633dso931201fa.3 for ; Thu, 20 Jun 2024 05:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718887673; x=1719492473; 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=kU4UhCQc9+764HGn+BU4tW5vcAuXA5Pmyz8qsif4vWs=; b=TShp/ttkj6f+2k7sB5BAii9rHyo8IkuYGZLaoGQElxSvsNhcR7bv2ZmcFbGFhRXuX9 JTKg97w//PutvFYMRicsqFUI54AFvN9OiGBsBVmViHXL6k6QgtZIksa2i54fQL1OXSw2 m1MH6uwhVziExFNzHbywuvEJe/7XIhsA5To6dPpYG3UIf3Bi3ldq3R5qlruXpoABw5mj FuxHcWryuOObRUFkR7Xn3Ch7NUxbHqBsXPHsWVD+pg4Qw+kufNKv1oS6Vx2OrJDWQxTd 26IELgTp3pkJPQGBuZ/1mhRZdS17EXQde6uKFyaRix7GWmw6WkT/o9WhhHKg4NW4ieJj L8Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718887673; x=1719492473; 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=kU4UhCQc9+764HGn+BU4tW5vcAuXA5Pmyz8qsif4vWs=; b=hDuwds1w52S4sb5dMdWc49lkHcRz4cELKRgZNi4U2H4oSRkmfbVK1wfi1O5uyb/mdh VEREKduDbe+yaXSoiJESptAfWYJcCkrufHt2EZnD4poocNW/9kd6acqvYwI1SS6bZI2n GfVdFKwTGUFJz32ztxyC2jMm7xG2Q0AfNm4qAHZgb0U0MO1/DxtjPRYtUeMxy23c/HxM ELoN12AiWhyCEVvRpan/XtZDZWWC9S3LKY/U5NVTDppSR6L4Syxb9/F53G23I2tihoFA 6UxZJIV03ZwVLwWFrkfPxZtcWLTTC9JFPgjvBXVSa4v+L3wuRmSANWFu5bKKtrurIjZv ZtwQ== X-Forwarded-Encrypted: i=1; AJvYcCXWdqCIzumOQYD5jk8O+wCTiZiLJWoav1BPIDiImv/VZLWJ0Bxnk7EbuVEUjm+RTkWyKAQCKIl+G+k6UJxsdBtNe7ApO45z+3XsuQQ= X-Gm-Message-State: AOJu0YwE0IcNpUqyITI+X/0OrNVCG7SA8v2GgMjYV6omKsqlYTlsjkaO Oi0dlMJ0O4Jty/9SatSmkK/S/iJomZdppTVCXbxpEmyA2+oMrGAPlGRolhEsz/o= X-Google-Smtp-Source: AGHT+IE2pOh2daHEILK+6XHiitvdvq9yF5/zOOktvf9tbV6nGyW3jjGwlRafV2mntrPBpgXDbVkYMg== X-Received: by 2002:a2e:a553:0:b0:2ec:ca8:4897 with SMTP id 38308e7fff4ca-2ec3cfe83camr37809031fa.4.1718887673146; Thu, 20 Jun 2024 05:47:53 -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-2ec05c17ba8sm22421411fa.72.2024.06.20.05.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 05:47:52 -0700 (PDT) From: Vladimir Zapolskiy To: Sakari Ailus Cc: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Mauro Carvalho Chehab , linux-media@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/3] media: i2c: og01a1b: Add support of an input system clock Date: Thu, 20 Jun 2024 15:47:45 +0300 Message-ID: <20240620124745.1265011-4-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240620124745.1265011-1-vladimir.zapolskiy@linaro.org> References: <20240620124745.1265011-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 To be properly configured at probe time the sensor module contains a required reference to xvclk clock on OF platforms, which is now enabled on probe and checked for a supported frequency rate. Signed-off-by: Vladimir Zapolskiy --- drivers/media/i2c/og01a1b.c | 43 +++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/og01a1b.c b/drivers/media/i2c/og01a1b.c index 9e756c1c47df..929a7e32bd6a 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,9 @@ static const struct og01a1b_mode supported_modes[] = { }; struct og01a1b { + struct device *dev; + struct clk *xvclk; + struct v4l2_subdev sd; struct media_pad pad; struct v4l2_ctrl_handler ctrl_handler; @@ -898,8 +902,9 @@ 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 device *dev = og01a1b->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) { @@ -977,6 +985,7 @@ static void og01a1b_remove(struct i2c_client *client) v4l2_ctrl_handler_free(sd->ctrl_handler); pm_runtime_disable(&client->dev); mutex_destroy(&og01a1b->mutex); + clk_disable_unprepare(og01a1b->xvclk); } static int og01a1b_probe(struct i2c_client *client) @@ -984,22 +993,35 @@ static int og01a1b_probe(struct i2c_client *client) struct og01a1b *og01a1b; int ret; - ret = og01a1b_check_hwcfg(&client->dev); + og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL); + if (!og01a1b) + return -ENOMEM; + + og01a1b->dev = &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 clock: %d\n", ret); + return ret; + } + + ret = og01a1b_check_hwcfg(og01a1b); if (ret) { dev_err(&client->dev, "failed to check HW configuration: %d", ret); return ret; } - og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL); - if (!og01a1b) - return -ENOMEM; + ret = clk_prepare_enable(og01a1b->xvclk); + 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 disable_clk; } mutex_init(&og01a1b->mutex); @@ -1045,6 +1067,9 @@ static int og01a1b_probe(struct i2c_client *client) v4l2_ctrl_handler_free(og01a1b->sd.ctrl_handler); mutex_destroy(&og01a1b->mutex); +disable_clk: + clk_disable_unprepare(og01a1b->xvclk); + return ret; }