1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com>
4  */
5 
6 #ifndef _PINCTRL_SOPHGO_SG2042_H
7 #define _PINCTRL_SOPHGO_SG2042_H
8 
9 #include <linux/bits.h>
10 #include <linux/bitfield.h>
11 #include <linux/device.h>
12 #include <linux/mutex.h>
13 #include <linux/spinlock.h>
14 #include <linux/platform_device.h>
15 #include <linux/pinctrl/pinctrl.h>
16 #include <linux/pinctrl/pinconf.h>
17 
18 #include "pinctrl-sophgo.h"
19 
20 #define PIN_FLAG_DEFAULT			0
21 #define PIN_FLAG_WRITE_HIGH			BIT(0)
22 #define PIN_FLAG_ONLY_ONE_PULL			BIT(1)
23 #define PIN_FLAG_NO_PINMUX			BIT(2)
24 #define PIN_FLAG_NO_OEX_EN			BIT(3)
25 #define PIN_FLAG_IS_ETH				BIT(4)
26 
27 struct sg2042_pin {
28 	struct sophgo_pin		pin;
29 	u16				offset;
30 };
31 
32 #define sophgo_to_sg2042_pin(_pin)		\
33 	container_of((_pin), struct sg2042_pin, pin)
34 
35 extern const struct pinctrl_ops sg2042_pctrl_ops;
36 extern const struct pinmux_ops sg2042_pmx_ops;
37 extern const struct pinconf_ops sg2042_pconf_ops;
38 extern const struct sophgo_cfg_ops sg2042_cfg_ops;
39 
40 #define SG2042_GENERAL_PIN(_id,	_offset, _flag)				\
41 	{								\
42 		.pin = {						\
43 			.id = (_id),					\
44 			.flags = (_flag),				\
45 		},							\
46 		.offset = (_offset),					\
47 	}
48 
49 #endif
50