carl9170: Update based on commit 467556acea56f361a21b2a3761ca056b9da2d237 dated Nov...
[linux-libre-firmware.git] / carl9170fw / carlfw / src / gpio.c
1 /*
2  * carl9170 firmware - used by the ar9170 wireless device
3  *
4  * GPIO interrupt service
5  *
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-2011  Christian Lamparter <chunkeey@googlemail.com>
10  *
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.
15  *
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.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; If not, see <http://www.gnu.org/licenses/>.
23  */
24
25 #include "carl9170.h"
26 #include "gpio.h"
27
28 #ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT
29 void gpio_timer(void)
30 {
31         uint32_t cur;
32
33         cur = get(AR9170_GPIO_REG_PORT_DATA) & CARL9170_GPIO_MASK;
34
35         if (cur != fw.cached_gpio_state.gpio) {
36                 fw.cached_gpio_state.gpio = cur;
37
38                 send_cmd_to_host(sizeof(struct carl9170_gpio),
39                                  CARL9170_RSP_GPIO, 0x00,
40                                  (uint8_t *)&fw.cached_gpio_state);
41
42 # ifdef CONFIG_CARL9170FW_WATCHDOG_BUTTON
43                 for (;;) {
44                         /*
45                          * Loop forever... Until the watchdog triggers.
46                          */
47                 }
48 # endif /* CONFIG_CARL9170FW_WATCHDOG_BUTTON */
49         }
50 }
51 #endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */