--- zzzz-none-000/linux-2.6.32.61/drivers/usb/core/generic.c 2013-06-10 09:43:48.000000000 +0000 +++ ar9-7330-650/linux-2.6.32.61/drivers/usb/core/generic.c 2014-11-18 18:35:11.000000000 +0000 @@ -21,6 +21,11 @@ #include "usb.h" #include "hcd.h" +#ifdef CONFIG_AVM_POWERMETER +#include +#include +#endif /*--- #ifdef CONFIG_AVM_POWERMETER ---*/ + static inline const char *plural(int n) { return (n == 1 ? "" : "s"); @@ -102,6 +107,95 @@ continue; } +#if defined(CONFIG_AVM_POWERMETER) + { + int hub_port; + enum _avm_hw_param param; +#if defined (CONFIG_MACH_AR934x) + //check if internal hub is not present + if (avm_get_hw_config(AVM_HW_CONFIG_VERSION, "usb_hub_external_port1", &hub_port, ¶m) != 0) { +#else + if (1) { +#endif + if (udev->level == 1) { + unsigned nextmA = (c->desc.bMaxPower * 2); + + /* A device should display at least 100 mA in AVM_POWERMETER */ + if (nextmA < 100) { + nextmA = 100; + } + + { +#if defined(CONFIG_AR9) + unsigned totalmA; + unsigned avm_powerdevice; + /* set minimum power (100mA) first, then query power for both ports */ + avm_powerdevice = (udev->bus->busnum == 1)? powerdevice_usb_host : powerdevice_usb_host2; + printk (KERN_INFO "Bus#%u config: AVM Powermeter biased to 100 mA\n", udev->bus->busnum); + PowerManagmentRessourceInfo(avm_powerdevice, 100); + + /* fix: 100 mA off for this very port */ + totalmA = PowerManagmentActivatePowerMode("usb_current_req") - 100; + if ((nextmA + totalmA) > 600) { + if (le16_to_cpu(udev->descriptor.idVendor) != 0x057C) { + printk (KERN_INFO "AVM: rejecting new USB device with %u mA; old power was %u mA!\n", nextmA, totalmA); + insufficient_power++; + continue; + } + } else +#endif // CONFIG_AR9 + { + unsigned avm_powerdevice; +#if defined (CONFIG_FUSIV_VX180) + if (1) { +#elif defined(CONFIG_VR9) + if (bus_to_hcd(udev->bus)->driver->flags & HCD_USB3) { + if (udev->portnum <= 2) { + nextmA = (c->desc.bMaxPower * 8); + if (nextmA <= 150) { + nextmA = 150; + } + } +#else + if (0) { +#endif + avm_powerdevice = (udev->portnum & 1)? powerdevice_usb_host : powerdevice_usb_host2; + printk (KERN_INFO "Port#%u config: AVM Powermeter changed to %u mA\n", udev->portnum, nextmA); + } else { + avm_powerdevice = (udev->bus->busnum == 1)? powerdevice_usb_host : powerdevice_usb_host2; + printk (KERN_INFO "Bus#%u config: AVM Powermeter changed to %u mA\n", udev->bus->busnum, nextmA); + } + PowerManagmentRessourceInfo(avm_powerdevice, nextmA); + } + } + } + } else { + if (udev->level == 2) { + unsigned avm_powerdevice = 0; + if (udev->portnum == hub_port) { + avm_powerdevice = powerdevice_usb_host; + } else { + if (avm_get_hw_config(AVM_HW_CONFIG_VERSION, "usb_hub_external_port2", &hub_port, ¶m) == 0) { + if (udev->portnum == hub_port) { + avm_powerdevice = powerdevice_usb_host2; + } + } + } + if (avm_powerdevice) { + unsigned nextmA = (c->desc.bMaxPower * 2); + + /* A device should display at least 100 mA in AVM_POWERMETER */ + if (nextmA < 100) { + nextmA = 100; + } + printk (KERN_INFO "HubPort#%u config: AVM Powermeter changed to %u mA\n", udev->portnum, nextmA); + PowerManagmentRessourceInfo(avm_powerdevice, nextmA); + } + } + } + } +#endif // CONFIG_AVM_POWERMETER + /* When the first config's first interface is one of Microsoft's * pet nonstandard Ethernet-over-USB protocols, ignore it unless * this kernel has enabled the necessary host side driver. @@ -162,6 +256,10 @@ ; /* Don't configure if the device is owned */ else if (udev->authorized == 0) dev_err(&udev->dev, "Device is not authorized for usage\n"); +#if 1 /* == 20101129 AVM/WK Extension == */ + else if (udev->noprobe) + dev_err(&udev->dev, "Probing is disabled for this device\n"); +#endif else { c = usb_choose_configuration(udev); if (c >= 0) {