Patchwork [U-Boot,7/8] tegra: usb: move implementation into right directory

login
register
mail settings
Submitter Lucas Stach
Date Oct. 30, 2012, 9:22 a.m.
Message ID <1351588973-20699-7-git-send-email-dev@lynxeye.de>
Download mbox | patch
Permalink /patch/195343/
State Superseded
Delegated to: Marek Vasut
Headers show

Comments

Lucas Stach - Oct. 30, 2012, 9:22 a.m.
This moves the Tegra USB implementation into the drivers/usb/host
directory.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/cpu/armv7/tegra20/Makefile                |  2 -
 .../tegra20/usb.c => drivers/usb/host/ehci-tegra.c | 60 ++++++++++++++++++++--
 2 Dateien geändert, 55 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
 rename arch/arm/cpu/armv7/tegra20/usb.c => drivers/usb/host/ehci-tegra.c (92%)
Simon Glass - Oct. 30, 2012, 1:33 p.m.
Hi Lucas,

On Tue, Oct 30, 2012 at 2:22 AM, Lucas Stach <dev@lynxeye.de> wrote:
> This moves the Tegra USB implementation into the drivers/usb/host
> directory.
>
> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>  arch/arm/cpu/armv7/tegra20/Makefile                |  2 -
>  .../tegra20/usb.c => drivers/usb/host/ehci-tegra.c | 60 ++++++++++++++++++++--
>  2 Dateien geändert, 55 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
>  rename arch/arm/cpu/armv7/tegra20/usb.c => drivers/usb/host/ehci-tegra.c (92%)

For me this patch did not apply:

Applying: tegra: usb: move implementation into right directory
error: drivers/usb/host/ehci-tegra.c: already exists in index
Patch failed at 0007 tegra: usb: move implementation into right directory
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

I tried master and tegra/master.

Regards,
Simon
Lucas Stach - Oct. 30, 2012, 1:38 p.m.
Am Dienstag, den 30.10.2012, 06:33 -0700 schrieb Simon Glass:
> Hi Lucas,
> 
> On Tue, Oct 30, 2012 at 2:22 AM, Lucas Stach <dev@lynxeye.de> wrote:
> > This moves the Tegra USB implementation into the drivers/usb/host
> > directory.
> >
> > Signed-off-by: Lucas Stach <dev@lynxeye.de>
> > ---
> >  arch/arm/cpu/armv7/tegra20/Makefile                |  2 -
> >  .../tegra20/usb.c => drivers/usb/host/ehci-tegra.c | 60 ++++++++++++++++++++--
> >  2 Dateien geändert, 55 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
> >  rename arch/arm/cpu/armv7/tegra20/usb.c => drivers/usb/host/ehci-tegra.c (92%)
> 
> For me this patch did not apply:
> 
> Applying: tegra: usb: move implementation into right directory
> error: drivers/usb/host/ehci-tegra.c: already exists in index
> Patch failed at 0007 tegra: usb: move implementation into right directory
> When you have resolved this problem run "git am --resolved".
> If you would prefer to skip this patch, instead run "git am --skip".
> To restore the original branch and stop patching run "git am --abort".
> 
> I tried master and tegra/master.

The series based on u-boot-usb/master, as it's supposed to go in through
this tree.

Regards,
Lucas
Simon Glass - Oct. 30, 2012, 1:53 p.m.
Hi Lucas,

