]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
clear port status change afte polling it
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 21 Aug 2010 19:39:15 +0000 (21:39 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 21 Aug 2010 19:39:15 +0000 (21:39 +0200)
bus/usb/ohci.c
bus/usb/uhci.c

index 66b7c08559a6b82526b9bad343e3eceb423fcb60..e3cd490ac518a6ce0f40464852f313fbfeb95f92 100644 (file)
@@ -1349,8 +1349,16 @@ grub_ohci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
 
    grub_dprintf ("ohci", "detect_dev status=0x%02x\n", status);
 
-  /* Connect Status Change bit - it detects change of connection */
-  *changed = ((status & GRUB_OHCI_RESET_CONNECT_CHANGE) != 0);
+   /* Connect Status Change bit - it detects change of connection */
+   if (status & GRUB_OHCI_RESET_CONNECT_CHANGE)
+     {
+       *changed = 1;
+       /* Reset bit Connect Status Change */
+       grub_ohci_writereg32 (o, GRUB_OHCI_REG_RHUBPORT + port,
+                            GRUB_OHCI_RESET_CONNECT_CHANGE);
+     }
+   else
+     *changed = 0;
 
    if (! (status & 1))
      return GRUB_USB_SPEED_NONE;
index addfb41e8820949e75c2a3cf121b17043174b8c4..472a7054e18b96206f8cc0a1dfc0720c2eefe017 100644 (file)
@@ -39,6 +39,18 @@ typedef enum
 #define GRUB_UHCI_LINK_TERMINATE       1
 #define GRUB_UHCI_LINK_QUEUE_HEAD      2
 
+enum
+  {
+    GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED = 0x0002,
+    GRUB_UHCI_REG_PORTSC_PORT_ENABLED    = 0x0004,
+    GRUB_UHCI_REG_PORTSC_RESUME          = 0x0040,
+    GRUB_UHCI_REG_PORTSC_RESET           = 0x0200,
+    GRUB_UHCI_REG_PORTSC_SUSPEND         = 0x1000,
+    GRUB_UHCI_REG_PORTSC_RW = GRUB_UHCI_REG_PORTSC_PORT_ENABLED
+    | GRUB_UHCI_REG_PORTSC_RESUME | GRUB_UHCI_REG_PORTSC_RESET
+    | GRUB_UHCI_REG_PORTSC_SUSPEND
+  };
+
 
 /* UHCI Queue Head.  */
 struct grub_uhci_qh
@@ -693,7 +705,7 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
       return grub_error (GRUB_ERR_IO, "UHCI Timed out");
 
   /* Reset bit Connect Status Change */
-  grub_uhci_writereg16 (u, reg, status | (1 << 1));
+  grub_uhci_writereg16 (u, reg, status | GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED);
 
   /* Read final port status */
   status = grub_uhci_readreg16 (u, reg);
@@ -725,7 +737,15 @@ grub_uhci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
   grub_dprintf ("uhci", "detect=0x%02x port=%d\n", status, port);
 
   /* Connect Status Change bit - it detects change of connection */
-  *changed = ((status & (1 << 1)) != 0);
+  if (status & (1 << 1))
+    {
+      *changed = 1;
+      /* Reset bit Connect Status Change */
+      grub_uhci_writereg16 (u, reg, (status & GRUB_UHCI_REG_PORTSC_RW)
+                           | GRUB_UHCI_REG_PORTSC_CONNECT_CHANGED);
+    }
+  else
+    *changed = 0;
     
   if (! (status & 1))
     return GRUB_USB_SPEED_NONE;