1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright 2021 NXP 4 * 5 * Helper Code for GPIO controller driver 6 * 7 */ 8 9 #ifndef __DRIVERS_LS_GPIO_H 10 #define __DRIVERS_LS_GPIO_H 11 12 #include <gpio.h> 13 #include <stdlib.h> 14 #include <tee_api_types.h> 15 16 /* supported ports for GPIO controller */ 17 #define MAX_GPIO_PINS 31 18 19 /* map register values to LE by subtracting pin number from MAX GPIO PINS */ 20 #define PIN_SHIFT(x) (1 << (MAX_GPIO_PINS - (x))) 21 22 /* gpio register offsets */ 23 #define GPIODIR 0x0 /* direction register */ 24 #define GPIOODR 0x4 /* open drain register */ 25 #define GPIODAT 0x8 /* data register */ 26 #define GPIOIER 0xc /* interrupt event register */ 27 #define GPIOIMR 0x10 /* interrupt mask register */ 28 #define GPIOICR 0x14 /* interrupt control register */ 29 #define GPIOIBE 0x18 /* input buffer enable register */ 30 31 /* 32 * struct ls_gpio_chip_data describes GPIO controller chip instance 33 * The structure contains below members: 34 * chip: generic GPIO chip handle. 35 * gpio_base: starting GPIO module base address managed by this GPIO 36 * controller. 37 * gpio_controller: GPIO controller to be used. 38 */ 39 struct ls_gpio_chip_data { 40 struct gpio_chip chip; 41 vaddr_t gpio_base; 42 uint8_t gpio_controller; 43 }; 44 45 /* 46 * Initialize GPIO Controller 47 * gpio_data is a pointer of type 'struct ls_gpio_chip_data'. 48 */ 49 TEE_Result ls_gpio_init(struct ls_gpio_chip_data *gpio_data); 50 51 #endif /* __DRIVERS_LS_GPIO_H */ 52