1/* 2 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * 16 * Header file for GPIO utility functions. 17 * 18 * $Id: bcmgpio.h 281567 2011-09-02 18:05:39Z $ 19 */ 20#ifndef __bcmgpio_h__ 21#define __bcmgpio_h__ 22 23#include <bcmtimer.h> 24 25 26#define BCMGPIO_MAXPINS 32 27#define BCMGPIO_MAXINDEX (BCMGPIO_MAXPINS - 1) 28#define BCMGPIO_UNDEFINED -1 29 30/* GPIO type */ 31typedef enum bcmgpio_dirn { 32 BCMGPIO_DIRN_IN = 0, 33 BCMGPIO_DIRN_OUT 34} bcmgpio_dirn_t; 35 36/* GPIO strobe information */ 37typedef struct bcmgpio_strobe { 38 int duty_percent; /* duty cycle of strobe in percent of strobe period */ 39 bcm_timer_module_id timer_module; /* timer module ID obtained by 40 * calling bcm_timer_module_init() 41 */ 42 unsigned long strobe_period_in_ms; /* strobe period of the GPIO in milliseconds */ 43 unsigned long num_strobes; /* total number of strobes */ 44 int *strobe_done; /* pointer to memory which is used to signal strobe completion */ 45} bcmgpio_strobe_t; 46 47/* Functions to implement Buttons and LEDs on the AP, using GPIOs */ 48int bcmgpio_connect(int gpio_pin, bcmgpio_dirn_t gpio_dirn); 49int bcmgpio_disconnect(int gpio_pin); 50int bcmgpio_in(unsigned long gpio_mask, unsigned long *value); 51int bcmgpio_out(unsigned long gpio_mask, unsigned long value); 52int bcmgpio_strobe_start(int gpio_pin, bcmgpio_strobe_t *strobe_info); 53int bcmgpio_strobe_stop(int gpio_pin); 54int bcmgpio_getpin(char *pin_name, uint def_pin); 55 56#endif /* __bcmgpio_h__ */ 57