down_trigger();
}
+static void handle_fw(void)
+{
+ if (fw.watchdog_enable == 1)
+ set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER);
+
+ if (fw.reboot)
+ reboot();
+}
+
static void __attribute__((noreturn)) main_loop(void)
{
clock_set(true, AHB_40MHZ_OSC);
/* main loop */
while (1) {
- if (fw.watchdog_enable == 1)
- set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER);
+ handle_fw();
/*
* Due to frame order persevation, the wlan subroutines
#include "printf.h"
#include "timer.h"
#include "rom.h"
-#include "gpio.h"
#include "shared/phy.h"
#ifdef CONFIG_CARL9170FW_DEBUG_USB
usb_trigger_in();
}
-/* Reset all the USB FIFO used for WLAN */
-static void usb_reset_FIFO(void)
-{
- uint32_t val;
-
- /*
- * of course,
- * simpley ORing AR9170_MAC_POWER_STATE_CTRL_RESET
- * would be... I dunno, maybe: just to simple?
- */
-
- val = get(AR9170_MAC_REG_POWER_STATE_CTRL);
- val |= AR9170_MAC_POWER_STATE_CTRL_RESET;
- set(AR9170_MAC_REG_POWER_STATE_CTRL, val);
-
- /* Reset USB FIFO */
- set(AR9170_PWR_REG_ADDA_BB, AR9170_PWR_ADDA_BB_USB_FIFO_RESET);
- set(AR9170_PWR_REG_ADDA_BB, 0x0);
-}
-
/* Turn off ADDA/RF power, PLL */
static void turn_power_off(void)
{
set(AR9170_PHY_REG_ADC_CTL, 0xa0000000 |
AR9170_PHY_ADC_CTL_OFF_PWDADC | AR9170_PHY_ADC_CTL_OFF_PWDDAC);
+ /* This will also turn-off the LEDs */
set(AR9170_GPIO_REG_PORT_DATA, 0);
set(AR9170_GPIO_REG_PORT_TYPE, 0xf);
set(AR9170_PWR_REG_BASE, 0x40021);
- set(AR9170_PWR_REG_ADDA_BB, 0);
+
+ set(AR9170_MAC_REG_POWER_STATE_CTRL,
+ AR9170_MAC_POWER_STATE_CTRL_RESET);
+
+ /* Reset USB FIFO */
+ set(AR9170_PWR_REG_RESET, AR9170_PWR_RESET_COMMIT_RESET_MASK |
+ AR9170_PWR_RESET_DMA_MASK |
+ AR9170_PWR_RESET_WLAN_MASK);
+ set(AR9170_PWR_REG_RESET, 0x0);
clock_set(false, AHB_20_22MHZ);
void __attribute__((noreturn)) reboot(void)
{
- /* turn off leds */
- led_set(0);
-
/* write watchdog magic pattern for suspend */
andl(AR9170_PWR_REG_WATCH_DOG_MAGIC, 0xffff);
orl(AR9170_PWR_REG_WATCH_DOG_MAGIC, 0x98760000);
/* Disable watchdog */
orl(AR9170_TIMER_REG_WATCH_DOG, 0xffff);
- /* Reset USB FIFO */
- usb_reset_FIFO();
-
/* Turn off power */
turn_power_off();
#define AR9170_PWR_REG_POWER_STATE (AR9170_PWR_REG_BASE + 0x000)
-#define AR9170_PWR_REG_ADDA_BB (AR9170_PWR_REG_BASE + 0x004)
-#define AR9170_PWR_ADDA_BB_USB_FIFO_RESET 0x00000005
-#define AR9170_PWR_ADDA_BB_COLD_RESET 0x00000800
-#define AR9170_PWR_ADDA_BB_WARM_RESET 0x00000400
+#define AR9170_PWR_REG_RESET (AR9170_PWR_REG_BASE + 0x004)
+#define AR9170_PWR_RESET_COMMIT_RESET_MASK BIT(0)
+#define AR9170_PWR_RESET_WLAN_MASK BIT(1)
+#define AR9170_PWR_RESET_DMA_MASK BIT(2)
+#define AR9170_PWR_RESET_BRIDGE_MASK BIT(3)
+#define AR9170_PWR_RESET_AHB_MASK BIT(9)
+#define AR9170_PWR_RESET_BB_WARM_RESET BIT(10)
+#define AR9170_PWR_RESET_BB_COLD_RESET BIT(11)
+#define AR9170_PWR_RESET_ADDA_CLK_COLD_RESET BIT(12)
+#define AR9170_PWR_RESET_PLL BIT(13)
+#define AR9170_PWR_RESET_USB_PLL BIT(14)
#define AR9170_PWR_REG_CLOCK_SEL (AR9170_PWR_REG_BASE + 0x008)
#define AR9170_PWR_CLK_AHB_40MHZ 0