On Tue, Oct 30, 2012 at 6:38 AM, Lucas Stach <dev@lynxeye.de> wrote:
> Am Dienstag, den 30.10.2012, 06:33 -0700 schrieb Simon Glass:
>> Hi Lucas,
>>
>> On Tue, Oct 30, 2012 at 2:22 AM, Lucas Stach <dev@lynxeye.de> wrote:
>> > This moves the Tegra USB implementation into the drivers/usb/host
>> > directory.
>> >
>> > Signed-off-by: Lucas Stach <dev@lynxeye.de>
>> > ---
>> >  arch/arm/cpu/armv7/tegra20/Makefile                |  2 -
>> >  .../tegra20/usb.c => drivers/usb/host/ehci-tegra.c | 60 ++++++++++++++++++++--
>> >  2 Dateien geändert, 55 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
>> >  rename arch/arm/cpu/armv7/tegra20/usb.c => drivers/usb/host/ehci-tegra.c (92%)
>>
>> For me this patch did not apply:
>>
>> Applying: tegra: usb: move implementation into right directory
>> error: drivers/usb/host/ehci-tegra.c: already exists in index
>> Patch failed at 0007 tegra: usb: move implementation into right directory
>> When you have resolved this problem run "git am --resolved".
>> If you would prefer to skip this patch, instead run "git am --skip".
>> To restore the original branch and stop patching run "git am --abort".
>>
>> I tried master and tegra/master.
>
> The series based on u-boot-usb/master, as it's supposed to go in through
> this tree.

OK thanks, I assumed that because tegra: was the first tag it would go
through tegra.

But it doesn't seem to help:

git remote -v |grep upstream-usb
upstream-usb	http://git.denx.de/u-boot-usb.git (fetch)
upstream-usb	http://git.denx.de/u-boot-usb.git (push)
git fetch upstream-usb
From http://git.denx.de/u-boot-usb
 * [new branch]      at91sam9x35-ek -> upstream-usb/at91sam9x35-ek
 + 5b2e031...0b92a45 cdc-at91   -> upstream-usb/cdc-at91  (forced update)
 + 6722fd5...76454b2 master     -> upstream-usb/master  (forced update)
 * [new branch]      merge_pending -> upstream-usb/merge_pending
 + 2c8b43b...01afc4f next       -> upstream-usb/next  (forced update)
 * [new branch]      uboot      -> upstream-usb/uboot
(try-usb=5cf309: include/ lq out/ tools/ x/) ~/u> co -b try-usb2
upstream-usb/master
Branch try-usb2 set up to track remote branch master from upstream-usb.
Switched to a new branch 'try-usb2'
(try-usb2=76454b: include/ lq out/ tools/ x/) ~/u> git am
~/Downloads/bundle-3480.mbox
Applying: tegra: usb: convert USB_PORTS_MAX to be a define
Applying: tegra: usb: make controller init functions more self contained
Applying: tegra: usb: fold initial pll setup into board_usb_init
Applying: tegra: usb: remove unneeded function parameter
Applying: tegra: usb: move controller init into start_port
Applying: tegra: usb: various small cleanups
Applying: tegra: usb: move implementation into right directory
error: drivers/usb/host/ehci-tegra.c: already exists in index
Patch failed at 0007 tegra: usb: move implementation into right directory
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

Where was the patch that removed drivers/usb/host/ehci-tegra.c?

>
> Regards,
> Lucas
>

