blob: ec0d34c339031c4d0c8a2b0e3342093533dc1be0 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) Maxime Coquelin 2015
4 * Copyright (C) STMicroelectronics 2017
5 * Author: Maxime Coquelin <mcoquelin.stm32@gmail.com>
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
David Brazdil0f672f62019-12-10 10:32:29 +000021/* package information */
22#define STM32MP_PKG_AA BIT(0)
23#define STM32MP_PKG_AB BIT(1)
24#define STM32MP_PKG_AC BIT(2)
25#define STM32MP_PKG_AD BIT(3)
26
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000027struct stm32_desc_function {
28 const char *name;
29 const unsigned char num;
30};
31
32struct stm32_desc_pin {
33 struct pinctrl_pin_desc pin;
34 const struct stm32_desc_function *functions;
David Brazdil0f672f62019-12-10 10:32:29 +000035 const unsigned int pkg;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000036};
37
38#define STM32_PIN(_pin, ...) \
39 { \
40 .pin = _pin, \
41 .functions = (struct stm32_desc_function[]){ \
42 __VA_ARGS__, { } }, \
43 }
44
David Brazdil0f672f62019-12-10 10:32:29 +000045#define STM32_PIN_PKG(_pin, _pkg, ...) \
46 { \
47 .pin = _pin, \
48 .pkg = _pkg, \
49 .functions = (struct stm32_desc_function[]){ \
50 __VA_ARGS__, { } }, \
51 }
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000052#define STM32_FUNCTION(_num, _name) \
53 { \
54 .num = _num, \
55 .name = _name, \
56 }
57
58struct stm32_pinctrl_match_data {
59 const struct stm32_desc_pin *pins;
60 const unsigned int npins;
61};
62
63struct stm32_gpio_bank;
64
65int stm32_pctl_probe(struct platform_device *pdev);
66void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
67 int pin, u32 *mode, u32 *alt);
David Brazdil0f672f62019-12-10 10:32:29 +000068int stm32_pinctrl_resume(struct device *dev);
69
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000070#endif /* __PINCTRL_STM32_H */
71