blob: 473a6238a27bfa9c0c6c27e32425a51278abff63 [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
21struct stm32_desc_function {
22 const char *name;
23 const unsigned char num;
24};
25
26struct stm32_desc_pin {
27 struct pinctrl_pin_desc pin;
28 const struct stm32_desc_function *functions;
29};
30
31#define STM32_PIN(_pin, ...) \
32 { \
33 .pin = _pin, \
34 .functions = (struct stm32_desc_function[]){ \
35 __VA_ARGS__, { } }, \
36 }
37
38#define STM32_FUNCTION(_num, _name) \
39 { \
40 .num = _num, \
41 .name = _name, \
42 }
43
44struct stm32_pinctrl_match_data {
45 const struct stm32_desc_pin *pins;
46 const unsigned int npins;
47};
48
49struct stm32_gpio_bank;
50
51int stm32_pctl_probe(struct platform_device *pdev);
52void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
53 int pin, u32 *mode, u32 *alt);
54#endif /* __PINCTRL_STM32_H */
55