blob: 1f1023ef42136e727078b7714e4a823eae5a5671 [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
11#include <common.h>
12
13struct mtmips_pmx_func {
14 const char *name;
15 int value;
16};
17
18struct mtmips_pmx_group {
19 const char *name;
20
21 u32 reg;
22 u32 shift;
23 char mask;
24
developer6d1a6302022-05-20 11:22:49 +080025 int pconf_avail;
26 u32 pconf_reg;
27 u32 pconf_shift;
28
developere1947812019-09-25 17:45:26 +080029 int nfuncs;
30 const struct mtmips_pmx_func *funcs;
31};
32
33struct 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
developer6d1a6302022-05-20 11:22:49 +080049#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
54void mtmips_pinctrl_reg_set(struct mtmips_pinctrl_priv *priv,
55 u32 reg, u32 shift, u32 mask, u32 value);
56
developere1947812019-09-25 17:45:26 +080057int mtmips_get_functions_count(struct udevice *dev);
58const char *mtmips_get_function_name(struct udevice *dev,
59 unsigned int selector);
60int mtmips_pinmux_group_set(struct udevice *dev, unsigned int group_selector,
61 unsigned int func_selector);
62int mtmips_pinctrl_probe(struct mtmips_pinctrl_priv *priv, u32 ngroups,
63 const struct mtmips_pmx_group *groups);
64
65#endif /* _PINCTRL_MTMIPS_COMMON_H_ */