Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-23 Thread Felipe Balbi
Hi,

On Tue, Oct 23, 2012 at 04:23:19PM +0530, Venu Byravarasu wrote:
> > -Original Message-
> > From: Venu Byravarasu
> > Sent: Monday, October 22, 2012 4:04 PM
> > To: 'ba...@ti.com'
> > Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org; linux-
> > u...@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> > 
> > >
> > > what is this SOC dependent PHY driver ?
> > 
> > SOC dependent PHY driver actually deals with the PHY interface
> > programming.
> > e.g. please see code present in tegra2_usb_driver.c.
> > 
> > > What sort of dependencies are
> > > there ? Those differences should be handled with runtime checks.
> > 
> > As PHY related bugs got fixed across different set of SOCs apart from
> > adding few features, wanted to separate this out from common PHY
> > functionality. This will help us in adding support for different SOCs with
> > minimum set of changes.
> 
> Felipe,
> 
> Please let me know if you have any more questions on this patch.
> If not, can you please merge this?

Like I said before, those differences should be handled by runtime
checks, you shouldn't need separate files for that. What you need to do
is implement a single PHY driver which can handle all tegras known to
date, later you can add support for new tegras by patching a few things
here and there.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-23 Thread Venu Byravarasu
> -Original Message-
> From: Venu Byravarasu
> Sent: Monday, October 22, 2012 4:04 PM
> To: 'ba...@ti.com'
> Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org; linux-
> u...@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> 
> >
> > what is this SOC dependent PHY driver ?
> 
> SOC dependent PHY driver actually deals with the PHY interface
> programming.
> e.g. please see code present in tegra2_usb_driver.c.
> 
> > What sort of dependencies are
> > there ? Those differences should be handled with runtime checks.
> 
> As PHY related bugs got fixed across different set of SOCs apart from
> adding few features, wanted to separate this out from common PHY
> functionality. This will help us in adding support for different SOCs with
> minimum set of changes.

Felipe,

Please let me know if you have any more questions on this patch.
If not, can you please merge this?

Thanks,
Venu

> 
> > --
> > balbi
> >
> > * Unknown Key
> > * 0x35CAA444
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Alan Stern
On Mon, 22 Oct 2012, Felipe Balbi wrote:

> Hi,
> 
> On Fri, Oct 19, 2012 at 10:29:35AM -0600, Stephen Warren wrote:
> > On 10/19/2012 09:35 AM, Felipe Balbi wrote:
> > > Hi,
> > > 
> > > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> > >> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In
> > >> order to support USB PHY drivers on these SoCs, existing PHY
> > >> driver is split into SoC agnostic common USB PHY driver and
> > >> Tegra20-specific USB phy driver. This will facilitate easy
> > >> addition and deletion of phy drivers for Tegra SoCs.
> > >> 
> > >> Signed-off-by: Venu Byravarasu 
> > > 
> > > I was reading this "driver" more closely and I have a bunch of
> > > questions about it, but the most important of all of them is: "why
> > > isn't that a real PHY driver ?". It doesn't have a probe()
> > > function, it doesn't use struct usb_phy to represent the PHY, it
> > > has a bunch of tegra-specific APIs and we can't let those
> > > continue.
> > 
> > One question here: If the PHY "driver" API changes, there will need to
> > be a bunch of ehci-tegra.c changes too. Will you take all those
> 
> hmm.. indeed.
> 
> > through the PHY tree? If you expect to do that, then I'd like to
> 
> I can take those if Alan is ok with it :-) Alan ?

I don't mind a bit.  It's kind of difficult for me to review changes to 
the platform-specific parts of the these drivers, anyway.  I have no 
way to test them and I'm not familiar with the interfaces involved.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Monday, October 22, 2012 3:46 PM
> To: Venu Byravarasu
> Cc: ba...@ti.com; st...@rowland.harvard.edu;
> gre...@linuxfoundation.org; linux-...@vger.kernel.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> 
> * PGP Signed by an unknown key
> 
> Hi,
> 
> >
> > Hi Felipe,
> >
> > The current patch splits out the existing tegra USB phy driver into two 
> > parts,
> as
> > you would have already noticed from the code.
> > The probe and etc changes that you asked to add, will be applicable to
> common
> > Phy driver and should not have any implications on SOC dependent phy
> driver.
> 
> what is this SOC dependent PHY driver ? 

