Skip to contentSkip to conversation

platform/x86: Add AMD ISP platform config for OV05C10

PATCH Superseded Pratap Nirujogi 3 participants 5 messages May 9, 2025 – May 12, 2025 x86 platform drivers

v13 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

PATCH v13 1/1 platform/x86: Add AMD ISP platform config for OV05C10

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.

---
Changes v12 -> v13:

* Add "struct amdisp_platform_info" to pass sensor specific configuration and make the driver generic to support OV05C10 and other supported sensor modules in future.

* Address cosmetic and other review comments.

 drivers/platform/x86/amd/Kconfig    |  11 +
 drivers/platform/x86/amd/Makefile   |   1 +
 drivers/platform/x86/amd/amd_isp4.c | 309 ++++++++++++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/platform/x86/amd/amd_isp4.c
drivers/platform/x86/amd/Kconfig +11 -0
index c3e086ea64fc..152a68a470e8 100644
@@ -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.
drivers/platform/x86/amd/Makefile +1 -0
index c6c40bdcbded..b0e284b5d497 100644
@@ -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
drivers/platform/x86/amd/amd_isp4.c new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 67 lines · Pratap Nirujogi

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.

---
Changes v12 -> v13:

* Add "struct amdisp_platform_info" to pass sensor specific configuration and make the driver generic to support OV05C10 and other supported sensor modules in future.

* Address cosmetic and other review comments.

 drivers/platform/x86/amd/Kconfig    |  11 +
 drivers/platform/x86/amd/Makefile   |   1 +
 drivers/platform/x86/amd/amd_isp4.c | 309 ++++++++++++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/platform/x86/amd/amd_isp4.c
drivers/platform/x86/amd/Kconfig +11 -0
index c3e086ea64fc..152a68a470e8 100644
@@ -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.
drivers/platform/x86/amd/Makefile +1 -0
index c6c40bdcbded..b0e284b5d497 100644
@@ -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
drivers/platform/x86/amd/amd_isp4.c new file +5 -0
new file mode 100644
index 000000000000..27939020634c
@@ -0,0 +1,309 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AMD ISP platform driver for sensor i2-client instantiation
+ *
+ * Copyright 2025 Advanced Micro Devices, Inc.

drivers/platform/x86/amd/amd_isp4.c line 15

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+ */
+
+#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"

This is not used anywhere?

Quoted 14 lines
drivers/platform/x86/amd/amd_isp4.c new file +14 -0
+#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 info definition to initialize sensor
+ * specific platform configuration to prepare the amdisp
+ * platform.
+ */
+struct amdisp_platform_info {
+	struct i2c_board_info board_info;
+	const struct software_node **swnodes;
+};
+

drivers/platform/x86/amd/amd_isp4.c line 39

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+/*
+ * AMD ISP platform definition to configure the device properties
+ * missing in the ACPI table.
+ */
+struct amdisp_platform {
+	const struct amdisp_platform_info *pinfo;
+	struct i2c_board_info board_info;
+	struct notifier_block i2c_nb;
+	struct i2c_client *i2c_dev;
+	struct mutex lock;	/* protects i2c client creation */

Missing #include.

Quoted 40 lines
drivers/platform/x86/amd/amd_isp4.c new file +40 -0
+};
+
+/* 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,
+};
+

drivers/platform/x86/amd/amd_isp4.c line 89

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+/*
+ * 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[] = {

+ #include <linux/types.h>

Quoted 52 lines
drivers/platform/x86/amd/amd_isp4.c new file +52 -0
+	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.
+ */
+static const struct software_node *ov05c10_nodes[] = {
+	&camera_node,
+	&ports,
+	&port_node,
+	&endpoint_node,
+	&remote_ep_isp_node,
+	NULL
+};
+
+/* OV05C10 specific AMD ISP platform configuration */
+static const struct amdisp_platform_info ov05c10_platform_config = {
+	.board_info = {
+		.dev_name = "ov05c10",
+		I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR),
+	},
+	.swnodes = ov05c10_nodes,
+};