Regards,
Simon
Lucas Stach - Oct. 30, 2012, 2:03 p.m.
Am Dienstag, den 30.10.2012, 06:53 -0700 schrieb Simon Glass:
> Hi Lucas,
> 
> On Tue, Oct 30, 2012 at 6:38 AM, Lucas Stach <dev@lynxeye.de> wrote:
> > Am Dienstag, den 30.10.2012, 06:33 -0700 schrieb Simon Glass:
> >> Hi Lucas,
> >>
> >> On Tue, Oct 30, 2012 at 2:22 AM, Lucas Stach <dev@lynxeye.de> wrote:
> >> > This moves the Tegra USB implementation into the drivers/usb/host
> >> > directory.
> >> >
> >> > Signed-off-by: Lucas Stach <dev@lynxeye.de>
> >> > ---
> >> >  arch/arm/cpu/armv7/tegra20/Makefile                |  2 -
> >> >  .../tegra20/usb.c => drivers/usb/host/ehci-tegra.c | 60 ++++++++++++++++++++--
> >> >  2 Dateien geändert, 55 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
> >> >  rename arch/arm/cpu/armv7/tegra20/usb.c => drivers/usb/host/ehci-tegra.c (92%)
> >>
> >> For me this patch did not apply:
> >>
> >> Applying: tegra: usb: move implementation into right directory
> >> error: drivers/usb/host/ehci-tegra.c: already exists in index
> >> Patch failed at 0007 tegra: usb: move implementation into right directory
> >> When you have resolved this problem run "git am --resolved".
> >> If you would prefer to skip this patch, instead run "git am --skip".
> >> To restore the original branch and stop patching run "git am --abort".
> >>
> >> I tried master and tegra/master.
> >
> > The series based on u-boot-usb/master, as it's supposed to go in through
> > this tree.
> 
> OK thanks, I assumed that because tegra: was the first tag it would go
> through tegra.
> 
> But it doesn't seem to help:
> 
> git remote -v |grep upstream-usb
> upstream-usb	http://git.denx.de/u-boot-usb.git (fetch)
> upstream-usb	http://git.denx.de/u-boot-usb.git (push)
> git fetch upstream-usb
> >From http://git.denx.de/u-boot-usb
>  * [new branch]      at91sam9x35-ek -> upstream-usb/at91sam9x35-ek
>  + 5b2e031...0b92a45 cdc-at91   -> upstream-usb/cdc-at91  (forced update)
>  + 6722fd5...76454b2 master     -> upstream-usb/master  (forced update)
>  * [new branch]      merge_pending -> upstream-usb/merge_pending
>  + 2c8b43b...01afc4f next       -> upstream-usb/next  (forced update)
>  * [new branch]      uboot      -> upstream-usb/uboot
> (try-usb=5cf309: include/ lq out/ tools/ x/) ~/u> co -b try-usb2
> upstream-usb/master
> Branch try-usb2 set up to track remote branch master from upstream-usb.
> Switched to a new branch 'try-usb2'
> (try-usb2=76454b: include/ lq out/ tools/ x/) ~/u> git am
> ~/Downloads/bundle-3480.mbox
> Applying: tegra: usb: convert USB_PORTS_MAX to be a define
> Applying: tegra: usb: make controller init functions more self contained
> Applying: tegra: usb: fold initial pll setup into board_usb_init
> Applying: tegra: usb: remove unneeded function parameter
> Applying: tegra: usb: move controller init into start_port
> Applying: tegra: usb: various small cleanups
> Applying: tegra: usb: move implementation into right directory
> error: drivers/usb/host/ehci-tegra.c: already exists in index
> Patch failed at 0007 tegra: usb: move implementation into right directory
> When you have resolved this problem run "git am --resolved".
> If you would prefer to skip this patch, instead run "git am --skip".
> To restore the original branch and stop patching run "git am --abort".
> 
> Where was the patch that removed drivers/usb/host/ehci-tegra.c?
> 
Hm I'm no expert here, but I didn't actually remove the file. I just
copied over the contents of the old implementation file and both git
commit and git format-patch recognized this as a rename. Also the
cherry-pick from my devel to the usb branch worked flawlessly.
If git am can't cope with the rename to an already existing file I may
post the patch with the rename forcibly removed, but this will yield a
much bigger patch. I'll investigate this.

Thanks for the heads up.

Regards,
Lucas
Simon Glass - Oct. 30, 2012, 4:18 p.m.
Hi Tom,

