From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Nagarjuna Kristam <nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
kishon-l0cyMroinI0@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH V2 6/8] phy: tegra: xusb: Add support for charger detect
Date: Mon, 4 May 2020 17:50:29 +0200 [thread overview]
Message-ID: <20200504155029.GB614153@ulmo> (raw)
In-Reply-To: <ea0f5906-4681-8b84-a55a-e959ce40aece-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2717 bytes --]
On Mon, May 04, 2020 at 02:32:51PM +0530, Nagarjuna Kristam wrote:
> >On 28-04-2020 16:25, Thierry Reding wrote:
> > > On Wed, Apr 15, 2020 at 01:55:06PM +0530, Nagarjuna Kristam wrote:
[...]
> > > diff --git a/drivers/phy/tegra/xusb-tegra-cd.c b/drivers/phy/tegra/xusb-tegra-cd.c
> > > +static void tegra_xusb_padctl_utmi_pad_dcd(struct tegra_xusb_padctl *padctl,
> > > + u32 index)
> > > +{
> > > + u32 value;
> > > + int dcd_timeout_ms = 0;
> > > + bool ret = false;
> > > +
> > > + /* Turn on IDP_SRC */
> > > + value = padctl_readl(padctl, USB2_BATTERY_CHRG_OTGPADX_CTL0(index));
> > > + value |= OP_I_SRC_EN;
> > > + padctl_writel(padctl, value, USB2_BATTERY_CHRG_OTGPADX_CTL0(index));
> > > +
> > > + /* Turn on D- pull-down resistor */
> > > + value = padctl_readl(padctl, USB2_BATTERY_CHRG_OTGPADX_CTL1(index));
> > > + value |= USBON_RPD_OVRD_VAL;
> > > + padctl_writel(padctl, value, USB2_BATTERY_CHRG_OTGPADX_CTL1(index));
> > > +
> > > + /* Wait for TDCD_DBNC */
> > > + usleep_range(10000, 120000);
> > From the comment this looks like we're waiting for some hardware
> > condition. Can we somehow obtain this rather than implementing a fixed
> > sleep? Especially since the range here is so large.
> >
> As per data sheet we need to wait for 10 micro seconds as settle time.
Okay, so TDCD_DBNC is a value that comes from a timing diagram in a
datasheet? Seems fine to leave it as-is then. Perhaps add parentheses
and mention which exact datasheet that's from, and perhaps which figure
so that people can more easily reference it. Provided there is a
publicly available datasheet, of course.
Actually, one other thing: If the data sheet says to wait 10 us, why do
you use an upper range of 120 us? Shouldn't a range of 10-20 us be good
enough?
> > > + /* Wait for TVDPSRC_ON */
> > > + msleep(40);
> > Again, is this a hardware condition that we can wait on by polling a
> > register?
> >
> It HW settle time before reading registers.
Again, perhaps link to the datasheet, or alternatively describe in the
comment what this is waiting for. That is, something like:
/* wait for TVDPSRC_ON (wait for hardware to settle) */
or similar.
> > > + if (tegra_xusb_padctl_utmi_pad_secondary_charger_detect(padctl,
> > > + index))
> > > + chrg_type = CDP_TYPE;
> > > + else
> > > + chrg_type = DCP_TYPE;
> > > + } else {
> > > + chrg_type = SDP_TYPE;
> > > + }
> > > +
> > > + dev_dbg(&port->dev, "charger detected of type %d", chrg_type);
> > Do we have a string representation of this?
> >
> No String representation available. Shall i add one for wasy reading ?
Yeah, I think that'd be nice.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-05-04 15:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 8:25 [PATCH V2 0/8] Tegra XUSB charger detect support Nagarjuna Kristam
2020-04-15 8:25 ` [PATCH V2 3/8] phy: tegra: xusb: Add support for UTMI pad power control Nagarjuna Kristam
[not found] ` <1586939108-10075-4-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 10:04 ` Thierry Reding
2020-04-28 10:16 ` Thierry Reding
[not found] ` <1586939108-10075-1-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-15 8:25 ` [PATCH V2 1/8] dt-bindings: phy: tegra-xusb: Add charger-detect property Nagarjuna Kristam
[not found] ` <1586939108-10075-2-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 9:57 ` Thierry Reding
2020-04-15 8:25 ` [PATCH V2 2/8] usb: gadget: tegra-xudc: Add vbus_draw support Nagarjuna Kristam
[not found] ` <1586939108-10075-3-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 9:59 ` Thierry Reding
2020-05-04 4:10 ` Nagarjuna Kristam
2020-04-15 8:25 ` [PATCH V2 4/8] phy: tegra: xusb: Add USB2 pad power control support for Tegra210 Nagarjuna Kristam
2020-04-28 10:06 ` Thierry Reding
[not found] ` <1586939108-10075-5-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 10:17 ` Thierry Reding
2020-04-15 8:25 ` [PATCH V2 5/8] phy: tegra: xusb: Add soc ops API to enable UTMI PAD protection Nagarjuna Kristam
2020-04-28 10:15 ` Thierry Reding
2020-05-04 10:26 ` Nagarjuna Kristam
2020-04-15 8:25 ` [PATCH V2 6/8] phy: tegra: xusb: Add support for charger detect Nagarjuna Kristam
[not found] ` <1586939108-10075-7-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 10:55 ` Thierry Reding
2020-05-04 9:02 ` Nagarjuna Kristam
[not found] ` <ea0f5906-4681-8b84-a55a-e959ce40aece-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-05-04 15:50 ` Thierry Reding [this message]
2020-05-11 3:19 ` Nagarjuna Kristam
2020-04-15 8:25 ` [PATCH V2 7/8] phy: tegra: xusb: Enable charger detect for Tegra186 Nagarjuna Kristam
[not found] ` <1586939108-10075-8-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 10:56 ` Thierry Reding
2020-04-15 8:25 ` [PATCH V2 8/8] phy: tegra: xusb: Enable charger detect for Tegra210 Nagarjuna Kristam
[not found] ` <1586939108-10075-9-git-send-email-nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-28 10:56 ` Thierry Reding
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=20200504155029.GB614153@ulmo \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=kishon-l0cyMroinI0@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=nkristam-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).