Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/chr/carl9170fw
[carl9170fw.git] / carlfw / usb / main.c
index bd8428a0e39a2940f24daec3a9f8815e22bac445..649dc4bd9f797ce8d92671aac5b763ff816ebb14 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2000-2005 ZyDAS Technology Corporation
  * Copyright (c) 2007-2009 Atheros Communications, Inc.
  * Copyright   2009    Johannes Berg <johannes@sipsolutions.net>
- * Copyright   2009    Christian Lamparter <chunkeey@googlemail.com>
+ * Copyright 2009-2011 Christian Lamparter <chunkeey@googlemail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -384,7 +384,9 @@ static void usb_handler(uint8_t usb_interrupt_level1)
 
                        fw.suspend_mode = CARL9170_HOST_SUSPENDED;
 
-                       if (!(fw.usb.device_feature & USB_DEVICE_REMOTE_WAKEUP)) {
+#ifdef CONFIG_CARL9170FW_WOL
+                       if (!(fw.usb.device_feature & USB_DEVICE_REMOTE_WAKEUP) ||
+                           !fw.wlan.wol.cmd.flags) {
                                disable_watchdog();
 
                                /* GO_TO_SUSPEND stops the CPU clock too. */
@@ -392,6 +394,12 @@ static void usb_handler(uint8_t usb_interrupt_level1)
                        } else {
                                wlan_prepare_wol();
                        }
+#else /* CONFIG_CARL9170FW_WOL */
+                       disable_watchdog();
+
+                       /* GO_TO_SUSPEND stops the CPU clock too. */
+                       orb(AR9170_USB_REG_MAIN_CTRL, AR9170_USB_MAIN_CTRL_GO_TO_SUSPEND);
+#endif /* CONFIG_CARL9170FW_WOL */
                }
 
                if (usb_interrupt_level2 & AR9170_USB_INTR_SRC7_USB_RESUME) {
@@ -420,9 +428,4 @@ void handle_usb(void)
 
 void usb_timer(void)
 {
-#ifdef CONFIG_CARL9170FW_WOL
-       if (fw.suspend_mode == CARL9170_AWAKE_HOST) {
-               set(AR9170_USB_REG_WAKE_UP, AR9170_USB_WAKE_UP_WAKE);
-       }
-#endif /* CONFIG_CARL9170FW_WOL */
 }