1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ 2 /* 3 * Copyright (C) 2022 Microchip 4 */ 5 6 #ifndef _DT_BINDINGS_GPIO_ATMEL_PIOBU_H 7 #define _DT_BINDINGS_GPIO_ATMEL_PIOBU_H 8 9 #define PIOBU_PIN_AFV_SHIFT 0 10 #define PIOBU_PIN_AFV_MASK 0xF 11 #define PIOBU_PIN_AFV(val) (((val) & PIOBU_PIN_AFV_MASK) >> \ 12 PIOBU_PIN_AFV_SHIFT) 13 14 #define PIOBU_PIN_RFV_SHIFT 4 15 #define PIOBU_PIN_RFV_MASK 0xF0 16 #define PIOBU_PIN_RFV(val) (((val) & PIOBU_PIN_RFV_MASK) >> \ 17 PIOBU_PIN_RFV_SHIFT) 18 19 #define PIOBU_PIN_PULL_MODE_SHIFT 8 20 #define PIOBU_PIN_PULL_MODE_MASK (0x3 << PIOBU_PIN_PULL_MODE_SHIFT) 21 #define PIOBU_PIN_PULL_MODE(val) (((val) & PIOBU_PIN_PULL_MODE_MASK) >> \ 22 PIOBU_PIN_PULL_MODE_SHIFT) 23 #define PIOBU_PIN_PULL_NONE 0 24 #define PIOBU_PIN_PULL_UP 1 25 #define PIOBU_PIN_PULL_DOWN 2 26 27 #define PIOBU_PIN_DEF_LEVEL_SHIFT 10 28 #define PIOBU_PIN_DEF_LEVEL_MASK (BIT(PIOBU_PIN_DEF_LEVEL_SHIFT)) 29 #define PIOBU_PIN_DEF_LEVEL(val) (((val) & PIOBU_PIN_DEF_LEVEL_MASK) >> \ 30 PIOBU_PIN_DEF_LEVEL_SHIFT) 31 #define PIOBU_PIN_DEF_LEVEL_LOW 0 32 #define PIOBU_PIN_DEF_LEVEL_HIGH 1 33 34 #define PIOBU_PIN_WAKEUP_SHIFT 11 35 #define PIOBU_PIN_WAKEUP_MASK (BIT(PIOBU_PIN_WAKEUP_SHIFT)) 36 #define PIOBU_PIN_WAKEUP(val) (((val) & PIOBU_PIN_WAKEUP_MASK) >> \ 37 PIOBU_PIN_WAKEUP_SHIFT) 38 #define PIOBU_PIN_WAKEUP_DISABLE 0 39 #define PIOBU_PIN_WAKEUP_ENABLE 1 40 41 #define PIOBU_PIN_INPUT(afv, rfv, pull_mode, def_level, wakeup) \ 42 ((afv) | \ 43 ((rfv) << PIOBU_PIN_RFV_SHIFT) & PIOBU_PIN_RFV_MASK | \ 44 ((pull_mode) << PIOBU_PIN_PULL_MODE_SHIFT) & \ 45 PIOBU_PIN_PULL_MODE_MASK | \ 46 ((def_level) << PIOBU_PIN_DEF_LEVEL_SHIFT) & \ 47 PIOBU_PIN_DEF_LEVEL_MASK | \ 48 ((wakeup) << PIOBU_PIN_WAKEUP_SHIFT) & PIOBU_PIN_WAKEUP_MASK) 49 50 #endif /* _DT_BINDINGS_GPIO_ATMEL_PIOBU_H */ 51