2 * carl9170 firmware - used by the ar9170 wireless device
4 * initialization and main() loop
6 * Copyright (c) 2000-2005 ZyDAS Technology Corporation
7 * Copyright (c) 2007-2009 Atheros Communications, Inc.
8 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
9 * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #define AR9170_WATCH_DOG_TIMER 0x100
35 static void init(void)
39 #ifdef CONFIG_CARL9170FW_DEBUG_UART
41 #endif /* CONFIG_CARL9170FW_DEBUG_UART */
43 /* 25/50/100ms timer (depends on cpu clock) */
46 /* turn off all leds */
50 dma_init_descriptors();
55 /* clear all interrupt */
56 set(AR9170_MAC_REG_INT_CTRL, 0xffff);
58 orl(AR9170_MAC_REG_AFTER_PNP, 1);
60 /* Init watch dog control flag */
61 #ifdef CONFIG_CARL9170FW_WATCHDOG
62 fw.watchdog_enable = 1;
64 set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER);
66 fw.watchdog_enable = 0;
67 set(AR9170_TIMER_REG_WATCH_DOG, 0xffff);
68 #endif /* CONFIG_CARL9170FW_WATCHDOG */
70 #ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
71 fw.cached_gpio_state.gpio = get(AR9170_GPIO_REG_PORT_DATA) &
73 #endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */
75 /* this will get the downqueue moving. */
79 static void __attribute__((noreturn)) main_loop(void)
81 clock_set(true, AHB_40MHZ_OSC);
85 if (fw.watchdog_enable == 1)
86 set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER);
89 * Due to frame order persevation, the wlan subroutines
90 * must be executed before handle_host_interface.
94 handle_host_interface();
105 * The bootcode will work with the device driver to load the firmware
106 * onto the device's Program SRAM. The Program SRAM has a size of 32 KB
107 * and also contains the stack, which grows down from 0x208000.
109 * The Program SRAM starts at address 0x200000 on the device.
110 * The firmware entry point (0x200004) is located in boot.S.
111 * we put _start() there with the linker script carl9170.lds.
114 void __attribute__((noreturn)) start(void)
116 /* initialize firmware context and DMA memory */
117 memset(&fw, 0, sizeof(fw));
118 memset(&dma_mem, 0, sizeof(dma_mem));
120 /* watchdog magic pattern check */
121 if ((get(AR9170_PWR_REG_WATCH_DOG_MAGIC) & 0xffff0000) == 0x12340000) {
122 /* watch dog warm start */
123 incl(AR9170_PWR_REG_WATCH_DOG_MAGIC);
125 } else if ((get(AR9170_PWR_REG_WATCH_DOG_MAGIC) & 0xffff0000) == 0x98760000) {
129 /* write the magic pattern for watch dog */
130 andl(AR9170_PWR_REG_WATCH_DOG_MAGIC, 0xFFFF);
131 orl(AR9170_PWR_REG_WATCH_DOG_MAGIC, 0x12340000);
135 #ifdef CONFIG_CARL9170FW_DEBUG
138 BUG_ON(0x2b || !0x2b);
139 INFO("INFO MESSAGE");
141 /* a set of unique characters to detect transfer data corruptions */
142 DBG("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
143 " ~`!1@2#3$4%%5^6&7*8(9)0_-+={[}]|\\:;\"'<,>.?/");
144 #endif /* CONFIG_CARL9170FW_DEBUG */