Re: [U-Boot] Googlers please reply: commiters in U-Boot
On Jan 12, 2013 9:20 AM, Simon Glass s...@chromium.org wrote: Hi, You are being copied because you have written U-Boot code which is now in mainline. The chromium.org domain does not automatically attribute U-Boot commits by company. Each author needs to be manually added to the list and this can only be done if you confirm your employer. So, if you are on the CC list and work at Google, please reply-all with a quick email stating this (without top posting). I work for Google and my CLs signed by vpala...@chromium.org can be attributed to Google Inc. Thanks Simon. -- Vincent ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 03/11] usb: ehci: generic PCI support
On Thu, Dec 13, 2012 at 9:30 AM, Marek Vasut ma...@denx.de wrote: Dear Simon Glass, From: Vincent Palatin vpala...@chromium.org Instead of hardcoding the PCI IDs on the USB controller, use the PCI class to detect them. Ensure the busmaster bit is properly set in the PCI configuration. Signed-off-by: Simon Glass s...@chromium.org --- drivers/usb/host/ehci-pci.c | 37 + 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 29af02d..0dc0e6e 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -32,6 +32,34 @@ static struct pci_device_id ehci_pci_ids[] = { {0x12D8, 0x400F}, /* Pericom */ {0, 0} }; +#else +static pci_dev_t ehci_find_class(void) +{ + int bus; + int devnum; + pci_dev_t bdf; + uint32_t class; + + for (bus = 0; bus pci_last_busno(); bus++) { + for (devnum = 0; devnum PCI_MAX_PCI_DEVICES-1; devnum++) { + pci_read_config_dword(PCI_BDF(bus, devnum, 0), + PCI_CLASS_REVISION, class); + if (class 16 == 0x) + continue; + + for (bdf = PCI_BDF(bus, devnum, 0); + bdf = PCI_BDF(bus, devnum, + PCI_MAX_PCI_FUNCTIONS - 1); + bdf += PCI_BDF(0, 0, 1)) { + pci_read_config_dword(bdf, PCI_CLASS_REVISION, + class); + if (class 8 == 0x0c0320) Can we at least describe this magic please? The PCI class word is something like that : class = [31:24] class code [23:16] subclass [15:8] Prog if [7:0] Revision ID For this use case : class code = 0x0C (Serial bus controller) subclass = 0x03 (USB controller) Program interface = 0x20 (EHCI) This is available in include/pci_ids.h as #define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320 so just replacing the numeric constant by this define should be ok ? + return bdf; + } + } + } + return -1; Let's try to use errno.h please. It won't be consistent for a while, but we'll get there. +} #endif /* @@ -41,8 +69,13 @@ static struct pci_device_id ehci_pci_ids[] = { int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { pci_dev_t pdev; + uint32_t cmd; +#ifdef CONFIG_PCI_EHCI_DEVICE pdev = pci_find_devices(ehci_pci_ids, CONFIG_PCI_EHCI_DEVICE); +#else + pdev = ehci_find_class(); +#endif if (pdev == -1) { printf(EHCI host controller not found\n); return -1; @@ -57,6 +90,10 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl((*hccr)-cr_capbase))); + /* enable busmaster */ + pci_read_config_dword(pdev, PCI_COMMAND, cmd); + cmd |= PCI_COMMAND_MASTER; + pci_write_config_dword(pdev, PCI_COMMAND, cmd); return 0; } Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] usb: fallback safely when a configuration descriptor is too large
When a USB configuration descriptor was larger than our USB buffer (512 bytes), we were skipping the full descriptor reading but then we were still parsing and using it, triggering memory corruptions. Now in that case, it just skips this device enumeration and displays the appropriate message to the user, so he can fix the buffer if he wants. This bug was triggered by some UVC webcams which have very large configuration descriptors (e.g. a couple of kB) describing all their supported video encodings. Signed-off-by: Vincent Palatin vpala...@chromium.org --- common/usb.c | 12 +--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/usb.c b/common/usb.c index 63a11c8..cfa1ad7 100644 --- a/common/usb.c +++ b/common/usb.c @@ -485,8 +485,8 @@ int usb_get_configuration_no(struct usb_device *dev, tmp = le16_to_cpu(config-wTotalLength); if (tmp USB_BUFSIZ) { - USB_PRINTF(usb_get_configuration_no: failed to get \ - descriptor - too long: %d\n, tmp); + printf(usb_get_configuration_no: failed to get \ + descriptor - too long: %d\n, tmp); return -1; } @@ -921,7 +921,13 @@ int usb_new_device(struct usb_device *dev) le16_to_cpus(dev-descriptor.idProduct); le16_to_cpus(dev-descriptor.bcdDevice); /* only support for one config for now */ - usb_get_configuration_no(dev, tmpbuf[0], 0); + err = usb_get_configuration_no(dev, tmpbuf[0], 0); + if (err 0) { + printf(usb_new_device: Cannot read configuration, \ + skipping device %04x:%04x\n, + dev-descriptor.idVendor, dev-descriptor.idProduct); + return -1; + } usb_parse_config(dev, tmpbuf[0], 0); usb_set_maxpacket(dev); /* we set the default configuration here */ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] net: re-enumerating usb-ethernet devices hangs the system
Hi, On Mon, Jan 9, 2012 at 04:02, Wolfgang Grandegger w...@grandegger.com wrote: as you already know, the re-enumerating of usb ethernet devices (calling usb start twice) hangs the system because eth_register() is called more than once. If have found a related patch from you with the subject eth: remove usb-ethernet devices before re-enumerating them in the chromium.org git repos. Could that be pushed mainline. Feel free to add my Tested-by: Wolfgang Grandegger w...@denx.de. Sure I will do that today. -- Vincent ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] USB: fix USB keyboard polling parameter
When doing a GET_REPORT request on the keyboard control endpoint, the report ID should 0 (ie report ID not used) rather than 1 as reports are not used in boot mode. Signed-off-by: Vincent Palatin vpala...@chromium.org --- common/usb_kbd.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 75107c9..aaf7d6f 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -320,7 +320,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev) struct usb_kbd_pdata *data = dev-privptr; iface = dev-config.if_desc[0]; usb_get_report(dev, iface-desc.bInterfaceNumber, - 1, 1, data-new, sizeof(data-new)); + 1, 0, data-new, sizeof(data-new)); if (memcmp(data-old, data-new, sizeof(data-new))) usb_kbd_irq_worker(dev); #endif -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] eth: remove usb-ethernet devices before re-enumerating them
Fix the crash when running several times usb_init() with a USB ethernet device plugged. Signed-off-by: Vincent Palatin vpala...@chromium.org Tested-by: Wolfgang Grandegger w...@denx.de --- drivers/usb/eth/usb_ether.c |7 +-- include/net.h |1 + net/eth.c | 29 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 6565ea5..73a0790 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -127,8 +127,11 @@ int usb_host_eth_scan(int mode) old_async = usb_disable_asynch(1); /* asynch transfer not allowed */ - for (i = 0; i USB_MAX_ETH_DEV; i++) - memset(usb_eth[i], 0, sizeof(usb_eth[i])); + /* unregister a previously detected device */ + for (i = 0; i usb_max_eth_dev; i++) + eth_unregister(usb_eth[i].eth_dev); + + memset(usb_eth, 0, sizeof(usb_eth)); for (i = 0; prob_dev[i].probe; i++) { if (prob_dev[i].before_probe) diff --git a/include/net.h b/include/net.h index e4d42c2..1707a7f 100644 --- a/include/net.h +++ b/include/net.h @@ -96,6 +96,7 @@ struct eth_device { extern int eth_initialize(bd_t *bis); /* Initialize network subsystem */ extern int eth_register(struct eth_device* dev);/* Register network device */ +extern int eth_unregister(struct eth_device *dev);/* Remove network device */ extern void eth_try_another(int first_restart);/* Change the device */ extern void eth_set_current(void); /* set nterface to ethcur var */ extern struct eth_device *eth_get_dev(void); /* get the current device MAC */ diff --git a/net/eth.c b/net/eth.c index b4b9b43..3fb5fb6 100644 --- a/net/eth.c +++ b/net/eth.c @@ -224,6 +224,35 @@ int eth_register(struct eth_device *dev) return 0; } +int eth_unregister(struct eth_device *dev) +{ + struct eth_device *cur; + + /* No device */ + if (!eth_devices) + return -1; + + for (cur = eth_devices; cur-next != eth_devices cur-next != dev; +cur = cur-next) + ; + + /* Device not found */ + if (cur-next != dev) + return -1; + + cur-next = dev-next; + + if (eth_devices == dev) + eth_devices = dev-next == eth_devices ? NULL : dev-next; + + if (eth_current == dev) { + eth_current = eth_devices; + eth_current_changed(); + } + + return 0; +} + int eth_initialize(bd_t *bis) { int num_devices = 0; -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] USB: fix USB keyboard polling parameter
On Mon, Jan 9, 2012 at 12:46, Marek Vasut marek.va...@gmail.com wrote: When doing a GET_REPORT request on the keyboard control endpoint, the report ID should 0 (ie report ID not used) rather than 1 as reports are not used in boot mode. Signed-off-by: Vincent Palatin vpala...@chromium.org --- common/usb_kbd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 75107c9..aaf7d6f 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -320,7 +320,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev) struct usb_kbd_pdata *data = dev-privptr; iface = dev-config.if_desc[0]; usb_get_report(dev, iface-desc.bInterfaceNumber, - 1, 1, data-new, sizeof(data-new)); + 1, 0, data-new, sizeof(data-new)); if (memcmp(data-old, data-new, sizeof(data-new))) usb_kbd_irq_worker(dev); #endif Good, did you test this? Yes, on about a dozen different keyboards : most don't care, a couple used to be confused and are now working. -- Vincent ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] eth: remove usb-ethernet devices before re-enumerating them
On Mon, Jan 9, 2012 at 12:57, Marek Vasut marek.va...@gmail.com wrote: Fix the crash when running several times usb_init() with a USB ethernet device plugged. Signed-off-by: Vincent Palatin vpala...@chromium.org Tested-by: Wolfgang Grandegger w...@denx.de --- drivers/usb/eth/usb_ether.c | 7 +-- include/net.h | 1 + net/eth.c | 29 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 6565ea5..73a0790 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -127,8 +127,11 @@ int usb_host_eth_scan(int mode) old_async = usb_disable_asynch(1); /* asynch transfer not allowed */ - for (i = 0; i USB_MAX_ETH_DEV; i++) - memset(usb_eth[i], 0, sizeof(usb_eth[i])); + /* unregister a previously detected device */ + for (i = 0; i usb_max_eth_dev; i++) + eth_unregister(usb_eth[i].eth_dev); + + memset(usb_eth, 0, sizeof(usb_eth)); for (i = 0; prob_dev[i].probe; i++) { if (prob_dev[i].before_probe) diff --git a/include/net.h b/include/net.h index e4d42c2..1707a7f 100644 --- a/include/net.h +++ b/include/net.h @@ -96,6 +96,7 @@ struct eth_device { extern int eth_initialize(bd_t *bis); /* Initialize network subsystem */ extern int eth_register(struct eth_device* dev);/* Register network device */ +extern int eth_unregister(struct eth_device *dev);/* Remove network device */ extern void eth_try_another(int first_restart); /* Change the device */ extern void eth_set_current(void); /* set nterface to ethcur var */ extern struct eth_device *eth_get_dev(void); /* get the current device MAC */ diff --git a/net/eth.c b/net/eth.c index b4b9b43..3fb5fb6 100644 --- a/net/eth.c +++ b/net/eth.c @@ -224,6 +224,35 @@ int eth_register(struct eth_device *dev) return 0; } +int eth_unregister(struct eth_device *dev) +{ + struct eth_device *cur; + + /* No device */ + if (!eth_devices) + return -1; + + for (cur = eth_devices; cur-next != eth_devices cur-next != dev; + cur = cur-next) + ; + + /* Device not found */ + if (cur-next != dev) + return -1; + + cur-next = dev-next; + + if (eth_devices == dev) + eth_devices = dev-next == eth_devices ? NULL : dev-next; + + if (eth_current == dev) { + eth_current = eth_devices; + eth_current_changed(); + } + + return 0; +} + int eth_initialize(bd_t *bis) { int num_devices = 0; Looks sane. On what hardware did this happen (just for the record)? I got it on x86 and ARM (tegra2) platforms (both with an EHCI controller). I did most of my testing with ASIX-based USB-ethernet dongle, but the issue seems pretty generic. -- Vincent ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] usb: add numeric keypad support to HID driver
When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter. Signed-off-by: Vincent Palatin vpala...@chromium.org --- common/usb_kbd.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index aaf7d6f..2472d25 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -87,6 +87,12 @@ static const unsigned char usb_kbd_numkey_shifted[] = { '|', '~', ':', '', '~', '', '', '?' }; +static const unsigned char usb_kbd_num_keypad[] = { + '/', '*', '-', '+', '\r', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', + '.', 0, 0, 0, '=' +}; + /* * NOTE: It's important for the NUM, CAPS, SCROLL-lock bits to be in this * order. See usb_kbd_setled() function! @@ -218,6 +224,10 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode, keycode = usb_kbd_numkey[scancode - 0x1e]; } + /* Numeric keypad */ + if ((scancode = 0x54) (scancode = 0x67)) + keycode = usb_kbd_num_keypad[scancode - 0x54]; + if (data-flags USB_KBD_CTRL) keycode = scancode - 0x3; -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ehci: speed up initialization
On Mon, Dec 19, 2011 at 04:07, Wolfgang Grandegger w...@grandegger.com wrote: I just realized that this patch breaks usb start on my mx53loco board: MX53LOCO U-Boot usb start (Re)start USB... USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 1 USB Device(s) found scanning bus for storage devices... 0 Storage Device(s) found scanning bus for ethernet devices... 0 Ethernet Device(s) found MX53LOCO U-Boot usb start (Re)start USB... USB: Register 10011 NbrPorts 1 USB EHCI 1.00 scanning bus for devices... 2 USB Device(s) found scanning bus for storage devices... 0 Storage Device(s) found scanning bus for ethernet devices... 1 Ethernet Device(s) found The device is not found at the first attempt. Obviously, a value of 10 for bPwrOn2PwrGood seems too short but 20 works fine. Would that be a resonable compromise? If yes, I could send a patch. This doesn't match the EHCI standard which explicity states that the power should be good after 20ms (paragraph 2.3.9 in EHCI 1.0), so we should probably find whether we are missing another delay somewhere in the generic EHCI code (which used to be hidden and should be fixed) or if i.MX53 is not compliant with the standard and need a special quirk. -- Vincent ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ehci: speed up initialization
On Mon, Dec 19, 2011 at 08:59, Remy Bohmer li...@bohmer.net wrote: Hi Wolfgang, 2011/12/19 Wolfgang Grandegger w...@grandegger.com: On 12/19/2011 01:51 PM, Vincent Palatin wrote: On Mon, Dec 19, 2011 at 04:07, Wolfgang Grandegger w...@grandegger.com wrote: I just realized that this patch breaks usb start on my mx53loco board: The device is not found at the first attempt. Obviously, a value of 10 for bPwrOn2PwrGood seems too short but 20 works fine. Would that be a resonable compromise? If yes, I could send a patch. This doesn't match the EHCI standard which explicity states that the power should be good after 20ms (paragraph 2.3.9 in EHCI 1.0), so we should probably find whether we are missing another delay somewhere in the generic EHCI code (which used to be hidden and should be fixed) or if i.MX53 is not compliant with the standard and need a special quirk. I'm not an USB expert but if I look into the hub_power_on() function of the Linux kernel it waits at least 100ms (and only once). See: http://lxr.linux.no/#linux+v3.1.5/drivers/usb/core/hub.c#L567 I would prefer a solution in line with the specification, but what is the reason why Linux takes 100 msec here? The patch adding this delay was the following one : commit b789696af8b4102b7cc26dec30c2c51ce51ee18b Author: David Brownell davi...@pacbell.net Date: Wed Aug 31 10:41:44 2005 -0700 [PATCH] USB: relax usbcore reset timings This appears to help some folk, please merge. This patch relaxes reset timings. There are some reports that it helps make enumeration work better on some high speed devices. Signed-off-by: David Brownell dbrown...@users.sourceforge.net Signed-off-by: Greg Kroah-Hartman gre...@suse.de Is that just chosen randomly , or was there a good reason for it? So random timings based on user inputs. -- Vincent Palatin ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] ehci: speed up initialization
According to EHCI specification v1.0, the controller should stabilize the power on a port at most 20 ms after the port power bit transition. So, we put this setting in the virtual descriptor corresponding field, (bPwrOn2PwrGood = 10 = 10 x 2ms = 20ms), this saves about 500ms at each controller initialization/enumeration. Signed-off-by: Vincent Palatin vpala...@chromium.org --- drivers/usb/host/ehci-hcd.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 2197119..caa0cfb 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -48,7 +48,7 @@ static struct descriptor { 0x29, /* bDescriptorType: hub descriptor */ 2, /* bNrPorts -- runtime modified */ 0, /* wHubCharacteristics */ - 0xff, /* bPwrOn2PwrGood */ + 10, /* bPwrOn2PwrGood */ 0, /* bHubCntrCurrent */ {}, /* Device removable */ {} /* at most 7 ports! XXX */ -- 1.7.3.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot