All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-omap@vger.kernel.org, devicetree@vger.kernel.org,
	Marcel Partap <mpartap@gmx.net>,
	Michael Scott <michael.scott@linaro.org>
Subject: Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Date: Mon, 27 Mar 2017 08:05:19 -0700	[thread overview]
Message-ID: <20170327150518.GH10760@atomide.com> (raw)
In-Reply-To: <d47b0f99-1ef8-3bff-0fbe-edb95ed41e23@ti.com>

* Kishon Vijay Abraham I <kishon@ti.com> [170326 23:27]:
> On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote:
> > +static const struct phy_ops ops = {
> > +	.owner		= THIS_MODULE,
> > +};
> 
> Given that this phy doesn't have any phy_ops, Is there a reason for registering
> this phy with the phy framework? Is it because this driver uses the phy_core's
> pm_runtime feature?

Well there's also an ULPI PHY on CPCAP, but it's not used in the
motorola-mapphone configuration. I think some other configurations
use it though, so probably best to keep it.

And yeah, for PM runtime, I was thinking that we can have the
UART mode be the idle state.

> > +static void cpcap_usb_detect(struct work_struct *work)
> > +{
> > +	struct cpcap_phy_ddata *ddata;
> > +	struct cpcap_usb_ints_state s;
> > +	bool vbus = false;
> > +	int error;
> > +
> > +	ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work);
> > +
> > +	error = cpcap_phy_get_ints_state(ddata, &s);
> > +	if (error)
> > +		return;
> > +
> > +	/* See also cpcap-charger.c phy_companion for VBUS handling */
> 
> I think this companion should have ideally used extcon framework. Then we could
> have used extcon_get_state() here.

OK I'll take a look at that. I'd like to do that as a follow-up
patches if that's OK with you.

FYI in case you're wondering, there are ADCs on the PMIC available
via IIO, and the charger is also using IIO framework for VBUS and
battery voltage. And the VBUS is set up as reverse mode in the
charger registers and the charging needs to be disabled for VBUS.

I guess Ideally the VBUS would be just a regulator from Linux point
of view that also allows negative current :)

> > +	ddata->vusb = devm_regulator_get(&pdev->dev, "vusb");
> > +	if (IS_ERR(ddata->vusb))
> > +		return PTR_ERR(ddata->vusb);
> > +
> > +	error = regulator_enable(ddata->vusb);
> > +	if (error)
> > +		return error;
> 
> Maybe we should create power_on ops and do regulator enable there?

This regulator is also needed for the UART mode, so it would have
to be disabled conditionally based on maybe a module parameter.
But yeah thanks for the pointer I did not even realize you have
power_on ops :)

Seems this can be also done when implementing PM runtime handling.
If you want some of these changes done for the initial patch,
please let me know.

Regards,

Tony

WARNING: multiple messages have this Message-ID (diff)
From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
To: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Marcel Partap <mpartap-hi6Y0CQ0nG0@public.gmane.org>,
	Michael Scott
	<michael.scott-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Date: Mon, 27 Mar 2017 08:05:19 -0700	[thread overview]
Message-ID: <20170327150518.GH10760@atomide.com> (raw)
In-Reply-To: <d47b0f99-1ef8-3bff-0fbe-edb95ed41e23-l0cyMroinI0@public.gmane.org>

* Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> [170326 23:27]:
> On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote:
> > +static const struct phy_ops ops = {
> > +	.owner		= THIS_MODULE,
> > +};
> 
> Given that this phy doesn't have any phy_ops, Is there a reason for registering
> this phy with the phy framework? Is it because this driver uses the phy_core's
> pm_runtime feature?

Well there's also an ULPI PHY on CPCAP, but it's not used in the
motorola-mapphone configuration. I think some other configurations
use it though, so probably best to keep it.

And yeah, for PM runtime, I was thinking that we can have the
UART mode be the idle state.

> > +static void cpcap_usb_detect(struct work_struct *work)
> > +{
> > +	struct cpcap_phy_ddata *ddata;
> > +	struct cpcap_usb_ints_state s;
> > +	bool vbus = false;
> > +	int error;
> > +
> > +	ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work);
> > +
> > +	error = cpcap_phy_get_ints_state(ddata, &s);
> > +	if (error)
> > +		return;
> > +
> > +	/* See also cpcap-charger.c phy_companion for VBUS handling */
> 
> I think this companion should have ideally used extcon framework. Then we could
> have used extcon_get_state() here.

OK I'll take a look at that. I'd like to do that as a follow-up
patches if that's OK with you.

FYI in case you're wondering, there are ADCs on the PMIC available
via IIO, and the charger is also using IIO framework for VBUS and
battery voltage. And the VBUS is set up as reverse mode in the
charger registers and the charging needs to be disabled for VBUS.

I guess Ideally the VBUS would be just a regulator from Linux point
of view that also allows negative current :)

> > +	ddata->vusb = devm_regulator_get(&pdev->dev, "vusb");
> > +	if (IS_ERR(ddata->vusb))
> > +		return PTR_ERR(ddata->vusb);
> > +
> > +	error = regulator_enable(ddata->vusb);
> > +	if (error)
> > +		return error;
> 
> Maybe we should create power_on ops and do regulator enable there?

This regulator is also needed for the UART mode, so it would have
to be disabled conditionally based on maybe a module parameter.
But yeah thanks for the pointer I did not even realize you have
power_on ops :)

Seems this can be also done when implementing PM runtime handling.
If you want some of these changes done for the initial patch,
please let me know.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-03-27 15:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 23:46 [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support Tony Lindgren
2017-03-25 20:42 ` kbuild test robot
2017-03-25 20:42   ` kbuild test robot
2017-03-25 22:10   ` Tony Lindgren
2017-03-27  6:25 ` Kishon Vijay Abraham I
2017-03-27  6:25   ` Kishon Vijay Abraham I
2017-03-27 15:05   ` Tony Lindgren [this message]
2017-03-27 15:05     ` Tony Lindgren
2017-03-30 11:49     ` Kishon Vijay Abraham I
2017-03-30 11:49       ` Kishon Vijay Abraham I
2017-04-04  3:27       ` Tony Lindgren
2017-04-04  3:27         ` Tony Lindgren
2017-03-29  2:04 ` Rob Herring
2017-03-29  2:04   ` Rob Herring

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=20170327150518.GH10760@atomide.com \
    --to=tony@atomide.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael.scott@linaro.org \
    --cc=mpartap@gmx.net \
    /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.