blob: 7a38f8d8753209becb538444ce97d023e145ec01 [file] [log] [blame]
developere1947812019-09-25 17:45:26 +08001/* 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
developere1947812019-09-25 17:45:26 +080011struct mtmips_pmx_func {
12 const char *name;
13 int value;
14};
15
16struct mtmips_pmx_group {
17 const char *name;
18
19 u32 reg;
20 u32 shift;
21 char mask;
22
developer6d1a6302022-05-20 11:22:49 +080023 int pconf_avail;
24 u32 pconf_reg;
25 u32 pconf_shift;
26
developere1947812019-09-25 17:45:26 +080027 int nfuncs;
28 const struct mtmips_pmx_func *funcs;
29};
30
31struct mtmips_pinctrl_priv {
32 void __iomem *base;
33
34 u32 ngroups;
35 const struct mtmips_pmx_group *groups;
36
37 u32 nfuncs;
38 const struct mtmips_pmx_func **funcs;
39};
40
41#define FUNC(name, value) { name, value }
42
43#define GRP(_name, _funcs, _reg, _shift, _mask) \
44 { .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \
45 .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs) }
46
developer6d1a6302022-05-20 11:22:49 +080047#define GRP_PCONF(_name, _funcs, _reg, _shift, _mask, _pconf_reg, _pconf_shift) \
48 { .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \
49 .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs), .pconf_avail = 1, \
50 .pconf_reg = (_pconf_reg), .pconf_shift = (_pconf_shift) }
51
52void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv,
53 u32 reg, u32 shift, u32 mask, u32 value);
54
developere1947812019-09-25 17:45:26 +080055int mtmips_get_functions_count(struct udevice *dev);
56const char *mtmips_get_function_name(struct udevice *dev,
57 unsigned int selector);
58int mtmips_pinmux_group_set(struct udevice *dev, unsigned int group_selector,
59 unsigned int func_selector);
60int mtmips_pinctrl_probe(struct mtmips_pinctrl_priv *priv, u32 ngroups,
61 const struct mtmips_pmx_group *groups);
62
63#endif /* _PINCTRL_MTMIPS_COMMON_H_ */