drivers/platform/x86/amd/amd_isp4.c line 151

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+
+static const struct acpi_device_id amdisp_sensor_ids[] = {
+	{ AMDISP_OV05C10_HID, (kernel_ulong_t)&ov05c10_platform_config },
+	{ }
+};
+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");

Missing #include.

Quoted 5 lines
drivers/platform/x86/amd/amd_isp4.c new file +5 -0
+}
+
+static void instantiate_isp_i2c_client(struct amdisp_platform *isp4_platform,
+				       struct i2c_adapter *adap)
+{

drivers/platform/x86/amd/amd_isp4.c line 166

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+	struct i2c_board_info *info = &isp4_platform->board_info;
+	struct i2c_client *i2c_dev;
+
+	guard(mutex)(&isp4_platform->lock);
+
+	if (isp4_platform->i2c_dev)
+		return;
+
+	i2c_dev = i2c_new_client_device(adap, info);
+	if (IS_ERR(i2c_dev)) {

Missing #include.

Quoted 63 lines
drivers/platform/x86/amd/amd_isp4.c new file +63 -0
+		dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
+		return;
+	}
+	isp4_platform->i2c_dev = i2c_dev;
+}
+
+static int isp_i2c_bus_notify(struct notifier_block *nb,
+			      unsigned long action, void *data)
+{
+	struct amdisp_platform *isp4_platform =
+		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(isp4_platform, adap);
+		break;
+	case BUS_NOTIFY_REMOVED_DEVICE:
+		client = i2c_verify_client(dev);
+		if (!client)
+			break;
+
+		scoped_guard(mutex, &isp4_platform->lock) {
+			if (isp4_platform->i2c_dev == client) {
+				dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+				isp4_platform->i2c_dev = NULL;
+			}
+		}
+		break;
+	default:
+		break;
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct amdisp_platform *prepare_amdisp_platform(struct device *dev,
+						       const struct amdisp_platform_info *src)
+{
+	struct amdisp_platform *isp4_platform;
+	int ret;
+
+	isp4_platform = devm_kzalloc(dev, sizeof(*isp4_platform), GFP_KERNEL);
+	if (!isp4_platform)
+		return ERR_PTR(-ENOMEM);
+
+	ret = devm_mutex_init(dev, &isp4_platform->lock);
+	if (ret)
+		return ERR_PTR(ret);
+
+	isp4_platform->board_info.dev_name = src->board_info.dev_name;
+	strscpy(isp4_platform->board_info.type, src->board_info.type);
+	isp4_platform->board_info.addr = src->board_info.addr;
+	isp4_platform->pinfo = src;
+
+	ret = software_node_register_node_group(src->swnodes);
+	if (ret)

drivers/platform/x86/amd/amd_isp4.c line 239

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+		return ERR_PTR(ret);
+
+	isp4_platform->board_info.swnode = src->swnodes[0];
+
+	return isp4_platform;
+}
+
+static int try_to_instantiate_i2c_client(struct device *dev, void *data)
+{
+	struct amdisp_platform *isp4_platform = (struct amdisp_platform *)data;

No need to cast from void *.

Quoted 27 lines
drivers/platform/x86/amd/amd_isp4.c new file +27 -0
+	struct i2c_adapter *adap = i2c_verify_adapter(dev);
+
+	if (!isp4_platform || !adap)
+		return 0;
+	if (!adap->owner)
+		return 0;
+
+	if (is_isp_i2c_adapter(adap))
+		instantiate_isp_i2c_client(isp4_platform, adap);
+
+	return 0;
+}
+
+static int amd_isp_probe(struct platform_device *pdev)
+{
+	const struct amdisp_platform_info *pinfo;
+	struct amdisp_platform *isp4_platform;
+	int ret;
+
+	pinfo = device_get_match_data(&pdev->dev);
+	if (!pinfo) {
+		return dev_err_probe(&pdev->dev, -EINVAL,
+				     "failed to get valid ACPI data\n");
+	}
+
+	isp4_platform = prepare_amdisp_platform(&pdev->dev, pinfo);
+	if (IS_ERR(isp4_platform))

drivers/platform/x86/amd/amd_isp4.c line 276

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+		return dev_err_probe(&pdev->dev, PTR_ERR(isp4_platform),
+				     "failed to prepare AMD ISP platform fwnode\n");
+
+	isp4_platform->i2c_nb.notifier_call = isp_i2c_bus_notify;
+	ret = bus_register_notifier(&i2c_bus_type, &isp4_platform->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 *)isp4_platform, try_to_instantiate_i2c_client);

No need to case pointer to/from void *.

Quoted 34 lines
drivers/platform/x86/amd/amd_isp4.c new file +33 -0
+
+	platform_set_drvdata(pdev, isp4_platform);
+	return 0;
+
+error_unregister_sw_node:
+	software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
+	return ret;
+}
+
+static void amd_isp_remove(struct platform_device *pdev)
+{
+	struct amdisp_platform *isp4_platform = platform_get_drvdata(pdev);
+
+	bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
+	i2c_unregister_device(isp4_platform->i2c_dev);
+	software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
+}
+
+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 <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
 i.
