Skip to content

Commit f7c4873

Browse files
jwrdegoedemchehab
authored andcommitted
media: atomisp: csi2-bridge: Add support for setting "clock-" and "link-frequencies" props
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. Link: https://lore.kernel.org/r/20230606133136.23619-1-hdegoede@redhat.com Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 4f7d133 commit f7c4873

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

drivers/staging/media/atomisp/pci/atomisp_csi2.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define CSI2_PADS_NUM 2
3232

3333
#define CSI2_MAX_LANES 4
34+
#define CSI2_MAX_LINK_FREQS 3
3435

3536
#define CSI2_MAX_ACPI_GPIOS 2u
3637

@@ -64,10 +65,12 @@ enum atomisp_csi2_sensor_swnodes {
6465
};
6566

6667
struct atomisp_csi2_property_names {
68+
char clock_frequency[16];
6769
char rotation[9];
6870
char bus_type[9];
6971
char data_lanes[11];
7072
char remote_endpoint[16];
73+
char link_frequencies[17];
7174
};
7275

7376
struct atomisp_csi2_node_names {
@@ -79,6 +82,8 @@ struct atomisp_csi2_node_names {
7982
struct atomisp_csi2_sensor_config {
8083
const char *hid;
8184
int lanes;
85+
int nr_link_freqs;
86+
u64 link_freqs[CSI2_MAX_LINK_FREQS];
8287
};
8388

8489
struct atomisp_csi2_sensor {
@@ -93,10 +98,10 @@ struct atomisp_csi2_sensor {
9398
struct software_node swnodes[SWNODE_COUNT];
9499
struct atomisp_csi2_node_names node_names;
95100
struct atomisp_csi2_property_names prop_names;
96-
/* "rotation" + terminating entry */
97-
struct property_entry dev_properties[2];
98-
/* "bus-type", "data-lanes", "remote-endpoint" + terminating entry */
99-
struct property_entry ep_properties[4];
101+
/* "clock-frequency", "rotation" + terminating entry */
102+
struct property_entry dev_properties[3];
103+
/* "bus-type", "data-lanes", "remote-endpoint" + "link-freq" + terminating entry */
104+
struct property_entry ep_properties[5];
100105
/* "data-lanes", "remote-endpoint" + terminating entry */
101106
struct property_entry csi2_properties[3];
102107
struct software_node_ref_args local_ref[1];

drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static const guid_t atomisp_dsm_guid =
8585

8686
/*
8787
* Extend this array with ACPI Hardware IDs of sensors known to be working
88-
* plus the number of links expected by their drivers.
88+
* plus the default number of links + link-frequencies.
8989
*
9090
* Do not add an entry for a sensor that is not actually supported,
9191
* 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,
492492
}
493493

494494
static const struct atomisp_csi2_property_names prop_names = {
495+
.clock_frequency = "clock-frequency",
495496
.rotation = "rotation",
496497
.bus_type = "bus-type",
497498
.data_lanes = "data-lanes",
498499
.remote_endpoint = "remote-endpoint",
500+
.link_frequencies = "link-frequencies",
499501
};
500502

501503
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
507509
sensor->local_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_CSI2_ENDPOINT]);
508510
sensor->remote_ref[0] = SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_SENSOR_ENDPOINT]);
509511

510-
sensor->dev_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.rotation, 0);
512+
sensor->dev_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.clock_frequency,
513+
PMC_CLK_RATE_19_2MHZ);
514+
sensor->dev_properties[1] = PROPERTY_ENTRY_U32(sensor->prop_names.rotation, 0);
511515

512516
sensor->ep_properties[0] = PROPERTY_ENTRY_U32(sensor->prop_names.bus_type,
513517
V4L2_FWNODE_BUS_TYPE_CSI2_DPHY);
@@ -516,6 +520,10 @@ static void atomisp_csi2_create_fwnode_properties(struct atomisp_csi2_sensor *se
516520
sensor->lanes);
517521
sensor->ep_properties[2] = PROPERTY_ENTRY_REF_ARRAY(sensor->prop_names.remote_endpoint,
518522
sensor->local_ref);
523+
if (cfg->nr_link_freqs > 0)
524+
sensor->ep_properties[3] =
525+
PROPERTY_ENTRY_U64_ARRAY_LEN(sensor->prop_names.link_frequencies,
526+
cfg->link_freqs, cfg->nr_link_freqs);
519527

520528
sensor->csi2_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN(sensor->prop_names.data_lanes,
521529
bridge->data_lanes,

0 commit comments

Comments
 (0)