mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: Ajay Neeli <ajay.neeli@amd.com>,
	git@amd.com, andi.shyti@kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: srinivas.goud@amd.com, radhey.shyam.pandey@amd.com
Subject: Re: [PATCH v2] i2c: cadence: Add shutdown handler
Date: Thu, 24 Jul 2025 07:28:53 +0200	[thread overview]
Message-ID: <d1a0374f-562e-465f-8332-1dc1f66ab2d2@amd.com> (raw)
In-Reply-To: <20250724051243.22051-1-ajay.neeli@amd.com>



On 7/24/25 07:12, Ajay Neeli wrote:
> Implement shutdown function for Cadence I2C driver to suspend the bus
> during system "reboot" or "shutdown".
> 
> Interrupts are disabled in the handler to avoid spurious events when the
> driver is in slave mode.
> 
> Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
> ---
> Changes in V2:
> Disable interrupts
> ---
>   drivers/i2c/busses/i2c-cadence.c | 32 ++++++++++++++++++++++++++------
>   1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index 8df63aa..e0a56df 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -192,6 +192,7 @@ enum cdns_i2c_slave_state {
>    * @transfer_size:	The maximum number of bytes in one transfer
>    * @atomic:		Mode of transfer
>    * @err_status_atomic:	Error status in atomic mode
> + * @irq:		IRQ Number
>    */
>   struct cdns_i2c {
>   	struct device		*dev;
> @@ -224,6 +225,7 @@ struct cdns_i2c {
>   	unsigned int transfer_size;
>   	bool atomic;
>   	int err_status_atomic;
> +	int irq;
>   };
>   
>   struct cdns_platform_data {
> @@ -1495,7 +1497,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
>   {
>   	struct resource *r_mem;
>   	struct cdns_i2c *id;
> -	int ret, irq;
> +	int ret;
>   	const struct of_device_id *match;
>   
>   	id = devm_kzalloc(&pdev->dev, sizeof(*id), GFP_KERNEL);
> @@ -1526,9 +1528,9 @@ static int cdns_i2c_probe(struct platform_device *pdev)
>   	if (IS_ERR(id->membase))
>   		return PTR_ERR(id->membase);
>   
> -	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0)
> -		return irq;
> +	id->irq = platform_get_irq(pdev, 0);
> +	if (id->irq < 0)
> +		return id->irq;
>   
>   	id->adap.owner = THIS_MODULE;
>   	id->adap.dev.of_node = pdev->dev.of_node;
> @@ -1590,10 +1592,10 @@ static int cdns_i2c_probe(struct platform_device *pdev)
>   		goto err_clk_notifier_unregister;
>   	}
>   
> -	ret = devm_request_irq(&pdev->dev, irq, cdns_i2c_isr, 0,
> +	ret = devm_request_irq(&pdev->dev, id->irq, cdns_i2c_isr, 0,
>   				 DRIVER_NAME, id);
>   	if (ret) {
> -		dev_err(&pdev->dev, "cannot get irq %d\n", irq);
> +		dev_err(&pdev->dev, "cannot get irq %d\n", id->irq);
>   		goto err_clk_notifier_unregister;
>   	}
>   	cdns_i2c_init(id);
> @@ -1636,6 +1638,23 @@ static void cdns_i2c_remove(struct platform_device *pdev)
>   	reset_control_assert(id->reset);
>   }
>   
> +/**
> + * cdns_i2c_shutdown - Shutdown the i2c device
> + * @pdev:	Handle to the platform device structure
> + *
> + * This function handles shutdown sequence
> + */
> +static void cdns_i2c_shutdown(struct platform_device *pdev)
> +{
> +	struct cdns_i2c *id = platform_get_drvdata(pdev);
> +
> +	/* Disable interrupts */
> +	disable_irq(id->irq);
> +
> +	/* Initiate failure of client i2c transfers */
> +	i2c_mark_adapter_suspended(&id->adap);
> +}
> +
>   static struct platform_driver cdns_i2c_drv = {
>   	.driver = {
>   		.name  = DRIVER_NAME,
> @@ -1644,6 +1663,7 @@ static void cdns_i2c_remove(struct platform_device *pdev)
>   	},
>   	.probe  = cdns_i2c_probe,
>   	.remove = cdns_i2c_remove,
> +	.shutdown = cdns_i2c_shutdown,
>   };
>   
>   module_platform_driver(cdns_i2c_drv);

Andi: I was checking other drivers and I can't see any other action which should 
be taken to have proper shutdown. Please let us know if driver should do 
something else too.

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal


  reply	other threads:[~2025-07-24  5:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  5:12 Ajay Neeli
2025-07-24  5:28 ` Michal Simek [this message]
2025-07-24 17:52 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1a0374f-562e-465f-8332-1dc1f66ab2d2@amd.com \
    --to=michal.simek@amd.com \
    --cc=ajay.neeli@amd.com \
    --cc=andi.shyti@kernel.org \
    --cc=git@amd.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=srinivas.goud@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®