1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2024 Yixun Lan <dlan@gentoo.org> */ 3 4 #ifndef _PINCTRL_SPACEMIT_K1_H 5 #define _PINCTRL_SPACEMIT_K1_H 6 7 #include <linux/bits.h> 8 #include <linux/bitfield.h> 9 #include <linux/device.h> 10 #include <linux/mutex.h> 11 #include <linux/spinlock.h> 12 #include <linux/platform_device.h> 13 #include <linux/pinctrl/pinctrl.h> 14 #include <linux/pinctrl/pinconf.h> 15 16 enum spacemit_pin_io_type { 17 IO_TYPE_NONE = 0, 18 IO_TYPE_1V8, 19 IO_TYPE_3V3, 20 IO_TYPE_EXTERNAL, 21 }; 22 23 #define PIN_POWER_STATE_1V8 1800 24 #define PIN_POWER_STATE_3V3 3300 25 26 #define K1_PIN_IO_TYPE GENMASK(2, 1) 27 28 #define K1_PIN_CAP_IO_TYPE(type) \ 29 FIELD_PREP_CONST(K1_PIN_IO_TYPE, type) 30 #define K1_PIN_GET_IO_TYPE(val) \ 31 FIELD_GET(K1_PIN_IO_TYPE, val) 32 33 #define K1_FUNC_PIN(_id, _gpiofunc, _io) \ 34 { \ 35 .pin = (_id), \ 36 .gpiofunc = (_gpiofunc), \ 37 .flags = (K1_PIN_CAP_IO_TYPE(_io)), \ 38 } 39 40 #endif /* _PINCTRL_SPACEMIT_K1_H */ 41