Re: [PATCH] i2c: amd-isp: Add ISP i2c-designware driver

Nirujogi, Pratap
2025-04-22T16:07:06Z

Hi CJ,

Please accept my apologies for the delayed response to your review comments.

Thanks,
Pratap

On 3/1/2025 3:32 AM, Christophe JAILLET wrote:
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Le 28/02/2025 à 17:45, Pratap Nirujogi a écrit :
>> 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 <pratap.nirujogi@amd.com>
>
> ...
>
>> diff --git a/drivers/i2c/busses/i2c-designware-amdisp.c b/drivers/i2c/
>> busses/i2c-designware-amdisp.c
>> new file mode 100644
>> index 000000000000..dc90510a440b
>> --- /dev/null
>> +++ b/drivers/i2c/busses/i2c-designware-amdisp.c
>> @@ -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.

>> +/*
>> + * Copyright 2024-2025 Advanced Micro Devices, Inc.
>> + *
>
> ...
>
>> +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.

>> +                                GFP_KERNEL);
>> +     if (!isp_i2c_dev)
>> +             return -ENOMEM;
>> +
>> +     dev = &isp_i2c_dev->dw_dev;
>> +     dev->dev = &pdev->dev;
>> +
>> +     /**
>
> Just /*
>
Thanks. Will fix this in V2.

>> +      * 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.
>
Thanks. Will update in V2.

>> +             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);
>> +     }
>
> Unneeded { } in both branches.
>
Thanks. Will remove them in V2.

>> +
>> +     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);
>
> dev_err_probe() would make code slightly simpler.
>
Thanks. Will update in V2.

>> +             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);
>
> Is it needed? (there is apparently no reset_control_deassert() in this
> driver)
>
Thanks. Its not needed, will remove it in V2.

>> +}
>
> ...
>
>> +MODULE_AUTHOR("Venkata Narendra Kumar Gutta <vengutta@amd.com>");
>> +MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>");
>> +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.

>> +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.

> ...
>
> CJ