developer | e194781 | 2019-09-25 17:45:26 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2019 MediaTek Inc. All Rights Reserved. |
| 4 | * |
| 5 | * Author: Weijie Gao <weijie.gao@mediatek.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _PINCTRL_MTMIPS_COMMON_H_ |
| 9 | #define _PINCTRL_MTMIPS_COMMON_H_ |
| 10 | |
| 11 | #include <common.h> |
| 12 | |
| 13 | struct mtmips_pmx_func { |
| 14 | const char *name; |
| 15 | int value; |
| 16 | }; |
| 17 | |
| 18 | struct mtmips_pmx_group { |
| 19 | const char *name; |
| 20 | |
| 21 | u32 reg; |
| 22 | u32 shift; |
| 23 | char mask; |
| 24 | |
developer | 6d1a630 | 2022-05-20 11:22:49 +0800 | [diff] [blame] | 25 | int pconf_avail; |
| 26 | u32 pconf_reg; |
| 27 | u32 pconf_shift; |
| 28 | |
developer | e194781 | 2019-09-25 17:45:26 +0800 | [diff] [blame] | 29 | int nfuncs; |
| 30 | const struct mtmips_pmx_func *funcs; |
| 31 | }; |
| 32 | |
| 33 | struct mtmips_pinctrl_priv { |
| 34 | void __iomem *base; |
| 35 | |
| 36 | u32 ngroups; |
| 37 | const struct mtmips_pmx_group *groups; |
| 38 | |
| 39 | u32 nfuncs; |
| 40 | const struct mtmips_pmx_func **funcs; |
| 41 | }; |
| 42 | |
| 43 | #define FUNC(name, value) { name, value } |
| 44 | |
| 45 | #define GRP(_name, _funcs, _reg, _shift, _mask) \ |
| 46 | { .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \ |
| 47 | .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs) } |
| 48 | |
developer | 6d1a630 | 2022-05-20 11:22:49 +0800 | [diff] [blame] | 49 | #define GRP_PCONF(_name, _funcs, _reg, _shift, _mask, _pconf_reg, _pconf_shift) \ |
| 50 | { .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \ |
| 51 | .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs), .pconf_avail = 1, \ |
| 52 | .pconf_reg = (_pconf_reg), .pconf_shift = (_pconf_shift) } |
| 53 | |
| 54 | void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv, |
| 55 | u32 reg, u32 shift, u32 mask, u32 value); |
| 56 | |
developer | e194781 | 2019-09-25 17:45:26 +0800 | [diff] [blame] | 57 | int mtmips_get_functions_count(struct udevice *dev); |
| 58 | const char *mtmips_get_function_name(struct udevice *dev, |
| 59 | unsigned int selector); |
| 60 | int mtmips_pinmux_group_set(struct udevice *dev, unsigned int group_selector, |
| 61 | unsigned int func_selector); |
| 62 | int mtmips_pinctrl_probe(struct mtmips_pinctrl_priv *priv, u32 ngroups, |
| 63 | const struct mtmips_pmx_group *groups); |
| 64 | |
| 65 | #endif /* _PINCTRL_MTMIPS_COMMON_H_ */ |