linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Tsuchiya Yuto <kitakar@gmail.com>,
	Andy Shevchenko <andy@kernel.org>,
	Yury Luneff <yury.lunev@gmail.com>,
	Nable <nable.maininbox@googlemail.com>,
	andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH] media: atomisp: csi2-bridge: Add support for setting "clock-" and "link-frequencies" props
Date: Tue,  6 Jun 2023 15:31:36 +0200	[thread overview]
Message-ID: <20230606133136.23619-1-hdegoede@redhat.com> (raw)

Some standard v4l2 sensor drivers from drivers/media/i2c expect a
"clock-frequency" property on the device indicating the frequency
of the extclk for the sensor. Example of such drivers are the
ov2680 and ov5693 drivers.

The standard ov5693 sensor also expects a "link-frequencies" property.
Add support for setting both properties.

Note the "clock-frequency" prop is added before the "rotation" prop while
the "link-frequencies" are added at the end to match the ipu3 cio2-bridge
code from which this is derived.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/media/atomisp/pci/atomisp_csi2.h    | 13 +++++++++----
 .../staging/media/atomisp/pci/atomisp_csi2_bridge.c | 12 ++++++++++--
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2.h b/drivers/staging/media/atomisp/pci/atomisp_csi2.h
index b389ccda5e98..16ddb3ab2963 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_csi2.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_csi2.h
@@ -31,6 +31,7 @@
 #define CSI2_PADS_NUM		2
 
 #define CSI2_MAX_LANES		4
+#define CSI2_MAX_LINK_FREQS	3
 
 #define CSI2_MAX_ACPI_GPIOS	2u
 
@@ -64,10 +65,12 @@ enum atomisp_csi2_sensor_swnodes {
 };
 
 struct atomisp_csi2_property_names {
+	char clock_frequency[16];
 	char rotation[9];
 	char bus_type[9];
 	char data_lanes[11];
 	char remote_endpoint[16];
+	char link_frequencies[17];
 };
 
 struct atomisp_csi2_node_names {
@@ -79,6 +82,8 @@ struct atomisp_csi2_node_names {
 struct atomisp_csi2_sensor_config {
 	const char *hid;
 	int lanes;
+	int nr_link_freqs;
+	u64 link_freqs[CSI2_MAX_LINK_FREQS];
 };
 
 struct atomisp_csi2_sensor {
@@ -93,10 +98,10 @@ struct atomisp_csi2_sensor {
 	struct software_node swnodes[SWNODE_COUNT];
 	struct atomisp_csi2_node_names node_names;
 	struct atomisp_csi2_property_names prop_names;
-	/* "rotation" + terminating entry */
-	struct property_entry dev_properties[2];
-	/* "bus-type", "data-lanes", "remote-endpoint" + terminating entry */
-	struct property_entry ep_properties[4];
+	/* "clock-frequency", "rotation" + terminating entry */
+	struct property_entry dev_properties[3];
+	/* "bus-type", "data-lanes", "remote-endpoint" + "link-freq" + terminating entry */
+	struct property_entry ep_properties[5];
 	/* "data-lanes", "remote-endpoint" + terminating entry */
 	struct property_entry csi2_properties[3];
 	struct software_node_ref_args local_ref[1];
diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c b/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
index 28d8779bbbc4..0d12ba78d9c1 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c
@@ -85,7 +85,7 @@ static const guid_t atomisp_dsm_guid =
 
 /*
  * Extend this array with ACPI Hardware IDs of sensors known to be working
- * plus the number of links expected by their drivers.
+ * plus the default number of links + link-frequencies.
  *
  * Do not add an entry for a sensor that is not actually supported,
  * or which have not yet been converted to work without atomisp_gmin
@@ -492,10 +492,12 @@ static int atomisp_csi2_add_gpio_mappings(struct atomisp_csi2_sensor *sensor,
 }
 
 static const struct atomisp_csi2_property_names prop_names = {
+	.clock_frequency = "clock-frequency",
 	.rotation = "rotation",
 	.bus_type = "bus-type",
 	.data_lanes = "data-lanes",
 	.remote_endpoint = "remote-endpoint",
+	.link_frequencies = "link-frequencies",
 };
 
 static void atomisp_csi2_create_fwnode_properties(struct atomisp_csi2_sensor *sensor,
@@ -507,7 +509,9 @@ static void atomisp_csi2_create_fwnode_properties(struct atomisp_csi2_sensor *se
 	sensor->local_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_CSI2_ENDPOINT]);
 	sensor->remote_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_SENSOR_ENDPOINT]);
 
-	sensor->dev_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.rotation, 0);
+	sensor->dev_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.clock_frequency,
+						       PMC_CLK_RATE_19_2MHZ);
+	sensor->dev_properties[1] = PROPERTY_ENTRY_U32(sensor->prop_names.rotation, 0);
 
 	sensor->ep_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.bus_type,
 						      V4L2_FWNODE_BUS_TYPE_CSI2_DPHY);
@@ -516,6 +520,10 @@ static void atomisp_csi2_create_fwnode_properties(struct atomisp_csi2_sensor *se
 								sensor->lanes);
 	sensor->ep_properties[2] = PROPERTY_ENTRY_REF_ARRAY(sensor->prop_names.remote_endpoint,
 							    sensor->local_ref);
+	if (cfg->nr_link_freqs > 0)
+		sensor->ep_properties[3] =
+			PROPERTY_ENTRY_U64_ARRAY_LEN(sensor->prop_names.link_frequencies,
+						     cfg->link_freqs, cfg->nr_link_freqs);
 
 	sensor->csi2_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN(sensor->prop_names.data_lanes,
 								  bridge->data_lanes,
-- 
2.40.1


             reply	other threads:[~2023-06-06 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 13:31 Hans de Goede [this message]
2023-06-06 14:28 ` [PATCH] media: atomisp: csi2-bridge: Add support for setting "clock-" and "link-frequencies" props Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230606133136.23619-1-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andrey.i.trufanov@gmail.com \
    --cc=andy@kernel.org \
    --cc=fabioaiuto83@gmail.com \
    --cc=kitakar@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nable.maininbox@googlemail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yury.lunev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).