projects
/
carl9170fw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
carl9170 firmware tools: show number of generated frames
[carl9170fw.git]
/
carlfw
/
usb
/
main.c
diff --git
a/carlfw/usb/main.c
b/carlfw/usb/main.c
index dc48bf2115a4537fb3477ade2a33e4a124f5850b..bd8428a0e39a2940f24daec3a9f8815e22bac445 100644
(file)
--- a/
carlfw/usb/main.c
+++ b/
carlfw/usb/main.c
@@
-27,6
+27,7
@@
#include "printf.h"
#include "timer.h"
#include "rom.h"
#include "printf.h"
#include "timer.h"
#include "rom.h"
+#include "wl.h"
#include "shared/phy.h"
#ifdef CONFIG_CARL9170FW_DEBUG_USB
#include "shared/phy.h"
#ifdef CONFIG_CARL9170FW_DEBUG_USB
@@
-244,7
+245,7
@@
static void turn_power_off(void)
AR9170_PWR_RESET_WLAN_MASK);
set(AR9170_PWR_REG_RESET, 0x0);
AR9170_PWR_RESET_WLAN_MASK);
set(AR9170_PWR_REG_RESET, 0x0);
-
clock_set(false, AHB_20_22MHZ
);
+
set(AR9170_PWR_REG_CLOCK_SEL, AHB_40MHZ_OSC
);
set(AR9170_PWR_REG_PLL_ADDAC, 0x5163); /* 0x502b; */
set(AR9170_PHY_REG_ADC_SERIAL_CTL, AR9170_PHY_ADC_SCTL_SEL_EXTERNAL_RADIO);
set(AR9170_PWR_REG_PLL_ADDAC, 0x5163); /* 0x502b; */
set(AR9170_PHY_REG_ADC_SERIAL_CTL, AR9170_PHY_ADC_SCTL_SEL_EXTERNAL_RADIO);
@@
-328,21
+329,22
@@
static void usb_handler(uint8_t usb_interrupt_level1)
if (usb_interrupt_level1 & BIT(0)) {
usb_interrupt_level2 = getb(AR9170_USB_REG_INTR_SOURCE_0);
if (usb_interrupt_level1 & BIT(0)) {
usb_interrupt_level2 = getb(AR9170_USB_REG_INTR_SOURCE_0);
- if (usb_interrupt_level2 &
BIT(0)
)
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_SETUP
)
usb_ep0setup();
usb_ep0setup();
- if (usb_interrupt_level2 &
BIT(1)
)
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_IN
)
usb_ep0tx();
usb_ep0tx();
- if (usb_interrupt_level2 &
BIT(2)
)
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_OUT
)
usb_ep0rx();
usb_ep0rx();
- if (usb_interrupt_level2 &
BIT(7)
) {
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_ABORT
) {
/* Clear the command abort interrupt */
/* Clear the command abort interrupt */
- andb(AR9170_USB_REG_INTR_SOURCE_0, 0x7f);
+ andb(AR9170_USB_REG_INTR_SOURCE_0, (uint8_t)
+ ~AR9170_USB_INTR_SRC0_ABORT);
}
}
- if (usb_interrupt_level2 &
BIT(3)
||
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_FAIL
||
fw.usb.ep0_action & CARL9170_EP0_STALL) {
/*
* transmission failure.
fw.usb.ep0_action & CARL9170_EP0_STALL) {
/*
* transmission failure.
@@
-352,7
+354,7
@@
static void usb_handler(uint8_t usb_interrupt_level1)
fw.usb.ep0_action &= ~CARL9170_EP0_STALL;
}
fw.usb.ep0_action &= ~CARL9170_EP0_STALL;
}
- if (usb_interrupt_level2 &
BIT(4)
||
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC0_END
||
fw.usb.ep0_action & CARL9170_EP0_TRIGGER) {
/*
* transmission done.
fw.usb.ep0_action & CARL9170_EP0_TRIGGER) {
/*
* transmission done.
@@
-366,28
+368,38
@@
static void usb_handler(uint8_t usb_interrupt_level1)
if (usb_interrupt_level1 & BIT(7)) {
usb_interrupt_level2 = getb(AR9170_USB_REG_INTR_SOURCE_7);
if (usb_interrupt_level1 & BIT(7)) {
usb_interrupt_level2 = getb(AR9170_USB_REG_INTR_SOURCE_7);
- if (usb_interrupt_level2 &
BIT(7)
)
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC7_RX0BYTE
)
usb_data_out0Byte();
usb_data_out0Byte();
- if (usb_interrupt_level2 &
BIT(6)
)
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC7_TX0BYTE
)
usb_data_in0Byte();
usb_data_in0Byte();
- if (usb_interrupt_level2 &
BIT(1)
) {
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC7_USB_RESET
) {
usb_reset_ack();
reboot();
}
usb_reset_ack();
reboot();
}
- if (usb_interrupt_level2 &
BIT(2)
) {
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC7_USB_SUSPEND
) {
usb_suspend_ack();
usb_suspend_ack();
-
disable_watchdog()
;
+
fw.suspend_mode = CARL9170_HOST_SUSPENDED
;
- /* GO_TO_SUSPEND stops the CPU clock too. */
- orb(AR9170_USB_REG_MAIN_CTRL, AR9170_USB_MAIN_CTRL_GO_TO_SUSPEND);
+ if (!(fw.usb.device_feature & USB_DEVICE_REMOTE_WAKEUP)) {
+ disable_watchdog();
+
+ /* GO_TO_SUSPEND stops the CPU clock too. */
+ orb(AR9170_USB_REG_MAIN_CTRL, AR9170_USB_MAIN_CTRL_GO_TO_SUSPEND);
+ } else {
+ wlan_prepare_wol();
+ }
}
}
- if (usb_interrupt_level2 &
BIT(3)
) {
+ if (usb_interrupt_level2 &
AR9170_USB_INTR_SRC7_USB_RESUME
) {
usb_resume_ack();
usb_resume_ack();
+
+ fw.suspend_mode = CARL9170_HOST_AWAKE;
+ set(AR9170_USB_REG_WAKE_UP, 0);
+
reboot();
}
}
reboot();
}
}
@@
-406,3
+418,11
@@
void handle_usb(void)
usb_trigger_in();
}
usb_trigger_in();
}
+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 */
+}