iPXE
Functions
ath5k_gpio.c File Reference
#include "ath5k.h"
#include "reg.h"
#include "base.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (MIT)
 
int ath5k_hw_set_gpio_input (struct ath5k_hw *ah, u32 gpio)
 
int ath5k_hw_set_gpio_output (struct ath5k_hw *ah, u32 gpio)
 
u32 ath5k_hw_get_gpio (struct ath5k_hw *ah, u32 gpio)
 
int ath5k_hw_set_gpio (struct ath5k_hw *ah, u32 gpio, u32 val)
 
void ath5k_hw_set_gpio_intr (struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level)
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( MIT  )

◆ ath5k_hw_set_gpio_input()

int ath5k_hw_set_gpio_input ( struct ath5k_hw ah,
u32  gpio 
)

Definition at line 34 of file ath5k_gpio.c.

35 {
36  if (gpio >= AR5K_NUM_GPIO)
37  return -EINVAL;
38 
42 
43  return 0;
44 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define AR5K_GPIOCR_IN(n)
Definition: reg.h:937
pseudo_bit_t gpio[0x00001]
Definition: arbel.h:30
#define AR5K_GPIOCR
Definition: reg.h:933
#define AR5K_NUM_GPIO
Definition: reg.h:931
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1222
#define AR5K_GPIOCR_OUT(n)
Definition: reg.h:940
uint8_t ah
Definition: registers.h:85
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1214

References ah, AR5K_GPIOCR, AR5K_GPIOCR_IN, AR5K_GPIOCR_OUT, AR5K_NUM_GPIO, ath5k_hw_reg_read(), ath5k_hw_reg_write(), EINVAL, and gpio.

Referenced by ath5k_hw_reset(), and ath5k_rfkill_set_intr().

◆ ath5k_hw_set_gpio_output()

int ath5k_hw_set_gpio_output ( struct ath5k_hw ah,
u32  gpio 
)

Definition at line 49 of file ath5k_gpio.c.

50 {
51  if (gpio >= AR5K_NUM_GPIO)
52  return -EINVAL;
53 
57 
58  return 0;
59 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
pseudo_bit_t gpio[0x00001]
Definition: arbel.h:30
#define AR5K_GPIOCR
Definition: reg.h:933
#define AR5K_NUM_GPIO
Definition: reg.h:931
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1222
#define AR5K_GPIOCR_OUT(n)
Definition: reg.h:940
uint8_t ah
Definition: registers.h:85
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1214

References ah, AR5K_GPIOCR, AR5K_GPIOCR_OUT, AR5K_NUM_GPIO, ath5k_hw_reg_read(), ath5k_hw_reg_write(), EINVAL, and gpio.

Referenced by ath5k_rfkill_disable(), and ath5k_rfkill_enable().

◆ ath5k_hw_get_gpio()

u32 ath5k_hw_get_gpio ( struct ath5k_hw ah,
u32  gpio 
)

Definition at line 64 of file ath5k_gpio.c.

65 {
66  if (gpio >= AR5K_NUM_GPIO)
67  return 0xffffffff;
68 
69  /* GPIO input magic */
71  0x1;
72 }
#define AR5K_GPIODI_M
Definition: reg.h:952
pseudo_bit_t gpio[0x00001]
Definition: arbel.h:30
#define AR5K_NUM_GPIO
Definition: reg.h:931
#define AR5K_GPIODI
Definition: reg.h:951
uint8_t ah
Definition: registers.h:85
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1214

References ah, AR5K_GPIODI, AR5K_GPIODI_M, AR5K_NUM_GPIO, ath5k_hw_reg_read(), and gpio.

Referenced by ath5k_hw_reset(), ath5k_is_rfkill_set(), and ath5k_rfkill_set_intr().

◆ ath5k_hw_set_gpio()

int ath5k_hw_set_gpio ( struct ath5k_hw ah,
u32  gpio,
u32  val 
)

Definition at line 77 of file ath5k_gpio.c.

78 {
79  u32 data;
80 
81  if (gpio >= AR5K_NUM_GPIO)
82  return -EINVAL;
83 
84  /* GPIO output magic */
86 
87  data &= ~(1 << gpio);
88  data |= (val & 1) << gpio;
89 
91 
92  return 0;
93 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define AR5K_GPIODO
Definition: reg.h:946
pseudo_bit_t gpio[0x00001]
Definition: arbel.h:30
#define AR5K_NUM_GPIO
Definition: reg.h:931
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1222
void __asmcall int val
Definition: setjmp.h:28
uint8_t ah
Definition: registers.h:85
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1214
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint32_t u32
Definition: stdint.h:23

References ah, AR5K_GPIODO, AR5K_NUM_GPIO, ath5k_hw_reg_read(), ath5k_hw_reg_write(), data, EINVAL, gpio, and val.

Referenced by ath5k_rfkill_disable(), and ath5k_rfkill_enable().

◆ ath5k_hw_set_gpio_intr()

void ath5k_hw_set_gpio_intr ( struct ath5k_hw ah,
unsigned int  gpio,
u32  interrupt_level 
)

Definition at line 98 of file ath5k_gpio.c.

100 {
101  u32 data;
102 
103  if (gpio >= AR5K_NUM_GPIO)
104  return;
105 
106  /*
107  * Set the GPIO interrupt
108  */
113 
114  ath5k_hw_reg_write(ah, interrupt_level ? data :
116 
117  ah->ah_imr |= AR5K_IMR_GPIO;
118 
119  /* Enable GPIO interrupts */
121 }
#define AR5K_GPIOCR_INT_ENA
Definition: reg.h:934
#define AR5K_IMR_GPIO
Definition: reg.h:410
#define AR5K_GPIOCR_INT_SEL(n)
Definition: reg.h:941
pseudo_bit_t gpio[0x00001]
Definition: arbel.h:30
#define AR5K_GPIOCR
Definition: reg.h:933
#define AR5K_PIMR
Definition: reg.h:380
#define AR5K_NUM_GPIO
Definition: reg.h:931
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1222
#define AR5K_GPIOCR_OUT(n)
Definition: reg.h:940
uint8_t ah
Definition: registers.h:85
#define AR5K_GPIOCR_INT_SELH
Definition: reg.h:936
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1214
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint32_t u32
Definition: stdint.h:23
#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)
Definition: ath5k.h:104

References ah, AR5K_GPIOCR, AR5K_GPIOCR_INT_ENA, AR5K_GPIOCR_INT_SEL, AR5K_GPIOCR_INT_SELH, AR5K_GPIOCR_OUT, AR5K_IMR_GPIO, AR5K_NUM_GPIO, AR5K_PIMR, AR5K_REG_ENABLE_BITS, ath5k_hw_reg_read(), ath5k_hw_reg_write(), data, and gpio.

Referenced by ath5k_hw_reset(), and ath5k_rfkill_set_intr().