All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Ajay Gupta <ajayg@nvidia.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	"wsa@the-dreams.de" <wsa@the-dreams.de>,
	"peda@axentia.se" <peda@axentia.se>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: [v13,2/2] usb: typec: ucsi: add support for Cypress CCGx
Date: Wed, 24 Oct 2018 12:25:03 +0300	[thread overview]
Message-ID: <20181024092503.GP10650@smile.fi.intel.com> (raw)

On Tue, Oct 23, 2018 at 06:56:59PM +0000, Ajay Gupta wrote:
> > On Wed, Oct 03, 2018 at 11:27:28AM -0700, Ajay Gupta wrote:
> > > Latest NVIDIA GPU cards have a Cypress CCGx Type-C controller over I2C
> > > interface.
> > >
> > > This UCSI I2C driver uses I2C bus driver interface for communicating
> > > with Type-C controller.

> > > +	/*
> > > +	 * Flush CCGx RESPONSE queue by acking interrupts. Above ucsi
> > control
> > > +	 * register write will push response which must be cleared.
> > > +	 */
> > > +	status = ccg_read(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
> > > +	if (status < 0)
> > > +		return status;

(1)

> > > +	do {
> > > +		status = ccg_write(uc, CCGX_RAB_INTR_REG, &data,
> > sizeof(data));
> > > +		if (status < 0)
> > > +			return status;

(2)

> > > +
> > > +		usleep_range(10000, 11000);
> > > +
> > > +		status = ccg_read(uc, CCGX_RAB_INTR_REG, &data,
> > sizeof(data));
> > > +		if (status < 0)
> > > +			return status;
> > > +	} while ((data != 0x00) && count--);
> > 
> > What's the significance of that count?
> It is like a retry count to clear interrupt status.
> 
> > Shouldn't you return -ETIMEDOUT if count == 0?
> Yes. Good catch. Does the below fix looks ok?

At least for me looks OK (I dunno why I missed that what Heikki found recently).
Nevertheless, I have one more question about (1) and (2) above.

Is it necessary to do one more read before do-while loop?

> 
>         do {
>                 status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
>                 if (status < 0)
>                         return status;
> 
>                 usleep_range(10000, 11000);
> 
>                 status = ccg_read(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
>                 if (status < 0)
>                         return status;
> 
>                 if (!data)
>                         return 0;
>         } while (data && count--);
> 
>         return -ETIMEDOUT;

             reply	other threads:[~2018-10-24  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24  9:25 Andy Shevchenko [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-10-26 16:25 [v13,2/2] usb: typec: ucsi: add support for Cypress CCGx Ajay Gupta
2018-10-26  7:27 Heikki Krogerus
2018-10-26  6:49 Peter Rosin
2018-10-25 21:55 Ajay Gupta
2018-10-25 21:30 Ajay Gupta
2018-10-25 21:29 Ajay Gupta
2018-10-25  9:26 Andy Shevchenko
2018-10-25  9:26 Heikki Krogerus
2018-10-25  9:07 Peter Rosin
2018-10-25  8:17 Heikki Krogerus
2018-10-24 17:43 Ajay Gupta
2018-10-23 18:56 Ajay Gupta
2018-10-23  9:35 Heikki Krogerus
2018-10-03 18:27 Ajay Gupta

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=20181024092503.GP10650@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=ajayg@nvidia.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=wsa@the-dreams.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.