diff mbox series

[3/4] i2c: nvidia-gpu: resume ccgx i2c client

Message ID 20190517163818.5007-4-ajayg@nvidia.com (mailing list archive)
State Superseded
Headers show
Series usb: typec: ucsi: ccg: add runtime pm support | expand

Commit Message

Ajay Gupta May 17, 2019, 4:38 p.m. UTC
From: Ajay Gupta <ajayg@nvidia.com>

Cypress USB Type-C CCGx controller firmware (which is being used
in many NVIDIA GPU cards) has known issue of not triggering
interrupt when a USB device is hot plugged to runtime resume the
controller. Many of these cards may get latest kernel but may not
get latest fixed firmware so a workaround to check for any
connector change event.

The workaround is to request runtime resume of i2c client
which is UCSI Cypress CCGx driver. CCG driver will call the ISR
for any connector change event only if NVIDIA GPU has old
CCG firmware with the known issue.

Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
---
 drivers/i2c/busses/i2c-nvidia-gpu.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Wolfram Sang May 19, 2019, 2:48 p.m. UTC | #1
> +	/* runtime resume ccgx client so that it can see for any
> +	 * connector change event. Old ccg firmware has known
> +	 * issue of not triggering interrupt when a device is
> +	 * connected to runtime resume the controller.
> +	 */

Check coding style for comments.

BTW how do you suggest this gets upstream? Through the usb-tree? Would
be fine with me. Are there any dependencies? The cover-letter doesn't
mention it.
Ajay Gupta May 20, 2019, 5:08 p.m. UTC | #2
Hi Wolfram,

> -----Original Message-----
> From: Wolfram Sang <wsa@the-dreams.de>
> Sent: Sunday, May 19, 2019 7:49 AM
> To: Ajay Gupta <ajaykuee@gmail.com>
> Cc: heikki.krogerus@linux.intel.com; linux-usb@vger.kernel.org; linux-
> i2c@vger.kernel.org; Ajay Gupta <ajayg@nvidia.com>
> Subject: Re: [PATCH 3/4] i2c: nvidia-gpu: resume ccgx i2c client
> 
> 
> > +	/* runtime resume ccgx client so that it can see for any
> > +	 * connector change event. Old ccg firmware has known
> > +	 * issue of not triggering interrupt when a device is
> > +	 * connected to runtime resume the controller.
> > +	 */
> 
> Check coding style for comments.
Sure, will fix.
> 
> BTW how do you suggest this gets upstream? Through the usb-tree? Would be
> fine with me. Are there any dependencies? The cover-letter doesn't mention it.
I would prefer it to go through usb-tree since usb ucsi_ccg driver is the main driver
getting runtime pm functionality with the series. I will add this information in cover
letter too.

Thanks
Ajay
>nvpublic
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
index 9d347583f8dc..2f72135a547b 100644
--- a/drivers/i2c/busses/i2c-nvidia-gpu.c
+++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
@@ -51,6 +51,7 @@  struct gpu_i2c_dev {
 	void __iomem *regs;
 	struct i2c_adapter adapter;
 	struct i2c_board_info *gpu_ccgx_ucsi;
+	struct i2c_client *ccgx_client;
 };
 
 static void gpu_enable_i2c_bus(struct gpu_i2c_dev *i2cd)
@@ -267,8 +268,6 @@  static const struct property_entry ccgx_props[] = {
 
 static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
 {
-	struct i2c_client *ccgx_client;
-
 	i2cd->gpu_ccgx_ucsi = devm_kzalloc(i2cd->dev,
 					   sizeof(*i2cd->gpu_ccgx_ucsi),
 					   GFP_KERNEL);
@@ -280,8 +279,8 @@  static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq)
 	i2cd->gpu_ccgx_ucsi->addr = 0x8;
 	i2cd->gpu_ccgx_ucsi->irq = irq;
 	i2cd->gpu_ccgx_ucsi->properties = ccgx_props;
-	ccgx_client = i2c_new_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
-	if (!ccgx_client)
+	i2cd->ccgx_client = i2c_new_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi);
+	if (!i2cd->ccgx_client)
 		return -ENODEV;
 
 	return 0;
@@ -371,6 +370,12 @@  static __maybe_unused int gpu_i2c_resume(struct device *dev)
 	struct gpu_i2c_dev *i2cd = dev_get_drvdata(dev);
 
 	gpu_enable_i2c_bus(i2cd);
+	/* runtime resume ccgx client so that it can see for any
+	 * connector change event. Old ccg firmware has known
+	 * issue of not triggering interrupt when a device is
+	 * connected to runtime resume the controller.
+	 */
+	pm_request_resume(&i2cd->ccgx_client->dev);
 	return 0;
 }