drivers/platform/x86/amd/Kconfig | 11 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 drivers/platform/x86/amd/amd_isp4.c
ISP device specific configuration is not available in ACPI. Add
swnode graph to configure the missing device properties for the
OV05C10 camera device supported on amdisp platform.
Add support to create i2c-client dynamically when amdisp i2c
adapter is available.
Co-developed-by: Benjamin Chan <benjamin.chan@amd.com>
Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
---
Changes v11 -> v12:
* Add missing space before the open parenthesis '('
drivers/platform/x86/amd/Kconfig | 11 ++
drivers/platform/x86/amd/Makefile | 1 +
drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++
3 files changed, 292 insertions(+)
create mode 100644 drivers/platform/x86/amd/amd_isp4.c
diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
index c3e086ea64fc..152a68a470e8 100644
--- a/drivers/platform/x86/amd/Kconfig
+++ b/drivers/platform/x86/amd/Kconfig
@@ -32,3 +32,14 @@ config AMD_WBRF
This mechanism will only be activated on platforms that advertise a
need for it.
+
+config AMD_ISP_PLATFORM
+ tristate "AMD ISP4 platform driver"
+ depends on I2C && X86_64 && ACPI
+ help
+ Platform driver for AMD platforms containing image signal processor
+ gen 4. Provides camera sensor module board information to allow
+ sensor and V4L drivers to work properly.
+
+ This driver can also be built as a module. If so, the module
+ will be called amd_isp4.
diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
index c6c40bdcbded..b0e284b5d497 100644
--- a/drivers/platform/x86/amd/Makefile
+++ b/drivers/platform/x86/amd/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/
obj-$(CONFIG_AMD_HSMP) += hsmp/
obj-$(CONFIG_AMD_PMF) += pmf/
obj-$(CONFIG_AMD_WBRF) += wbrf.o
+obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.o
diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
new file mode 100644
index 000000000000..1520ebb94507
--- /dev/null
+++ b/drivers/platform/x86/amd/amd_isp4.c
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AMD ISP platform driver for sensor i2-client instantiation
+ *
+ * Copyright 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/units.h>
+
+#define AMDISP_OV05C10_I2C_ADDR 0x10
+#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
+#define AMDISP_OV05C10_HID "OMNI5C10"
+#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
+#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
+
+/*
+ * AMD ISP platform definition to configure the device properties
+ * missing in the ACPI table.
+ */
+struct amdisp_platform {
+ struct i2c_board_info board_info;
+ struct notifier_block i2c_nb;
+ struct i2c_client *i2c_dev;
+ struct mutex lock; /* protects i2c client creation */
+};
+
+/* Top-level OV05C10 camera node property table */
+static const struct property_entry ov05c10_camera_props[] = {
+ PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
+ { }
+};
+
+/* Root AMD ISP OV05C10 camera node definition */
+static const struct software_node camera_node = {
+ .name = AMDISP_OV05C10_HID,
+ .properties = ov05c10_camera_props,
+};
+
+/*
+ * AMD ISP OV05C10 Ports node definition. No properties defined for
+ * ports node for OV05C10.
+ */
+static const struct software_node ports = {
+ .name = "ports",
+ .parent = &camera_node,
+};
+
+/*
+ * AMD ISP OV05C10 Port node definition. No properties defined for
+ * port node for OV05C10.
+ */
+static const struct software_node port_node = {
+ .name = "port@",
+ .parent = &ports,
+};
+
+/*
+ * Remote endpoint AMD ISP node definition. No properties defined for
+ * remote endpoint node for OV05C10.
+ */
+static const struct software_node remote_ep_isp_node = {
+ .name = AMDISP_OV05C10_REMOTE_EP_NAME,
+};
+
+/*
+ * Remote endpoint reference for isp node included in the
+ * OV05C10 endpoint.
+ */
+static const struct software_node_ref_args ov05c10_refs[] = {
+ SOFTWARE_NODE_REFERENCE(&remote_ep_isp_node),
+};
+
+/* OV05C supports one single link frequency */
+static const u64 ov05c10_link_freqs[] = {
+ 925 * HZ_PER_MHZ,
+};
+
+/* OV05C supports only 2-lane configuration */
+static const u32 ov05c10_data_lanes[] = {
+ 1,
+ 2,
+};
+
+/* OV05C10 endpoint node properties table */
+static const struct property_entry ov05c10_endpoint_props[] = {
+ PROPERTY_ENTRY_U32("bus-type", 4),
+ PROPERTY_ENTRY_U32_ARRAY_LEN("data-lanes", ov05c10_data_lanes,
+ ARRAY_SIZE(ov05c10_data_lanes)),
+ PROPERTY_ENTRY_U64_ARRAY_LEN("link-frequencies", ov05c10_link_freqs,
+ ARRAY_SIZE(ov05c10_link_freqs)),
+ PROPERTY_ENTRY_REF_ARRAY("remote-endpoint", ov05c10_refs),
+ { }
+};
+
+/* AMD ISP endpoint node definition */
+static const struct software_node endpoint_node = {
+ .name = "endpoint",
+ .parent = &port_node,
+ .properties = ov05c10_endpoint_props,
+};
+
+/*
+ * AMD ISP swnode graph uses 5 nodes and also its relationship is
+ * fixed to align with the structure that v4l2 expects for successful
+ * endpoint fwnode parsing.
+ *
+ * It is only the node property_entries that will vary for each platform
+ * supporting different sensor modules.
+ */
+#define NUM_SW_NODES 5
+
+static const struct software_node *ov05c10_nodes[NUM_SW_NODES + 1] = {
+ &camera_node,
+ &ports,
+ &port_node,
+ &endpoint_node,
+ &remote_ep_isp_node,
+ NULL
+};
+
+static const struct acpi_device_id amdisp_sensor_ids[] = {
+ { AMDISP_OV05C10_HID },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
+
+static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
+{
+ return !strcmp(adap->owner->name, "i2c_designware_amdisp");
+}
+
+static void instantiate_isp_i2c_client(struct amdisp_platform *ov05c10, struct i2c_adapter *adap)
+{
+ struct i2c_board_info *info = &ov05c10->board_info;
+ struct i2c_client *i2c_dev;
+
+ guard(mutex)(&ov05c10->lock);
+
+ if (ov05c10->i2c_dev)
+ return;
+
+ i2c_dev = i2c_new_client_device(adap, info);
+ if (IS_ERR(i2c_dev)) {
+ dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
+ return;
+ }
+ ov05c10->i2c_dev = i2c_dev;
+}
+
+static int isp_i2c_bus_notify(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct amdisp_platform *ov05c10 = container_of(nb, struct amdisp_platform, i2c_nb);
+ struct device *dev = data;
+ struct i2c_client *client;
+ struct i2c_adapter *adap;
+
+ switch (action) {
+ case BUS_NOTIFY_ADD_DEVICE:
+ adap = i2c_verify_adapter(dev);
+ if (!adap)
+ break;
+ if (is_isp_i2c_adapter(adap))
+ instantiate_isp_i2c_client(ov05c10, adap);
+ break;
+ case BUS_NOTIFY_REMOVED_DEVICE:
+ client = i2c_verify_client(dev);
+ if (!client)
+ break;
+
+ scoped_guard(mutex, &ov05c10->lock) {
+ if (ov05c10->i2c_dev == client) {
+ dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+ ov05c10->i2c_dev = NULL;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct amdisp_platform *prepare_amdisp_platform(struct device *dev)
+{
+ struct amdisp_platform *isp_ov05c10;
+ int ret;
+
+ isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL);
+ if (!isp_ov05c10)
+ return ERR_PTR(-ENOMEM);
+
+ ret = devm_mutex_init(dev, &isp_ov05c10->lock);
+ if (ret)
+ return ERR_PTR(ret);
+
+ isp_ov05c10->board_info.dev_name = "ov05c10";
+ strscpy(isp_ov05c10->board_info.type, "ov05c10", I2C_NAME_SIZE);
+ isp_ov05c10->board_info.addr = AMDISP_OV05C10_I2C_ADDR;
+
+ ret = software_node_register_node_group(ov05c10_nodes);
+ if (ret)
+ return ERR_PTR(ret);
+
+ isp_ov05c10->board_info.swnode = ov05c10_nodes[0];
+
+ return isp_ov05c10;
+}
+
+static int try_to_instantiate_i2c_client(struct device *dev, void *data)
+{
+ struct amdisp_platform *ov05c10 = (struct amdisp_platform *)data;
+ struct i2c_adapter *adap = i2c_verify_adapter(dev);
+
+ if (!ov05c10 || !adap)
+ return 0;
+ if (!adap->owner)
+ return 0;
+
+ if (is_isp_i2c_adapter(adap))
+ instantiate_isp_i2c_client(ov05c10, adap);
+
+ return 0;
+}
+
+static int amd_isp_probe(struct platform_device *pdev)
+{
+ struct amdisp_platform *ov05c10;
+ int ret;
+
+ ov05c10 = prepare_amdisp_platform(&pdev->dev);
+ if (IS_ERR(ov05c10))
+ return dev_err_probe(&pdev->dev, PTR_ERR(ov05c10),
+ "failed to prepare AMD ISP platform fwnode\n");
+
+ ov05c10->i2c_nb.notifier_call = isp_i2c_bus_notify;
+ ret = bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
+ if (ret)
+ goto error_unregister_sw_node;
+
+ /* check if adapter is already registered and create i2c client instance */
+ i2c_for_each_dev((void *)ov05c10, try_to_instantiate_i2c_client);
+
+ platform_set_drvdata(pdev, ov05c10);
+ return 0;
+
+error_unregister_sw_node:
+ software_node_unregister_node_group(ov05c10_nodes);
+ return ret;
+}
+
+static void amd_isp_remove(struct platform_device *pdev)
+{
+ struct amdisp_platform *ov05c10 = platform_get_drvdata(pdev);
+
+ bus_unregister_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
+ i2c_unregister_device(ov05c10->i2c_dev);
+ software_node_unregister_node_group(ov05c10_nodes);
+}
+
+static struct platform_driver amd_isp_platform_driver = {
+ .driver = {
+ .name = AMD_ISP_PLAT_DRV_NAME,
+ .acpi_match_table = amdisp_sensor_ids,
+ },
+ .probe = amd_isp_probe,
+ .remove = amd_isp_remove,
+};
+
+module_platform_driver(amd_isp_platform_driver);
+
+MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>");
+MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
+MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
+MODULE_LICENSE("GPL");
--
2.43.0
Hi Pratap,
On Mon, May 05, 2025 at 01:11:26PM -0400, Pratap Nirujogi wrote:
> ISP device specific configuration is not available in ACPI. Add
> swnode graph to configure the missing device properties for the
> OV05C10 camera device supported on amdisp platform.
>
> Add support to create i2c-client dynamically when amdisp i2c
> adapter is available.
>
> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com>
> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> ---
> Changes v11 -> v12:
>
> * Add missing space before the open parenthesis '('
>
> drivers/platform/x86/amd/Kconfig | 11 ++
> drivers/platform/x86/amd/Makefile | 1 +
> drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++
> 3 files changed, 292 insertions(+)
> create mode 100644 drivers/platform/x86/amd/amd_isp4.c
>
> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
> index c3e086ea64fc..152a68a470e8 100644
> --- a/drivers/platform/x86/amd/Kconfig
> +++ b/drivers/platform/x86/amd/Kconfig
> @@ -32,3 +32,14 @@ config AMD_WBRF
>
> This mechanism will only be activated on platforms that advertise a
> need for it.
> +
> +config AMD_ISP_PLATFORM
> + tristate "AMD ISP4 platform driver"
> + depends on I2C && X86_64 && ACPI
> + help
> + Platform driver for AMD platforms containing image signal processor
> + gen 4. Provides camera sensor module board information to allow
> + sensor and V4L drivers to work properly.
> +
> + This driver can also be built as a module. If so, the module
> + will be called amd_isp4.
> diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
> index c6c40bdcbded..b0e284b5d497 100644
> --- a/drivers/platform/x86/amd/Makefile
> +++ b/drivers/platform/x86/amd/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/
> obj-$(CONFIG_AMD_HSMP) += hsmp/
> obj-$(CONFIG_AMD_PMF) += pmf/
> obj-$(CONFIG_AMD_WBRF) += wbrf.o
> +obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.o
> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
> new file mode 100644
> index 000000000000..1520ebb94507
> --- /dev/null
> +++ b/drivers/platform/x86/amd/amd_isp4.c
> @@ -0,0 +1,280 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * AMD ISP platform driver for sensor i2-client instantiation
> + *
> + * Copyright 2025 Advanced Micro Devices, Inc.
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/units.h>
> +
> +#define AMDISP_OV05C10_I2C_ADDR 0x10
> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
> +#define AMDISP_OV05C10_HID "OMNI5C10"
What's the purpose of this _HID and is it present on actual firmware
implementation? There's no such ACPI vendor ID as "OMNI".
> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
> +
> +/*
> + * AMD ISP platform definition to configure the device properties
> + * missing in the ACPI table.
> + */
> +struct amdisp_platform {
> + struct i2c_board_info board_info;
> + struct notifier_block i2c_nb;
> + struct i2c_client *i2c_dev;
> + struct mutex lock; /* protects i2c client creation */
> +};
> +
> +/* Top-level OV05C10 camera node property table */
> +static const struct property_entry ov05c10_camera_props[] = {
> + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
> + { }
> +};
> +
> +/* Root AMD ISP OV05C10 camera node definition */
> +static const struct software_node camera_node = {
> + .name = AMDISP_OV05C10_HID,
> + .properties = ov05c10_camera_props,
> +};
> +
> +/*
> + * AMD ISP OV05C10 Ports node definition. No properties defined for
> + * ports node for OV05C10.
> + */
> +static const struct software_node ports = {
> + .name = "ports",
> + .parent = &camera_node,
> +};
> +
> +/*
> + * AMD ISP OV05C10 Port node definition. No properties defined for
> + * port node for OV05C10.
> + */
> +static const struct software_node port_node = {
> + .name = "port@",
> + .parent = &ports,
> +};
> +
> +/*
> + * Remote endpoint AMD ISP node definition. No properties defined for
> + * remote endpoint node for OV05C10.
How will this scale? Can you use other sensors with this ISP? Although if
you get little from firmware, there's not much you can do. That being said,
switching to DisCo for Imaging could be an easier step in this case.
> + */
> +static const struct software_node remote_ep_isp_node = {
> + .name = AMDISP_OV05C10_REMOTE_EP_NAME,
> +};
> +
> +/*
> + * Remote endpoint reference for isp node included in the
> + * OV05C10 endpoint.
> + */
> +static const struct software_node_ref_args ov05c10_refs[] = {
> + SOFTWARE_NODE_REFERENCE(&remote_ep_isp_node),
> +};
> +
> +/* OV05C supports one single link frequency */
> +static const u64 ov05c10_link_freqs[] = {
> + 925 * HZ_PER_MHZ,
> +};
> +
> +/* OV05C supports only 2-lane configuration */
> +static const u32 ov05c10_data_lanes[] = {
> + 1,
> + 2,
> +};
> +
> +/* OV05C10 endpoint node properties table */
> +static const struct property_entry ov05c10_endpoint_props[] = {
> + PROPERTY_ENTRY_U32("bus-type", 4),
> + PROPERTY_ENTRY_U32_ARRAY_LEN("data-lanes", ov05c10_data_lanes,
> + ARRAY_SIZE(ov05c10_data_lanes)),
> + PROPERTY_ENTRY_U64_ARRAY_LEN("link-frequencies", ov05c10_link_freqs,
> + ARRAY_SIZE(ov05c10_link_freqs)),
> + PROPERTY_ENTRY_REF_ARRAY("remote-endpoint", ov05c10_refs),
> + { }
> +};
> +
> +/* AMD ISP endpoint node definition */
> +static const struct software_node endpoint_node = {
> + .name = "endpoint",
> + .parent = &port_node,
> + .properties = ov05c10_endpoint_props,
> +};
> +
> +/*
> + * AMD ISP swnode graph uses 5 nodes and also its relationship is
> + * fixed to align with the structure that v4l2 expects for successful
> + * endpoint fwnode parsing.
> + *
> + * It is only the node property_entries that will vary for each platform
> + * supporting different sensor modules.
> + */
> +#define NUM_SW_NODES 5
> +
> +static const struct software_node *ov05c10_nodes[NUM_SW_NODES + 1] = {
Defining the number of entries seems to be redundant here.
> + &camera_node,
> + &ports,
> + &port_node,
> + &endpoint_node,
> + &remote_ep_isp_node,
> + NULL
> +};
> +
> +static const struct acpi_device_id amdisp_sensor_ids[] = {
> + { AMDISP_OV05C10_HID },
> + { }
> +};
> +MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
> +
> +static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
> +{
> + return !strcmp(adap->owner->name, "i2c_designware_amdisp");
> +}
> +
> +static void instantiate_isp_i2c_client(struct amdisp_platform *ov05c10, struct i2c_adapter *adap)
> +{
> + struct i2c_board_info *info = &ov05c10->board_info;
> + struct i2c_client *i2c_dev;
> +
> + guard(mutex)(&ov05c10->lock);
> +
> + if (ov05c10->i2c_dev)
> + return;
> +
> + i2c_dev = i2c_new_client_device(adap, info);
> + if (IS_ERR(i2c_dev)) {
> + dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
> + return;
> + }
> + ov05c10->i2c_dev = i2c_dev;
> +}
> +
> +static int isp_i2c_bus_notify(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct amdisp_platform *ov05c10 = container_of(nb, struct amdisp_platform, i2c_nb);
> + struct device *dev = data;
> + struct i2c_client *client;
> + struct i2c_adapter *adap;
> +
> + switch (action) {
> + case BUS_NOTIFY_ADD_DEVICE:
> + adap = i2c_verify_adapter(dev);
> + if (!adap)
> + break;
> + if (is_isp_i2c_adapter(adap))
> + instantiate_isp_i2c_client(ov05c10, adap);
> + break;
> + case BUS_NOTIFY_REMOVED_DEVICE:
> + client = i2c_verify_client(dev);
> + if (!client)
> + break;
> +
> + scoped_guard(mutex, &ov05c10->lock) {
> + if (ov05c10->i2c_dev == client) {
> + dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
> + ov05c10->i2c_dev = NULL;
> + }
> + }
> + break;
> + default:
> + break;
> + }
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct amdisp_platform *prepare_amdisp_platform(struct device *dev)
> +{
> + struct amdisp_platform *isp_ov05c10;
> + int ret;
> +
> + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL);
> + if (!isp_ov05c10)
> + return ERR_PTR(-ENOMEM);
> +
> + ret = devm_mutex_init(dev, &isp_ov05c10->lock);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + isp_ov05c10->board_info.dev_name = "ov05c10";
> + strscpy(isp_ov05c10->board_info.type, "ov05c10", I2C_NAME_SIZE);
> + isp_ov05c10->board_info.addr = AMDISP_OV05C10_I2C_ADDR;
> +
> + ret = software_node_register_node_group(ov05c10_nodes);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + isp_ov05c10->board_info.swnode = ov05c10_nodes[0];
> +
> + return isp_ov05c10;
> +}
> +
> +static int try_to_instantiate_i2c_client(struct device *dev, void *data)
> +{
> + struct amdisp_platform *ov05c10 = (struct amdisp_platform *)data;
> + struct i2c_adapter *adap = i2c_verify_adapter(dev);
> +
> + if (!ov05c10 || !adap)
> + return 0;
> + if (!adap->owner)
> + return 0;
> +
> + if (is_isp_i2c_adapter(adap))
> + instantiate_isp_i2c_client(ov05c10, adap);
> +
> + return 0;
> +}
> +
> +static int amd_isp_probe(struct platform_device *pdev)
> +{
> + struct amdisp_platform *ov05c10;
> + int ret;
> +
> + ov05c10 = prepare_amdisp_platform(&pdev->dev);
> + if (IS_ERR(ov05c10))
> + return dev_err_probe(&pdev->dev, PTR_ERR(ov05c10),
> + "failed to prepare AMD ISP platform fwnode\n");
> +
> + ov05c10->i2c_nb.notifier_call = isp_i2c_bus_notify;
> + ret = bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
> + if (ret)
> + goto error_unregister_sw_node;
> +
> + /* check if adapter is already registered and create i2c client instance */
> + i2c_for_each_dev((void *)ov05c10, try_to_instantiate_i2c_client);
> +
> + platform_set_drvdata(pdev, ov05c10);
> + return 0;
> +
> +error_unregister_sw_node:
> + software_node_unregister_node_group(ov05c10_nodes);
> + return ret;
> +}
> +
> +static void amd_isp_remove(struct platform_device *pdev)
> +{
> + struct amdisp_platform *ov05c10 = platform_get_drvdata(pdev);
> +
> + bus_unregister_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
> + i2c_unregister_device(ov05c10->i2c_dev);
> + software_node_unregister_node_group(ov05c10_nodes);
> +}
> +
> +static struct platform_driver amd_isp_platform_driver = {
> + .driver = {
> + .name = AMD_ISP_PLAT_DRV_NAME,
> + .acpi_match_table = amdisp_sensor_ids,
> + },
> + .probe = amd_isp_probe,
> + .remove = amd_isp_remove,
> +};
> +
> +module_platform_driver(amd_isp_platform_driver);
> +
> +MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>");
> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
> +MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
> +MODULE_LICENSE("GPL");
--
Regards,
Sakari Ailus
Hi Sakari, On 6-May-25 5:37 PM, Sakari Ailus wrote: > Hi Pratap, > > On Mon, May 05, 2025 at 01:11:26PM -0400, Pratap Nirujogi wrote: >> ISP device specific configuration is not available in ACPI. Add >> swnode graph to configure the missing device properties for the >> OV05C10 camera device supported on amdisp platform. >> >> Add support to create i2c-client dynamically when amdisp i2c >> adapter is available. >> >> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com> >> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com> >> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> >> Reviewed-by: Hans de Goede <hdegoede@redhat.com> >> Reviewed-by: Armin Wolf <W_Armin@gmx.de> >> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com> >> --- <snip> >> +/* >> + * Remote endpoint AMD ISP node definition. No properties defined for >> + * remote endpoint node for OV05C10. > > How will this scale? Can you use other sensors with this ISP? Although if > you get little from firmware, there's not much you can do. That being said, > switching to DisCo for Imaging could be an easier step in this case. Note I've already talked to AMD about the way the camera setup is currently being described in ACPI tables is suboptimal and how they really should use proper ACPI description using e.g. a _CRS with an I2cSerialBus resource for the sensor. Although I must admit I did not bring up the ACPI DisCo for imaging spec as something to also look at for future generations. Note that there currently is hw shipping using the somewhat broken ACPI sensor description this glue driver binds to, so we're stuck with dealing with these ACPI tables as they are already out there in the wild. But yes for future hw generations it would be good to have a better description of the hw in ACPI. Regards, Hans
Hi Hans, On Wed, May 07, 2025 at 11:13:18PM +0200, Hans de Goede wrote: > Hi Sakari, > > On 6-May-25 5:37 PM, Sakari Ailus wrote: > > Hi Pratap, > > > > On Mon, May 05, 2025 at 01:11:26PM -0400, Pratap Nirujogi wrote: > >> ISP device specific configuration is not available in ACPI. Add > >> swnode graph to configure the missing device properties for the > >> OV05C10 camera device supported on amdisp platform. > >> > >> Add support to create i2c-client dynamically when amdisp i2c > >> adapter is available. > >> > >> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com> > >> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com> > >> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > >> Reviewed-by: Hans de Goede <hdegoede@redhat.com> > >> Reviewed-by: Armin Wolf <W_Armin@gmx.de> > >> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com> > >> --- > > <snip> > > >> +/* > >> + * Remote endpoint AMD ISP node definition. No properties defined for > >> + * remote endpoint node for OV05C10. > > > > How will this scale? Can you use other sensors with this ISP? Although if > > you get little from firmware, there's not much you can do. That being said, > > switching to DisCo for Imaging could be an easier step in this case. > > Note I've already talked to AMD about the way the camera setup > is currently being described in ACPI tables is suboptimal and > how they really should use proper ACPI description using e.g. > a _CRS with an I2cSerialBus resource for the sensor. That's one thing, yes, but it's not enough to get rid of the board code. > > Although I must admit I did not bring up the ACPI DisCo for imaging > spec as something to also look at for future generations. I think we should really try to get rid of the board code the raw cameras on ACPI systems currently depend on, in future systems, instead of just reducing it a little bit. MIPI DisCo for Imaging enables that. I guess you're not very familiar with Intel-based ChromeOS systems in this area? Maybe largely because they work out of the box. And there's no board code for these systems in the kernel. These are based (albeit I'm not quite sure about the latest ones) on older Linux-based definitions whereas newer MIPI DisCo for Imaging spec is OS-independent. > > Note that there currently is hw shipping using the somewhat > broken ACPI sensor description this glue driver binds to, > so we're stuck with dealing with these ACPI tables as they > are already out there in the wild. I agree, there's little that can be done at this point. > > But yes for future hw generations it would be good to have > a better description of the hw in ACPI. -- Regards, Sakari Ailus
On 5/8/2025 3:17 AM, Sakari Ailus wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > > Hi Hans, > > On Wed, May 07, 2025 at 11:13:18PM +0200, Hans de Goede wrote: >> Hi Sakari, >> >> On 6-May-25 5:37 PM, Sakari Ailus wrote: >>> Hi Pratap, >>> >>> On Mon, May 05, 2025 at 01:11:26PM -0400, Pratap Nirujogi wrote: >>>> ISP device specific configuration is not available in ACPI. Add >>>> swnode graph to configure the missing device properties for the >>>> OV05C10 camera device supported on amdisp platform. >>>> >>>> Add support to create i2c-client dynamically when amdisp i2c >>>> adapter is available. >>>> >>>> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com> >>>> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com> >>>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> >>>> Reviewed-by: Hans de Goede <hdegoede@redhat.com> >>>> Reviewed-by: Armin Wolf <W_Armin@gmx.de> >>>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com> >>>> --- >> >> <snip> >> >>>> +/* >>>> + * Remote endpoint AMD ISP node definition. No properties defined for >>>> + * remote endpoint node for OV05C10. >>> >>> How will this scale? Can you use other sensors with this ISP? Although if >>> you get little from firmware, there's not much you can do. That being said, >>> switching to DisCo for Imaging could be an easier step in this case. >> >> Note I've already talked to AMD about the way the camera setup >> is currently being described in ACPI tables is suboptimal and >> how they really should use proper ACPI description using e.g. >> a _CRS with an I2cSerialBus resource for the sensor. > > That's one thing, yes, but it's not enough to get rid of the board code. > >> >> Although I must admit I did not bring up the ACPI DisCo for imaging >> spec as something to also look at for future generations. > > I think we should really try to get rid of the board code the raw cameras > on ACPI systems currently depend on, in future systems, instead of just > reducing it a little bit. MIPI DisCo for Imaging enables that. > > I guess you're not very familiar with Intel-based ChromeOS systems in this > area? Maybe largely because they work out of the box. And there's no board > code for these systems in the kernel. These are based (albeit I'm not quite > sure about the latest ones) on older Linux-based definitions whereas newer > MIPI DisCo for Imaging spec is OS-independent. > >> >> Note that there currently is hw shipping using the somewhat >> broken ACPI sensor description this glue driver binds to, >> so we're stuck with dealing with these ACPI tables as they >> are already out there in the wild. > > I agree, there's little that can be done at this point. > >> >> But yes for future hw generations it would be good to have >> a better description of the hw in ACPI. > Hi Sakari, Hans, Thanks for your support and understanding. We will work internally and ensure our future models adheres to MIPI DisCo Imaging spec. Thanks, Pratap > -- > Regards, > > Sakari Ailus
Hi Sakari,
On 5/6/2025 11:37 AM, Sakari Ailus wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Hi Pratap,
>
> On Mon, May 05, 2025 at 01:11:26PM -0400, Pratap Nirujogi wrote:
>> ISP device specific configuration is not available in ACPI. Add
>> swnode graph to configure the missing device properties for the
>> OV05C10 camera device supported on amdisp platform.
>>
>> Add support to create i2c-client dynamically when amdisp i2c
>> adapter is available.
>>
>> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com>
>> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
>> ---
>> Changes v11 -> v12:
>>
>> * Add missing space before the open parenthesis '('
>>
>> drivers/platform/x86/amd/Kconfig | 11 ++
>> drivers/platform/x86/amd/Makefile | 1 +
>> drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++
>> 3 files changed, 292 insertions(+)
>> create mode 100644 drivers/platform/x86/amd/amd_isp4.c
>>
>> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
>> index c3e086ea64fc..152a68a470e8 100644
>> --- a/drivers/platform/x86/amd/Kconfig
>> +++ b/drivers/platform/x86/amd/Kconfig
>> @@ -32,3 +32,14 @@ config AMD_WBRF
>>
>> This mechanism will only be activated on platforms that advertise a
>> need for it.
>> +
>> +config AMD_ISP_PLATFORM
>> + tristate "AMD ISP4 platform driver"
>> + depends on I2C && X86_64 && ACPI
>> + help
>> + Platform driver for AMD platforms containing image signal processor
>> + gen 4. Provides camera sensor module board information to allow
>> + sensor and V4L drivers to work properly.
>> +
>> + This driver can also be built as a module. If so, the module
>> + will be called amd_isp4.
>> diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
>> index c6c40bdcbded..b0e284b5d497 100644
>> --- a/drivers/platform/x86/amd/Makefile
>> +++ b/drivers/platform/x86/amd/Makefile
>> @@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/
>> obj-$(CONFIG_AMD_HSMP) += hsmp/
>> obj-$(CONFIG_AMD_PMF) += pmf/
>> obj-$(CONFIG_AMD_WBRF) += wbrf.o
>> +obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.o
>> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
>> new file mode 100644
>> index 000000000000..1520ebb94507
>> --- /dev/null
>> +++ b/drivers/platform/x86/amd/amd_isp4.c
>> @@ -0,0 +1,280 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * AMD ISP platform driver for sensor i2-client instantiation
>> + *
>> + * Copyright 2025 Advanced Micro Devices, Inc.
>> + */
>> +
>> +#include <linux/i2c.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/property.h>
>> +#include <linux/units.h>
>> +
>> +#define AMDISP_OV05C10_I2C_ADDR 0x10
>> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
>> +#define AMDISP_OV05C10_HID "OMNI5C10"
>
> What's the purpose of this _HID and is it present on actual firmware
> implementation? There's no such ACPI vendor ID as "OMNI".
>
The (_HID, "OMNI5C10") is used to check if the OV05C10 ACPI device is
actually present before creating the AMD ISP4 platform driver. Yes, ACPI
entry is present for OV05C10 sensor in _SB/CAMF.
Scope (_SB)
{
Device (CAMF)
{
Name (_HID, "OMNI5C10") // _HID: Hardware ID
Name (_DDN, "OV05C-RGB") // _DDN: DOS Device Name
Name (_SUB, "OV05C") // _SUB: Subsystem ID
>> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
>> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
>> +
>> +/*
>> + * AMD ISP platform definition to configure the device properties
>> + * missing in the ACPI table.
>> + */
>> +struct amdisp_platform {
>> + struct i2c_board_info board_info;
>> + struct notifier_block i2c_nb;
>> + struct i2c_client *i2c_dev;
>> + struct mutex lock; /* protects i2c client creation */
>> +};
>> +
>> +/* Top-level OV05C10 camera node property table */
>> +static const struct property_entry ov05c10_camera_props[] = {
>> + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
>> + { }
>> +};
>> +
>> +/* Root AMD ISP OV05C10 camera node definition */
>> +static const struct software_node camera_node = {
>> + .name = AMDISP_OV05C10_HID,
>> + .properties = ov05c10_camera_props,
>> +};
>> +
>> +/*
>> + * AMD ISP OV05C10 Ports node definition. No properties defined for
>> + * ports node for OV05C10.
>> + */
>> +static const struct software_node ports = {
>> + .name = "ports",
>> + .parent = &camera_node,
>> +};
>> +
>> +/*
>> + * AMD ISP OV05C10 Port node definition. No properties defined for
>> + * port node for OV05C10.
>> + */
>> +static const struct software_node port_node = {
>> + .name = "port@",
>> + .parent = &ports,
>> +};
>> +
>> +/*
>> + * Remote endpoint AMD ISP node definition. No properties defined for
>> + * remote endpoint node for OV05C10.
>
> How will this scale? Can you use other sensors with this ISP? Although if
> you get little from firmware, there's not much you can do. That being said,
> switching to DisCo for Imaging could be an easier step in this case.
>
the scope of this driver is limited to ov05c10, and it can be enhanced
to support other sensor modules in future.
Sorry, I'm not familiar with the term DisCo. Could you please elaborate.
>> + */
>> +static const struct software_node remote_ep_isp_node = {
>> + .name = AMDISP_OV05C10_REMOTE_EP_NAME,
>> +};
>> +
>> +/*
>> + * Remote endpoint reference for isp node included in the
>> + * OV05C10 endpoint.
>> + */
>> +static const struct software_node_ref_args ov05c10_refs[] = {
>> + SOFTWARE_NODE_REFERENCE(&remote_ep_isp_node),
>> +};
>> +
>> +/* OV05C supports one single link frequency */
>> +static const u64 ov05c10_link_freqs[] = {
>> + 925 * HZ_PER_MHZ,
>> +};
>> +
>> +/* OV05C supports only 2-lane configuration */
>> +static const u32 ov05c10_data_lanes[] = {
>> + 1,
>> + 2,
>> +};
>> +
>> +/* OV05C10 endpoint node properties table */
>> +static const struct property_entry ov05c10_endpoint_props[] = {
>> + PROPERTY_ENTRY_U32("bus-type", 4),
>> + PROPERTY_ENTRY_U32_ARRAY_LEN("data-lanes", ov05c10_data_lanes,
>> + ARRAY_SIZE(ov05c10_data_lanes)),
>> + PROPERTY_ENTRY_U64_ARRAY_LEN("link-frequencies", ov05c10_link_freqs,
>> + ARRAY_SIZE(ov05c10_link_freqs)),
>> + PROPERTY_ENTRY_REF_ARRAY("remote-endpoint", ov05c10_refs),
>> + { }
>> +};
>> +
>> +/* AMD ISP endpoint node definition */
>> +static const struct software_node endpoint_node = {
>> + .name = "endpoint",
>> + .parent = &port_node,
>> + .properties = ov05c10_endpoint_props,
>> +};
>> +
>> +/*
>> + * AMD ISP swnode graph uses 5 nodes and also its relationship is
>> + * fixed to align with the structure that v4l2 expects for successful
>> + * endpoint fwnode parsing.
>> + *
>> + * It is only the node property_entries that will vary for each platform
>> + * supporting different sensor modules.
>> + */
>> +#define NUM_SW_NODES 5
>> +
>> +static const struct software_node *ov05c10_nodes[NUM_SW_NODES + 1] = {
>
> Defining the number of entries seems to be redundant here.
>
yes, NUM_SW_NODES can be removed, its no longer important. Will remove
it in v13.
Thanks,
Pratap
>> + &camera_node,
>> + &ports,
>> + &port_node,
>> + &endpoint_node,
>> + &remote_ep_isp_node,
>> + NULL
>> +};
>> +
>> +static const struct acpi_device_id amdisp_sensor_ids[] = {
>> + { AMDISP_OV05C10_HID },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
>> +
>> +static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
>> +{
>> + return !strcmp(adap->owner->name, "i2c_designware_amdisp");
>> +}
>> +
>> +static void instantiate_isp_i2c_client(struct amdisp_platform *ov05c10, struct i2c_adapter *adap)
>> +{
>> + struct i2c_board_info *info = &ov05c10->board_info;
>> + struct i2c_client *i2c_dev;
>> +
>> + guard(mutex)(&ov05c10->lock);
>> +
>> + if (ov05c10->i2c_dev)
>> + return;
>> +
>> + i2c_dev = i2c_new_client_device(adap, info);
>> + if (IS_ERR(i2c_dev)) {
>> + dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
>> + return;
>> + }
>> + ov05c10->i2c_dev = i2c_dev;
>> +}
>> +
>> +static int isp_i2c_bus_notify(struct notifier_block *nb,
>> + unsigned long action, void *data)
>> +{
>> + struct amdisp_platform *ov05c10 = container_of(nb, struct amdisp_platform, i2c_nb);
>> + struct device *dev = data;
>> + struct i2c_client *client;
>> + struct i2c_adapter *adap;
>> +
>> + switch (action) {
>> + case BUS_NOTIFY_ADD_DEVICE:
>> + adap = i2c_verify_adapter(dev);
>> + if (!adap)
>> + break;
>> + if (is_isp_i2c_adapter(adap))
>> + instantiate_isp_i2c_client(ov05c10, adap);
>> + break;
>> + case BUS_NOTIFY_REMOVED_DEVICE:
>> + client = i2c_verify_client(dev);
>> + if (!client)
>> + break;
>> +
>> + scoped_guard(mutex, &ov05c10->lock) {
>> + if (ov05c10->i2c_dev == client) {
>> + dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
>> + ov05c10->i2c_dev = NULL;
>> + }
>> + }
>> + break;
>> + default:
>> + break;
>> + }
>> +
>> + return NOTIFY_DONE;
>> +}
>> +
>> +static struct amdisp_platform *prepare_amdisp_platform(struct device *dev)
>> +{
>> + struct amdisp_platform *isp_ov05c10;
>> + int ret;
>> +
>> + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL);
>> + if (!isp_ov05c10)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ret = devm_mutex_init(dev, &isp_ov05c10->lock);
>> + if (ret)
>> + return ERR_PTR(ret);
>> +
>> + isp_ov05c10->board_info.dev_name = "ov05c10";
>> + strscpy(isp_ov05c10->board_info.type, "ov05c10", I2C_NAME_SIZE);
>> + isp_ov05c10->board_info.addr = AMDISP_OV05C10_I2C_ADDR;
>> +
>> + ret = software_node_register_node_group(ov05c10_nodes);
>> + if (ret)
>> + return ERR_PTR(ret);
>> +
>> + isp_ov05c10->board_info.swnode = ov05c10_nodes[0];
>> +
>> + return isp_ov05c10;
>> +}
>> +
>> +static int try_to_instantiate_i2c_client(struct device *dev, void *data)
>> +{
>> + struct amdisp_platform *ov05c10 = (struct amdisp_platform *)data;
>> + struct i2c_adapter *adap = i2c_verify_adapter(dev);
>> +
>> + if (!ov05c10 || !adap)
>> + return 0;
>> + if (!adap->owner)
>> + return 0;
>> +
>> + if (is_isp_i2c_adapter(adap))
>> + instantiate_isp_i2c_client(ov05c10, adap);
>> +
>> + return 0;
>> +}
>> +
>> +static int amd_isp_probe(struct platform_device *pdev)
>> +{
>> + struct amdisp_platform *ov05c10;
>> + int ret;
>> +
>> + ov05c10 = prepare_amdisp_platform(&pdev->dev);
>> + if (IS_ERR(ov05c10))
>> + return dev_err_probe(&pdev->dev, PTR_ERR(ov05c10),
>> + "failed to prepare AMD ISP platform fwnode\n");
>> +
>> + ov05c10->i2c_nb.notifier_call = isp_i2c_bus_notify;
>> + ret = bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
>> + if (ret)
>> + goto error_unregister_sw_node;
>> +
>> + /* check if adapter is already registered and create i2c client instance */
>> + i2c_for_each_dev((void *)ov05c10, try_to_instantiate_i2c_client);
>> +
>> + platform_set_drvdata(pdev, ov05c10);
>> + return 0;
>> +
>> +error_unregister_sw_node:
>> + software_node_unregister_node_group(ov05c10_nodes);
>> + return ret;
>> +}
>> +
>> +static void amd_isp_remove(struct platform_device *pdev)
>> +{
>> + struct amdisp_platform *ov05c10 = platform_get_drvdata(pdev);
>> +
>> + bus_unregister_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
>> + i2c_unregister_device(ov05c10->i2c_dev);
>> + software_node_unregister_node_group(ov05c10_nodes);
>> +}
>> +
>> +static struct platform_driver amd_isp_platform_driver = {
>> + .driver = {
>> + .name = AMD_ISP_PLAT_DRV_NAME,
>> + .acpi_match_table = amdisp_sensor_ids,
>> + },
>> + .probe = amd_isp_probe,
>> + .remove = amd_isp_remove,
>> +};
>> +
>> +module_platform_driver(amd_isp_platform_driver);
>> +
>> +MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>");
>> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
>> +MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
>> +MODULE_LICENSE("GPL");
>
> --
> Regards,
>
> Sakari Ailus
Hi Pratap,
On Wed, May 07, 2025 at 04:16:04PM -0400, Nirujogi, Pratap wrote:
> > > diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
> > > new file mode 100644
> > > index 000000000000..1520ebb94507
> > > --- /dev/null
> > > +++ b/drivers/platform/x86/amd/amd_isp4.c
> > > @@ -0,0 +1,280 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * AMD ISP platform driver for sensor i2-client instantiation
> > > + *
> > > + * Copyright 2025 Advanced Micro Devices, Inc.
> > > + */
> > > +
> > > +#include <linux/i2c.h>
> > > +#include <linux/module.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/property.h>
> > > +#include <linux/units.h>
> > > +
> > > +#define AMDISP_OV05C10_I2C_ADDR 0x10
> > > +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
> > > +#define AMDISP_OV05C10_HID "OMNI5C10"
> >
> > What's the purpose of this _HID and is it present on actual firmware
> > implementation? There's no such ACPI vendor ID as "OMNI".
> >
> The (_HID, "OMNI5C10") is used to check if the OV05C10 ACPI device is
> actually present before creating the AMD ISP4 platform driver. Yes, ACPI
> entry is present for OV05C10 sensor in _SB/CAMF.
>
> Scope (_SB)
> {
> Device (CAMF)
> {
> Name (_HID, "OMNI5C10") // _HID: Hardware ID
Please tell your BIOS folks this ACPI ID is invalid. In the future, either
allocate one yourself with your own vendor ID or get one from the sensor
vendor, which they would have allocated using their own ACPI vendor ID.
> Name (_DDN, "OV05C-RGB") // _DDN: DOS Device Name
> Name (_SUB, "OV05C") // _SUB: Subsystem ID
>
>
> > > +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
> > > +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
> > > +
> > > +/*
> > > + * AMD ISP platform definition to configure the device properties
> > > + * missing in the ACPI table.
> > > + */
> > > +struct amdisp_platform {
> > > + struct i2c_board_info board_info;
> > > + struct notifier_block i2c_nb;
> > > + struct i2c_client *i2c_dev;
> > > + struct mutex lock; /* protects i2c client creation */
> > > +};
> > > +
> > > +/* Top-level OV05C10 camera node property table */
> > > +static const struct property_entry ov05c10_camera_props[] = {
> > > + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
> > > + { }
> > > +};
> > > +
> > > +/* Root AMD ISP OV05C10 camera node definition */
> > > +static const struct software_node camera_node = {
> > > + .name = AMDISP_OV05C10_HID,
> > > + .properties = ov05c10_camera_props,
> > > +};
> > > +
> > > +/*
> > > + * AMD ISP OV05C10 Ports node definition. No properties defined for
> > > + * ports node for OV05C10.
> > > + */
> > > +static const struct software_node ports = {
> > > + .name = "ports",
> > > + .parent = &camera_node,
> > > +};
> > > +
> > > +/*
> > > + * AMD ISP OV05C10 Port node definition. No properties defined for
> > > + * port node for OV05C10.
> > > + */
> > > +static const struct software_node port_node = {
> > > + .name = "port@",
> > > + .parent = &ports,
> > > +};
> > > +
> > > +/*
> > > + * Remote endpoint AMD ISP node definition. No properties defined for
> > > + * remote endpoint node for OV05C10.
> >
> > How will this scale? Can you use other sensors with this ISP? Although if
> > you get little from firmware, there's not much you can do. That being said,
> > switching to DisCo for Imaging could be an easier step in this case.
> >
> the scope of this driver is limited to ov05c10, and it can be enhanced to
> support other sensor modules in future.
>
> Sorry, I'm not familiar with the term DisCo. Could you please elaborate.
See my reply to Hans.
--
Regards,
Sakari Ailus
Hi Sakari,
On 5/8/2025 1:44 AM, Sakari Ailus wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Hi Pratap,
>
> On Wed, May 07, 2025 at 04:16:04PM -0400, Nirujogi, Pratap wrote:
>>>> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
>>>> new file mode 100644
>>>> index 000000000000..1520ebb94507
>>>> --- /dev/null
>>>> +++ b/drivers/platform/x86/amd/amd_isp4.c
>>>> @@ -0,0 +1,280 @@
>>>> +// SPDX-License-Identifier: GPL-2.0+
>>>> +/*
>>>> + * AMD ISP platform driver for sensor i2-client instantiation
>>>> + *
>>>> + * Copyright 2025 Advanced Micro Devices, Inc.
>>>> + */
>>>> +
>>>> +#include <linux/i2c.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/platform_device.h>
>>>> +#include <linux/property.h>
>>>> +#include <linux/units.h>
>>>> +
>>>> +#define AMDISP_OV05C10_I2C_ADDR 0x10
>>>> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
>>>> +#define AMDISP_OV05C10_HID "OMNI5C10"
>>>
>>> What's the purpose of this _HID and is it present on actual firmware
>>> implementation? There's no such ACPI vendor ID as "OMNI".
>>>
>> The (_HID, "OMNI5C10") is used to check if the OV05C10 ACPI device is
>> actually present before creating the AMD ISP4 platform driver. Yes, ACPI
>> entry is present for OV05C10 sensor in _SB/CAMF.
>>
>> Scope (_SB)
>> {
>> Device (CAMF)
>> {
>> Name (_HID, "OMNI5C10") // _HID: Hardware ID
>
> Please tell your BIOS folks this ACPI ID is invalid. In the future, either
> allocate one yourself with your own vendor ID or get one from the sensor
> vendor, which they would have allocated using their own ACPI vendor ID.
>
Thanks for the feedback. I will share it with the BIOS team and make
sure its taken into account for future models.
Thanks,
Pratap
>> Name (_DDN, "OV05C-RGB") // _DDN: DOS Device Name
>> Name (_SUB, "OV05C") // _SUB: Subsystem ID
>>
>>
>>>> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
>>>> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
>>>> +
>>>> +/*
>>>> + * AMD ISP platform definition to configure the device properties
>>>> + * missing in the ACPI table.
>>>> + */
>>>> +struct amdisp_platform {
>>>> + struct i2c_board_info board_info;
>>>> + struct notifier_block i2c_nb;
>>>> + struct i2c_client *i2c_dev;
>>>> + struct mutex lock; /* protects i2c client creation */
>>>> +};
>>>> +
>>>> +/* Top-level OV05C10 camera node property table */
>>>> +static const struct property_entry ov05c10_camera_props[] = {
>>>> + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
>>>> + { }
>>>> +};
>>>> +
>>>> +/* Root AMD ISP OV05C10 camera node definition */
>>>> +static const struct software_node camera_node = {
>>>> + .name = AMDISP_OV05C10_HID,
>>>> + .properties = ov05c10_camera_props,
>>>> +};
>>>> +
>>>> +/*
>>>> + * AMD ISP OV05C10 Ports node definition. No properties defined for
>>>> + * ports node for OV05C10.
>>>> + */
>>>> +static const struct software_node ports = {
>>>> + .name = "ports",
>>>> + .parent = &camera_node,
>>>> +};
>>>> +
>>>> +/*
>>>> + * AMD ISP OV05C10 Port node definition. No properties defined for
>>>> + * port node for OV05C10.
>>>> + */
>>>> +static const struct software_node port_node = {
>>>> + .name = "port@",
>>>> + .parent = &ports,
>>>> +};
>>>> +
>>>> +/*
>>>> + * Remote endpoint AMD ISP node definition. No properties defined for
>>>> + * remote endpoint node for OV05C10.
>>>
>>> How will this scale? Can you use other sensors with this ISP? Although if
>>> you get little from firmware, there's not much you can do. That being said,
>>> switching to DisCo for Imaging could be an easier step in this case.
>>>
>> the scope of this driver is limited to ov05c10, and it can be enhanced to
>> support other sensor modules in future.
>>
>> Sorry, I'm not familiar with the term DisCo. Could you please elaborate.
>
> See my reply to Hans.
>
> --
> Regards,
>
> Sakari Ailus
On Mon, 5 May 2025, Pratap Nirujogi wrote:
> ISP device specific configuration is not available in ACPI. Add
> swnode graph to configure the missing device properties for the
> OV05C10 camera device supported on amdisp platform.
>
> Add support to create i2c-client dynamically when amdisp i2c
> adapter is available.
>
> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com>
> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> ---
> Changes v11 -> v12:
>
> * Add missing space before the open parenthesis '('
>
> drivers/platform/x86/amd/Kconfig | 11 ++
> drivers/platform/x86/amd/Makefile | 1 +
> drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++
> 3 files changed, 292 insertions(+)
> create mode 100644 drivers/platform/x86/amd/amd_isp4.c
>
> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
> index c3e086ea64fc..152a68a470e8 100644
> --- a/drivers/platform/x86/amd/Kconfig
> +++ b/drivers/platform/x86/amd/Kconfig
> @@ -32,3 +32,14 @@ config AMD_WBRF
>
> This mechanism will only be activated on platforms that advertise a
> need for it.
> +
> +config AMD_ISP_PLATFORM
> + tristate "AMD ISP4 platform driver"
> + depends on I2C && X86_64 && ACPI
> + help
> + Platform driver for AMD platforms containing image signal processor
> + gen 4. Provides camera sensor module board information to allow
> + sensor and V4L drivers to work properly.
> +
> + This driver can also be built as a module. If so, the module
> + will be called amd_isp4.
> diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
> index c6c40bdcbded..b0e284b5d497 100644
> --- a/drivers/platform/x86/amd/Makefile
> +++ b/drivers/platform/x86/amd/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/
> obj-$(CONFIG_AMD_HSMP) += hsmp/
> obj-$(CONFIG_AMD_PMF) += pmf/
> obj-$(CONFIG_AMD_WBRF) += wbrf.o
> +obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.o
> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
> new file mode 100644
> index 000000000000..1520ebb94507
> --- /dev/null
> +++ b/drivers/platform/x86/amd/amd_isp4.c
> @@ -0,0 +1,280 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * AMD ISP platform driver for sensor i2-client instantiation
> + *
> + * Copyright 2025 Advanced Micro Devices, Inc.
> + */
> +
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/units.h>
> +
> +#define AMDISP_OV05C10_I2C_ADDR 0x10
> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
> +#define AMDISP_OV05C10_HID "OMNI5C10"
> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
> +
> +/*
> + * AMD ISP platform definition to configure the device properties
> + * missing in the ACPI table.
> + */
> +struct amdisp_platform {
> + struct i2c_board_info board_info;
> + struct notifier_block i2c_nb;
> + struct i2c_client *i2c_dev;
> + struct mutex lock; /* protects i2c client creation */
Please add one tab before the comment such that it moves a bit more right.
> +};
> +
> +/* Top-level OV05C10 camera node property table */
> +static const struct property_entry ov05c10_camera_props[] = {
> + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
> + { }
> +};
> +
> +/* Root AMD ISP OV05C10 camera node definition */
> +static const struct software_node camera_node = {
> + .name = AMDISP_OV05C10_HID,
> + .properties = ov05c10_camera_props,
> +};
> +
> +/*
> + * AMD ISP OV05C10 Ports node definition. No properties defined for
> + * ports node for OV05C10.
> + */
> +static const struct software_node ports = {
> + .name = "ports",
> + .parent = &camera_node,
> +};
> +
> +/*
> + * AMD ISP OV05C10 Port node definition. No properties defined for
> + * port node for OV05C10.
> + */
> +static const struct software_node port_node = {
> + .name = "port@",
> + .parent = &ports,
> +};
> +
> +/*
> + * Remote endpoint AMD ISP node definition. No properties defined for
> + * remote endpoint node for OV05C10.
> + */
> +static const struct software_node remote_ep_isp_node = {
> + .name = AMDISP_OV05C10_REMOTE_EP_NAME,
> +};
> +
> +/*
> + * Remote endpoint reference for isp node included in the
> + * OV05C10 endpoint.
> + */
> +static const struct software_node_ref_args ov05c10_refs[] = {
> + SOFTWARE_NODE_REFERENCE(&remote_ep_isp_node),
> +};
> +
> +/* OV05C supports one single link frequency */
> +static const u64 ov05c10_link_freqs[] = {
> + 925 * HZ_PER_MHZ,
> +};
> +
> +/* OV05C supports only 2-lane configuration */
> +static const u32 ov05c10_data_lanes[] = {
> + 1,
> + 2,
> +};
> +
> +/* OV05C10 endpoint node properties table */
> +static const struct property_entry ov05c10_endpoint_props[] = {
> + PROPERTY_ENTRY_U32("bus-type", 4),
> + PROPERTY_ENTRY_U32_ARRAY_LEN("data-lanes", ov05c10_data_lanes,
> + ARRAY_SIZE(ov05c10_data_lanes)),
> + PROPERTY_ENTRY_U64_ARRAY_LEN("link-frequencies", ov05c10_link_freqs,
> + ARRAY_SIZE(ov05c10_link_freqs)),
> + PROPERTY_ENTRY_REF_ARRAY("remote-endpoint", ov05c10_refs),
> + { }
> +};
> +
> +/* AMD ISP endpoint node definition */
> +static const struct software_node endpoint_node = {
> + .name = "endpoint",
> + .parent = &port_node,
> + .properties = ov05c10_endpoint_props,
> +};
> +
> +/*
> + * AMD ISP swnode graph uses 5 nodes and also its relationship is
> + * fixed to align with the structure that v4l2 expects for successful
> + * endpoint fwnode parsing.
> + *
> + * It is only the node property_entries that will vary for each platform
> + * supporting different sensor modules.
> + */
> +#define NUM_SW_NODES 5
> +
> +static const struct software_node *ov05c10_nodes[NUM_SW_NODES + 1] = {
> + &camera_node,
> + &ports,
> + &port_node,
> + &endpoint_node,
> + &remote_ep_isp_node,
> + NULL
> +};
> +
> +static const struct acpi_device_id amdisp_sensor_ids[] = {
> + { AMDISP_OV05C10_HID },
> + { }
> +};
> +MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
> +
> +static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
> +{
> + return !strcmp(adap->owner->name, "i2c_designware_amdisp");
> +}
> +
> +static void instantiate_isp_i2c_client(struct amdisp_platform *ov05c10, struct i2c_adapter *adap)
> +{
> + struct i2c_board_info *info = &ov05c10->board_info;
> + struct i2c_client *i2c_dev;
> +
> + guard(mutex)(&ov05c10->lock);
> +
> + if (ov05c10->i2c_dev)
> + return;
> +
> + i2c_dev = i2c_new_client_device(adap, info);
> + if (IS_ERR(i2c_dev)) {
> + dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
> + return;
> + }
> + ov05c10->i2c_dev = i2c_dev;
> +}
> +
> +static int isp_i2c_bus_notify(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct amdisp_platform *ov05c10 = container_of(nb, struct amdisp_platform, i2c_nb);
> + struct device *dev = data;
> + struct i2c_client *client;
> + struct i2c_adapter *adap;
> +
> + switch (action) {
> + case BUS_NOTIFY_ADD_DEVICE:
> + adap = i2c_verify_adapter(dev);
> + if (!adap)
> + break;
> + if (is_isp_i2c_adapter(adap))
> + instantiate_isp_i2c_client(ov05c10, adap);
> + break;
> + case BUS_NOTIFY_REMOVED_DEVICE:
> + client = i2c_verify_client(dev);
> + if (!client)
> + break;
> +
> + scoped_guard(mutex, &ov05c10->lock) {
> + if (ov05c10->i2c_dev == client) {
> + dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
> + ov05c10->i2c_dev = NULL;
> + }
> + }
> + break;
> + default:
> + break;
> + }
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct amdisp_platform *prepare_amdisp_platform(struct device *dev)
> +{
> + struct amdisp_platform *isp_ov05c10;
> + int ret;
> +
> + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL);
> + if (!isp_ov05c10)
> + return ERR_PTR(-ENOMEM);
> +
> + ret = devm_mutex_init(dev, &isp_ov05c10->lock);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + isp_ov05c10->board_info.dev_name = "ov05c10";
> + strscpy(isp_ov05c10->board_info.type, "ov05c10", I2C_NAME_SIZE);
There's some clever VA_ARGS magic in the strscpy() macro such that the
size parameter is optional in many cases. Thus, in cases where the size
parameter is the same as the size of the dst known to the compiler, please
only provide dst and src to strscpy().
--
i.
> + isp_ov05c10->board_info.addr = AMDISP_OV05C10_I2C_ADDR;
> +
> + ret = software_node_register_node_group(ov05c10_nodes);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + isp_ov05c10->board_info.swnode = ov05c10_nodes[0];
> +
> + return isp_ov05c10;
> +}
> +
> +static int try_to_instantiate_i2c_client(struct device *dev, void *data)
> +{
> + struct amdisp_platform *ov05c10 = (struct amdisp_platform *)data;
> + struct i2c_adapter *adap = i2c_verify_adapter(dev);
> +
> + if (!ov05c10 || !adap)
> + return 0;
> + if (!adap->owner)
> + return 0;
> +
> + if (is_isp_i2c_adapter(adap))
> + instantiate_isp_i2c_client(ov05c10, adap);
> +
> + return 0;
> +}
> +
> +static int amd_isp_probe(struct platform_device *pdev)
> +{
> + struct amdisp_platform *ov05c10;
> + int ret;
> +
> + ov05c10 = prepare_amdisp_platform(&pdev->dev);
> + if (IS_ERR(ov05c10))
> + return dev_err_probe(&pdev->dev, PTR_ERR(ov05c10),
> + "failed to prepare AMD ISP platform fwnode\n");
> +
> + ov05c10->i2c_nb.notifier_call = isp_i2c_bus_notify;
> + ret = bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
> + if (ret)
> + goto error_unregister_sw_node;
> +
> + /* check if adapter is already registered and create i2c client instance */
> + i2c_for_each_dev((void *)ov05c10, try_to_instantiate_i2c_client);
> +
> + platform_set_drvdata(pdev, ov05c10);
> + return 0;
> +
> +error_unregister_sw_node:
> + software_node_unregister_node_group(ov05c10_nodes);
> + return ret;
> +}
> +
> +static void amd_isp_remove(struct platform_device *pdev)
> +{
> + struct amdisp_platform *ov05c10 = platform_get_drvdata(pdev);
> +
> + bus_unregister_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
> + i2c_unregister_device(ov05c10->i2c_dev);
> + software_node_unregister_node_group(ov05c10_nodes);
> +}
> +
> +static struct platform_driver amd_isp_platform_driver = {
> + .driver = {
> + .name = AMD_ISP_PLAT_DRV_NAME,
> + .acpi_match_table = amdisp_sensor_ids,
> + },
> + .probe = amd_isp_probe,
> + .remove = amd_isp_remove,
> +};
> +
> +module_platform_driver(amd_isp_platform_driver);
> +
> +MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>");
> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
> +MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
> +MODULE_LICENSE("GPL");
>
Hi Ilpo,
On 5/6/2025 9:00 AM, Ilpo Järvinen wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Mon, 5 May 2025, Pratap Nirujogi wrote:
>
>> ISP device specific configuration is not available in ACPI. Add
>> swnode graph to configure the missing device properties for the
>> OV05C10 camera device supported on amdisp platform.
>>
>> Add support to create i2c-client dynamically when amdisp i2c
>> adapter is available.
>>
>> Co-developed-by: Benjamin Chan <benjamin.chan@amd.com>
>> Signed-off-by: Benjamin Chan <benjamin.chan@amd.com>
>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
>> ---
>> Changes v11 -> v12:
>>
>> * Add missing space before the open parenthesis '('
>>
>> drivers/platform/x86/amd/Kconfig | 11 ++
>> drivers/platform/x86/amd/Makefile | 1 +
>> drivers/platform/x86/amd/amd_isp4.c | 280 ++++++++++++++++++++++++++++
>> 3 files changed, 292 insertions(+)
>> create mode 100644 drivers/platform/x86/amd/amd_isp4.c
>>
>> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
>> index c3e086ea64fc..152a68a470e8 100644
>> --- a/drivers/platform/x86/amd/Kconfig
>> +++ b/drivers/platform/x86/amd/Kconfig
>> @@ -32,3 +32,14 @@ config AMD_WBRF
>>
>> This mechanism will only be activated on platforms that advertise a
>> need for it.
>> +
>> +config AMD_ISP_PLATFORM
>> + tristate "AMD ISP4 platform driver"
>> + depends on I2C && X86_64 && ACPI
>> + help
>> + Platform driver for AMD platforms containing image signal processor
>> + gen 4. Provides camera sensor module board information to allow
>> + sensor and V4L drivers to work properly.
>> +
>> + This driver can also be built as a module. If so, the module
>> + will be called amd_isp4.
>> diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile
>> index c6c40bdcbded..b0e284b5d497 100644
>> --- a/drivers/platform/x86/amd/Makefile
>> +++ b/drivers/platform/x86/amd/Makefile
>> @@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/
>> obj-$(CONFIG_AMD_HSMP) += hsmp/
>> obj-$(CONFIG_AMD_PMF) += pmf/
>> obj-$(CONFIG_AMD_WBRF) += wbrf.o
>> +obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.o
>> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
>> new file mode 100644
>> index 000000000000..1520ebb94507
>> --- /dev/null
>> +++ b/drivers/platform/x86/amd/amd_isp4.c
>> @@ -0,0 +1,280 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * AMD ISP platform driver for sensor i2-client instantiation
>> + *
>> + * Copyright 2025 Advanced Micro Devices, Inc.
>> + */
>> +
>> +#include <linux/i2c.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/property.h>
>> +#include <linux/units.h>
>> +
>> +#define AMDISP_OV05C10_I2C_ADDR 0x10
>> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform"
>> +#define AMDISP_OV05C10_HID "OMNI5C10"
>> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1"
>> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4"
>> +
>> +/*
>> + * AMD ISP platform definition to configure the device properties
>> + * missing in the ACPI table.
>> + */
>> +struct amdisp_platform {
>> + struct i2c_board_info board_info;
>> + struct notifier_block i2c_nb;
>> + struct i2c_client *i2c_dev;
>> + struct mutex lock; /* protects i2c client creation */
>
> Please add one tab before the comment such that it moves a bit more right.
>
sure, will take care of it in next v13 patch.
>> +};
>> +
>> +/* Top-level OV05C10 camera node property table */
>> +static const struct property_entry ov05c10_camera_props[] = {
>> + PROPERTY_ENTRY_U32("clock-frequency", 24 * HZ_PER_MHZ),
>> + { }
>> +};
>> +
>> +/* Root AMD ISP OV05C10 camera node definition */
>> +static const struct software_node camera_node = {
>> + .name = AMDISP_OV05C10_HID,
>> + .properties = ov05c10_camera_props,
>> +};
>> +
>> +/*
>> + * AMD ISP OV05C10 Ports node definition. No properties defined for
>> + * ports node for OV05C10.
>> + */
>> +static const struct software_node ports = {
>> + .name = "ports",
>> + .parent = &camera_node,
>> +};
>> +
>> +/*
>> + * AMD ISP OV05C10 Port node definition. No properties defined for
>> + * port node for OV05C10.
>> + */
>> +static const struct software_node port_node = {
>> + .name = "port@",
>> + .parent = &ports,
>> +};
>> +
>> +/*
>> + * Remote endpoint AMD ISP node definition. No properties defined for
>> + * remote endpoint node for OV05C10.
>> + */
>> +static const struct software_node remote_ep_isp_node = {
>> + .name = AMDISP_OV05C10_REMOTE_EP_NAME,
>> +};
>> +
>> +/*
>> + * Remote endpoint reference for isp node included in the
>> + * OV05C10 endpoint.
>> + */
>> +static const struct software_node_ref_args ov05c10_refs[] = {
>> + SOFTWARE_NODE_REFERENCE(&remote_ep_isp_node),
>> +};
>> +
>> +/* OV05C supports one single link frequency */
>> +static const u64 ov05c10_link_freqs[] = {
>> + 925 * HZ_PER_MHZ,
>> +};
>> +
>> +/* OV05C supports only 2-lane configuration */
>> +static const u32 ov05c10_data_lanes[] = {
>> + 1,
>> + 2,
>> +};
>> +
>> +/* OV05C10 endpoint node properties table */
>> +static const struct property_entry ov05c10_endpoint_props[] = {
>> + PROPERTY_ENTRY_U32("bus-type", 4),
>> + PROPERTY_ENTRY_U32_ARRAY_LEN("data-lanes", ov05c10_data_lanes,
>> + ARRAY_SIZE(ov05c10_data_lanes)),
>> + PROPERTY_ENTRY_U64_ARRAY_LEN("link-frequencies", ov05c10_link_freqs,
>> + ARRAY_SIZE(ov05c10_link_freqs)),
>> + PROPERTY_ENTRY_REF_ARRAY("remote-endpoint", ov05c10_refs),
>> + { }
>> +};
>> +
>> +/* AMD ISP endpoint node definition */
>> +static const struct software_node endpoint_node = {
>> + .name = "endpoint",
>> + .parent = &port_node,
>> + .properties = ov05c10_endpoint_props,
>> +};
>> +
>> +/*
>> + * AMD ISP swnode graph uses 5 nodes and also its relationship is
>> + * fixed to align with the structure that v4l2 expects for successful
>> + * endpoint fwnode parsing.
>> + *
>> + * It is only the node property_entries that will vary for each platform
>> + * supporting different sensor modules.
>> + */
>> +#define NUM_SW_NODES 5
>> +
>> +static const struct software_node *ov05c10_nodes[NUM_SW_NODES + 1] = {
>> + &camera_node,
>> + &ports,
>> + &port_node,
>> + &endpoint_node,
>> + &remote_ep_isp_node,
>> + NULL
>> +};
>> +
>> +static const struct acpi_device_id amdisp_sensor_ids[] = {
>> + { AMDISP_OV05C10_HID },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
>> +
>> +static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
>> +{
>> + return !strcmp(adap->owner->name, "i2c_designware_amdisp");
>> +}
>> +
>> +static void instantiate_isp_i2c_client(struct amdisp_platform *ov05c10, struct i2c_adapter *adap)
>> +{
>> + struct i2c_board_info *info = &ov05c10->board_info;
>> + struct i2c_client *i2c_dev;
>> +
>> + guard(mutex)(&ov05c10->lock);
>> +
>> + if (ov05c10->i2c_dev)
>> + return;
>> +
>> + i2c_dev = i2c_new_client_device(adap, info);
>> + if (IS_ERR(i2c_dev)) {
>> + dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
>> + return;
>> + }
>> + ov05c10->i2c_dev = i2c_dev;
>> +}
>> +
>> +static int isp_i2c_bus_notify(struct notifier_block *nb,
>> + unsigned long action, void *data)
>> +{
>> + struct amdisp_platform *ov05c10 = container_of(nb, struct amdisp_platform, i2c_nb);
>> + struct device *dev = data;
>> + struct i2c_client *client;
>> + struct i2c_adapter *adap;
>> +
>> + switch (action) {
>> + case BUS_NOTIFY_ADD_DEVICE:
>> + adap = i2c_verify_adapter(dev);
>> + if (!adap)
>> + break;
>> + if (is_isp_i2c_adapter(adap))
>> + instantiate_isp_i2c_client(ov05c10, adap);
>> + break;
>> + case BUS_NOTIFY_REMOVED_DEVICE:
>> + client = i2c_verify_client(dev);
>> + if (!client)
>> + break;
>> +
>> + scoped_guard(mutex, &ov05c10->lock) {
>> + if (ov05c10->i2c_dev == client) {
>> + dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
>> + ov05c10->i2c_dev = NULL;
>> + }
>> + }
>> + break;
>> + default:
>> + break;
>> + }
>> +
>> + return NOTIFY_DONE;
>> +}
>> +
>> +static struct amdisp_platform *prepare_amdisp_platform(struct device *dev)
>> +{
>> + struct amdisp_platform *isp_ov05c10;
>> + int ret;
>> +
>> + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL);
>> + if (!isp_ov05c10)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ret = devm_mutex_init(dev, &isp_ov05c10->lock);
>> + if (ret)
>> + return ERR_PTR(ret);
>> +
>> + isp_ov05c10->board_info.dev_name = "ov05c10";
>> + strscpy(isp_ov05c10->board_info.type, "ov05c10", I2C_NAME_SIZE);
>
> There's some clever VA_ARGS magic in the strscpy() macro such that the
> size parameter is optional in many cases. Thus, in cases where the size
> parameter is the same as the size of the dst known to the compiler, please
> only provide dst and src to strscpy().
>
Thanks, good to know size parameter can be optional when src and dst
sizes are same. Will remove size param in v13.
Thanks,
Pratap
> --
> i.
>
>> + isp_ov05c10->board_info.addr = AMDISP_OV05C10_I2C_ADDR;
>> +
>> + ret = software_node_register_node_group(ov05c10_nodes);
>> + if (ret)
>> + return ERR_PTR(ret);
>> +
>> + isp_ov05c10->board_info.swnode = ov05c10_nodes[0];
>> +
>> + return isp_ov05c10;
>> +}
>> +
>> +static int try_to_instantiate_i2c_client(struct device *dev, void *data)
>> +{
>> + struct amdisp_platform *ov05c10 = (struct amdisp_platform *)data;
>> + struct i2c_adapter *adap = i2c_verify_adapter(dev);
>> +
>> + if (!ov05c10 || !adap)
>> + return 0;
>> + if (!adap->owner)
>> + return 0;
>> +
>> + if (is_isp_i2c_adapter(adap))
>> + instantiate_isp_i2c_client(ov05c10, adap);
>> +
>> + return 0;
>> +}
>> +
>> +static int amd_isp_probe(struct platform_device *pdev)
>> +{
>> + struct amdisp_platform *ov05c10;
>> + int ret;
>> +
>> + ov05c10 = prepare_amdisp_platform(&pdev->dev);
>> + if (IS_ERR(ov05c10))
>> + return dev_err_probe(&pdev->dev, PTR_ERR(ov05c10),
>> + "failed to prepare AMD ISP platform fwnode\n");
>> +
>> + ov05c10->i2c_nb.notifier_call = isp_i2c_bus_notify;
>> + ret = bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
>> + if (ret)
>> + goto error_unregister_sw_node;
>> +
>> + /* check if adapter is already registered and create i2c client instance */
>> + i2c_for_each_dev((void *)ov05c10, try_to_instantiate_i2c_client);
>> +
>> + platform_set_drvdata(pdev, ov05c10);
>> + return 0;
>> +
>> +error_unregister_sw_node:
>> + software_node_unregister_node_group(ov05c10_nodes);
>> + return ret;
>> +}
>> +
>> +static void amd_isp_remove(struct platform_device *pdev)
>> +{
>> + struct amdisp_platform *ov05c10 = platform_get_drvdata(pdev);
>> +
>> + bus_unregister_notifier(&i2c_bus_type, &ov05c10->i2c_nb);
>> + i2c_unregister_device(ov05c10->i2c_dev);
>> + software_node_unregister_node_group(ov05c10_nodes);
>> +}
>> +
>> +static struct platform_driver amd_isp_platform_driver = {
>> + .driver = {
>> + .name = AMD_ISP_PLAT_DRV_NAME,
>> + .acpi_match_table = amdisp_sensor_ids,
>> + },
>> + .probe = amd_isp_probe,
>> + .remove = amd_isp_remove,
>> +};
>> +
>> +module_platform_driver(amd_isp_platform_driver);
>> +
>> +MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>");
>> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
>> +MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
>> +MODULE_LICENSE("GPL");
>>
> +#define AMDISP_OV05C10_I2C_ADDR 0x10 > +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform" > +#define AMDISP_OV05C10_HID "OMNI5C10" > +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1" > +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4" Hey folks, I know v12 might be a bit too late for this one, but I've got another device here (Asus GZ302EA tablet) with a very similar camera setup, but a different sensor (OV13B10), and it looks like this driver just assumes a certain hardcoded configuration... I wonder if it makes sense to reorganize the code so that more sensor configurations can be added without making a separate module? I'd be happy to help with refactoring/testing/etc, if people are interested.
On Tue, 6 May 2025, Ilya K wrote: > > +#define AMDISP_OV05C10_I2C_ADDR 0x10 > > +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform" > > +#define AMDISP_OV05C10_HID "OMNI5C10" > > +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1" > > +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4" > > Hey folks, I know v12 might be a bit too late for this one, but I've got > another device here (Asus GZ302EA tablet) with a very similar camera > setup, but a different sensor (OV13B10), and it looks like this driver > just assumes a certain hardcoded configuration... I wonder if it makes > sense to reorganize the code so that more sensor configurations can be > added without making a separate module? I'd be happy to help with > refactoring/testing/etc, if people are interested. v12 is not too late, and besides, v9..v12 has happened within 5 days which is rather short time (hint to the submitter that there's no need to burn patch series version numbers at that speed :-)). I'll give folks some time to sort this out if you need to add e.g., some driver_data instead. -- i.
On 5/6/2025 8:53 AM, Ilpo Järvinen wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > > On Tue, 6 May 2025, Ilya K wrote: > >>> +#define AMDISP_OV05C10_I2C_ADDR 0x10 >>> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform" >>> +#define AMDISP_OV05C10_HID "OMNI5C10" >>> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1" >>> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4" >> >> Hey folks, I know v12 might be a bit too late for this one, but I've got >> another device here (Asus GZ302EA tablet) with a very similar camera >> setup, but a different sensor (OV13B10), and it looks like this driver >> just assumes a certain hardcoded configuration... I wonder if it makes >> sense to reorganize the code so that more sensor configurations can be >> added without making a separate module? I'd be happy to help with >> refactoring/testing/etc, if people are interested. > > v12 is not too late, and besides, v9..v12 has happened within 5 days > which is rather short time (hint to the submitter that there's no need > to burn patch series version numbers at that speed :-)). > > I'll give folks some time to sort this out if you need to add e.g., some > driver_data instead. > > -- > i. > Hi Ilya, Ilpo, I agree with the suggestion, but how about taking-up the refactoring part in a separate patch. Yes this patch focussed on supporting OV05C10 and even the code review proceeded with this understanding. Refactoring now for generic support would require changes that would undo some of the recent review feedback (especially related to global variables usage). Please let us know what do you think. Thanks, Pratap
On Wed, 7 May 2025, Nirujogi, Pratap wrote: > On 5/6/2025 8:53 AM, Ilpo Järvinen wrote: > > Caution: This message originated from an External Source. Use proper caution > > when opening attachments, clicking links, or responding. > > > > > > On Tue, 6 May 2025, Ilya K wrote: > > > > > > +#define AMDISP_OV05C10_I2C_ADDR 0x10 > > > > +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform" > > > > +#define AMDISP_OV05C10_HID "OMNI5C10" > > > > +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1" > > > > +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4" > > > > > > Hey folks, I know v12 might be a bit too late for this one, but I've got > > > another device here (Asus GZ302EA tablet) with a very similar camera > > > setup, but a different sensor (OV13B10), and it looks like this driver > > > just assumes a certain hardcoded configuration... I wonder if it makes > > > sense to reorganize the code so that more sensor configurations can be > > > added without making a separate module? I'd be happy to help with > > > refactoring/testing/etc, if people are interested. > > > > v12 is not too late, and besides, v9..v12 has happened within 5 days > > which is rather short time (hint to the submitter that there's no need > > to burn patch series version numbers at that speed :-)). > > > > I'll give folks some time to sort this out if you need to add e.g., some > > driver_data instead. > > > > -- > > i. > > > Hi Ilya, Ilpo, > > I agree with the suggestion, but how about taking-up the refactoring part in a > separate patch. Yes this patch focussed on supporting OV05C10 and even the > code review proceeded with this understanding. Refactoring now for generic > support would require changes that would undo some of the recent review > feedback (especially related to global variables usage). Please let us know > what do you think. Hi, If you refer to comments given to v7 that resulted in removal of swnodes field from struct amdisp_platform (and some other fields along with it), I don't think the comment was given to mean that you could not have platform info structure (const struct amdisp_platform_info that never was been there) but that it should be separate struct from the runtime one (struct amdisp_platform). The runtime struct can have a pointer to the info struct if it's content is needed after probe. When the platform info struct exists, pointer to it can be put into driver_data in amdisp_sensor_ids. I don't expect you to necessarily add the other sensor there but I'd like to see this adapted such that it can be relatively easily added which likely requires having that separate struct for platform info. So in a sense, it undoes some of the changes done after v7 but looking into history of this patch, it looks the post v7 patches went slightly into wrong direction which makes adding next device harder than it needs to be (I'm sorry I didn't realize this sooner). TBH, I don't think adding the info struct is that much extra effort for you given what you had in v7, the info just needs another struct separate from struct amdisp_platform but the ingrediments kind of where there already. -- i.
Hi Ilpo, On 5/8/2025 4:52 AM, Ilpo Järvinen wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > > On Wed, 7 May 2025, Nirujogi, Pratap wrote: >> On 5/6/2025 8:53 AM, Ilpo Järvinen wrote: >>> Caution: This message originated from an External Source. Use proper caution >>> when opening attachments, clicking links, or responding. >>> >>> >>> On Tue, 6 May 2025, Ilya K wrote: >>> >>>>> +#define AMDISP_OV05C10_I2C_ADDR 0x10 >>>>> +#define AMDISP_OV05C10_PLAT_NAME "amdisp_ov05c10_platform" >>>>> +#define AMDISP_OV05C10_HID "OMNI5C10" >>>>> +#define AMDISP_OV05C10_REMOTE_EP_NAME "ov05c10_isp_4_1_1" >>>>> +#define AMD_ISP_PLAT_DRV_NAME "amd-isp4" >>>> >>>> Hey folks, I know v12 might be a bit too late for this one, but I've got >>>> another device here (Asus GZ302EA tablet) with a very similar camera >>>> setup, but a different sensor (OV13B10), and it looks like this driver >>>> just assumes a certain hardcoded configuration... I wonder if it makes >>>> sense to reorganize the code so that more sensor configurations can be >>>> added without making a separate module? I'd be happy to help with >>>> refactoring/testing/etc, if people are interested. >>> >>> v12 is not too late, and besides, v9..v12 has happened within 5 days >>> which is rather short time (hint to the submitter that there's no need >>> to burn patch series version numbers at that speed :-)). >>> >>> I'll give folks some time to sort this out if you need to add e.g., some >>> driver_data instead. >>> >>> -- >>> i. >>> >> Hi Ilya, Ilpo, >> >> I agree with the suggestion, but how about taking-up the refactoring part in a >> separate patch. Yes this patch focussed on supporting OV05C10 and even the >> code review proceeded with this understanding. Refactoring now for generic >> support would require changes that would undo some of the recent review >> feedback (especially related to global variables usage). Please let us know >> what do you think. > > Hi, > > If you refer to comments given to v7 that resulted in removal of swnodes > field from struct amdisp_platform (and some other fields along with it), I > don't think the comment was given to mean that you could not have > platform info structure (const struct amdisp_platform_info that never was > been there) but that it should be separate struct from the runtime one > (struct amdisp_platform). The runtime struct can have a pointer to the > info struct if it's content is needed after probe. > > When the platform info struct exists, pointer to it can be put into > driver_data in amdisp_sensor_ids. I don't expect you to necessarily add > the other sensor there but I'd like to see this adapted such that it can > be relatively easily added which likely requires having that separate > struct for platform info. > > So in a sense, it undoes some of the changes done after v7 but looking > into history of this patch, it looks the post v7 patches went slightly > into wrong direction which makes adding next device harder than it needs > to be (I'm sorry I didn't realize this sooner). TBH, I don't think adding > the info struct is that much extra effort for you given what you had in > v7, the info just needs another struct separate from struct > amdisp_platform but the ingrediments kind of where there already. > Thanks for clarifying and providing direction. I agree adding the new amdisp_platform_info structure should be straightforward. I will implement the changes and submit the new patch v13. Thanks, Pratap > -- > i.
© 2016 - 2025 Red Hat, Inc.