blob: b51d8f009c03cf622e8c44241af8023fbd3690cd [file] [log] [blame]
Weijie Gao3fad4412019-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
25 int nfuncs;
26 const struct mtmips_pmx_func *funcs;
27};
28
29struct mtmips_pinctrl_priv {
30 void __iomem *base;
31
32 u32 ngroups;
33 const struct mtmips_pmx_group *groups;
34
35 u32 nfuncs;
36 const struct mtmips_pmx_func **funcs;
37};
38
39#define FUNC(name, value) { name, value }
40
41#define GRP(_name, _funcs, _reg, _shift, _mask) \
42 { .name = (_name), .reg = (_reg), .shift = (_shift), .mask = (_mask), \
43 .funcs = (_funcs), .nfuncs = ARRAY_SIZE(_funcs) }
44
45int mtmips_get_functions_count(struct udevice *dev);
46const char *mtmips_get_function_name(struct udevice *dev,
47 unsigned int selector);
48int mtmips_pinmux_group_set(struct udevice *dev, unsigned int group_selector,
49 unsigned int func_selector);
50int mtmips_pinctrl_probe(struct mtmips_pinctrl_priv *priv, u32 ngroups,
51 const struct mtmips_pmx_group *groups);
52
53#endif /* _PINCTRL_MTMIPS_COMMON_H_ */