SOC dependent PHY driver actually deals with the PHY interface programming.
e.g. please see code present in tegra2_usb_driver.c. 

> What sort of dependencies are
> there ? Those differences should be handled with runtime checks.
 
As PHY related bugs got fixed across different set of SOCs apart from
adding few features, wanted to separate this out from common PHY
functionality. This will help us in adding support for different SOCs with
minimum set of changes.

> --
> balbi
> 
> * Unknown Key
> * 0x35CAA444
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Felipe Balbi
Hi,

On Mon, Oct 22, 2012 at 03:47:02PM +0530, Venu Byravarasu wrote:
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Monday, October 22, 2012 3:33 PM
> > To: Venu Byravarasu
> > Cc: ba...@ti.com; st...@rowland.harvard.edu;
> > gre...@linuxfoundation.org; linux-...@vger.kernel.org; linux-
> > ker...@vger.kernel.org
> > Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> > 
> > * PGP Signed by an unknown key
> > 
> > Hi,
> > 
> > On Mon, Oct 22, 2012 at 02:00:00PM +0530, Venu Byravarasu wrote:
> > > > -Original Message-
> > > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > > Sent: Friday, October 19, 2012 9:06 PM
> > > > To: Venu Byravarasu
> > > > Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
> > > > ba...@ti.com; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
> > > > Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY
> > driver
> > > >
> > > > > Old Signed by an unknown key
> > > >
> > > > Hi,
> > > >
> > > > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> > > > > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> > > >
> > > > I was reading this "driver" more closely and I have a bunch of questions
> > > > about it, but the most important of all of them is: "why isn't that a
> > > > real PHY driver ?". It doesn't have a probe() function, it doesn't use
> > > > struct usb_phy to represent the PHY, it has a bunch of tegra-specific
> > > > APIs and we can't let those continue.
> > > >
> > > > Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
> > > > should be phy-omap-usb2.c so we have a common prefix) to see how
> > your
> > > > PHY driver should look like and which sort of functionality if should
> > > > expose to the rest of the kernel.
> > >
> > > Hi Felipe,
> > >
> > > I'll go through omap phy driver and prepare similar patches for tegra
> > > phy driver and push them with upcoming patches.
> > > As current patch is mostly re-organizing the existing phy driver, can
> > > you plz merge This as is?
> > 
> > I would have to convince me about the need for that (and I'm open to be
> > convinced ;-), because if a later series of patches will come getting
> > rid of the current driver and turning it into a real PHY driver, I don't
> > see the benefit of taking $SUBJECT.
> > 
> 
> Hi Felipe,
> 
> The current patch splits out the existing tegra USB phy driver into two 
> parts, as
> you would have already noticed from the code.
> The probe and etc changes that you asked to add, will be applicable to common
> Phy driver and should not have any implications on SOC dependent phy driver.

what is this SOC dependent PHY driver ? What sort of dependencies are
there ? Those differences should be handled with runtime checks.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Monday, October 22, 2012 3:33 PM
> To: Venu Byravarasu
> Cc: ba...@ti.com; st...@rowland.harvard.edu;
> gre...@linuxfoundation.org; linux-...@vger.kernel.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> 
> * PGP Signed by an unknown key
> 
> Hi,
> 
> On Mon, Oct 22, 2012 at 02:00:00PM +0530, Venu Byravarasu wrote:
> > > -Original Message-
> > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > Sent: Friday, October 19, 2012 9:06 PM
> > > To: Venu Byravarasu
> > > Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
> > > ba...@ti.com; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
> > > Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY
> driver
> > >
> > > > Old Signed by an unknown key
> > >
> > > Hi,
> > >
> > > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> > > > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> > >
> > > I was reading this "driver" more closely and I have a bunch of questions
> > > about it, but the most important of all of them is: "why isn't that a
> > > real PHY driver ?". It doesn't have a probe() function, it doesn't use
> > > struct usb_phy to represent the PHY, it has a bunch of tegra-specific
> > > APIs and we can't let those continue.
> > >
> > > Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
> > > should be phy-omap-usb2.c so we have a common prefix) to see how
> your
> > > PHY driver should look like and which sort of functionality if should
> > > expose to the rest of the kernel.
> >
> > Hi Felipe,
> >
> > I'll go through omap phy driver and prepare similar patches for tegra
> > phy driver and push them with upcoming patches.
> > As current patch is mostly re-organizing the existing phy driver, can
> > you plz merge This as is?
> 
> I would have to convince me about the need for that (and I'm open to be
> convinced ;-), because if a later series of patches will come getting
> rid of the current driver and turning it into a real PHY driver, I don't
> see the benefit of taking $SUBJECT.
> 

