xref: /linux/drivers/pinctrl/nuvoton/pinctrl-ma35.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1*f805e356SJacky Huang /* SPDX-License-Identifier: GPL-2.0 */
2*f805e356SJacky Huang /*
3*f805e356SJacky Huang  * Copyright (C) 2024 Nuvoton Technology Corp.
4*f805e356SJacky Huang  *
5*f805e356SJacky Huang  * Author: Shan-Chun Hung <schung@nuvoton.com>
6*f805e356SJacky Huang  * *       Jacky Huang <ychuang3@nuvoton.com>
7*f805e356SJacky Huang  */
8*f805e356SJacky Huang #ifndef __PINCTRL_MA35_H
9*f805e356SJacky Huang #define __PINCTRL_MA35_H
10*f805e356SJacky Huang 
11*f805e356SJacky Huang #include <linux/pinctrl/pinconf-generic.h>
12*f805e356SJacky Huang #include <linux/pinctrl/pinmux.h>
13*f805e356SJacky Huang #include <linux/platform_device.h>
14*f805e356SJacky Huang 
15*f805e356SJacky Huang struct ma35_mux_desc {
16*f805e356SJacky Huang 	const char *name;
17*f805e356SJacky Huang 	u32 muxval;
18*f805e356SJacky Huang };
19*f805e356SJacky Huang 
20*f805e356SJacky Huang struct ma35_pin_data {
21*f805e356SJacky Huang 	u32 offset;
22*f805e356SJacky Huang 	u32 shift;
23*f805e356SJacky Huang 	struct ma35_mux_desc *muxes;
24*f805e356SJacky Huang };
25*f805e356SJacky Huang 
26*f805e356SJacky Huang struct ma35_pinctrl_soc_info {
27*f805e356SJacky Huang 	const struct pinctrl_pin_desc *pins;
28*f805e356SJacky Huang 	unsigned int npins;
29*f805e356SJacky Huang 	int (*get_pin_num)(int offset, int shift);
30*f805e356SJacky Huang };
31*f805e356SJacky Huang 
32*f805e356SJacky Huang #define MA35_PIN(num, n, o, s, ...) {			\
33*f805e356SJacky Huang 	.number = num,					\
34*f805e356SJacky Huang 	.name = #n,					\
35*f805e356SJacky Huang 	.drv_data = &(struct ma35_pin_data) {		\
36*f805e356SJacky Huang 		.offset = o,				\
37*f805e356SJacky Huang 		.shift = s,				\
38*f805e356SJacky Huang 		.muxes = (struct ma35_mux_desc[]) {	\
39*f805e356SJacky Huang 			 __VA_ARGS__, { } },		\
40*f805e356SJacky Huang 	},						\
41*f805e356SJacky Huang }
42*f805e356SJacky Huang 
43*f805e356SJacky Huang #define MA35_MUX(_val, _name) {				\
44*f805e356SJacky Huang 	.name = _name,					\
45*f805e356SJacky Huang 	.muxval = _val,					\
46*f805e356SJacky Huang }
47*f805e356SJacky Huang 
48*f805e356SJacky Huang int ma35_pinctrl_probe(struct platform_device *pdev, const struct ma35_pinctrl_soc_info *info);
49*f805e356SJacky Huang int ma35_pinctrl_suspend(struct device *dev);
50*f805e356SJacky Huang int ma35_pinctrl_resume(struct device *dev);
51*f805e356SJacky Huang 
52*f805e356SJacky Huang #endif /* __PINCTRL_MA35_H */
53