iPXE
ath5k_gpio.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
4 *
5 * Lightly modified for iPXE, July 2009, by Joshua Oreman <oremanj@rwcr.net>.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
22FILE_SECBOOT ( FORBIDDEN );
23
24/****************\
25 GPIO Functions
26\****************/
27
28#include "ath5k.h"
29#include "reg.h"
30#include "base.h"
31
32/*
33 * Set GPIO inputs
34 */
46
47/*
48 * Set GPIO outputs
49 */
61
62/*
63 * Get GPIO state
64 */
66{
67 if (gpio >= AR5K_NUM_GPIO)
68 return 0xffffffff;
69
70 /* GPIO input magic */
72 0x1;
73}
74
75/*
76 * Set GPIO state
77 */
79{
80 u32 data;
81
82 if (gpio >= AR5K_NUM_GPIO)
83 return -EINVAL;
84
85 /* GPIO output magic */
87
88 data &= ~(1 << gpio);
89 data |= (val & 1) << gpio;
90
92
93 return 0;
94}
95
96/*
97 * Initialize the GPIO interrupt (RFKill switch)
98 */
99void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
100 u32 interrupt_level)
101{
102 u32 data;
103
104 if (gpio >= AR5K_NUM_GPIO)
105 return;
106
107 /*
108 * Set the GPIO interrupt
109 */
114
115 ath5k_hw_reg_write(ah, interrupt_level ? data :
117
118 ah->ah_imr |= AR5K_IMR_GPIO;
119
120 /* Enable GPIO interrupts */
122}
123
#define AR5K_GPIOCR_OUT(n)
Definition reg.h:937
#define AR5K_GPIOCR_INT_SEL(n)
Definition reg.h:938
#define AR5K_GPIODI_M
Definition reg.h:949
#define AR5K_GPIOCR_INT_SELH
Definition reg.h:933
#define AR5K_GPIODO
Definition reg.h:943
#define AR5K_NUM_GPIO
Definition reg.h:928
#define AR5K_GPIOCR_IN(n)
Definition reg.h:934
#define AR5K_GPIOCR
Definition reg.h:930
#define AR5K_IMR_GPIO
Definition reg.h:410
#define AR5K_PIMR
Definition reg.h:381
#define AR5K_GPIODI
Definition reg.h:948
#define AR5K_GPIOCR_INT_ENA
Definition reg.h:931
#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)
Definition ath5k.h:106
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition ath5k.h:1216
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition ath5k.h:1224
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
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
void __asmcall int val
Definition setjmp.h:12
uint8_t ah
Definition registers.h:1
ath5k_hw_get_isr - Get interrupt status
Definition ath5k.h:955
A GPIO pin.
Definition gpio.h:18
#define u32
Definition vga.h:21