[U-Boot] unassigned-patches/25: [PATCH] USB EHCI: reset root hub

Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
--- Added to GNATS database as unassigned-patches/25
Responsible: patch-coord Message-Id: 1218807733-26929-3-git-send-email-dzu@denx.de In-Reply-To: 1218807733-26929-2-git-send-email-dzu@denx.de References: 1218807733-26929-1-git-send-email-dzu@denx.de 1218807733-26929-2-git-send-email-dzu@denx.de Patch-Date: Fri Aug 15 15:42:10 +0200 2008
--- drivers/usb/usb_ohci.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/usb_ohci.c b/drivers/usb/usb_ohci.c index fd60edb..0f5bd06 100644 --- a/drivers/usb/usb_ohci.c +++ b/drivers/usb/usb_ohci.c @@ -1571,11 +1571,42 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
static int hc_reset (ohci_t *ohci) { +#ifdef CONFIG_PCI_EHCI_DEVNO + pci_dev_t pdev; + struct pci_device_id ehci_pci_ids[] = { + {0x1131, 0x1562}, /* Philips 1562 PCI EHCI module ids */ + {0, 0} + }; +#endif int timeout = 30; int smm_timeout = 50; /* 0,5 sec */
dbg("%s\n", __FUNCTION__);
+#ifdef CONFIG_PCI_EHCI_DEVNO + /* + * Some multi-function controllers (e.g. ISP1562) allow root hub + * resetting via EHCI registers only. + */ + pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVNO); + if (pdev != -1) { + u32 base; + int timeout = 1000; + + pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base); + writel (readl(base + EHCI_USBCMD_OFF) | EHCI_USBCMD_HCRESET, + base + EHCI_USBCMD_OFF); + + while (readl(base + EHCI_USBCMD_OFF) & EHCI_USBCMD_HCRESET) { + if (timeout-- <= 0) { + printf("USB RootHub reset timed out!"); + break; + } + udelay(1); + } + } else + printf("No EHCI func at %d index!\n", CONFIG_PCI_EHCI_DEVNO); +#endif if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */ writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */ info("USB HC TakeOver from SMM"); diff --git a/drivers/usb/usb_ohci.h b/drivers/usb/usb_ohci.h index 380cb4c..7a04bf5 100644 --- a/drivers/usb/usb_ohci.h +++ b/drivers/usb/usb_ohci.h @@ -195,6 +195,9 @@ struct ohci_regs { } roothub; } __attribute((aligned(32)));
+/* Some EHCI controls */ +#define EHCI_USBCMD_OFF 0x20 +#define EHCI_USBCMD_HCRESET (1 << 1)
/* OHCI CONTROL AND STATUS REGISTER MASKS */
diff --git a/include/configs/socrates.h b/include/configs/socrates.h index 8a64942..fdc1557 100644 --- a/include/configs/socrates.h +++ b/include/configs/socrates.h @@ -403,6 +403,7 @@ #define CONFIG_USB_OHCI_NEW 1 #define CONFIG_PCI_OHCI 1 #define CONFIG_PCI_OHCI_DEVNO 3 /* Number in PCI list */ +#define CONFIG_PCI_EHCI_DEVNO (CONFIG_PCI_OHCI_DEVNO / 2) #define CFG_USB_OHCI_MAX_ROOT_PORTS 15 #define CFG_USB_OHCI_SLOT_NAME "ohci_pci" #define CFG_OHCI_SWAP_REG_ACCESS 1

Hi Markus,
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
Added to GNATS database as unassigned-patches/25
Responsible: patch-coord Message-Id: 1218807733-26929-3-git-send-email-dzu@denx.de In-Reply-To: 1218807733-26929-2-git-send-email-dzu@denx.de References: 1218807733-26929-1-git-send-email-dzu@denx.de 1218807733-26929-2-git-send-email-dzu@denx.de Patch-Date: Fri Aug 15 15:42:10 +0200 2008
drivers/usb/usb_ohci.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 35 insertions(+), 0 deletions(-)
Any comments on this?
Thanks Detlev

Hi Detlev,
On Mon, Sep 01, 2008 at 05:41:48PM +0200, Detlev Zundel wrote:
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
Added to GNATS database as unassigned-patches/25
Responsible: patch-coord Message-Id: 1218807733-26929-3-git-send-email-dzu@denx.de In-Reply-To: 1218807733-26929-2-git-send-email-dzu@denx.de References: 1218807733-26929-1-git-send-email-dzu@denx.de 1218807733-26929-2-git-send-email-dzu@denx.de Patch-Date: Fri Aug 15 15:42:10 +0200 2008
drivers/usb/usb_ohci.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 35 insertions(+), 0 deletions(-)
Any comments on this?
Not yet, but I promise to look into it this week.
Best regards Markus

Dear Yuri,
On Fri, Aug 15, 2008 at 03:45:02PM +0200, u-boot@bugs.denx.de wrote:
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
Added to GNATS database as unassigned-patches/25
Responsible: patch-coord Message-Id: 1218807733-26929-3-git-send-email-dzu@denx.de In-Reply-To: 1218807733-26929-2-git-send-email-dzu@denx.de References: 1218807733-26929-1-git-send-email-dzu@denx.de 1218807733-26929-2-git-send-email-dzu@denx.de Patch-Date: Fri Aug 15 15:42:10 +0200 2008
drivers/usb/usb_ohci.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/usb_ohci.c b/drivers/usb/usb_ohci.c index fd60edb..0f5bd06 100644 --- a/drivers/usb/usb_ohci.c +++ b/drivers/usb/usb_ohci.c @@ -1571,11 +1571,42 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
static int hc_reset (ohci_t *ohci) { +#ifdef CONFIG_PCI_EHCI_DEVNO
- pci_dev_t pdev;
- struct pci_device_id ehci_pci_ids[] = {
{0x1131, 0x1562}, /* Philips 1562 PCI EHCI module ids */
{0, 0}
- };
Please move this out of the function, preferrably next to the OHCI device ids.
Thanks!
Best regards
Markus

From: Yuri Tikhonov yur@emcraft.com
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com --- drivers/usb/usb_ohci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 39 insertions(+), 0 deletions(-)
This new version addresses Markus feedback.
diff --git a/drivers/usb/usb_ohci.c b/drivers/usb/usb_ohci.c index fd60edb..ce13866 100644 --- a/drivers/usb/usb_ohci.c +++ b/drivers/usb/usb_ohci.c @@ -108,6 +108,14 @@ static struct pci_device_id ohci_pci_ids[] = { }; #endif
+#ifdef CONFIG_PCI_EHCI_DEVNO +static struct pci_device_id ehci_pci_ids[] = { + {0x1131, 0x1562}, /* Philips 1562 PCI EHCI module ids */ + /* Please add supported PCI EHCI controller ids here */ + {0, 0} +}; +#endif + #ifdef DEBUG #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg) #else @@ -1571,11 +1579,38 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
static int hc_reset (ohci_t *ohci) { +#ifdef CONFIG_PCI_EHCI_DEVNO + pci_dev_t pdev; +#endif int timeout = 30; int smm_timeout = 50; /* 0,5 sec */
dbg("%s\n", __FUNCTION__);
+#ifdef CONFIG_PCI_EHCI_DEVNO + /* + * Some multi-function controllers (e.g. ISP1562) allow root hub + * resetting via EHCI registers only. + */ + pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVNO); + if (pdev != -1) { + u32 base; + int timeout = 1000; + + pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &base); + writel (readl(base + EHCI_USBCMD_OFF) | EHCI_USBCMD_HCRESET, + base + EHCI_USBCMD_OFF); + + while (readl(base + EHCI_USBCMD_OFF) & EHCI_USBCMD_HCRESET) { + if (timeout-- <= 0) { + printf("USB RootHub reset timed out!"); + break; + } + udelay(1); + } + } else + printf("No EHCI func at %d index!\n", CONFIG_PCI_EHCI_DEVNO); +#endif if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */ writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */ info("USB HC TakeOver from SMM"); diff --git a/drivers/usb/usb_ohci.h b/drivers/usb/usb_ohci.h index 380cb4c..7a04bf5 100644 --- a/drivers/usb/usb_ohci.h +++ b/drivers/usb/usb_ohci.h @@ -195,6 +195,9 @@ struct ohci_regs { } roothub; } __attribute((aligned(32)));
+/* Some EHCI controls */ +#define EHCI_USBCMD_OFF 0x20 +#define EHCI_USBCMD_HCRESET (1 << 1)
/* OHCI CONTROL AND STATUS REGISTER MASKS */
diff --git a/include/configs/socrates.h b/include/configs/socrates.h index 8a64942..fdc1557 100644 --- a/include/configs/socrates.h +++ b/include/configs/socrates.h @@ -403,6 +403,7 @@ #define CONFIG_USB_OHCI_NEW 1 #define CONFIG_PCI_OHCI 1 #define CONFIG_PCI_OHCI_DEVNO 3 /* Number in PCI list */ +#define CONFIG_PCI_EHCI_DEVNO (CONFIG_PCI_OHCI_DEVNO / 2) #define CFG_USB_OHCI_MAX_ROOT_PORTS 15 #define CFG_USB_OHCI_SLOT_NAME "ohci_pci" #define CFG_OHCI_SWAP_REG_ACCESS 1

On Thu, Sep 04, 2008 at 11:19:05AM +0200, Detlev Zundel wrote:
From: Yuri Tikhonov yur@emcraft.com
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
Acked-by: Markus Klotzbuecher mk@denx.de
Wolfgang, please pick up directly (I consider this a bugfix).
Best regards Markus

Dear Detlev Zundel,
In message 1220519945-12872-1-git-send-email-dzu@denx.de you wrote:
From: Yuri Tikhonov yur@emcraft.com
Some of multi-function USB controllers (e.g. ISP1562) allow root hub resetting only via EHCI registers. So, this patch adds the corresponding kind of reset to OHCI's hc_reset() if the newly introduced CONFIG_PCI_EHCI_DEVNO option is set (e.g. for Socrates board).
Signed-off-by: Yuri Tikhonov yur@emcraft.com
drivers/usb/usb_ohci.c | 35 +++++++++++++++++++++++++++++++++++ drivers/usb/usb_ohci.h | 3 +++ include/configs/socrates.h | 1 + 3 files changed, 39 insertions(+), 0 deletions(-)
This new version addresses Markus feedback.
Applied, thanks.
Best regards,
Wolfgang Denk
participants (4)
-
Detlev Zundel
-
Markus Klotzbücher
-
u-boot@bugs.denx.de
-
Wolfgang Denk