Hi Felipe,

The current patch splits out the existing tegra USB phy driver into two parts, 
as
you would have already noticed from the code.
The probe and etc changes that you asked to add, will be applicable to common
Phy driver and should not have any implications on SOC dependent phy driver.
Hence once this patch gets merged, it will be easier for me to modify SOC
agnostic common phy driver in the way you suggested.

Thanks,
Venu

> --
> balbi
> 
> * Unknown Key
> * 0x35CAA444
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Felipe Balbi
Hi,

On Mon, Oct 22, 2012 at 02:00:00PM +0530, Venu Byravarasu wrote:
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Friday, October 19, 2012 9:06 PM
> > To: Venu Byravarasu
> > Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
> > ba...@ti.com; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> > 
> > * PGP Signed by an unknown key
> > 
> > Hi,
> > 
> > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> > > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> > 
> > I was reading this "driver" more closely and I have a bunch of questions
> > about it, but the most important of all of them is: "why isn't that a
> > real PHY driver ?". It doesn't have a probe() function, it doesn't use
> > struct usb_phy to represent the PHY, it has a bunch of tegra-specific
> > APIs and we can't let those continue.
> > 
> > Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
> > should be phy-omap-usb2.c so we have a common prefix) to see how your
> > PHY driver should look like and which sort of functionality if should
> > expose to the rest of the kernel.
> 
> Hi Felipe, 
> 
> I'll go through omap phy driver and prepare similar patches for tegra
> phy driver and push them with upcoming patches.
> As current patch is mostly re-organizing the existing phy driver, can
> you plz merge This as is?

I would have to convince me about the need for that (and I'm open to be
convinced ;-), because if a later series of patches will come getting
rid of the current driver and turning it into a real PHY driver, I don't
see the benefit of taking $SUBJECT.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu

> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Friday, October 19, 2012 9:06 PM
> To: Venu Byravarasu
> Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
> ba...@ti.com; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
> 
> * PGP Signed by an unknown key
> 
> Hi,
> 
> On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> 
> I was reading this "driver" more closely and I have a bunch of questions
> about it, but the most important of all of them is: "why isn't that a
> real PHY driver ?". It doesn't have a probe() function, it doesn't use
> struct usb_phy to represent the PHY, it has a bunch of tegra-specific
> APIs and we can't let those continue.
> 
> Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
> should be phy-omap-usb2.c so we have a common prefix) to see how your
> PHY driver should look like and which sort of functionality if should
> expose to the rest of the kernel.

Hi Felipe, 

I'll go through omap phy driver and prepare similar patches for tegra phy driver
and push them with upcoming patches.
As current patch is mostly re-organizing the existing phy driver, can you plz 
merge
This as is?

Thanks,
Venu

> 
> Please comment on the above.
> 
> cheers
> 
> --
> balbi
> 
> * Unknown Key
> * 0x35CAA444
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 10:29:35AM -0600, Stephen Warren wrote:
> On 10/19/2012 09:35 AM, Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> >> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In
> >> order to support USB PHY drivers on these SoCs, existing PHY
> >> driver is split into SoC agnostic common USB PHY driver and
> >> Tegra20-specific USB phy driver. This will facilitate easy
> >> addition and deletion of phy drivers for Tegra SoCs.
> >> 
> >> Signed-off-by: Venu Byravarasu 
> > 
> > I was reading this "driver" more closely and I have a bunch of
> > questions about it, but the most important of all of them is: "why
> > isn't that a real PHY driver ?". It doesn't have a probe()
> > function, it doesn't use struct usb_phy to represent the PHY, it
> > has a bunch of tegra-specific APIs and we can't let those
> > continue.
> 
> One question here: If the PHY "driver" API changes, there will need to
> be a bunch of ehci-tegra.c changes too. Will you take all those

hmm.. indeed.

> through the PHY tree? If you expect to do that, then I'd like to

I can take those if Alan is ok with it :-) Alan ?