#2 lore raw

Hi Ilpo,

Quoted 76 lines · Ilpo Järvinen

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 71 lines · Pratap Nirujogi

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.

---
Changes v12 -> v13:

* Add "struct amdisp_platform_info" to pass sensor specific configuration and make the driver generic to support OV05C10 and other supported sensor modules in future.

* Address cosmetic and other review comments.

  drivers/platform/x86/amd/Kconfig    |  11 +
  drivers/platform/x86/amd/Makefile   |   1 +
  drivers/platform/x86/amd/amd_isp4.c | 309 ++++++++++++++++++++++++++++
  3 files changed, 321 insertions(+)

create mode 100644 drivers/platform/x86/amd/amd_isp4.c

drivers/platform/x86/amd/Kconfig +11 -0
index c3e086ea64fc..152a68a470e8 100644
@@ -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.
drivers/platform/x86/amd/Makefile +1 -0
index c6c40bdcbded..b0e284b5d497 100644
@@ -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
drivers/platform/x86/amd/amd_isp4.c new file +9 -0
new file mode 100644
index 000000000000..27939020634c
@@ -0,0 +1,309 @@
+// 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>
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 15

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+#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"

This is not used anywhere?

Thanks. Will remove it, its not used anymore.

Quoted 18 lines
Quoted 18 lines
drivers/platform/x86/amd/amd_isp4.c new file +18 -0
+#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 info definition to initialize sensor
+ * specific platform configuration to prepare the amdisp
+ * platform.
+ */
+struct amdisp_platform_info {
+     struct i2c_board_info board_info;
+     const struct software_node **swnodes;
+};
+
+/*
+ * AMD ISP platform definition to configure the device properties
+ * missing in the ACPI table.
+ */
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 39

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+struct amdisp_platform {
+     const struct amdisp_platform_info *pinfo;
+     struct i2c_board_info board_info;
+     struct notifier_block i2c_nb;
+     struct i2c_client *i2c_dev;
+     struct mutex lock;      /* protects i2c client creation */

Missing #include.

ok, will #include <linux/mutex.h>. I have not included some of these header files seprately as they are already part of one or the other existing headers in the patch.

Quoted 44 lines
Quoted 44 lines
drivers/platform/x86/amd/amd_isp4.c new file +44 -0
+};
+
+/* 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.
+ */
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 89

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+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[] = {

+ #include <linux/types.h>

ok, will add it.

Quoted 56 lines
Quoted 56 lines
drivers/platform/x86/amd/amd_isp4.c new file +56 -0
+     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.
+ */
+static const struct software_node *ov05c10_nodes[] = {
+     &camera_node,
+     &ports,
+     &port_node,
+     &endpoint_node,
+     &remote_ep_isp_node,
+     NULL
+};
+
+/* OV05C10 specific AMD ISP platform configuration */
+static const struct amdisp_platform_info ov05c10_platform_config = {
+     .board_info = {
+             .dev_name = "ov05c10",
+             I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR),
+     },
+     .swnodes = ov05c10_nodes,
+};
+
+static const struct acpi_device_id amdisp_sensor_ids[] = {
+     { AMDISP_OV05C10_HID, (kernel_ulong_t)&ov05c10_platform_config },
+     { }
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 151

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+};
+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");

Missing #include.

ok, will #include <linux/string.h>

