i2c: amd-isp: Add ISP i2c-designware driver
Subsystems (4)
Pratap Nirujogi
maintainerPATCH 1/1 i2c: amd-isp: Add ISP i2c-designware driver
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdisp.c | 266 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-amdisp.h | 24 ++ 4 files changed, 301 insertions(+) create mode 100644 drivers/i2c/busses/i2c-designware-amdisp.c create mode 100644 drivers/i2c/busses/i2c-designware-amdisp.h
drivers/i2c/busses/Kconfig +10 -0
@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. + config I2C_DESIGNWARE_AMDPSP bool "AMD PSP I2C semaphore support" depends on ACPI
drivers/i2c/busses/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o
drivers/i2c/busses/i2c-designware-amdisp.c new file +266 -0
266 lines not on this page · raw message
drivers/i2c/busses/i2c-designware-amdisp.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +int isp_power_set (int on);
Signature · 1 line
2.43.0
Quoted 89 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdisp.c | 266 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-amdisp.h | 24 ++ 4 files changed, 301 insertions(+)create mode 100644
drivers/i2c/busses/i2c-designware-amdisp.ccreate mode 100644drivers/i2c/busses/i2c-designware-amdisp.hdrivers/i2c/busses/Kconfig +10
-0@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. + config I2C_DESIGNWARE_AMDPSP bool "AMD PSP I2C semaphore support" depends on ACPIdrivers/i2c/busses/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +36
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h>
drivers/i2c/busses/i2c-designware-amdisp.c line 46
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/suspend.h> +#include <linux/units.h>
Can you please audit this list for accuracy? It seems like a very large number of headers.
Just off the bat for example I didn't see any DMI use, so dmi.h probably isn't needed. I suspect there are others.
Quoted 61 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +61
-0+ +#include "i2c-designware-core.h" +#include "i2c-designware-amdisp.h" + +#define AMD_ISP_I2C_INPUT_CLK 100 //100 Mhz + +#define to_amd_isp_i2c_dev (dev) \ + ((struct amd_isp_i2c_dev *)container_of(dev, struct amd_isp_i2c_dev, dw_dev)) + +struct amd_isp_i2c_dev { +struct dw_i2c_dev dw_dev; +}; + +static void amd_isp_dw_i2c_plat_pm_cleanup (struct dw_i2c_dev *dev) +{ +pm_runtime_disable (dev->dev); + +if (dev->shared_with_punit) +pm_runtime_put_noidle (dev->dev); +} + +static u32 amd_isp_dw_i2c_get_clk_rate (struct dw_i2c_dev *dev) +{ +return AMD_ISP_I2C_INPUT_CLK *1000 ; +} + +static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ +struct i2c_adapter *adap; +struct amd_isp_i2c_dev *isp_i2c_dev; +struct dw_i2c_dev *dev; +int ret; + + isp_i2c_dev =devm_kzalloc (&pdev->dev,sizeof (struct amd_isp_i2c_dev ), +GFP_KERNEL ); +if (!isp_i2c_dev) +return -ENOMEM ; + + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + +/** +* Use the polling mode to send/receive the data, because +* no IRQ connection from ISP I2C +*/ + dev->flags |=ACCESS_POLLING ; +platform_set_drvdata (pdev, dev); + + dev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + + ret =isp_power_set (true); +if (ret) { +dev_err (dev->dev,"unable to turn on the amdisp i2c power:%d\n" , ret); +return ret; + } + + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret =i2c_dw_fw_parse_and_configure (dev); +if (ret)
drivers/i2c/busses/i2c-designware-amdisp.c line 117
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ goto exit; + +i2c_dw_configure (dev); + + adap = &dev->adapter; + adap->owner =THIS_MODULE ; +ACPI_COMPANION_SET (&adap->dev,ACPI_COMPANION (&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; +/* arbitrary large number to avoid any conflicts */ + adap->nr =99 ;
Would it be better to allocate an IDA here?
Quoted 27 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +27
-0+ +if (dev->flags &ACCESS_NO_IRQ_SUSPEND ) { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE ); + }else { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND ); + } + +device_enable_async_suspend (&pdev->dev); + +/* The code below assumes runtime PM to be disabled. */ +WARN_ON (pm_runtime_enabled (&pdev->dev)); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_set_active (&pdev->dev); + +if (dev->shared_with_punit) +pm_runtime_get_noresume (&pdev->dev); + +pm_runtime_enable (&pdev->dev); + + ret =i2c_dw_probe (dev); +if (ret) { +dev_err (dev->dev,"i2c_dw_probe failed %d\n" , ret); + goto exit_probe;
drivers/i2c/busses/i2c-designware-amdisp.c line 154
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ } + +isp_power_set (false); +return ret; + +exit_probe: +amd_isp_dw_i2c_plat_pm_cleanup (dev); +isp_power_set (false); +exit: +isp_power_set (false);
I see 3 cases that isp_power_set(false) is called above:
* success
* failure exit probe
* failure exit
exit_probe falls through to exit, which means it's called twice. That seems to be a mistake to me.
But since it's also called in the success flow this makes me wonder if it's better to use a macro like _free() which will automatically call isp_power_set(false) when the function exits.
Furthermore; are you missing a call to isp_power_set(true) in runtime resume and isp_power_set(false) in runtime suspend? It would seem logical to me that when runtime suspended the tile is off and when on runtime resumed it's back on.
Quoted 132 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +112
-0+return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ +struct dw_i2c_dev *dev =platform_get_drvdata (pdev); + +pm_runtime_get_sync (&pdev->dev); + +i2c_del_adapter (&dev->adapter); + +i2c_dw_disable (dev); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +amd_isp_dw_i2c_plat_pm_cleanup (dev); + +reset_control_assert (dev->rst); +} + +static int amd_isp_dw_i2c_plat_prepare (struct device *dev) +{ +/* +* If the ACPI companion device object is present for this device, it +* may be accessed during suspend and resume of other devices via I2C +* operation regions, so tell the PM core and middle layers to avoid +* skipping system suspend/resume callbacks for it in that case. +*/ +return !has_acpi_companion (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (i_dev->shared_with_punit) +return 0 ; + +i2c_dw_disable (i_dev); +i2c_dw_prepare_clk (i_dev, false); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +i2c_mark_adapter_suspended (&i_dev->adapter); + +return amd_isp_dw_i2c_plat_runtime_suspend (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (!i_dev->shared_with_punit) +i2c_dw_prepare_clk (i_dev, true); + + i_dev->init (i_dev); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +amd_isp_dw_i2c_plat_runtime_resume (dev); +i2c_mark_adapter_resumed (&i_dev->adapter); + +return 0 ; +} + +static const struct dev_pm_ops amd_isp_dw_i2c_dev_pm_ops = { + .prepare =pm_sleep_ptr (amd_isp_dw_i2c_plat_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(amd_isp_dw_i2c_plat_suspend, amd_isp_dw_i2c_plat_resume) +RUNTIME_PM_OPS (amd_isp_dw_i2c_plat_runtime_suspend, amd_isp_dw_i2c_plat_runtime_resume,NULL ) +}; + +/* Work with hotplug and coldplug */ +MODULE_ALIAS ("platform:amd_isp_i2c_designware" ); + +static struct platform_driver amd_isp_dw_i2c_driver = { + .probe = amd_isp_dw_i2c_plat_probe, + .remove = amd_isp_dw_i2c_plat_remove, + .driver = { + .name ="amd_isp_i2c_designware" , + .pm =pm_ptr (&amd_isp_dw_i2c_dev_pm_ops), + }, +}; + +static int __init amd_isp_dw_i2c_init_driver (void ) +{ +return platform_driver_register (&amd_isp_dw_i2c_driver); +} +subsys_initcall (amd_isp_dw_i2c_init_driver); + +static void __exit amd_isp_dw_i2c_exit_driver(void) +{ +platform_driver_unregister (&amd_isp_dw_i2c_driver); +} +module_exit (amd_isp_dw_i2c_exit_driver); + +MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );drivers/i2c/busses/i2c-designware-amdisp.h new file +14
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +*
drivers/i2c/busses/i2c-designware-amdisp.h line 24
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +10
-0+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +int isp_power_set (int on);
Where does this symbol actually come from? I didn't see it in this series.
Nirujogi, Pratap
maintainer[AMD Official Use Only - AMD Internal Distribution Only]
Hi Mario, CJ, Krzysztof
Thanks for the review. The symbol " isp_power_set" is exported from V4L2 ISP driver, which is not yet submitted for review. My apologies for the confusion caused. I will resubmit this patch addressing your valuable comments along with V4L2 ISP patch series.
Thanks,
Pratap
-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Friday, February 28, 2025 10:34 PM
To: Nirujogi, Pratap <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Chan, Benjamin (Koon Pan) <[email protected]>
Subject: Re: [PATCH] i2c: amd-isp: Add ISP i2c-designware driver
Quoted 103 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdisp.c | 266 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-amdisp.h | 24 ++ 4 files changed, 301 insertions(+)create mode 100644
drivers/i2c/busses/i2c-designware-amdisp.ccreate mode 100644drivers/i2c/busses/i2c-designware-amdisp.hdrivers/i2c/busses/Kconfig +10
-0@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. + config I2C_DESIGNWARE_AMDPSP bool "AMD PSP I2C semaphore support" depends on ACPIdrivers/i2c/busses/Makefile +0
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) +=i2c-designware-baytrail.o
drivers/i2c/busses/Makefile +1
-0+obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +48
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, +sublicense, +* and/or sell copies of the Software, and to permit persons to whom +the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be +included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h>
drivers/i2c/busses/i2c-designware-amdisp.c line 58
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/suspend.h> +#include <linux/units.h>
Can you please audit this list for accuracy? It seems like a very large number of headers.
Just off the bat for example I didn't see any DMI use, so dmi.h probably isn't needed. I suspect there are others.
Quoted 58 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +58
-0+ +#include "i2c-designware-core.h" +#include "i2c-designware-amdisp.h" + +#define AMD_ISP_I2C_INPUT_CLK 100 //100 Mhz + +#define to_amd_isp_i2c_dev (dev) \ + ((struct amd_isp_i2c_dev *)container_of(dev, struct amd_isp_i2c_dev, +dw_dev)) + +struct amd_isp_i2c_dev { +struct dw_i2c_dev dw_dev; +}; + +static void amd_isp_dw_i2c_plat_pm_cleanup (struct dw_i2c_dev *dev) { +pm_runtime_disable (dev->dev); + +if (dev->shared_with_punit) +pm_runtime_put_noidle (dev->dev); +} + +static u32 amd_isp_dw_i2c_get_clk_rate (struct dw_i2c_dev *dev) { +return AMD_ISP_I2C_INPUT_CLK *1000 ; } + +static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) { +struct i2c_adapter *adap; +struct amd_isp_i2c_dev *isp_i2c_dev; +struct dw_i2c_dev *dev; +int ret; + + isp_i2c_dev =devm_kzalloc (&pdev->dev,sizeof (struct amd_isp_i2c_dev ), +GFP_KERNEL ); +if (!isp_i2c_dev) +return -ENOMEM ; + + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + +/** +* Use the polling mode to send/receive the data, because +* no IRQ connection from ISP I2C +*/ + dev->flags |=ACCESS_POLLING ; +platform_set_drvdata (pdev, dev); + + dev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + + ret =isp_power_set (true); +if (ret) { +dev_err (dev->dev,"unable to turn on the amdisp i2c power:%d\n" , ret); +return ret; + } + + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret =i2c_dw_fw_parse_and_configure (dev); +if (ret)
drivers/i2c/busses/i2c-designware-amdisp.c line 117
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ goto exit; + +i2c_dw_configure (dev); + + adap = &dev->adapter; + adap->owner =THIS_MODULE ; +ACPI_COMPANION_SET (&adap->dev,ACPI_COMPANION (&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; +/* arbitrary large number to avoid any conflicts */ + adap->nr =99 ;
Would it be better to allocate an IDA here?
Quoted 27 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +27
-0+ +if (dev->flags &ACCESS_NO_IRQ_SUSPEND ) { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE ); + }else { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND ); + } + +device_enable_async_suspend (&pdev->dev); + +/* The code below assumes runtime PM to be disabled. */ +WARN_ON (pm_runtime_enabled (&pdev->dev)); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_set_active (&pdev->dev); + +if (dev->shared_with_punit) +pm_runtime_get_noresume (&pdev->dev); + +pm_runtime_enable (&pdev->dev); + + ret =i2c_dw_probe (dev); +if (ret) { +dev_err (dev->dev,"i2c_dw_probe failed %d\n" , ret); + goto exit_probe;
drivers/i2c/busses/i2c-designware-amdisp.c line 154
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ } + +isp_power_set (false); +return ret; + +exit_probe: +amd_isp_dw_i2c_plat_pm_cleanup (dev); +isp_power_set (false); +exit: +isp_power_set (false);
I see 3 cases that isp_power_set(false) is called above:
* success
* failure exit probe
* failure exit
exit_probe falls through to exit, which means it's called twice. That seems to be a mistake to me.
But since it's also called in the success flow this makes me wonder if it's better to use a macro like _free() which will automatically call isp_power_set(false) when the function exits.
Furthermore; are you missing a call to isp_power_set(true) in runtime resume and isp_power_set(false) in runtime suspend? It would seem logical to me that when runtime suspended the tile is off and when on runtime resumed it's back on.
Quoted 137 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +104
-0+return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ +struct dw_i2c_dev *dev =platform_get_drvdata (pdev); + +pm_runtime_get_sync (&pdev->dev); + +i2c_del_adapter (&dev->adapter); + +i2c_dw_disable (dev); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +amd_isp_dw_i2c_plat_pm_cleanup (dev); + +reset_control_assert (dev->rst); +} + +static int amd_isp_dw_i2c_plat_prepare (struct device *dev) { +/* +* If the ACPI companion device object is present for this device, it +* may be accessed during suspend and resume of other devices via I2C +* operation regions, so tell the PM core and middle layers to avoid +* skipping system suspend/resume callbacks for it in that case. +*/ +return !has_acpi_companion (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_suspend (struct device *dev) { +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (i_dev->shared_with_punit) +return 0 ; + +i2c_dw_disable (i_dev); +i2c_dw_prepare_clk (i_dev, false); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_suspend (struct device *dev) { +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +i2c_mark_adapter_suspended (&i_dev->adapter); + +return amd_isp_dw_i2c_plat_runtime_suspend (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_resume (struct device *dev) { +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (!i_dev->shared_with_punit) +i2c_dw_prepare_clk (i_dev, true); + + i_dev->init (i_dev); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_resume (struct device *dev) { +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +amd_isp_dw_i2c_plat_runtime_resume (dev); +i2c_mark_adapter_resumed (&i_dev->adapter); + +return 0 ; +} + +static const struct dev_pm_ops amd_isp_dw_i2c_dev_pm_ops = { + .prepare =pm_sleep_ptr (amd_isp_dw_i2c_plat_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(amd_isp_dw_i2c_plat_suspend, amd_isp_dw_i2c_plat_resume) +RUNTIME_PM_OPS (amd_isp_dw_i2c_plat_runtime_suspend, +amd_isp_dw_i2c_plat_runtime_resume,NULL ) }; + +/* Work with hotplug and coldplug */ +MODULE_ALIAS ("platform:amd_isp_i2c_designware" ); + +static struct platform_driver amd_isp_dw_i2c_driver = { + .probe = amd_isp_dw_i2c_plat_probe, + .remove = amd_isp_dw_i2c_plat_remove, + .driver = { + .name ="amd_isp_i2c_designware" , + .pm =pm_ptr (&amd_isp_dw_i2c_dev_pm_ops), + }, +}; + +static int __init amd_isp_dw_i2c_init_driver (void ) { +return platform_driver_register (&amd_isp_dw_i2c_driver); +} +subsys_initcall (amd_isp_dw_i2c_init_driver); + +static void __exit amd_isp_dw_i2c_exit_driver(void) { +platform_driver_unregister (&amd_isp_dw_i2c_driver); +} +module_exit (amd_isp_dw_i2c_exit_driver); + +MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" );MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );drivers/i2c/busses/i2c-designware-amdisp.h new file +26
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, +sublicense, +* and/or sell copies of the Software, and to permit persons to whom +the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be +included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL
drivers/i2c/busses/i2c-designware-amdisp.h
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +10
-0+* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, +DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +int isp_power_set (int on);
Where does this symbol actually come from? I didn't see it in this series.
Hi Mario,
Please accept my apologies for the delayed response to your review comments.
Thanks,
Pratap
Quoted 112 lines · Mario Limonciello
Quoted 98 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>---
drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 +drivers/i2c/busses/i2c-designware-amdisp.c| 266 +++++++++++++++++++++drivers/i2c/busses/i2c-designware-amdisp.h| 24 ++4 files changed, 301 insertions(+)create mode 100644
drivers/i2c/busses/i2c-designware-amdisp.ccreate mode 100644drivers/i2c/busses/i2c-designware-amdisp.hdrivers/i2c/busses/Kconfig +0
-0@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORMThis driver can also be built as a module. If so, the module will be called i2c-designware-platform.
drivers/i2c/busses/Kconfig +10
-0+config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. +config
I2C_DESIGNWARE_AMDPSP
bool "AMD PSP I2C semaphore support"
depends on ACPIdrivers/i2c/busses/Makefile +0
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) +=i2c-designware-platform.o
i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c- designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c- designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +5
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */drivers/i2c/busses/i2c-designware-amdisp.c new file +14
-0+ +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h> drivers/i2c/busses/i2c-designware-amdisp.c line 46
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/suspend.h> +#include <linux/units.h> Can you please audit this list for accuracy? It seems like a very large number of headers.
Quoted 2 lines
Just off the bat for example I didn't see any DMI use, so
dmi.hprobably isn't needed. I suspect there are others.
Thanks. Will clean-up headers files in V2.
Quoted 68 lines
Quoted 68 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+ +#include "i2c-designware-core.h" +#include "i2c-designware-amdisp.h" + +#define AMD_ISP_I2C_INPUT_CLK 100 //100 Mhz + +#define to_amd_isp_i2c_dev (dev) \ + ((struct amd_isp_i2c_dev *)container_of(dev, struct
amd_isp_i2c_dev,dw_dev))drivers/i2c/busses/i2c-designware-amdisp.c new file +26
-0+ +struct amd_isp_i2c_dev { + struct dw_i2c_dev dw_dev; +}; + +static void amd_isp_dw_i2c_plat_pm_cleanup (struct dw_i2c_dev *dev) +{ + pm_runtime_disable(dev->dev); + + if (dev->shared_with_punit) + pm_runtime_put_noidle(dev->dev); +} + +static u32 amd_isp_dw_i2c_get_clk_rate (struct dw_i2c_dev *dev) +{ + return AMD_ISP_I2C_INPUT_CLK * 1000; +} + +static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ + struct i2c_adapter *adap; + struct amd_isp_i2c_dev *isp_i2c_dev; + struct dw_i2c_dev *dev; + int ret; + + isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(struct
amd_isp_i2c_dev),
+GFP_KERNEL);
+ if (!isp_i2c_dev)
+ return-ENOMEM;drivers/i2c/busses/i2c-designware-amdisp.c new file +18
-0+ + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + + /** + * Use the polling mode to send/receive the data, because + * no IRQ connection from ISP I2C + */ + dev->flags |= ACCESS_POLLING; + platform_set_drvdata(pdev, dev); + + dev->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(dev->base)) + return PTR_ERR(dev->base); + + ret = isp_power_set(true); + if (ret) { + dev_err(dev->dev, "unable to turn on the amdisp i2c power:%d\n", ret);
+ return ret;
+ }drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+ + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret = i2c_dw_fw_parse_and_configure(dev); + if (ret) + goto exit; + + i2c_dw_configure(dev); +
Quoted 9 lines
Quoted 6 lines
+ adap =
&dev->adapter;
+adap->owner=THIS_MODULE;
+ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); +adap->dev.of_node=pdev->dev.of_node;
+ /* arbitrary large number to avoid any conflicts */ +adap->nr= 99;Would it be better to allocate an IDA here?
Thanks. Will remove this hardcoding and use the dynamically assigned bus id in V2.
Quoted 34 lines
Quoted 34 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +34
-0+ + if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { + dev_pm_set_driver_flags(&pdev->dev, + DPM_FLAG_SMART_PREPARE); + } else { + dev_pm_set_driver_flags(&pdev->dev, + DPM_FLAG_SMART_PREPARE | + DPM_FLAG_SMART_SUSPEND); + } + + device_enable_async_suspend(&pdev->dev); + + /* The code below assumes runtime PM to be disabled. */ + WARN_ON(pm_runtime_enabled(&pdev->dev)); + + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + + if (dev->shared_with_punit) + pm_runtime_get_noresume(&pdev->dev); + + pm_runtime_enable(&pdev->dev); + + ret = i2c_dw_probe(dev); + if (ret) { + dev_err(dev->dev, "i2c_dw_probe failed %d\n", ret); + goto exit_probe; + } + + isp_power_set(false); + return ret; + +exit_probe: + amd_isp_dw_i2c_plat_pm_cleanup(dev);
Quoted 9 lines
Quoted 3 lines
+
isp_power_set(false);
+exit:
+isp_power_set(false);I see 3 cases that
isp_power_set(false)is called above:
* success
* failure exit probe
* failure exit
I should have removed isp_power_set() references before submitting the patch. Sorry its overlooked.
isp_power_set() is the exported symbol from ISP driver. Will take care of removing the dependency on isp_power_set() in V2.
Quoted 2 lines
exit_probefalls through to exit, which means it's called twice. That seems to be a mistake to me.
Thanks of identifying the bug with "exit_probe" and "exit", will fix it in V2.
Quoted 4 lines
But since it's also called in the success flow this makes me wonder if it's better to use a macro like
_free()which will automatically callisp_power_set(false)when the function exits.Furthermore; are you missing a call to
isp_power_set(true)in runtime resume andisp_power_set(false)in runtime suspend? It would seem logical to me that when runtime suspended the tile is off and when on runtime resumed it's back on.
Instead of direct call to ISP driver function, will add the ISP device to generic power domain (gpd) to control power remotely using pm runtime calls.
Quoted 149 lines
Quoted 149 lines
+ return ret;
drivers/i2c/busses/i2c-designware-amdisp.c new file +23
-0+} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ + struct dw_i2c_dev *dev = platform_get_drvdata(pdev); + + pm_runtime_get_sync(&pdev->dev); + + i2c_del_adapter(&dev->adapter); + + i2c_dw_disable(dev); + + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + amd_isp_dw_i2c_plat_pm_cleanup(dev); + + reset_control_assert(dev->rst); +} + +static int amd_isp_dw_i2c_plat_prepare (struct device *dev) +{ + /* +* If the ACPI companion device object is present for this device, it
+ * may be accessed during suspend and resume of other devices via I2C
+ * operation regions, so tell the PM core and middle layers to avoid + * skipping system suspend/resume callbacks for it in that case. + */
+ return !has_acpi_companion(dev);drivers/i2c/busses/i2c-designware-amdisp.c new file +49
-0+} + +static int amd_isp_dw_i2c_plat_runtime_suspend (struct device *dev) +{ + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); + + if (i_dev->shared_with_punit) + return 0; + + i2c_dw_disable(i_dev); + i2c_dw_prepare_clk(i_dev, false); + + return 0; +} + +static int amd_isp_dw_i2c_plat_suspend (struct device *dev) +{ + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); + + i2c_mark_adapter_suspended(&i_dev->adapter); + + return amd_isp_dw_i2c_plat_runtime_suspend(dev); +} + +static int amd_isp_dw_i2c_plat_runtime_resume (struct device *dev) +{ + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); + + if (!i_dev->shared_with_punit) + i2c_dw_prepare_clk(i_dev, true); + + i_dev->init(i_dev); + + return 0; +} + +static int amd_isp_dw_i2c_plat_resume (struct device *dev) +{ + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); + + amd_isp_dw_i2c_plat_runtime_resume(dev); + i2c_mark_adapter_resumed(&i_dev->adapter); + + return 0; +} + +static const struct dev_pm_ops amd_isp_dw_i2c_dev_pm_ops = { + .prepare = pm_sleep_ptr(amd_isp_dw_i2c_plat_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(amd_isp_dw_i2c_plat_suspend,
amd_isp_dw_i2c_plat_resume)
+RUNTIME_PM_OPS(amd_isp_dw_i2c_plat_runtime_suspend, amd_isp_dw_i2c_plat_runtime_resume, NULL)drivers/i2c/busses/i2c-designware-amdisp.c new file +33
-0+}; + +/* Work with hotplug and coldplug */ +MODULE_ALIAS ("platform:amd_isp_i2c_designware" ); + +static struct platform_driver amd_isp_dw_i2c_driver = { + .probe = amd_isp_dw_i2c_plat_probe, + .remove = amd_isp_dw_i2c_plat_remove, + .driver = { + .name = "amd_isp_i2c_designware", + .pm = pm_ptr(&amd_isp_dw_i2c_dev_pm_ops), + }, +}; + +static int __init amd_isp_dw_i2c_init_driver (void ) +{ + return platform_driver_register(&amd_isp_dw_i2c_driver); +} +subsys_initcall (amd_isp_dw_i2c_init_driver); + +static void __exit amd_isp_dw_i2c_exit_driver(void) +{ + platform_driver_unregister(&amd_isp_dw_i2c_driver); +} +module_exit (amd_isp_dw_i2c_exit_driver); + +MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );drivers/i2c/busses/i2c-designware-amdisp.h new file +5
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
Quoted 8 lines
drivers/i2c/busses/i2c-designware-amdisp.h line 24
Quoted 6 lines
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */drivers/i2c/busses/i2c-designware-amdisp.h new file +2
-0+ +int isp_power_set (int on);Where does this symbol actually come from? I didn't see it in this series.
Sorry for the confusion caused. This symbol is coming from ISP driver which is not part of this series. We are planning to submit ISP driver patches after the completion of platform and sensor driver patches review.
Le 28/02/2025 à 17:45, Pratap Nirujogi a écrit :
Quoted 5 lines
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>
...
drivers/i2c/busses/i2c-designware-amdisp.c line 1
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +1
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */
I think that this should be // comment style for SPDX-License-Identifier en c files.
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +3
-0+/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +*
...
drivers/i2c/busses/i2c-designware-amdisp.c line 80
Quoted 8 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ +struct i2c_adapter *adap; +struct amd_isp_i2c_dev *isp_i2c_dev; +struct dw_i2c_dev *dev; +int ret; + + isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(struct amd_isp_i2c_dev),
sizeof(*isp_i2c_dev) maybe?
drivers/i2c/busses/i2c-designware-amdisp.c line 88
Quoted 8 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+ GFP_KERNEL); +if (!isp_i2c_dev) +return -ENOMEM ; + + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + +/**
Just /*
drivers/i2c/busses/i2c-designware-amdisp.c line 101
Quoted 13 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +13
-0+* Use the polling mode to send/receive the data, because +* no IRQ connection from ISP I2C +*/ + dev->flags |=ACCESS_POLLING ; +platform_set_drvdata (pdev, dev); + + dev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + + ret =isp_power_set (true); +if (ret) { +dev_err (dev->dev,"unable to turn on the amdisp i2c power:%d\n" , ret);
return dev_err_probe() would make code slightly simpler.
Quoted 15 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +15
-0+return ret; + } + + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret =i2c_dw_fw_parse_and_configure (dev); +if (ret) + goto exit; + +i2c_dw_configure (dev); + + adap = &dev->adapter; + adap->owner =THIS_MODULE ; +ACPI_COMPANION_SET (&adap->dev,ACPI_COMPANION (&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; +/* arbitrary large number to avoid any conflicts */
drivers/i2c/busses/i2c-designware-amdisp.c line 126
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ adap->nr =99 ; + +if (dev->flags &ACCESS_NO_IRQ_SUSPEND ) { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE ); + }else { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND ); + }
Unneeded { } in both branches.
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +7
-0+ +device_enable_async_suspend (&pdev->dev); + +/* The code below assumes runtime PM to be disabled. */ +WARN_ON (pm_runtime_enabled (&pdev->dev)); + +pm_runtime_dont_use_autosuspend (&pdev->dev);
drivers/i2c/busses/i2c-designware-amdisp.c line 143
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+pm_runtime_set_active (&pdev->dev); + +if (dev->shared_with_punit) +pm_runtime_get_noresume (&pdev->dev); + +pm_runtime_enable (&pdev->dev); + + ret =i2c_dw_probe (dev); +if (ret) { +dev_err (dev->dev,"i2c_dw_probe failed %d\n" , ret);
dev_err_probe() would make code slightly simpler.
Quoted 19 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +19
-0+ goto exit_probe; + } + +isp_power_set (false); +return ret; + +exit_probe: +amd_isp_dw_i2c_plat_pm_cleanup (dev); +isp_power_set (false); +exit: +isp_power_set (false); +return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ +struct dw_i2c_dev *dev =platform_get_drvdata (pdev); + +pm_runtime_get_sync (&pdev->dev);
drivers/i2c/busses/i2c-designware-amdisp.c line 172
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ +i2c_del_adapter (&dev->adapter); + +i2c_dw_disable (dev); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +amd_isp_dw_i2c_plat_pm_cleanup (dev); + +reset_control_assert (dev->rst);
Is it needed? (there is apparently no reset_control_deassert() in this driver)
Quoted 1 line
+}
...
drivers/i2c/busses/i2c-designware-amdisp.c line 263
Quoted 4 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +4
-0+MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" );
MIT is stated in SPDX-License-Identifier
drivers/i2c/busses/i2c-designware-amdisp.c line 266
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +3
-0+MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );
Is it allowed to have several MODULE_LICENSE?
...
CJ
Hi CJ,
Please accept my apologies for the delayed response to your review comments.
Thanks,
Pratap
Quoted 12 lines · Christophe JAILLET
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 5 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>...
Quoted 11 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 1
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +1
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ I think that this should be // comment style for SPDX-License-Identifier en c files.
Thanks. Will update in V2.
Quoted 6 lines
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +3
-0+/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* ...
Quoted 12 lines
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ + struct i2c_adapter *adap; + struct amd_isp_i2c_dev *isp_i2c_dev; + struct dw_i2c_dev *dev; + int ret; + + isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(struct
amd_isp_i2c_dev),
sizeof(*isp_i2c_dev)maybe?
Thanks. Will update in V2.
Quoted 11 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 88
Quoted 8 lines
+
GFP_KERNEL);
+ if (!isp_i2c_dev)
+ return-ENOMEM;drivers/i2c/busses/i2c-designware-amdisp.c new file +5
-0+ + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + + /**Just /*
Thanks. Will fix this in V2.
Quoted 8 lines
Quoted 8 lines
+ * Use the polling mode to send/receive the data, because + * no IRQ connection from ISP I2C
+ */
+dev->flags|=ACCESS_POLLING;
+platform_set_drvdata(pdev, dev);
+
+dev->base=devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(dev->base))
Quoted 9 lines
Quoted 6 lines
+ return
PTR_ERR(dev->base);
+
+ ret =isp_power_set(true);
+ if (ret) {
+dev_err(dev->dev, "unable to turn on the amdisp i2c power:%d\n", ret);return
dev_err_probe()would make code slightly simpler.
Thanks. Will update in V2.
Quoted 19 lines
Quoted 19 lines
+ return ret;
+ }drivers/i2c/busses/i2c-designware-amdisp.c new file +17
-0+ + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret = i2c_dw_fw_parse_and_configure(dev); + if (ret) + goto exit; + + i2c_dw_configure(dev); + + adap = &dev->adapter; + adap->owner = THIS_MODULE; + ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; + /* arbitrary large number to avoid any conflicts */ + adap->nr = 99; + + if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { + dev_pm_set_driver_flags(&pdev->dev,
Quoted 9 lines
Quoted 6 lines
+
DPM_FLAG_SMART_PREPARE); + } else {
+ dev_pm_set_driver_flags(&pdev->dev,
+DPM_FLAG_SMART_PREPARE| +DPM_FLAG_SMART_SUSPEND); + }Unneeded { } in both branches.
Thanks. Will remove them in V2.
Quoted 11 lines
Quoted 11 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +11
-0+ + device_enable_async_suspend(&pdev->dev); + + /* The code below assumes runtime PM to be disabled. */ + WARN_ON(pm_runtime_enabled(&pdev->dev)); + + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + + if (dev->shared_with_punit) + pm_runtime_get_noresume(&pdev->dev);
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 143
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+ + pm_runtime_enable(&pdev->dev); + + ret = i2c_dw_probe(dev); + if (ret) { + dev_err(dev->dev, "i2c_dw_probe failed %d\n", ret);
dev_err_probe()would make code slightly simpler.
Thanks. Will update in V2.
Quoted 24 lines
Quoted 24 lines
+ goto
exit_probe;
+ }drivers/i2c/busses/i2c-designware-amdisp.c new file +22
-0+ + isp_power_set(false); + return ret; + +exit_probe: + amd_isp_dw_i2c_plat_pm_cleanup(dev); + isp_power_set(false); +exit: + isp_power_set(false); + return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ + struct dw_i2c_dev *dev = platform_get_drvdata(pdev); + + pm_runtime_get_sync(&pdev->dev); + + i2c_del_adapter(&dev->adapter); + + i2c_dw_disable(dev); +
Quoted 9 lines
Quoted 5 lines
+
pm_runtime_dont_use_autosuspend(&pdev->dev); +pm_runtime_put_sync(&pdev->dev);
+amd_isp_dw_i2c_plat_pm_cleanup(dev); +
+reset_control_assert(dev->rst);Is it needed? (there is apparently no
reset_control_deassert()in this driver)
Thanks. Its not needed, will remove it in V2.
Quoted 11 lines
Quoted 1 line
+}
...
drivers/i2c/busses/i2c-designware-amdisp.c line 263
Quoted 4 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +4
-0+MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" );MIT is stated in SPDX-License-Identifier
Thanks. Will update the license info.
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 266
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +3
-0+MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );Is it allowed to have several
MODULE_LICENSE?
Thanks. Will use GPL alone in V2.
Quoted 3 lines
...
CJ
Quoted 32 lines · Pratap Nirujogi
config
I2C_DESIGNWARE_AMDPSPdrivers/i2c/busses/Kconfig +0
-0bool "AMD PSP I2C semaphore support" depends on ACPIdrivers/i2c/busses/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +11
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +*
drivers/i2c/busses/i2c-designware-amdisp.c line 21
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE.
Don't add custom license boilerplate.
Quoted 23 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +23
-0+*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/sched.h> +#include <linux/slab.h>
drivers/i2c/busses/i2c-designware-amdisp.c line 54
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+#include <linux/suspend.h> +#include <linux/units.h> + +#include "i2c-designware-core.h" +#include "i2c-designware-amdisp.h" + +#define AMD_ISP_I2C_INPUT_CLK 100 //100 Mhz + +#define to_amd_isp_i2c_dev (dev) \ + ((struct amd_isp_i2c_dev *)container_of(dev, struct amd_isp_i2c_dev, dw_dev))
Why do you need to cast? To drop const? That's poor coding.
Quoted 16 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +16
-0+ +struct amd_isp_i2c_dev { +struct dw_i2c_dev dw_dev; +}; + +static void amd_isp_dw_i2c_plat_pm_cleanup (struct dw_i2c_dev *dev) +{ +pm_runtime_disable (dev->dev); + +if (dev->shared_with_punit) +pm_runtime_put_noidle (dev->dev); +} + +static u32 amd_isp_dw_i2c_get_clk_rate (struct dw_i2c_dev *dev) +{ +return AMD_ISP_I2C_INPUT_CLK *1000 ;
drivers/i2c/busses/i2c-designware-amdisp.c line 80
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+} + +static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ +struct i2c_adapter *adap; +struct amd_isp_i2c_dev *isp_i2c_dev; +struct dw_i2c_dev *dev; +int ret; + + isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(struct amd_isp_i2c_dev),
sizeof(*)
drivers/i2c/busses/i2c-designware-amdisp.c line 88
Quoted 8 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+ GFP_KERNEL); +if (!isp_i2c_dev) +return -ENOMEM ; + + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + +/**
Not a kerneldoc.
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
drivers/i2c/busses/i2c-designware-amdisp.c line 101
Quoted 13 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +13
-0+* Use the polling mode to send/receive the data, because +* no IRQ connection from ISP I2C +*/ + dev->flags |=ACCESS_POLLING ; +platform_set_drvdata (pdev, dev); + + dev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + + ret =isp_power_set (true); +if (ret) { +dev_err (dev->dev,"unable to turn on the amdisp i2c power:%d\n" , ret);
Syntax is return dev_err_probe()
Quoted 20 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +20
-0+return ret; + } + + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret =i2c_dw_fw_parse_and_configure (dev); +if (ret) + goto exit; + +i2c_dw_configure (dev); + + adap = &dev->adapter; + adap->owner =THIS_MODULE ; +ACPI_COMPANION_SET (&adap->dev,ACPI_COMPANION (&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; +/* arbitrary large number to avoid any conflicts */ + adap->nr =99 ; + +if (dev->flags &ACCESS_NO_IRQ_SUSPEND ) { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE );
drivers/i2c/busses/i2c-designware-amdisp.c line 131
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ }else { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND ); + } + +device_enable_async_suspend (&pdev->dev); + +/* The code below assumes runtime PM to be disabled. */ +WARN_ON (pm_runtime_enabled (&pdev->dev));
And how it could be enabled? Drop or fix your driver.
drivers/i2c/busses/i2c-designware-amdisp.c line 143
Quoted 12 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +12
-0+ +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_set_active (&pdev->dev); + +if (dev->shared_with_punit) +pm_runtime_get_noresume (&pdev->dev); + +pm_runtime_enable (&pdev->dev); + + ret =i2c_dw_probe (dev); +if (ret) { +dev_err (dev->dev,"i2c_dw_probe failed %d\n" , ret);
Use dev_err_probe()
Quoted 99 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +99
-0+ goto exit_probe; + } + +isp_power_set (false); +return ret; + +exit_probe: +amd_isp_dw_i2c_plat_pm_cleanup (dev); +isp_power_set (false); +exit: +isp_power_set (false); +return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ +struct dw_i2c_dev *dev =platform_get_drvdata (pdev); + +pm_runtime_get_sync (&pdev->dev); + +i2c_del_adapter (&dev->adapter); + +i2c_dw_disable (dev); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +amd_isp_dw_i2c_plat_pm_cleanup (dev); + +reset_control_assert (dev->rst); +} + +static int amd_isp_dw_i2c_plat_prepare (struct device *dev) +{ +/* +* If the ACPI companion device object is present for this device, it +* may be accessed during suspend and resume of other devices via I2C +* operation regions, so tell the PM core and middle layers to avoid +* skipping system suspend/resume callbacks for it in that case. +*/ +return !has_acpi_companion (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (i_dev->shared_with_punit) +return 0 ; + +i2c_dw_disable (i_dev); +i2c_dw_prepare_clk (i_dev, false); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +i2c_mark_adapter_suspended (&i_dev->adapter); + +return amd_isp_dw_i2c_plat_runtime_suspend (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (!i_dev->shared_with_punit) +i2c_dw_prepare_clk (i_dev, true); + + i_dev->init (i_dev); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +amd_isp_dw_i2c_plat_runtime_resume (dev); +i2c_mark_adapter_resumed (&i_dev->adapter); + +return 0 ; +} + +static const struct dev_pm_ops amd_isp_dw_i2c_dev_pm_ops = { + .prepare =pm_sleep_ptr (amd_isp_dw_i2c_plat_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(amd_isp_dw_i2c_plat_suspend, amd_isp_dw_i2c_plat_resume) +RUNTIME_PM_OPS (amd_isp_dw_i2c_plat_runtime_suspend, amd_isp_dw_i2c_plat_runtime_resume,NULL ) +}; + +/* Work with hotplug and coldplug */ +MODULE_ALIAS ("platform:amd_isp_i2c_designware" ); + +static struct platform_driver amd_isp_dw_i2c_driver = { + .probe = amd_isp_dw_i2c_plat_probe, + .remove = amd_isp_dw_i2c_plat_remove, + .driver = {
drivers/i2c/busses/i2c-designware-amdisp.c line 252
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+ .name = "amd_isp_i2c_designware", + .pm = pm_ptr(&amd_isp_dw_i2c_dev_pm_ops), + }, +}; + +static int __init amd_isp_dw_i2c_init_driver (void ) +{ +return platform_driver_register (&amd_isp_dw_i2c_driver); +} +subsys_initcall (amd_isp_dw_i2c_init_driver);
Why this cannot be standard module initcall? This is ISP, not a critical boot component.
Quoted 31 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +14
-0+ +static void __exit amd_isp_dw_i2c_exit_driver(void) +{ +platform_driver_unregister (&amd_isp_dw_i2c_driver); +} +module_exit (amd_isp_dw_i2c_exit_driver); + +MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );drivers/i2c/busses/i2c-designware-amdisp.h new file +11
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +*
drivers/i2c/busses/i2c-designware-amdisp.h line 21
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +10
-0+* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE.
Don't add custom license boilerplate.
drivers/i2c/busses/i2c-designware-amdisp.h line 24
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +3
-0+*/ + +int isp_power_set (int on);
Best regards,
Krzysztof
Hi Krzysztof,
Please accept my apologies for the delayed response to your review comments.
Thanks,
Pratap
Quoted 40 lines · Krzysztof Kozlowski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 36 lines · Pratap Nirujogi
config
I2C_DESIGNWARE_AMDPSP
bool "AMD PSP I2C semaphore support"
depends on ACPIdrivers/i2c/busses/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +15
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 21
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. Don't add custom license boilerplate.
Thanks. Will remove it in V2.
Quoted 28 lines
Quoted 28 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +27
-0+*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/property.h> +#include <linux/regmap.h> +#include <linux/reset.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/suspend.h> +#include <linux/units.h> + +#include "i2c-designware-core.h"
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 54
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+#include "i2c-designware-amdisp.h" + +#define AMD_ISP_I2C_INPUT_CLK 100 //100 Mhz + +#define to_amd_isp_i2c_dev (dev) \ + ((struct amd_isp_i2c_dev *)container_of(dev, struct amd_isp_i2c_dev, dw_dev))Why do you need to cast? To drop const? That's poor coding.
Thanks. Will remove it in V2.
Quoted 40 lines
Quoted 16 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +16
-0+ +struct amd_isp_i2c_dev { +struct dw_i2c_dev dw_dev; +}; + +static void amd_isp_dw_i2c_plat_pm_cleanup (struct dw_i2c_dev *dev) +{ +pm_runtime_disable (dev->dev); + +if (dev->shared_with_punit) +pm_runtime_put_noidle (dev->dev); +} + +static u32 amd_isp_dw_i2c_get_clk_rate (struct dw_i2c_dev *dev) +{ +return AMD_ISP_I2C_INPUT_CLK *1000 ;drivers/i2c/busses/i2c-designware-amdisp.c line 80
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+} + +static int amd_isp_dw_i2c_plat_probe (struct platform_device *pdev) +{ +struct i2c_adapter *adap; +struct amd_isp_i2c_dev *isp_i2c_dev; +struct dw_i2c_dev *dev; +int ret; + + isp_i2c_dev = devm_kzalloc(&pdev->dev, sizeof(struct amd_isp_i2c_dev),
sizeof(*)drivers/i2c/busses/i2c-designware-amdisp.c line 88
Quoted 8 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +8
-0+ GFP_KERNEL); +if (!isp_i2c_dev) +return -ENOMEM ; + + dev = &isp_i2c_dev->dw_dev; + dev->dev = &pdev->dev; + +/** Not a kerneldoc.
Quoted 7 lines
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Thanks. Will run the suggested tools and fix the warnings reported in V2.
Quoted 7 lines
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +7
-0+* Use the polling mode to send/receive the data, because +* no IRQ connection from ISP I2C +*/ + dev->flags |=ACCESS_POLLING ; +platform_set_drvdata (pdev, dev); + + dev->base =devm_platform_ioremap_resource (pdev,0 );
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 101
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+if (IS_ERR (dev->base)) +return PTR_ERR (dev->base); + + ret =isp_power_set (true); +if (ret) { +dev_err (dev->dev,"unable to turn on the amdisp i2c power:%d\n" , ret);Syntax is return
dev_err_probe()
Thanks. Will update in V2.
Quoted 24 lines
Quoted 24 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +24
-0+return ret; + } + + dev->get_clk_rate_khz = amd_isp_dw_i2c_get_clk_rate; + ret =i2c_dw_fw_parse_and_configure (dev); +if (ret) + goto exit; + +i2c_dw_configure (dev); + + adap = &dev->adapter; + adap->owner =THIS_MODULE ; +ACPI_COMPANION_SET (&adap->dev,ACPI_COMPANION (&pdev->dev)); + adap->dev.of_node = pdev->dev.of_node; +/* arbitrary large number to avoid any conflicts */ + adap->nr =99 ; + +if (dev->flags &ACCESS_NO_IRQ_SUSPEND ) { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE ); + }else { +dev_pm_set_driver_flags (&pdev->dev, +DPM_FLAG_SMART_PREPARE | +DPM_FLAG_SMART_SUSPEND );
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 131
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+ } + +device_enable_async_suspend (&pdev->dev); + +/* The code below assumes runtime PM to be disabled. */ +WARN_ON (pm_runtime_enabled (&pdev->dev));And how it could be enabled? Drop or fix your driver.
Thanks. Will drop this in V2.
Quoted 6 lines
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+ +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_set_active (&pdev->dev); + +if (dev->shared_with_punit) +pm_runtime_get_noresume (&pdev->dev);
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 143
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +6
-0+ +pm_runtime_enable (&pdev->dev); + + ret =i2c_dw_probe (dev); +if (ret) { +dev_err (dev->dev,"i2c_dw_probe failed %d\n" , ret);Use
dev_err_probe()
Thanks. Will update in V2.
Quoted 104 lines
Quoted 104 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +104
-0+ goto exit_probe; + } + +isp_power_set (false); +return ret; + +exit_probe: +amd_isp_dw_i2c_plat_pm_cleanup (dev); +isp_power_set (false); +exit: +isp_power_set (false); +return ret; +} + +static void amd_isp_dw_i2c_plat_remove (struct platform_device *pdev) +{ +struct dw_i2c_dev *dev =platform_get_drvdata (pdev); + +pm_runtime_get_sync (&pdev->dev); + +i2c_del_adapter (&dev->adapter); + +i2c_dw_disable (dev); + +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +amd_isp_dw_i2c_plat_pm_cleanup (dev); + +reset_control_assert (dev->rst); +} + +static int amd_isp_dw_i2c_plat_prepare (struct device *dev) +{ +/* +* If the ACPI companion device object is present for this device, it +* may be accessed during suspend and resume of other devices via I2C +* operation regions, so tell the PM core and middle layers to avoid +* skipping system suspend/resume callbacks for it in that case. +*/ +return !has_acpi_companion (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (i_dev->shared_with_punit) +return 0 ; + +i2c_dw_disable (i_dev); +i2c_dw_prepare_clk (i_dev, false); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_suspend (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +i2c_mark_adapter_suspended (&i_dev->adapter); + +return amd_isp_dw_i2c_plat_runtime_suspend (dev); +} + +static int amd_isp_dw_i2c_plat_runtime_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +if (!i_dev->shared_with_punit) +i2c_dw_prepare_clk (i_dev, true); + + i_dev->init (i_dev); + +return 0 ; +} + +static int amd_isp_dw_i2c_plat_resume (struct device *dev) +{ +struct dw_i2c_dev *i_dev =dev_get_drvdata (dev); + +amd_isp_dw_i2c_plat_runtime_resume (dev); +i2c_mark_adapter_resumed (&i_dev->adapter); + +return 0 ; +} + +static const struct dev_pm_ops amd_isp_dw_i2c_dev_pm_ops = { + .prepare =pm_sleep_ptr (amd_isp_dw_i2c_plat_prepare), + LATE_SYSTEM_SLEEP_PM_OPS(amd_isp_dw_i2c_plat_suspend, amd_isp_dw_i2c_plat_resume) +RUNTIME_PM_OPS (amd_isp_dw_i2c_plat_runtime_suspend, amd_isp_dw_i2c_plat_runtime_resume,NULL ) +}; + +/* Work with hotplug and coldplug */ +MODULE_ALIAS ("platform:amd_isp_i2c_designware" ); + +static struct platform_driver amd_isp_dw_i2c_driver = { + .probe = amd_isp_dw_i2c_plat_probe, + .remove = amd_isp_dw_i2c_plat_remove, + .driver = { + .name ="amd_isp_i2c_designware" , + .pm =pm_ptr (&amd_isp_dw_i2c_dev_pm_ops), + }, +}; +
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.c line 252
Quoted 5 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +5
-0+static int __init amd_isp_dw_i2c_init_driver (void ) +{ +return platform_driver_register (&amd_isp_dw_i2c_driver); +} +subsys_initcall (amd_isp_dw_i2c_init_driver);Why this cannot be standard module initcall? This is ISP, not a critical boot component.
Thanks. It need not be subsys_initcall. Will use module_init in V2.
Quoted 35 lines
Quoted 35 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +14
-0+ +static void __exit amd_isp_dw_i2c_exit_driver(void) +{ +platform_driver_unregister (&amd_isp_dw_i2c_driver); +} +module_exit (amd_isp_dw_i2c_exit_driver); + +MODULE_AUTHOR ("Venkata Narendra Kumar Gutta <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsys DesignWare I2C bus adapter in AMD ISP" ); +MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS ("I2C_DW" ); +MODULE_IMPORT_NS ("I2C_DW_COMMON" ); +MODULE_LICENSE ("GPL and additional rights" );drivers/i2c/busses/i2c-designware-amdisp.h new file +15
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Quoted 9 lines
drivers/i2c/busses/i2c-designware-amdisp.h line 21
Quoted 6 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +6
-0+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. Don't add custom license boilerplate.
Thanks. Will remove it in V2.
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.h line 24
Quoted 3 lines
drivers/i2c/busses/i2c-designware-amdisp.h new file +3
-0+*/ + +int isp_power_set (int on);Best regards,
Krzysztof
Quoted 72 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdisp.c | 266 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-amdisp.h | 24 ++ 4 files changed, 301 insertions(+) create mode 100644 drivers/i2c/busses/i2c-designware-amdisp.c create mode 100644 drivers/i2c/busses/i2c-designware-amdisp.hdrivers/i2c/busses/Kconfig +10
-0@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. + config I2C_DESIGNWARE_AMDPSP bool "AMD PSP I2C semaphore support" depends on ACPIdrivers/i2c/busses/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +19
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/i2c/busses/i2c-designware-amdisp.c line 29
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h>
Hm?
drivers/i2c/busses/i2c-designware-amdisp.c line 36
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +7
-0+#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h>
Drop... or you miss bindings.
Many more headers look not used or even wrong.
Best regards,
Krzysztof
Quoted 99 lines · Krzysztof Kozlowski
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 72 lines · Pratap Nirujogi
The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW.
Signed-off-by Pratap Nirujogi <[email protected]>--- drivers/i2c/busses/Kconfig | 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware-amdisp.c | 266 +++++++++++++++++++++ drivers/i2c/busses/i2c-designware-amdisp.h | 24 ++ 4 files changed, 301 insertions(+)create mode 100644
drivers/i2c/busses/i2c-designware-amdisp.ccreate mode 100644drivers/i2c/busses/i2c-designware-amdisp.hdrivers/i2c/busses/Kconfig +10
-0@@ -592,6 +592,16 @@ config I2C_DESIGNWARE_PLATFORM This driver can also be built as a module. If so, the module will be called i2c-designware-platform. +config I2C_DESIGNWARE_AMDISP + tristate "Synopsys DesignWare Platform for AMDISP" + depends on I2C_DESIGNWARE_CORE + help + If you say yes to this option, support will be included for the + AMDISP Synopsys DesignWare I2C adapter. + + This driver can also be built as a module. If so, the module + will be called amd_isp_i2c_designware. + config I2C_DESIGNWARE_AMDPSP bool "AMD PSP I2C semaphore support" depends on ACPIdrivers/i2c/busses/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o i2c-designware-platform-y := i2c-designware-platdrv.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_AMDPSP) += i2c-designware-amdpsp.o i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o +obj-$(CONFIG_I2C_DESIGNWARE_AMDISP) += i2c-designware-amdisp.o obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o i2c-designware-pci-y := i2c-designware-pcidrv.o obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.odrivers/i2c/busses/i2c-designware-amdisp.c new file +19
-0@@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2024-2025 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, drivers/i2c/busses/i2c-designware-amdisp.c line 29
Quoted 10 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +10
-0+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dmi.h> +#include <linux/err.h> +#include <linux/errno.h> Hm?
drivers/i2c/busses/i2c-designware-amdisp.c line 36
Quoted 7 lines
drivers/i2c/busses/i2c-designware-amdisp.c new file +7
-0+#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/of.h> Drop... or you miss bindings.
Quoted 2 lines
Many more headers look not used or even wrong.
Thanks. Will clean-up header files in V2.
Quoted 2 lines
Best regards,
Krzysztof
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Pratap,
kernel test robot noticed the following build errors:
[auto build test ERROR on andi-shyti/i2c/i2c-host]
[also build test ERROR on linus/master v6.14-rc5 next-20250228] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pratap-Nirujogi/i2c-amd-isp-Add-ISP-i2c-designware-driver/20250301-005001 base: https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host patch link: https://lore.kernel.org/r/20250228164519.3453927-1-pratap.nirujogi%40amd.com patch subject: [PATCH] i2c: amd-isp: Add ISP i2c-designware driver config: x86_64-randconfig-005-20250303 (https://download.01.org/0day-ci/archive/20250303/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250303/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-mgr-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-bridge-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fpga/tests/fpga-region-test.o
>> ERROR: modpost: "isp_power_set" [drivers/i2c/busses/i2c-designware-amdisp.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki