aboutsummaryrefslogtreecommitdiff
path: root/core/include/drivers/bcm_gpio.h
blob: 348592a0421e8961a9d909abb296094a15c883fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright 2019 Broadcom.
 */

#ifndef BCM_GPIO_H
#define BCM_GPIO_H

#include <gpio.h>
#include <stdlib.h>
#include <sys/queue.h>

/**
 * struct bcm_gpio_chip describes GPIO controller chip instance
 * @chip:       generic GPIO chip handle.
 * @gpio_base:  starting GPIO number managed by this GPIO controller.
 * @ngpios:     number of GPIOs managed by this GPIO controller.
 * @base:       virtual base address of the GPIO controller registers.
 */
struct bcm_gpio_chip {
	struct gpio_chip chip;
	unsigned int gpio_base;
	unsigned int ngpios;
	vaddr_t base;

	SLIST_ENTRY(bcm_gpio_chip) link;
};

/* returns bcm_gpio_chip handle for a GPIO pin */
struct bcm_gpio_chip *bcm_gpio_pin_to_chip(unsigned int pin);
#endif	/* BCM_GPIO_H */