Quoted 9 lines
Quoted 9 lines
drivers/platform/x86/amd/amd_isp4.c new file +9 -0
+}
+
+static void instantiate_isp_i2c_client(struct amdisp_platform *isp4_platform,
+                                    struct i2c_adapter *adap)
+{
+     struct i2c_board_info *info = &isp4_platform->board_info;
+     struct i2c_client *i2c_dev;
+
+     guard(mutex)(&isp4_platform->lock);
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 166

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+
+     if (isp4_platform->i2c_dev)
+             return;
+
+     i2c_dev = i2c_new_client_device(adap, info);
+     if (IS_ERR(i2c_dev)) {

Missing #include.

ok, will #include <linux/err.h>

Quoted 107 lines
Quoted 63 lines
drivers/platform/x86/amd/amd_isp4.c new file +63 -0
+             dev_err(&adap->dev, "error %pe registering isp i2c_client\n", i2c_dev);
+             return;
+     }
+     isp4_platform->i2c_dev = i2c_dev;
+}
+
+static int isp_i2c_bus_notify(struct notifier_block *nb,
+                           unsigned long action, void *data)
+{
+     struct amdisp_platform *isp4_platform =
+             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(isp4_platform, adap);
+             break;
+     case BUS_NOTIFY_REMOVED_DEVICE:
+             client = i2c_verify_client(dev);
+             if (!client)
+                     break;
+
+             scoped_guard(mutex, &isp4_platform->lock) {
+                     if (isp4_platform->i2c_dev == client) {
+                             dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+                             isp4_platform->i2c_dev = NULL;
+                     }
+             }
+             break;
+     default:
+             break;
+     }
+
+     return NOTIFY_DONE;
+}
+
+static struct amdisp_platform *prepare_amdisp_platform(struct device *dev,
+                                                    const struct amdisp_platform_info *src)
+{
+     struct amdisp_platform *isp4_platform;
+     int ret;
+
+     isp4_platform = devm_kzalloc(dev, sizeof(*isp4_platform), GFP_KERNEL);
+     if (!isp4_platform)
+             return ERR_PTR(-ENOMEM);
+
+     ret = devm_mutex_init(dev, &isp4_platform->lock);
+     if (ret)
+             return ERR_PTR(ret);
+
+     isp4_platform->board_info.dev_name = src->board_info.dev_name;
+     strscpy(isp4_platform->board_info.type, src->board_info.type);
+     isp4_platform->board_info.addr = src->board_info.addr;
+     isp4_platform->pinfo = src;
+
+     ret = software_node_register_node_group(src->swnodes);
+     if (ret)

drivers/platform/x86/amd/amd_isp4.c line 239

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+             return ERR_PTR(ret);
+
+     isp4_platform->board_info.swnode = src->swnodes[0];
+
+     return isp4_platform;
+}
+
+static int try_to_instantiate_i2c_client(struct device *dev, void *data)
+{
+     struct amdisp_platform *isp4_platform = (struct amdisp_platform *)data;

No need to cast from void *.

Quoted 31 lines
drivers/platform/x86/amd/amd_isp4.c new file +31 -0
+     struct i2c_adapter *adap = i2c_verify_adapter(dev);
+
+     if (!isp4_platform || !adap)
+             return 0;
+     if (!adap->owner)
+             return 0;
+
+     if (is_isp_i2c_adapter(adap))
+             instantiate_isp_i2c_client(isp4_platform, adap);
+
+     return 0;
+}
+
+static int amd_isp_probe(struct platform_device *pdev)
+{
+     const struct amdisp_platform_info *pinfo;
+     struct amdisp_platform *isp4_platform;
+     int ret;
+
+     pinfo = device_get_match_data(&pdev->dev);
+     if (!pinfo) {
+             return dev_err_probe(&pdev->dev, -EINVAL,
+                                  "failed to get valid ACPI data\n");
+     }
+
+     isp4_platform = prepare_amdisp_platform(&pdev->dev, pinfo);
+     if (IS_ERR(isp4_platform))
+             return dev_err_probe(&pdev->dev, PTR_ERR(isp4_platform),
+                                  "failed to prepare AMD ISP platform fwnode\n");
+
+     isp4_platform->i2c_nb.notifier_call = isp_i2c_bus_notify;
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 276

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+     ret = bus_register_notifier(&i2c_bus_type, &isp4_platform->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 *)isp4_platform, try_to_instantiate_i2c_client);