On Tue, Oct 30, 2012 at 9:11 AM, Tom Warren <TWarren@nvidia.com> wrote:
> Simon, et al,
[snip]
> Please apply/develop all Tegra patches on tegra/next. That's where I'll be applying new patches as they come in. /master is usually behind /next until a pull request occurs (which just happens to be what the state is now, so master == next, but that's not the norm).

OK thanks for the clarification. I was tending towards that, but had
sometimes found next was old, if that makes any sense. Will do from
now on.

The LCD series applied on top of tegra/next for me without trouble.

Regards,
Simon

>
> Thanks,
>
> Tom
>>
>> Regards,
>> Simon
> --
> nvpublic
>
Stephen Warren - Oct. 30, 2012, 6:38 p.m.
On 10/30/2012 03:22 AM, Lucas Stach wrote:
> This moves the Tegra USB implementation into the drivers/usb/host
> directory.

> diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/drivers/usb/host/ehci-tegra.c

> + * Copyright (c) 2009-2012 NVIDIA Corporation
>   * Copyright (c) 2011 The Chromium OS Authors.
> - * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>

Why does NVIDIA's (c) notice change?
Lucas Stach - Oct. 30, 2012, 6:45 p.m.
Am Dienstag, den 30.10.2012, 12:38 -0600 schrieb Stephen Warren:
> On 10/30/2012 03:22 AM, Lucas Stach wrote:
> > This moves the Tegra USB implementation into the drivers/usb/host
> > directory.
> 
> > diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/drivers/usb/host/ehci-tegra.c
> 
> > + * Copyright (c) 2009-2012 NVIDIA Corporation
> >   * Copyright (c) 2011 The Chromium OS Authors.
> > - * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
> 
> Why does NVIDIA's (c) notice change?
> 
Just because I took most of the licence header from the ehci_tegra.c
file, but as the patch shows the the diff modulo the copied part it
looks like a change. I choose this one as it actually spans the longer
copyright timeframe of the both licence headers. Is this a problem?
Should I also include the web address?

Regards,
Lucas
Stephen Warren - Oct. 30, 2012, 6:51 p.m.
On 10/30/2012 12:45 PM, Lucas Stach wrote:
> Am Dienstag, den 30.10.2012, 12:38 -0600 schrieb Stephen Warren:
>> On 10/30/2012 03:22 AM, Lucas Stach wrote:
>>> This moves the Tegra USB implementation into the drivers/usb/host
>>> directory.
>>
>>> diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/drivers/usb/host/ehci-tegra.c
>>
>>> + * Copyright (c) 2009-2012 NVIDIA Corporation
>>>   * Copyright (c) 2011 The Chromium OS Authors.
>>> - * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
>>
>> Why does NVIDIA's (c) notice change?
>>
> Just because I took most of the licence header from the ehci_tegra.c
> file, but as the patch shows the the diff modulo the copied part it
> looks like a change. I choose this one as it actually spans the longer
> copyright timeframe of the both licence headers. Is this a problem?
> Should I also include the web address?

Hmm. So this patch merges two files together into one? The diff looks
like it's creating a new file. If the new content in this patch came
from some other file, shouldn't the patch also remove it from the old
file? That would make the (c) header change more obvious.
Lucas Stach - Oct. 30, 2012, 6:58 p.m.
Am Dienstag, den 30.10.2012, 12:51 -0600 schrieb Stephen Warren:
> On 10/30/2012 12:45 PM, Lucas Stach wrote:
> > Am Dienstag, den 30.10.2012, 12:38 -0600 schrieb Stephen Warren:
> >> On 10/30/2012 03:22 AM, Lucas Stach wrote:
> >>> This moves the Tegra USB implementation into the drivers/usb/host
> >>> directory.
> >>
> >>> diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/drivers/usb/host/ehci-tegra.c
> >>
> >>> + * Copyright (c) 2009-2012 NVIDIA Corporation
> >>>   * Copyright (c) 2011 The Chromium OS Authors.
> >>> - * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
> >>
> >> Why does NVIDIA's (c) notice change?
> >>
> > Just because I took most of the licence header from the ehci_tegra.c
> > file, but as the patch shows the the diff modulo the copied part it
> > looks like a change. I choose this one as it actually spans the longer
> > copyright timeframe of the both licence headers. Is this a problem?
> > Should I also include the web address?
> 
> Hmm. So this patch merges two files together into one? The diff looks
> like it's creating a new file. If the new content in this patch came
> from some other file, shouldn't the patch also remove it from the old
> file? That would make the (c) header change more obvious.
> 
Hm, the rename presentation of this patch seems to cause major
confusion. Yes, this patch merges the Tegra usb implementation into the
pre-existing ehci_tegra.c file, which before this change did not much
more than to call into the Tegra SoC usb implementation. As the Tegra
usb implementation is not really SoC specific, but rather controller
specific this should really move over.

I will send this patch in the usual remove-add presentation for a V2 of
the series, as it even seems to confuse git right now.

Regards,
Lucas

Patch

diff --git a/arch/arm/cpu/armv7/tegra20/Makefile b/arch/arm/cpu/armv7/tegra20/Makefile
index 09a0314..2c4d5c9 100644
--- a/arch/arm/cpu/armv7/tegra20/Makefile
+++ b/arch/arm/cpu/armv7/tegra20/Makefile
@@ -27,8 +27,6 @@  include $(TOPDIR)/config.mk
 
 LIB	=  $(obj)lib$(SOC).o
 
-COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o
-
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/arch/arm/cpu/armv7/tegra20/usb.c b/drivers/usb/host/ehci-tegra.c
similarity index 92%
rename from arch/arm/cpu/armv7/tegra20/usb.c
rename to drivers/usb/host/ehci-tegra.c
index 2cc95d2..3df43a9 100644
--- a/arch/arm/cpu/armv7/tegra20/usb.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -1,6 +1,7 @@ 
 /*
+ * Copyright (c) 2009-2012 NVIDIA Corporation
  * Copyright (c) 2011 The Chromium OS Authors.
- * (C) Copyright 2010,2011 NVIDIA Corporation <www.nvidia.com>
+ * Copyright (c) 2012 Lucas Stach
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -21,14 +22,16 @@ 
  * MA 02111-1307 USA
  */
 
-#include <common.h>
 #include <asm/io.h>
-#include <asm-generic/gpio.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/usb.h>
-#include <usb/ulpi.h>
-#include <libfdt.h>
+#include <asm-generic/gpio.h>
+#include <common.h>
 #include <fdtdec.h>
+#include <libfdt.h>
+#include <usb.h>
+#include <usb/ulpi.h>
+#include "ehci.h"
 
 #ifdef CONFIG_USB_ULPI
 	#ifndef CONFIG_USB_ULPI_VIEWPORT
@@ -138,6 +141,23 @@  static const u8 utmip_elastic_limit = 16;
 /* UTMIP High Speed Sync Start Delay */
 static const u8 utmip_hs_sync_start_delay = 9;
 
+/*
+ * A known hardware issue where Connect Status Change bit of PORTSC register
+ * of USB1 controller will be set after Port Reset.
+ * We have to clear it in order for later device enumeration to proceed.
+ * This ehci_powerup_fixup overrides the weak function ehci_powerup_fixup
+ * in "ehci-hcd.c".
+ */
+void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
+{
+	mdelay(50);
+	if (((u32) status_reg & TEGRA_USB_ADDR_MASK) != TEGRA_USB1_BASE)
+		return;
+	/* For EHCI_PS_CSC to be cleared in ehci_hcd.c */
+	if (ehci_readl(status_reg) & EHCI_PS_CSC)
+		*reg |= EHCI_PS_CSC;
+}
+
 /* Put the port into host mode */
 static void set_host_mode(struct fdt_usb *config)
 {
@@ -534,3 +554,33 @@  int board_usb_init(const void *blob)
 
 	return 0;
 }
+
+/*
+ * Create the appropriate control structures to manage
+ * a new EHCI host controller.
+ */
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+{
+	u32 our_hccr, our_hcor;
+
+	/*
+	 * Select the first port, as we don't have a way of selecting others
+	 * yet
+	 */
+	if (tegrausb_start_port(index, &our_hccr, &our_hcor))
+		return -1;
+
+	*hccr = (struct ehci_hccr *)our_hccr;
+	*hcor = (struct ehci_hcor *)our_hcor;
+
+	return 0;
+}
+
+/*
+ * Destroy the appropriate control structures corresponding
+ * the the EHCI host controller.
+ */
+int ehci_hcd_stop(int index)
+{
+	return tegrausb_stop_port(index);
+}