platform/x86: Add AMD ISP platform config for OV05C10
PATCH v7 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 v6 -> v7:
* Use devm_kzalloc() inplace of kmemdup()
* Use IS_ERR() inplace of i2c_client_has_driver()
* Remove the extra cast
drivers/platform/x86/amd/Kconfig | 11 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/amd_isp4.c | 269 ++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+) create mode 100644 drivers/platform/x86/amd/amd_isp4.c
drivers/platform/x86/amd/Kconfig +11 -0
@@ -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 && AMD_ISP4 + 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
@@ -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 +269 -0
269 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 10 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.
Co-developed-by Benjamin Chan <[email protected]>Signed-off-by Benjamin Chan <[email protected]>Signed-off-by Pratap Nirujogi <[email protected]>
Quoted 316 lines
---
Changes v6 -> v7:* Use
devm_kzalloc()inplace ofkmemdup()
* UseIS_ERR()inplace ofi2c_client_has_driver()
* Remove the extra castdrivers/platform/x86/amd/Kconfig | 11 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/amd_isp4.c | 269 ++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+)create mode 100644
drivers/platform/x86/amd/amd_isp4.cdrivers/platform/x86/amd/Kconfig +11
-0@@ -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 && AMD_ISP4 + 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@@ -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.odrivers/platform/x86/amd/amd_isp4.c new file +269
-0@@ -0,0 +1,269 @@ +// 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 { +const char *name; +u8 i2c_addr; +u8 max_num_swnodes; +struct i2c_board_info board_info; +struct notifier_block i2c_nb; +struct i2c_client *i2c_dev; +const struct software_node **swnodes; +}; + +/* 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 +}; + +/* OV05C10 specific AMD ISP platform configuration */ +static const struct amdisp_platform amdisp_ov05c10_platform_config = { + .name =AMDISP_OV05C10_PLAT_NAME , + .board_info = { + .dev_name ="ov05c10" , +I2C_BOARD_INFO ("ov05c10" ,AMDISP_OV05C10_I2C_ADDR ), + }, + .i2c_addr =AMDISP_OV05C10_I2C_ADDR , + .max_num_swnodes =NUM_SW_NODES , + .swnodes = ov05c10_nodes, +}; + +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; + +if (ov05c10->i2c_dev) +return ; + +if (!info->addr) { +dev_err (&adap->dev,"invalid i2c_addr 0x%x detected\n" , ov05c10->i2c_addr); +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 ; +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, +const struct amdisp_platform *src) +{ +struct amdisp_platform *isp_ov05c10; +struct i2c_board_info *info; +int ret; + + isp_ov05c10 =devm_kzalloc (dev,sizeof (*isp_ov05c10),GFP_KERNEL ); +if (!isp_ov05c10) +return ERR_PTR (-ENOMEM ); +memcpy (isp_ov05c10, src,sizeof (*isp_ov05c10)); + + info = &isp_ov05c10->board_info; + + ret =software_node_register_node_group (src->swnodes); +if (ret) +return ERR_PTR (ret); + + info->swnode = src->swnodes[0 ]; + +return isp_ov05c10; +} + +static int amd_isp_probe (struct platform_device *pdev) +{ +struct amdisp_platform *ov05c10; +int ret; + + ov05c10 =prepare_amdisp_platform (&pdev->dev, &amdisp_ov05c10_platform_config); +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) +return ret; + +platform_set_drvdata (pdev, ov05c10); +return 0 ; +} + +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->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" );
Am 17.04.25 um 20:28 schrieb Pratap Nirujogi:
Quoted 28 lines
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 <[email protected]>Signed-off-by Benjamin Chan <[email protected]>Signed-off-by Pratap Nirujogi <[email protected]>---
Changes v6 -> v7:* Use
devm_kzalloc()inplace ofkmemdup()
* UseIS_ERR()inplace ofi2c_client_has_driver()
* Remove the extra castdrivers/platform/x86/amd/Kconfig | 11 ++ drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/amd_isp4.c | 269 ++++++++++++++++++++++++++++ 3 files changed, 281 insertions(+)create mode 100644
drivers/platform/x86/amd/amd_isp4.cdrivers/platform/x86/amd/Kconfig +0
-0
drivers/platform/x86/amd/Kconfig config AMD_WBRF · line 38
Quoted 7 lines
drivers/platform/x86/amd/Kconfig +4
-0@@ -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 && AMD_ISP4
Hi,
just a question: when will the CONFIG_AMD_ISP4 symbol be introduced?
Quoted 142 lines
drivers/platform/x86/amd/Kconfig +7
-0+ 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@@ -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.odrivers/platform/x86/amd/amd_isp4.c new file +120
-0@@ -0,0 +1,269 @@ +// 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 { +const char *name; +u8 i2c_addr; +u8 max_num_swnodes; +struct i2c_board_info board_info; +struct notifier_block i2c_nb; +struct i2c_client *i2c_dev; +const struct software_node **swnodes; +}; + +/* 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,
drivers/platform/x86/amd/amd_isp4.c line 130
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+ &ports, + &port_node, + &endpoint_node, + &remote_ep_isp_node, +NULL +}; + +/* OV05C10 specific AMD ISP platform configuration */ +static const struct amdisp_platform amdisp_ov05c10_platform_config = { + .name = AMDISP_OV05C10_PLAT_NAME,
Where is this field being used?
drivers/platform/x86/amd/amd_isp4.c line 135
Quoted 5 lines
drivers/platform/x86/amd/amd_isp4.c new file +5
-0+ .board_info = { + .dev_name ="ov05c10" , + I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR), + }, + .i2c_addr = AMDISP_OV05C10_I2C_ADDR,
Please reuse board_info->addr.
drivers/platform/x86/amd/amd_isp4.c line 136
Quoted 1 line
drivers/platform/x86/amd/amd_isp4.c new file +1
-0+ .max_num_swnodes = NUM_SW_NODES,
Where is max_num_swnodes being used?
drivers/platform/x86/amd/amd_isp4.c line 137
Quoted 1 line
drivers/platform/x86/amd/amd_isp4.c new file +1
-0+ .swnodes = ov05c10_nodes,
Why not drop .swnodes and referencing ov05c10_nodes directly?
Quoted 54 lines
drivers/platform/x86/amd/amd_isp4.c new file +54
-0+}; + +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; + +if (ov05c10->i2c_dev) +return ; + +if (!info->addr) { +dev_err (&adap->dev,"invalid i2c_addr 0x%x detected\n" , ov05c10->i2c_addr); +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 ;
drivers/platform/x86/amd/amd_isp4.c line 201
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+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 ;
You still need to handle the situation where the AMD I2C adapter is already registered when registering the bus notifier. In this case you will miss the BUS_NOTIFY_ADD_DEVICE event.
drivers/platform/x86/amd/amd_isp4.c line 214
Quoted 13 lines
drivers/platform/x86/amd/amd_isp4.c new file +13
-0+} + +static struct amdisp_platform *prepare_amdisp_platform (struct device *dev, +const struct amdisp_platform *src) +{ +struct amdisp_platform *isp_ov05c10; +struct i2c_board_info *info; +int ret; + + isp_ov05c10 =devm_kzalloc (dev,sizeof (*isp_ov05c10),GFP_KERNEL ); +if (!isp_ov05c10) +return ERR_PTR (-ENOMEM ); +memcpy (isp_ov05c10, src,sizeof (*isp_ov05c10));
This is not what i meant. I was complaining that amdisp_ov05c10_platform_config contains both static data (swnodes) and data assigned during runtime (board_info->swnode, i2c_dev, ...).
Please do not use a global instance of struct amdisp_platform for initialization. Instead initialize a fresh instance of this struct inside prepare_amdisp_platform().
Quoted 16 lines
drivers/platform/x86/amd/amd_isp4.c new file +16
-0+ + info = &isp_ov05c10->board_info; + + ret =software_node_register_node_group (src->swnodes); +if (ret) +return ERR_PTR (ret); + + info->swnode = src->swnodes[0 ]; + +return isp_ov05c10; +} + +static int amd_isp_probe (struct platform_device *pdev) +{ +struct amdisp_platform *ov05c10; +int ret;
drivers/platform/x86/amd/amd_isp4.c line 240
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+ + ov05c10 =prepare_amdisp_platform (&pdev->dev, &amdisp_ov05c10_platform_config); +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) +return ret;
You need to call software_node_unregister_node_group() here when bus_register_notifier() fails.
Thanks,
Armin Wolf
Quoted 29 lines
drivers/platform/x86/amd/amd_isp4.c new file +29
-0+ +platform_set_drvdata (pdev, ov05c10); +return 0 ; +} + +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->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" );
Hi Armin,
Quoted 43 lines · Armin Wolf
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 17.04.25 um 20:28 schrieb Pratap Nirujogi:
Quoted 31 lines
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 <[email protected]>Signed-off-by Benjamin Chan <[email protected]>Signed-off-by Pratap Nirujogi <[email protected]>---
Changes v6 -> v7:* Use
devm_kzalloc()inplace ofkmemdup()
* UseIS_ERR()inplace ofi2c_client_has_driver()
* Remove the extra castdrivers/platform/x86/amd/Kconfig | 11 ++ drivers/platform/x86/amd/Makefile | 1 +
drivers/platform/x86/amd/amd_isp4.c| 269 ++++++++++++++++++++++++++++3 files changed, 281 insertions(+)create mode 100644
drivers/platform/x86/amd/amd_isp4.cdrivers/platform/x86/amd/Kconfig +0
-0@@ -32,3 +32,14 @@ config AMD_WBRFThis mechanism will only be activated on platforms that advertise a need for it.
drivers/platform/x86/amd/Kconfig config AMD_WBRF · line 38
Quoted 4 lines
drivers/platform/x86/amd/Kconfig +4
-0+ +config AMD_ISP_PLATFORM + tristate "AMD ISP4 platform driver" + depends on I2C && X86_64 && ACPI && AMD_ISP4Hi,
Quoted 2 lines
just a question: when will the
CONFIG_AMD_ISP4symbol be introduced?
CONFIG_AMD_ISP4 will be introduced in the V4L2 ISP driver patches. We are working on isp driver patches and planning to submit once the review for x86/platform and sensor driver patches completes.
Quoted 165 lines
Quoted 144 lines
+ 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.drivers/platform/x86/amd/Kconfig +3
-0+ + This driver can also be built as a module. If so, the module + will be called amd_isp4.drivers/platform/x86/amd/Makefile +0
-0@@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/obj-$(CONFIG_AMD_HSMP) += hsmp/
obj-$(CONFIG_AMD_PMF) += pmf/
obj-$(CONFIG_AMD_WBRF) += wbrf.odrivers/platform/x86/amd/Makefile +1
-0+obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.odrivers/platform/x86/amd/amd_isp4.c new file +96
-0@@ -0,0 +1,269 @@ +// 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 { + const char *name; + u8 i2c_addr; + u8 max_num_swnodes; + struct i2c_board_info board_info; + struct notifier_block i2c_nb; + struct i2c_client *i2c_dev; + const struct software_node **swnodes; +}; + +/* 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), + { }drivers/platform/x86/amd/amd_isp4.c new file +21
-0+}; + +/* 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,drivers/platform/x86/amd/amd_isp4.c line 130
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+ &ports, + &port_node, + &endpoint_node, + &remote_ep_isp_node, + NULL +}; + +/* OV05C10 specific AMD ISP platform configuration */ +static const struct amdisp_platform amdisp_ov05c10_platform_config = { + .name = AMDISP_OV05C10_PLAT_NAME,Where is this field being used?
Quoted 5 lines
+ .board_info = {
+ .dev_name = "ov05c10",
+I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR), + },
+ .i2c_addr =AMDISP_OV05C10_I2C_ADDR,Please reuse
board_info->addr.
Quoted 8 lines
Quoted 1 line
+ .max_num_swnodes =
NUM_SW_NODES,Where is
max_num_swnodesbeing used?Quoted 1 line
+ .swnodes =
ov05c10_nodes,Why not drop .swnodes and referencing
ov05c10_nodesdirectly?
Thanks. Some of the variables phased out with the ongoing development and patching. I will take care of removing the unused and redudant variables in 'struct amdisp_platform'.
Quoted 64 lines
Quoted 64 lines
drivers/platform/x86/amd/amd_isp4.c new file +14
-0+}; + +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)drivers/platform/x86/amd/amd_isp4.c new file +9
-0+{ + struct i2c_board_info *info = &ov05c10->board_info; + struct i2c_client *i2c_dev; + + if (ov05c10->i2c_dev) + return; + + if (!info->addr) { + dev_err(&adap->dev, "invalid i2c_addr 0x%x detected\n",
ov05c10->i2c_addr);
+ 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;drivers/platform/x86/amd/amd_isp4.c new file +6
-0+} + +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;
+ structi2c_client*client;
+ structi2c_adapter*adap;
+
+ switch (action) {
+ caseBUS_NOTIFY_ADD_DEVICE:
+ adap =i2c_verify_adapter(dev);
+ if (!adap)
+ break;
+ if (is_isp_i2c_adapter(adap))
+instantiate_isp_i2c_client(ov05c10, adap); + break;
+ caseBUS_NOTIFY_REMOVED_DEVICE:
+ client =i2c_verify_client(dev);
+ if (!client)
+ break;
+ if (ov05c10->i2c_dev== client) {
+dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+ov05c10->i2c_dev= NULL;
+ }
+ break;
Quoted 9 lines
Quoted 5 lines
+ default:
+ break;
+ }
+
+ returnNOTIFY_DONE;You still need to handle the situation where the AMD I2C adapter is already registered when registering the bus notifier. In this case you will miss the
BUS_NOTIFY_ADD_DEVICEevent.
Thanks. I will cover this case using the below sequence.
1. bus_register_notifier()
2. i2c_for_each_dev()
If at all i2c adapter is registered by the time bus_register_notifier() is called, it should be detected in i2c_for_each_dev(). I will add checks to avoid creation of duplicate i2c_client devices when both notifier callback and i2c_for_each_dev() passes especially when i2c adapter gets added between 1 and 2.
Please suggest if there is an alternate better approach that I should use to handle this case.
Quoted 18 lines
Quoted 6 lines
drivers/platform/x86/amd/amd_isp4.c new file +3
-0+} + +static struct amdisp_platform *prepare_amdisp_platform(struct device*dev,
+ const structamdisp_platform*src)drivers/platform/x86/amd/amd_isp4.c line 214
Quoted 9 lines
drivers/platform/x86/amd/amd_isp4.c new file +9
-0+{ + struct amdisp_platform *isp_ov05c10; + struct i2c_board_info *info; + int ret; + + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10), GFP_KERNEL); + if (!isp_ov05c10) + return ERR_PTR(-ENOMEM); + memcpy(isp_ov05c10, src, sizeof(*isp_ov05c10));This is not what i meant. I was complaining that
amdisp_ov05c10_platform_configcontains both static data (swnodes) and data assigned during runtime (board_info-
Quoted 5 lines
Quoted 1 line
swnode,
i2c_dev, ...).Please do not use a global instance of struct
amdisp_platformfor initialization. Instead initialize a fresh instance of this struct insideprepare_amdisp_platform().
sure, will remove the global variable 'amdisp_ov05c10_platform_config', and will take care of initializing the amdisp_platform instance in the prepare_amdisp_platform().
Quoted 22 lines
Quoted 22 lines
drivers/platform/x86/amd/amd_isp4.c new file +18
-0+ + info = &isp_ov05c10->board_info; + + ret = software_node_register_node_group(src->swnodes); + if (ret) + return ERR_PTR(ret); + + info->swnode = src->swnodes[0]; + + return isp_ov05c10; +} + +static int amd_isp_probe (struct platform_device *pdev) +{ + struct amdisp_platform *ov05c10; + int ret; + + ov05c10 = prepare_amdisp_platform(&pdev->dev,
&amdisp_ov05c10_platform_config);
+ if (IS_ERR(ov05c10))
+ return dev_err_probe(&pdev->dev,PTR_ERR(ov05c10), + "failed to prepare AMD ISP platform
Quoted 9 lines
Quoted 6 lines
fwnode\n");
+
+ov05c10->i2c_nb.notifier_call=isp_i2c_bus_notify; + ret =bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb); + if (ret)
+ return ret;You need to call
software_node_unregister_node_group()here whenbus_register_notifier()fails.
Thanks. I will fix this in the next V8 patch.
Quoted 2 lines
Thanks,
Armin Wolf>
Thanks,
Pratap
Quoted 29 lines
Quoted 29 lines
drivers/platform/x86/amd/amd_isp4.c new file +29
-0+ + platform_set_drvdata(pdev, ov05c10); + return 0; +} + +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->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" );
Quoted 6 lines
Quoted 4 lines
Hi,
just a question: when will the
CONFIG_AMD_ISP4symbol be introduced?
CONFIG_AMD_ISP4will be introduced in the V4L2 ISP driver patches. We are working on isp driver patches and planning to submit once the review for x86/platform and sensor driver patches completes.
I had a side bar conversation with Pratap on this and that dependency isn't needed right now as no symbols are used from it.
The drivers are coming in different subsystems and can be enabled independently. That dependency can be dropped for the next version.
Quoted 10 lines · Mario Limonciello
Quoted 6 lines
Quoted 4 lines
Hi,
just a question: when will the
CONFIG_AMD_ISP4symbol be introduced?
CONFIG_AMD_ISP4will be introduced in the V4L2 ISP driver patches. We are working on isp driver patches and planning to submit once the review for x86/platform and sensor driver patches completes.I had a side bar conversation with Pratap on this and that dependency isn't needed right now as no symbols are used from it.
The drivers are coming in different subsystems and can be enabled independently. That dependency can be dropped for the next version.
Thanks Mario. Yes, this driver has no strict dependency on ISP driver. I will drop this dependency in V8.
Am 29.04.25 um 20:33 schrieb Nirujogi, Pratap:
Quoted 47 lines
Hi Armin,
Quoted 44 lines · Armin Wolf
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 17.04.25 um 20:28 schrieb Pratap Nirujogi:
Quoted 32 lines
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 <[email protected]>Signed-off-by Benjamin Chan <[email protected]>Signed-off-by Pratap Nirujogi <[email protected]>---
Changes v6 -> v7:* Use
devm_kzalloc()inplace ofkmemdup()
* UseIS_ERR()inplace ofi2c_client_has_driver()
* Remove the extra castdrivers/platform/x86/amd/Kconfig | 11 ++
drivers/platform/x86/amd/Makefile | 1 +
drivers/platform/x86/amd/amd_isp4.c| 269
++++++++++++++++++++++++++++3 files changed, 281 insertions(+)create mode 100644
drivers/platform/x86/amd/amd_isp4.cdrivers/platform/x86/amd/Kconfig +0
-0@@ -32,3 +32,14 @@ config AMD_WBRFThis mechanism will only be activated on platforms that advertise a need for it.
drivers/platform/x86/amd/Kconfig config AMD_WBRF · line 38
Quoted 4 lines
drivers/platform/x86/amd/Kconfig +4
-0+ +config AMD_ISP_PLATFORM + tristate "AMD ISP4 platform driver" + depends on I2C && X86_64 && ACPI && AMD_ISP4Hi,
Quoted 3 lines
Quoted 2 lines
just a question: when will the
CONFIG_AMD_ISP4symbol be introduced?
CONFIG_AMD_ISP4will be introduced in the V4L2 ISP driver patches. We are working on isp driver patches and planning to submit once the review for x86/platform and sensor driver patches completes.
Alright.
Quoted 250 lines
Quoted 167 lines
Quoted 146 lines
+ 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.drivers/platform/x86/amd/Kconfig +3
-0+ + This driver can also be built as a module. If so, the module + will be called amd_isp4.drivers/platform/x86/amd/Makefile +0
-0@@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/obj-$(CONFIG_AMD_HSMP) += hsmp/
obj-$(CONFIG_AMD_PMF) += pmf/
obj-$(CONFIG_AMD_WBRF) += wbrf.odrivers/platform/x86/amd/Makefile +1
-0+obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.odrivers/platform/x86/amd/amd_isp4.c new file +96
-0@@ -0,0 +1,269 @@ +// 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 { + const char *name; + u8 i2c_addr; + u8 max_num_swnodes; + struct i2c_board_info board_info; + struct notifier_block i2c_nb; + struct i2c_client *i2c_dev; + const struct software_node **swnodes; +}; + +/* 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), + { }drivers/platform/x86/amd/amd_isp4.c new file +15
-0+}; + +/* 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.
+ */drivers/platform/x86/amd/amd_isp4.c new file +4
-0+#define NUM_SW_NODES 5 + +static const struct software_node *ov05c10_nodes[NUM_SW_NODES +1 ] = { + &camera_node,drivers/platform/x86/amd/amd_isp4.c line 130
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+ &ports, + &port_node, + &endpoint_node, + &remote_ep_isp_node, + NULL +}; + +/* OV05C10 specific AMD ISP platform configuration */ +static const struct amdisp_platform amdisp_ov05c10_platform_config = { + .name = AMDISP_OV05C10_PLAT_NAME,Where is this field being used?
Quoted 5 lines
+ .board_info = {
+ .dev_name = "ov05c10",
+I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR), + },
+ .i2c_addr =AMDISP_OV05C10_I2C_ADDR,Please reuse
board_info->addr.Quoted 8 lines
Quoted 1 line
+ .max_num_swnodes =
NUM_SW_NODES,Where is
max_num_swnodesbeing used?Quoted 1 line
+ .swnodes =
ov05c10_nodes,Why not drop .swnodes and referencing
ov05c10_nodesdirectly?Thanks. Some of the variables phased out with the ongoing development and patching. I will take care of removing the unused and redudant variables in 'struct
amdisp_platform'.Quoted 64 lines
Quoted 64 lines
drivers/platform/x86/amd/amd_isp4.c new file +14
-0+}; + +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)drivers/platform/x86/amd/amd_isp4.c new file +9
-0+{ + struct i2c_board_info *info = &ov05c10->board_info; + struct i2c_client *i2c_dev; + + if (ov05c10->i2c_dev) + return; + + if (!info->addr) { + dev_err(&adap->dev, "invalid i2c_addr 0x%xdetected\n",
ov05c10->i2c_addr);
+ 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;drivers/platform/x86/amd/amd_isp4.c new file +6
-0+} + +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;
+ structi2c_client*client;
+ structi2c_adapter*adap;
+
+ switch (action) {
+ caseBUS_NOTIFY_ADD_DEVICE:
+ adap =i2c_verify_adapter(dev);
+ if (!adap)
+ break;
+ if (is_isp_i2c_adapter(adap))
+instantiate_isp_i2c_client(ov05c10, adap); + break;
+ caseBUS_NOTIFY_REMOVED_DEVICE:
+ client =i2c_verify_client(dev);
+ if (!client)
+ break;
+ if (ov05c10->i2c_dev== client) {
+dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+ov05c10->i2c_dev= NULL;
+ }
+ break;Quoted 9 lines
Quoted 5 lines
+ default:
+ break;
+ }
+
+ returnNOTIFY_DONE;You still need to handle the situation where the AMD I2C adapter is already registered when registering the bus notifier. In this case you will miss the
BUS_NOTIFY_ADD_DEVICEevent.
Quoted 9 lines
Thanks. I will cover this case using the below sequence.
1.
bus_register_notifier()
2.i2c_for_each_dev()If at all i2c adapter is registered by the time
bus_register_notifier()is called, it should be detected ini2c_for_each_dev(). I will add checks to avoid creation of duplicatei2c_clientdevices when both notifier callback andi2c_for_each_dev()passes especially when i2c adapter gets added between 1 and 2.Please suggest if there is an alternate better approach that I should use to handle this case.
This approach seems good to me, i2c-dev uses something similar.
Thanks,
Armin Wolf
Quoted 94 lines
Quoted 20 lines
Quoted 12 lines
drivers/platform/x86/amd/amd_isp4.c new file +3
-0+} + +static struct amdisp_platform *prepare_amdisp_platform(structdevice *dev,
+ const structamdisp_platform*src)drivers/platform/x86/amd/amd_isp4.c new file +6
-0+{ + struct amdisp_platform *isp_ov05c10; + struct i2c_board_info *info; + int ret; + + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10),Quoted 4 lines
GFP_KERNEL);
+ if (!isp_ov05c10)
+ returnERR_PTR(-ENOMEM);
+memcpy(isp_ov05c10, src, sizeof(*isp_ov05c10));This is not what i meant. I was complaining that
amdisp_ov05c10_platform_configcontains both static data (swnodes) and data assigned during runtime (board_info- >swnode,i2c_dev, ...).Quoted 3 lines
Please do not use a global instance of struct
amdisp_platformfor initialization. Instead initialize a fresh instance of this struct insideprepare_amdisp_platform().sure, will remove the global variable '
amdisp_ov05c10_platform_config', and will take care of initializing theamdisp_platforminstance in theprepare_amdisp_platform().Quoted 22 lines
Quoted 22 lines
drivers/platform/x86/amd/amd_isp4.c new file +18
-0+ + info = &isp_ov05c10->board_info; + + ret = software_node_register_node_group(src->swnodes); + if (ret) + return ERR_PTR(ret); + + info->swnode = src->swnodes[0]; + + return isp_ov05c10; +} + +static int amd_isp_probe (struct platform_device *pdev) +{ + struct amdisp_platform *ov05c10; + int ret; + + ov05c10 = prepare_amdisp_platform(&pdev->dev,
&amdisp_ov05c10_platform_config);
+ if (IS_ERR(ov05c10))
+ return dev_err_probe(&pdev->dev,PTR_ERR(ov05c10), + "failed to prepare AMD ISPQuoted 9 lines
Quoted 6 lines
platform fwnode\n");
+
+ov05c10->i2c_nb.notifier_call=isp_i2c_bus_notify; + ret =bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb); + if (ret)
+ return ret;You need to call
software_node_unregister_node_group()here whenbus_register_notifier()fails.Thanks. I will fix this in the next V8 patch.
Quoted 2 lines
Thanks,
Armin Wolf>Thanks,
PratapQuoted 29 lines
Quoted 29 lines
drivers/platform/x86/amd/amd_isp4.c new file +29
-0+ + platform_set_drvdata(pdev, ov05c10); + return 0; +} + +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->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" );
Quoted 330 lines · Armin Wolf
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 29.04.25 um 20:33 schrieb Nirujogi, Pratap:
Quoted 50 lines
Hi Armin,
Quoted 47 lines · Armin Wolf
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Am 17.04.25 um 20:28 schrieb Pratap Nirujogi:
Quoted 34 lines
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 <[email protected]>Signed-off-by Benjamin Chan <[email protected]>Signed-off-by Pratap Nirujogi <[email protected]>---
Changes v6 -> v7:* Use
devm_kzalloc()inplace ofkmemdup()
* UseIS_ERR()inplace ofi2c_client_has_driver()
* Remove the extra castdrivers/platform/x86/amd/Kconfig | 11 ++
drivers/platform/x86/amd/Makefile | 1 +
drivers/platform/x86/amd/amd_isp4.c| 269
++++++++++++++++++++++++++++3 files changed, 281 insertions(+)create mode 100644
drivers/platform/x86/amd/amd_isp4.c(quoted diff) +0
-0b/drivers/platform/x86/ amd/Kconfig
indexc3e086ea64fc..ec755b5fc93c100644drivers/platform/x86/amd/Kconfig +0
-0@@ -32,3 +32,14 @@ config AMD_WBRFThis mechanism will only be activated on platforms that advertise a
need for it.drivers/platform/x86/amd/Kconfig config AMD_WBRF · line 38
Quoted 4 lines
drivers/platform/x86/amd/Kconfig +4
-0+ +config AMD_ISP_PLATFORM + tristate "AMD ISP4 platform driver" + depends on I2C && X86_64 && ACPI && AMD_ISP4Hi,
Quoted 5 lines
Quoted 2 lines
just a question: when will the
CONFIG_AMD_ISP4symbol be introduced?
CONFIG_AMD_ISP4will be introduced in the V4L2 ISP driver patches. We are working on isp driver patches and planning to submit once the review for x86/platform and sensor driver patches completes.Alright.
Quoted 267 lines
Quoted 169 lines
Quoted 148 lines
+ 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.drivers/platform/x86/amd/Kconfig +3
-0+ + This driver can also be built as a module. If so, the module + will be called amd_isp4.(quoted diff) +0
-0b/drivers/platform/x86/ amd/Makefile
indexc6c40bdcbded..b0e284b5d497100644drivers/platform/x86/amd/Makefile +0
-0@@ -10,3 +10,4 @@ obj-$(CONFIG_AMD_PMC) += pmc/obj-$(CONFIG_AMD_HSMP) += hsmp/
obj-$(CONFIG_AMD_PMF) += pmf/
obj-$(CONFIG_AMD_WBRF) += wbrf.odrivers/platform/x86/amd/Makefile +1
-0+obj-$(CONFIG_AMD_ISP_PLATFORM) += amd_isp4.odrivers/platform/ renamed from drivers/platform/x86/amd/amd_isp4.c +0
-0
x86/amd/amd_isp4.c
new file mode 100644
index 000000000000..461a10be5ccddrivers/platform/x86/amd/amd_isp4.c new file +96
-0@@ -0,0 +1,269 @@ +// 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 { + const char *name; + u8 i2c_addr; + u8 max_num_swnodes; + struct i2c_board_info board_info; + struct notifier_block i2c_nb; + struct i2c_client *i2c_dev; + const struct software_node **swnodes; +}; + +/* 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), + { }drivers/platform/x86/amd/amd_isp4.c new file +15
-0+}; + +/* 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.
+ */drivers/platform/x86/amd/amd_isp4.c new file +4
-0+#define NUM_SW_NODES 5 + +static const struct software_node *ov05c10_nodes[NUM_SW_NODES +1 ] = { + &camera_node,drivers/platform/x86/amd/amd_isp4.c line 130
Quoted 10 lines
drivers/platform/x86/amd/amd_isp4.c new file +10
-0+ &ports, + &port_node, + &endpoint_node, + &remote_ep_isp_node, + NULL +}; + +/* OV05C10 specific AMD ISP platform configuration */ +static const struct amdisp_platform amdisp_ov05c10_platform_config = { + .name = AMDISP_OV05C10_PLAT_NAME,Where is this field being used?
Quoted 5 lines
+ .board_info = {
+ .dev_name = "ov05c10",
+I2C_BOARD_INFO("ov05c10", AMDISP_OV05C10_I2C_ADDR), + },
+ .i2c_addr =AMDISP_OV05C10_I2C_ADDR,Please reuse
board_info->addr.Quoted 8 lines
Quoted 1 line
+ .max_num_swnodes =
NUM_SW_NODES,Where is
max_num_swnodesbeing used?Quoted 1 line
+ .swnodes =
ov05c10_nodes,Why not drop .swnodes and referencing
ov05c10_nodesdirectly?Thanks. Some of the variables phased out with the ongoing development and patching. I will take care of removing the unused and redudant variables in 'struct
amdisp_platform'.Quoted 66 lines
Quoted 66 lines
drivers/platform/x86/amd/amd_isp4.c new file +14
-0+}; + +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)drivers/platform/x86/amd/amd_isp4.c new file +9
-0+{ + struct i2c_board_info *info = &ov05c10->board_info; + struct i2c_client *i2c_dev; + + if (ov05c10->i2c_dev) + return; + + if (!info->addr) { + dev_err(&adap->dev, "invalid i2c_addr 0x%xdetected\n",
ov05c10->i2c_addr);
+ 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;drivers/platform/x86/amd/amd_isp4.c new file +6
-0+} + +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;
+ structi2c_client*client;
+ structi2c_adapter*adap;
+
+ switch (action) {
+ caseBUS_NOTIFY_ADD_DEVICE:
+ adap =i2c_verify_adapter(dev);
+ if (!adap)
+ break;
+ if (is_isp_i2c_adapter(adap))
+instantiate_isp_i2c_client(ov05c10, adap); + break;
+ caseBUS_NOTIFY_REMOVED_DEVICE:
+ client =i2c_verify_client(dev);
+ if (!client)
+ break;
+ if (ov05c10->i2c_dev== client) {
+dev_dbg(&client->adapter->dev, "amdisp i2c_client removed\n");
+ov05c10->i2c_dev= NULL;
+ }
+ break;
+ default:
+ break;Quoted 9 lines
Quoted 3 lines
+ }
+
+ returnNOTIFY_DONE;You still need to handle the situation where the AMD I2C adapter is already registered when
registering the bus notifier. In this case you will miss theBUS_NOTIFY_ADD_DEVICEevent.Thanks. I will cover this case using the below sequence.
1.
bus_register_notifier()
2.i2c_for_each_dev()If at all i2c adapter is registered by the time
bus_register_notifier()is called, it should be detected ini2c_for_each_dev(). I will add checks to avoid creation of duplicatei2c_clientdevices when both notifier callback andi2c_for_each_dev()passes especially when i2c adapter gets added between 1 and 2.
Quoted 5 lines
Quoted 3 lines
Please suggest if there is an alternate better approach that I should use to handle this case.
This approach seems good to me, i2c-dev uses something similar.
Thanks Armin for confirming and providing the reference. I will address the comments and submit the patch V8 soon.
Quoted 103 lines
Thanks,
Armin WolfQuoted 100 lines
Quoted 22 lines
Quoted 12 lines
drivers/platform/x86/amd/amd_isp4.c new file +3
-0+} + +static struct amdisp_platform *prepare_amdisp_platform(structdevice *dev,
+ const structamdisp_platform*src)drivers/platform/x86/amd/amd_isp4.c new file +6
-0+{ + struct amdisp_platform *isp_ov05c10; + struct i2c_board_info *info; + int ret; + + isp_ov05c10 = devm_kzalloc(dev, sizeof(*isp_ov05c10),Quoted 4 lines
GFP_KERNEL);
+ if (!isp_ov05c10)
+ returnERR_PTR(-ENOMEM);
+memcpy(isp_ov05c10, src, sizeof(*isp_ov05c10));This is not what i meant. I was complaining that
amdisp_ov05c10_platform_configcontains both
static data (swnodes) and data assigned during runtime (board_info- >swnode,i2c_dev, ...).Quoted 4 lines
Please do not use a global instance of struct
amdisp_platformfor initialization. Instead initialize a
fresh instance of this struct insideprepare_amdisp_platform().sure, will remove the global variable '
amdisp_ov05c10_platform_config', and will take care of initializing theamdisp_platforminstance in theprepare_amdisp_platform().Quoted 23 lines
Quoted 23 lines
drivers/platform/x86/amd/amd_isp4.c new file +18
-0+ + info = &isp_ov05c10->board_info; + + ret = software_node_register_node_group(src->swnodes); + if (ret) + return ERR_PTR(ret); + + info->swnode = src->swnodes[0]; + + return isp_ov05c10; +} + +static int amd_isp_probe (struct platform_device *pdev) +{ + struct amdisp_platform *ov05c10; + int ret; + + ov05c10 = prepare_amdisp_platform(&pdev->dev,
&amdisp_ov05c10_platform_config);
+ if (IS_ERR(ov05c10))
+ return dev_err_probe(&pdev->dev,PTR_ERR(ov05c10), + "failed to prepare AMD ISP platform fwnode\n");Quoted 9 lines
Quoted 5 lines
+
+ov05c10->i2c_nb.notifier_call=isp_i2c_bus_notify; + ret =bus_register_notifier(&i2c_bus_type, &ov05c10->i2c_nb); + if (ret)
+ return ret;You need to call
software_node_unregister_node_group()here whenbus_register_notifier()fails.Thanks. I will fix this in the next V8 patch.
Quoted 2 lines
Thanks,
Armin Wolf>Thanks,
PratapQuoted 29 lines
Quoted 29 lines
drivers/platform/x86/amd/amd_isp4.c new file +29
-0+ + platform_set_drvdata(pdev, ov05c10); + return 0; +} + +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->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" );