No need to case pointer to/from void *.

sure, will remove these redundant casts.

Thanks,
Pratap

Quoted 38 lines
Quoted 24 lines
drivers/platform/x86/amd/amd_isp4.c new file +23 -0
+
+     platform_set_drvdata(pdev, isp4_platform);
+     return 0;
+
+error_unregister_sw_node:
+     software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
+     return ret;
+}
+
+static void amd_isp_remove(struct platform_device *pdev)
+{
+     struct amdisp_platform *isp4_platform = platform_get_drvdata(pdev);
+
+     bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
+     i2c_unregister_device(isp4_platform->i2c_dev);
+     software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
+}
+
+static struct platform_driver amd_isp_platform_driver = {
+     .driver = {
+             .name                   = AMD_ISP_PLAT_DRV_NAME,
+             .acpi_match_table       = amdisp_sensor_ids,
+     },

drivers/platform/x86/amd/amd_isp4.c line 309

Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10 -0
+     .probe  = amd_isp_probe,
+     .remove = amd_isp_remove,
+};
+
+module_platform_driver(amd_isp_platform_driver);
+
+MODULE_AUTHOR("Benjamin Chan <[email protected]>");
+MODULE_AUTHOR("Pratap Nirujogi <[email protected]>");
+MODULE_DESCRIPTION("AMD ISP4 Platform Driver");
+MODULE_LICENSE("GPL");

--
i.

maintainer
#3 lore raw
Quoted 123 lines · Pratap

Hi Ilpo,

Quoted 82 lines · Ilpo Järvinen

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 76 lines · Pratap Nirujogi

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.

---
Changes v12 -> v13:

* Add "struct amdisp_platform_info" to pass sensor specific configuration and make the driver generic to support OV05C10 and other supported sensor modules in future.

* Address cosmetic and other review comments.

  drivers/platform/x86/amd/Kconfig    |  11 +
  drivers/platform/x86/amd/Makefile   |   1 +
  drivers/platform/x86/amd/amd_isp4.c | 309 ++++++++++++++++++++++++++++
  3 files changed, 321 insertions(+)

create mode 100644 drivers/platform/x86/amd/amd_isp4.c

drivers/platform/x86/amd/Kconfig +0 -0
index c3e086ea64fc..152a68a470e8 100644
@@ -32,3 +32,14 @@ config AMD_WBRF
 
         This mechanism will only be activated on platforms that advertise

a
need for it.

drivers/platform/x86/amd/Kconfig +6 -0
+
+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

drivers/platform/x86/amd/Kconfig +5 -0
+       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.
drivers/platform/x86/amd/Makefile +1 -0
index c6c40bdcbded..b0e284b5d497 100644
@@ -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
drivers/platform/x86/amd/amd_isp4.c new file +9 -0
new file mode 100644
index 000000000000..27939020634c
@@ -0,0 +1,309 @@
+// 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>
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 15

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+#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"

This is not used anywhere?

Thanks. Will remove it, its not used anymore.

