Debian Codegraph @

drivers/pinctrl/stm32/pinctrl-stm32.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) Maxime Coquelin 2015
4 * Copyright (C) STMicroelectronics 2017
5 * Author: Maxime Coquelin <[email protected]>
6 */
7 #ifndef __PINCTRL_STM32_H
8 #define __PINCTRL_STM32_H
9
10 #include <linux/pinctrl/pinctrl.h>
11 #include <linux/pinctrl/pinconf-generic.h>
12
13 #define STM32_PIN_NO(x) ((x) << 8)
14 #define STM32_GET_PIN_NO(x) ((x) >> 8)
15 #define STM32_GET_PIN_FUNC(x) ((x) & 0xff)
16
17 #define STM32_PIN_GPIO 0
18 #define STM32_PIN_AF(x) ((x) + 1)
19 #define STM32_PIN_ANALOG (STM32_PIN_AF(15) + 1)
20 #define STM32_PIN_RSVD (STM32_PIN_ANALOG + 1)
21 #define STM32_CONFIG_NUM (STM32_PIN_RSVD + 1)
22
23 /* package information */
24 #define STM32MP_PKG_AA BIT(0)
25 #define STM32MP_PKG_AB BIT(1)
26 #define STM32MP_PKG_AC BIT(2)
27 #define STM32MP_PKG_AD BIT(3)
28 #define STM32MP_PKG_AI BIT(8)
29 #define STM32MP_PKG_AK BIT(10)
30 #define STM32MP_PKG_AL BIT(11)
31
32 struct stm32_desc_function {
33 const char *name;
34 const unsigned char num;
35 };
36
37 struct stm32_desc_pin {
38 struct pinctrl_pin_desc pin;
39 const struct stm32_desc_function functions[STM32_CONFIG_NUM];
40 const unsigned int pkg;
41 };
42
43 #define STM32_PIN(_pin, ...) \
44 { \
45 .pin = _pin, \
46 .functions = { \
47 __VA_ARGS__}, \
48 }
49
50 #define STM32_PIN_PKG(_pin, _pkg, ...) \
51 { \
52 .pin = _pin, \
53 .pkg = _pkg, \
54 .functions = { \
55 __VA_ARGS__}, \
56 }
57 #define STM32_FUNCTION(_num, _name) \
58 [_num] = { \
59 .num = _num, \
60 .name = _name, \
61 }
62
63 struct stm32_pinctrl_match_data {
64 const struct stm32_desc_pin *pins;
65 const unsigned int npins;
66 bool secure_control;
67 bool io_sync_control;
68 bool rif_control;
69 };
70
71 /**
72 * stm32_pctl_probe() - Common probe for stm32 pinctrl drivers.
73 * @pdev: Pinctrl platform device.
74 */
75 int stm32_pctl_probe(struct platform_device *pdev);
76
77 /**
78 * stm32_pinctrl_suspend() - Common suspend for stm32 pinctrl drivers.
79 * @dev: Pinctrl device.
80 */
81 int stm32_pinctrl_suspend(struct device *dev);
82
83 /**
84 * stm32_pinctrl_resume() - Common resume for stm32 pinctrl drivers.
85 * @dev: Pinctrl device.
86 */
87 int stm32_pinctrl_resume(struct device *dev);
88
89 #endif /* __PINCTRL_STM32_H */
90