iPXE
ath5k_rfkill.c
Go to the documentation of this file.
1/*
2 * RFKILL support for ath5k
3 *
4 * Copyright (c) 2009 Tobias Doerffel <tobias.doerffel@gmail.com>
5 * Lightly modified for iPXE, Sep 2008 by Joshua Oreman <oremanj@rwcr.net>
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer,
14 * without modification.
15 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
16 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
17 * redistribution must be conditioned upon including a substantially
18 * similar Disclaimer requirement for further binary redistribution.
19 * 3. Neither the names of the above-listed copyright holders nor the names
20 * of any contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * NO WARRANTY
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
29 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGES.
35 */
36
38FILE_SECBOOT ( FORBIDDEN );
39
40#include "base.h"
41
42
43static inline void ath5k_rfkill_disable(struct ath5k_softc *sc)
44{
45 DBG("ath5k: rfkill disable (gpio:%d polarity:%d)\n",
46 sc->rf_kill.gpio, sc->rf_kill.polarity);
49}
50
51
52static inline void ath5k_rfkill_enable(struct ath5k_softc *sc)
53{
54 DBG("ath5k: rfkill enable (gpio:%d polarity:%d)\n",
55 sc->rf_kill.gpio, sc->rf_kill.polarity);
58}
59
60static inline void ath5k_rfkill_set_intr(struct ath5k_softc *sc, int enable)
61{
62 struct ath5k_hw *ah = sc->ah;
63 u32 curval;
64
66 curval = ath5k_hw_get_gpio(ah, sc->rf_kill.gpio);
68 !!curval : !curval);
69}
70
71static int __unused
73{
74 /* configuring GPIO for input for some reason disables rfkill */
75 /*ath5k_hw_set_gpio_input(sc->ah, sc->rf_kill.gpio);*/
76 return (ath5k_hw_get_gpio(sc->ah, sc->rf_kill.gpio) ==
77 sc->rf_kill.polarity);
78}
79
80void
82{
83 struct ath5k_softc *sc = ah->ah_sc;
84
85 /* read rfkill GPIO configuration from EEPROM header */
86 sc->rf_kill.gpio = ah->ah_capabilities.cap_eeprom.ee_rfkill_pin;
87 sc->rf_kill.polarity = ah->ah_capabilities.cap_eeprom.ee_rfkill_pol;
88
90
91 /* enable interrupt for rfkill switch */
92 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
94}
95
96
97void
99{
100 struct ath5k_softc *sc = ah->ah_sc;
101
102 /* disable interrupt for rfkill switch */
103 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header))
105
106 /* enable RFKILL when stopping HW so Wifi LED is turned off */
108}
#define AR5K_EEPROM_HDR_RFKILL(_v)
Definition eeprom.h:75
u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio)
Definition ath5k_gpio.c:65
int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
Definition ath5k_gpio.c:35
int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val)
Definition ath5k_gpio.c:78
void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level)
Definition ath5k_gpio.c:99
int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio)
Definition ath5k_gpio.c:50
static void ath5k_rfkill_disable(struct ath5k_softc *sc)
void ath5k_rfkill_hw_stop(struct ath5k_hw *ah)
static void ath5k_rfkill_set_intr(struct ath5k_softc *sc, int enable)
static int __unused ath5k_is_rfkill_set(struct ath5k_softc *sc)
void ath5k_rfkill_hw_start(struct ath5k_hw *ah)
static void ath5k_rfkill_enable(struct ath5k_softc *sc)
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
uint8_t ah
Definition registers.h:1
ath5k_hw_get_isr - Get interrupt status
Definition ath5k.h:955
struct ath5k_hw * ah
Definition base.h:93
u16 gpio
Definition base.h:128
struct ath5k_softc::@344164377243325166301233055376377150275233304000 rf_kill
unsigned polarity
Definition base.h:129
#define u32
Definition vga.h:21