> request you also take:
> 
> usb: host: tegra remove include of 
> http://www.spinics.net/lists/linux-usb/msg72429.html
> 
> ... since that should get merged before any large changes to
> ehci-tegra.c; it's the EHCI equivalent of the PHY patch you already
> merged.
> 
> (The same request applies to put that into a branch I can pull into
> the Tegra tree as a basis for cleanup in the Tegra tree)

sure, that should be simple enough to do ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Stephen Warren
On 10/19/2012 09:35 AM, Felipe Balbi wrote:
> Hi,
> 
> On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
>> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In
>> order to support USB PHY drivers on these SoCs, existing PHY
>> driver is split into SoC agnostic common USB PHY driver and
>> Tegra20-specific USB phy driver. This will facilitate easy
>> addition and deletion of phy drivers for Tegra SoCs.
>> 
>> Signed-off-by: Venu Byravarasu 
> 
> I was reading this "driver" more closely and I have a bunch of
> questions about it, but the most important of all of them is: "why
> isn't that a real PHY driver ?". It doesn't have a probe()
> function, it doesn't use struct usb_phy to represent the PHY, it
> has a bunch of tegra-specific APIs and we can't let those
> continue.

One question here: If the PHY "driver" API changes, there will need to
be a bunch of ehci-tegra.c changes too. Will you take all those
through the PHY tree? If you expect to do that, then I'd like to
request you also take:

usb: host: tegra remove include of 
http://www.spinics.net/lists/linux-usb/msg72429.html

... since that should get merged before any large changes to
ehci-tegra.c; it's the EHCI equivalent of the PHY patch you already
merged.

(The same request applies to put that into a branch I can pull into
the Tegra tree as a basis for cleanup in the Tegra tree)

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> In order to support USB PHY drivers on these SoCs, existing
> PHY driver is split into SoC agnostic common USB PHY driver
> and Tegra20-specific USB phy driver. This will facilitate
> easy addition and deletion of phy drivers for Tegra SoCs.
> 
> Signed-off-by: Venu Byravarasu 

I was reading this "driver" more closely and I have a bunch of questions
about it, but the most important of all of them is: "why isn't that a
real PHY driver ?". It doesn't have a probe() function, it doesn't use
struct usb_phy to represent the PHY, it has a bunch of tegra-specific
APIs and we can't let those continue.

Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
should be phy-omap-usb2.c so we have a common prefix) to see how your
PHY driver should look like and which sort of functionality if should
expose to the rest of the kernel.

Please comment on the above.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Alan Stern
On Fri, 19 Oct 2012, Venu Byravarasu wrote:

> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> In order to support USB PHY drivers on these SoCs, existing
> PHY driver is split into SoC agnostic common USB PHY driver
> and Tegra20-specific USB phy driver. This will facilitate
> easy addition and deletion of phy drivers for Tegra SoCs.
> 
> Signed-off-by: Venu Byravarasu 
> ---
> delta from v3 resend:
> For unknown reasons, email-id in signed-off-by got corrupted.
> Hence re-sending the patch, after fixing it.
> 
> delta from v3:
> Rebased the v3 changes on top of xceiv branch.
> 
> delta from v2:
> Added an if condition to check for device_node to be not NULL,
> before dereferencing it.

For the changes to drivers/usb/host/ehci-tegra.c:

Acked-by: Alan Stern 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Venu Byravarasu
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
In order to support USB PHY drivers on these SoCs, existing
PHY driver is split into SoC agnostic common USB PHY driver
and Tegra20-specific USB phy driver. This will facilitate
easy addition and deletion of phy drivers for Tegra SoCs.

Signed-off-by: Venu Byravarasu 
---
delta from v3 resend:
For unknown reasons, email-id in signed-off-by got corrupted.
Hence re-sending the patch, after fixing it.

delta from v3:
Rebased the v3 changes on top of xceiv branch.

delta from v2:
Added an if condition to check for device_node to be not NULL,
before dereferencing it.


 drivers/usb/host/ehci-tegra.c  |   20 +-
 drivers/usb/phy/Makefile   |1 +
 .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c}  |  372 ++-
 drivers/usb/phy/tegra2_usb_phy.h   |  178 +
 drivers/usb/phy/tegra_usb_phy.c|  725 +---
 include/linux/usb/tegra_usb_phy.h  |   34 +-
 6 files changed, 304 insertions(+), 1026 deletions(-)
 copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%)
 create mode 100644 drivers/usb/phy/tegra2_usb_phy.h

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d17..e08aea3 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev->id;
+   struct device_node *np = pdev->dev.of_node;
+   struct phy_params params;
+   int phy_type;
 
pdata = pdev->dev.platform_data;
if (!pdata) {
@@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
}
 
+   phy_type = of_property_match_string(np, "phy_type", "utmi");
+   if (phy_type >= 0)
+   params.type = TEGRA_USB_PHY_TYPE_UTMI;
+   else {
+   phy_type = of_property_match_string(np, "phy_type", "ulpi");
+   if (phy_type >= 0)
+   params.type = TEGRA_USB_PHY_TYPE_ULPI;
+   else
+   params.type = TEGRA_USB_PHY_TYPE_INVALID;
+   }
+
+   params.mode = TEGRA_USB_PHY_MODE_HOST;
+   params.config = pdata->phy_config;
+
tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs,
-   pdata->phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   ¶ms);
if (IS_ERR(tegra->phy)) {
dev_err(&pdev->dev, "Failed to open USB phy\n");
err = -ENXIO;
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..21872e1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra2_usb_phy.o
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c
similarity index 57%
copy from drivers/usb/phy/tegra_usb_phy.c
copy to drivers/usb/phy/tegra2_usb_phy.c
index 9d13c81..2ff6dcb 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra2_usb_phy.c
@@ -1,9 +1,11 @@
 /*
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  *
  * Author:
  * Erik Gilling 
  * Benoit Goby 
+ * Venu Byravarasu 
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -29,191 +31,20 @@
 #include 
 #include 
 #include 
+#include 
 
-#define TEGRA_USB_BASE 0xC500
-#define TEGRA_USB_SIZE SZ_16K
-
-#define ULPI_VIEWPORT  0x170
-
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x) & 0x3) << 30)
-#define   USB_PORTSC1_PSPD(x)  (((x) & 0x3) << 26)
-#define   USB_PORTSC1_PHCD (1 << 23)
-#define   USB_PORTSC1_WKOC (1 << 22)
-#define   USB_PORTSC1_WKDS (1 << 21)
-#define   USB_PORTSC1_WKCN (1 << 20)
-#define   USB_PORTSC1_PTC(x)   (((x) & 0xf) << 16)
-#define   USB_PORTSC1_PP   (1 << 12)
-#define   USB_PORTSC1_SUSP (1 << 7)
-#define   USB_PORTSC1_PE   (1 << 2)
-#define   USB_PORTSC1_CCS  (1 << 0)
-
-#define USB_SUSP_CTRL  0x400
-#define   USB_WAKE_ON_CNNT_EN_DEV  (1 << 3)
-#define   USB_WAKE_ON_DISCON_EN_DEV(1 << 4)
-#define   USB_SUSP_CLR (1 << 5)
-#define   USB_PHY_CLK_VALID(1 << 7)
-#define   UTMIP_RESET  (1 << 11)
-#define   UHSIC_RESET  (1 << 11)
-#define   UTMIP_PHY_ENABLE (1 << 12)
-#define   ULPI_PHY_ENABLE  (1 << 13)
-#define   USB_SUSP_SET (1 << 14)
-#define   USB_WAKEUP_DEBOUNCE_COUNT(x) (((

Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 04:03:26PM +0530, Venu Byravarasu wrote:
> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
> In order to support USB PHY drivers on these SoCs, existing
> PHY driver is split into SoC agnostic common USB PHY driver
> and Tegra20-specific USB phy driver. This will facilitate
> easy addition and deletion of phy drivers for Tegra SoCs.
> 
> Signed-off-by: Venu Byravarasu 

you mail ID is wrong here...

> ---
> delta from v3:
> 
> Rebased the v3 changes on top of xceiv branch.
> 
> delta from v2:
> 
> Added an if condition to check for device_node to be not NULL,
> before dereferencing it.
> ---
>  drivers/usb/host/ehci-tegra.c  |   20 +-
>  drivers/usb/phy/Makefile   |1 +
>  .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c}  |  372 ++-
>  drivers/usb/phy/tegra2_usb_phy.h   |  178 +
>  drivers/usb/phy/tegra_usb_phy.c|  725 
> +---
>  include/linux/usb/tegra_usb_phy.h  |   34 +-
>  6 files changed, 304 insertions(+), 1026 deletions(-)
>  copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%)
>  create mode 100644 drivers/usb/phy/tegra2_usb_phy.h
> 
> diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
> index 6223d17..e08aea3 100644
> --- a/drivers/usb/host/ehci-tegra.c
> +++ b/drivers/usb/host/ehci-tegra.c
> @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
>   int err = 0;
>   int irq;
>   int instance = pdev->id;
> + struct device_node *np = pdev->dev.of_node;
> + struct phy_params params;
> + int phy_type;
>  
>   pdata = pdev->dev.platform_data;
>   if (!pdata) {
> @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev)
>   }
>   }
>  
> + phy_type = of_property_match_string(np, "phy_type", "utmi");
> + if (phy_type >= 0)
> + params.type = TEGRA_USB_PHY_TYPE_UTMI;
> + else {
> + phy_type = of_property_match_string(np, "phy_type", "ulpi");
> + if (phy_type >= 0)
> + params.type = TEGRA_USB_PHY_TYPE_ULPI;
> + else
> + params.type = TEGRA_USB_PHY_TYPE_INVALID;
> + }
> +
> + params.mode = TEGRA_USB_PHY_MODE_HOST;
> + params.config = pdata->phy_config;
> +
>   tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs,
> - pdata->phy_config,
> - TEGRA_USB_PHY_MODE_HOST);
> + ¶ms);
>   if (IS_ERR(tegra->phy)) {
>   dev_err(&pdev->dev, "Failed to open USB phy\n");
>   err = -ENXIO;

Alan, if you're ok with the ehci-tegra changes, I can carry this patch
by myself.

> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index b069f29..21872e1 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
> +obj-$(CONFIG_USB_EHCI_TEGRA) += tegra2_usb_phy.o
> diff --git a/drivers/usb/phy/tegra_usb_phy.c 
> b/drivers/usb/phy/tegra2_usb_phy.c
> similarity index 57%
> copy from drivers/usb/phy/tegra_usb_phy.c
> copy to drivers/usb/phy/tegra2_usb_phy.c
> index 9d13c81..2ff6dcb 100644
> --- a/drivers/usb/phy/tegra_usb_phy.c
> +++ b/drivers/usb/phy/tegra2_usb_phy.c
> @@ -1,9 +1,11 @@
>  /*
>   * Copyright (C) 2010 Google, Inc.
> + * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
>   *
>   * Author:
>   *   Erik Gilling 
>   *   Benoit Goby 
> + *   Venu Byravarasu 
>   *
>   * This software is licensed under the terms of the GNU General Public
>   * License version 2, as published by the Free Software Foundation, and
> @@ -29,191 +31,20 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
> -#define TEGRA_USB_BASE   0xC500
> -#define TEGRA_USB_SIZE   SZ_16K
> -
> -#define ULPI_VIEWPORT0x170
> -
> -#define USB_PORTSC1  0x184
> -#define   USB_PORTSC1_PTS(x) (((x) & 0x3) << 30)
> -#define   USB_PORTSC1_PSPD(x)(((x) & 0x3) << 26)
> -#define   USB_PORTSC1_PHCD   (1 << 23)
> -#define   USB_PORTSC1_WKOC   (1 << 22)
> -#define   USB_PORTSC1_WKDS   (1 << 21)
> -#define   USB_PORTSC1_WKCN   (1 << 20)
> -#define   USB_PORTSC1_PTC(x) (((x) & 0xf) << 16)
> -#define   USB_PORTSC1_PP (1 << 12)
> -#define   USB_PORTSC1_SUSP   (1 << 7)
> -#define   USB_PORTSC1_PE (1 << 2)
> -#define   USB_PORTSC1_CCS(1 << 0)
> -
> -#define USB_SUSP_CTRL0x400
> -#define   USB_WAKE_ON_CNNT_EN_DEV(1 << 3)
> -#define   USB_WAKE_ON_DISCON_EN_DEV  (1 << 4)
> -#define   USB_SUSP_CLR   (1 << 5)
> -#define   USB_PHY_CLK_VALID  (1 << 7)
> -#define   UTMIP_RESET

[PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-19 Thread Venu Byravarasu
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
In order to support USB PHY drivers on these SoCs, existing
PHY driver is split into SoC agnostic common USB PHY driver
and Tegra20-specific USB phy driver. This will facilitate
easy addition and deletion of phy drivers for Tegra SoCs.

Signed-off-by: Venu Byravarasu 
---
delta from v3:

Rebased the v3 changes on top of xceiv branch.

delta from v2:

Added an if condition to check for device_node to be not NULL,
before dereferencing it.
---
 drivers/usb/host/ehci-tegra.c  |   20 +-
 drivers/usb/phy/Makefile   |1 +
 .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c}  |  372 ++-
 drivers/usb/phy/tegra2_usb_phy.h   |  178 +
 drivers/usb/phy/tegra_usb_phy.c|  725 +---
 include/linux/usb/tegra_usb_phy.h  |   34 +-
 6 files changed, 304 insertions(+), 1026 deletions(-)
 copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%)
 create mode 100644 drivers/usb/phy/tegra2_usb_phy.h

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d17..e08aea3 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev->id;
+   struct device_node *np = pdev->dev.of_node;
+   struct phy_params params;
+   int phy_type;
 
pdata = pdev->dev.platform_data;
if (!pdata) {
@@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
}
 
+   phy_type = of_property_match_string(np, "phy_type", "utmi");
+   if (phy_type >= 0)
+   params.type = TEGRA_USB_PHY_TYPE_UTMI;
+   else {
+   phy_type = of_property_match_string(np, "phy_type", "ulpi");
+   if (phy_type >= 0)
+   params.type = TEGRA_USB_PHY_TYPE_ULPI;
+   else
+   params.type = TEGRA_USB_PHY_TYPE_INVALID;
+   }
+
+   params.mode = TEGRA_USB_PHY_MODE_HOST;
+   params.config = pdata->phy_config;
+
tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs,
-   pdata->phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   ¶ms);
if (IS_ERR(tegra->phy)) {
dev_err(&pdev->dev, "Failed to open USB phy\n");
err = -ENXIO;
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..21872e1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra2_usb_phy.o
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c
similarity index 57%
copy from drivers/usb/phy/tegra_usb_phy.c
copy to drivers/usb/phy/tegra2_usb_phy.c
index 9d13c81..2ff6dcb 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra2_usb_phy.c
@@ -1,9 +1,11 @@
 /*
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  *
  * Author:
  * Erik Gilling 
  * Benoit Goby 
+ * Venu Byravarasu 
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -29,191 +31,20 @@
 #include 
 #include 
 #include 
+#include 
 
-#define TEGRA_USB_BASE 0xC500
-#define TEGRA_USB_SIZE SZ_16K
-
-#define ULPI_VIEWPORT  0x170
-
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x) & 0x3) << 30)
-#define   USB_PORTSC1_PSPD(x)  (((x) & 0x3) << 26)
-#define   USB_PORTSC1_PHCD (1 << 23)
-#define   USB_PORTSC1_WKOC (1 << 22)
-#define   USB_PORTSC1_WKDS (1 << 21)
-#define   USB_PORTSC1_WKCN (1 << 20)
-#define   USB_PORTSC1_PTC(x)   (((x) & 0xf) << 16)
-#define   USB_PORTSC1_PP   (1 << 12)
-#define   USB_PORTSC1_SUSP (1 << 7)
-#define   USB_PORTSC1_PE   (1 << 2)
-#define   USB_PORTSC1_CCS  (1 << 0)
-
-#define USB_SUSP_CTRL  0x400
-#define   USB_WAKE_ON_CNNT_EN_DEV  (1 << 3)
-#define   USB_WAKE_ON_DISCON_EN_DEV(1 << 4)
-#define   USB_SUSP_CLR (1 << 5)
-#define   USB_PHY_CLK_VALID(1 << 7)
-#define   UTMIP_RESET  (1 << 11)
-#define   UHSIC_RESET  (1 << 11)
-#define   UTMIP_PHY_ENABLE (1 << 12)
-#define   ULPI_PHY_ENABLE  (1 << 13)
-#define   USB_SUSP_SET (1 << 14)
-#define   USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16)
-
-#define USB1_LEGACY_CTRL   0x410
-#define   USB1_NO_LEGACY_MODE  (1 << 0)
-#define   U