Quoted 18 lines
Quoted 18 lines
drivers/platform/x86/amd/amd_isp4.c new file +18 -0
+#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 info definition to initialize sensor
+ * specific platform configuration to prepare the amdisp
+ * platform.
+ */
+struct amdisp_platform_info {
+     struct i2c_board_info board_info;
+     const struct software_node **swnodes;
+};
+
+/*
+ * AMD ISP platform definition to configure the device properties
+ * missing in the ACPI table.
+ */
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 39

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+struct amdisp_platform {
+     const struct amdisp_platform_info *pinfo;
+     struct i2c_board_info board_info;
+     struct notifier_block i2c_nb;
+     struct i2c_client *i2c_dev;
+     struct mutex lock;      /* protects i2c client creation */

Missing #include.

Quoted 3 lines

ok, will #include <linux/mutex.h>. I have not included some of these header files seprately as they are already part of one or the other existing headers in the patch.

We try to include what is used by the file itself but as there's no ready to use tool to enforce it automatically, it largely depends on devs / reviewers noticing what should be added. Whenever adding a call to anything outside the .c file itself or use of non-local macro, it's good to check if another #include needs to be added (but I understand devs, me included, will often forget it).

There are a few obvious includes where the other one is not needed as the path is practically guaranteed, typical examples: linux/xx.h including asm/xx.h or uapi/linux/xx.h.

Relying intentionally on indirect includes creates very hard to track dependencies making it complex to remove any header from another header when the headerfile itself no longer needs that include. Build testing will catch some resulting fallout from such removal but it's coverage is not perfect.

Signature · 1 line
 i.
#4 lore raw
Quoted 143 lines · Ilpo Järvinen

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 123 lines · Pratap

Hi Ilpo,

Quoted 82 lines · Ilpo Järvinen

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 76 lines · Pratap Nirujogi

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.

---
Changes v12 -> v13:

* Add "struct amdisp_platform_info" to pass sensor specific configuration and make the driver generic to support OV05C10 and other supported sensor modules in future.

* Address cosmetic and other review comments.

   drivers/platform/x86/amd/Kconfig    |  11 +
   drivers/platform/x86/amd/Makefile   |   1 +
   drivers/platform/x86/amd/amd_isp4.c | 309 ++++++++++++++++++++++++++++
   3 files changed, 321 insertions(+)

create mode 100644 drivers/platform/x86/amd/amd_isp4.c

drivers/platform/x86/amd/Kconfig +0 -0
index c3e086ea64fc..152a68a470e8 100644
@@ -32,3 +32,14 @@ config AMD_WBRF
 
          This mechanism will only be activated on platforms that advertise

a
need for it.

drivers/platform/x86/amd/Kconfig +6 -0
+
+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

drivers/platform/x86/amd/Kconfig +5 -0
+       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.
drivers/platform/x86/amd/Makefile +1 -0
index c6c40bdcbded..b0e284b5d497 100644
@@ -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
drivers/platform/x86/amd/amd_isp4.c new file +9 -0
new file mode 100644
index 000000000000..27939020634c
@@ -0,0 +1,309 @@
+// 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>
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 15

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+#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"

This is not used anywhere?

Thanks. Will remove it, its not used anymore.

Quoted 18 lines
Quoted 18 lines
drivers/platform/x86/amd/amd_isp4.c new file +18 -0
+#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 info definition to initialize sensor
+ * specific platform configuration to prepare the amdisp
+ * platform.
+ */
+struct amdisp_platform_info {
+     struct i2c_board_info board_info;
+     const struct software_node **swnodes;
+};
+
+/*
+ * AMD ISP platform definition to configure the device properties
+ * missing in the ACPI table.
+ */
Quoted 9 lines

drivers/platform/x86/amd/amd_isp4.c line 39

Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +6 -0
+struct amdisp_platform {
+     const struct amdisp_platform_info *pinfo;
+     struct i2c_board_info board_info;
+     struct notifier_block i2c_nb;
+     struct i2c_client *i2c_dev;
+     struct mutex lock;      /* protects i2c client creation */

Missing #include.

Quoted 3 lines

ok, will #include <linux/mutex.h>. I have not included some of these header files seprately as they are already part of one or the other existing headers in the patch.

We try to include what is used by the file itself but as there's no ready to use tool to enforce it automatically, it largely depends on devs / reviewers noticing what should be added. Whenever adding a call to anything outside the .c file itself or use of non-local macro, it's good to check if another #include needs to be added (but I understand devs, me included, will often forget it).

There are a few obvious includes where the other one is not needed as the path is practically guaranteed, typical examples: linux/xx.h including asm/xx.h or uapi/linux/xx.h.

Quoted 6 lines

Relying intentionally on indirect includes creates very hard to track dependencies making it complex to remove any header from another header when the headerfile itself no longer needs that include. Build testing will catch some resulting fallout from such removal but it's coverage is not perfect.

Thanks Ilpo for the detailed explanation and clarifying the significance of avoiding the indirect includes. Its really helpful. Thanks.

Quoted 2 lines

--
i.