--- zzzz-none-000/linux-2.6.28.10/drivers/usb/core/hub.c 2009-05-02 18:54:43.000000000 +0000 +++ fusiv-7390-686/linux-2.6.28.10/drivers/usb/core/hub.c 2016-08-18 09:49:46.000000000 +0000 @@ -30,6 +30,10 @@ #include "hcd.h" #include "hub.h" +#ifdef CONFIG_AVM_POWERMETER +#include +#endif /*--- #ifdef CONFIG_AVM_POWERMETER ---*/ + /* if we are in debug mode, always announce new devices */ #ifdef DEBUG #ifndef CONFIG_USB_ANNOUNCE_NEW_DEVICES @@ -37,6 +41,28 @@ #endif #endif +/* 20160715 AVM/VGJ USB KPI */ +#if defined (CONFIG_AVM_ENHANCED) + +unsigned long disconnect_time[2]; +unsigned int disconnect_device_id[2]; + +int reconnect_count = 0; +module_param(reconnect_count, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(reconnect_count, "Count of reconnects"); + +int enum_error_count = 0; +module_param(enum_error_count, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(enum_error_count, "Count of enumeration errors"); + +// Overcurrent detection not yet supported in Ikanos Hardware +int overcurrent_error_count = -1; +module_param(overcurrent_error_count, int, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(overcurrent_error_count, "Count of overcurrent errors"); + +#endif + + struct usb_hub { struct device *intfdev; /* the "interface" device */ struct usb_device *hdev; @@ -1274,6 +1300,12 @@ unsigned long flags; spin_lock_irqsave(&device_state_lock, flags); +#ifdef CONFIG_FUSIV_USB_LED + if (new_state == USB_STATE_NOTATTACHED) + fusiv_usb_led_clear(udev->portnum -1 ,FUSIV_USB_LED_ATTCHD_BIT); + else + fusiv_usb_led_set(udev->portnum - 1,FUSIV_USB_LED_ATTCHD_BIT); +#endif if (udev->state == USB_STATE_NOTATTACHED) ; /* do nothing */ else if (new_state != USB_STATE_NOTATTACHED) { @@ -1418,6 +1450,39 @@ usb_set_device_state(udev, USB_STATE_NOTATTACHED); dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum); +#if defined(CONFIG_AVM_POWERMETER) + if (udev->level == 1) { + unsigned nextmA = 0; + unsigned avm_powerdevice; + +#if defined (CONFIG_FUSIV_VX180) || (CONFIG_FUSIV_VX185) || defined (CONFIG_MACH_AR934x) + avm_powerdevice = (udev->portnum == 1)? powerdevice_usb_host : powerdevice_usb_host2; + printk (KERN_INFO "Port#%u disconnect: 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 disconnect: AVM Powermeter changed to %u mA\n", udev->bus->busnum, nextmA); +#endif + PowerManagmentRessourceInfo(avm_powerdevice, nextmA); + } +#endif // CONFIG_AVM_POWERMETER + +/* 20160715 AVM/VGJ store disconnect timestamp to check possible reconnects */ +#if defined (CONFIG_AVM_ENHANCED) + // Only check reconnects of devices directly connected to root-hub + if (udev->level == 1) { + int port_index; + unsigned int device_id; +#if defined (CONFIG_FUSIV_VX180) || (CONFIG_FUSIV_VX185) || defined (CONFIG_MACH_AR934x) + port_index = udev->portnum & 1 ? 0 : 1; +#else + port_index = udev->bus->busnum & 1 ? 0 : 1; +#endif + disconnect_time[port_index] = jiffies; + device_id = (udev->descriptor.idVendor << 16) | udev->descriptor.idProduct; + disconnect_device_id[port_index] = device_id; + } +#endif + usb_lock_device(udev); /* Free up all the children before we remove this device */ @@ -2948,9 +3013,14 @@ } if (hub->hdev->parent || !hcd->driver->port_handed_over || - !(hcd->driver->port_handed_over)(hcd, port1)) - dev_err(hub_dev, "unable to enumerate USB device on port %d\n", - port1); + !(hcd->driver->port_handed_over)(hcd, port1)) { + dev_err(hub_dev, "unable to enumerate USB device on port %d\n", + port1); +/* 20160715 AVM/VGJ increment enumeration error */ +#if defined (CONFIG_AVM_ENHANCED) + enum_error_count++; +#endif + } done: hub_port_disable(hub, port1, 1);