1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2019 Broadcom.
4  */
5 
6 #ifndef BCM_GPIO_H
7 #define BCM_GPIO_H
8 
9 #include <gpio.h>
10 #include <stdlib.h>
11 #include <sys/queue.h>
12 
13 /**
14  * struct bcm_gpio_chip describes GPIO controller chip instance
15  * @chip:       generic GPIO chip handle.
16  * @gpio_base:  starting GPIO number managed by this GPIO controller.
17  * @ngpios:     number of GPIOs managed by this GPIO controller.
18  * @base:       virtual base address of the GPIO controller registers.
19  */
20 struct bcm_gpio_chip {
21 	struct gpio_chip chip;
22 	unsigned int gpio_base;
23 	unsigned int ngpios;
24 	vaddr_t base;
25 
26 	SLIST_ENTRY(bcm_gpio_chip) link;
27 };
28 
29 /* Returns bcm_gpio_chip handle for a GPIO pin */
30 struct bcm_gpio_chip *bcm_gpio_pin_to_chip(unsigned int pin);
31 /* Set gpiopin as secure */
32 void iproc_gpio_set_secure(int gpiopin);
33 #endif	/* BCM_GPIO_H */
34