blob: 35ebc94c01e4e7e9bd4fd463ed3c168979acbafc [file] [log] [blame]
Maxime Coquelinaceb16d2016-01-14 13:16:30 +01001/*
2 * Copyright (C) Maxime Coquelin 2015
3 * Author: Maxime Coquelin <mcoquelin.stm32@gmail.com>
4 * License terms: GNU General Public License (GPL), version 2
5 */
6#ifndef __PINCTRL_STM32_H
7#define __PINCTRL_STM32_H
8
9#include <linux/pinctrl/pinctrl.h>
10#include <linux/pinctrl/pinconf-generic.h>
11
Maxime Coquelin38a3fbf2016-02-08 18:57:38 +010012#define STM32_PIN_NO(x) ((x) << 8)
13#define STM32_GET_PIN_NO(x) ((x) >> 8)
14#define STM32_GET_PIN_FUNC(x) ((x) & 0xff)
15
16#define STM32_PIN_GPIO 0
17#define STM32_PIN_AF(x) ((x) + 1)
18#define STM32_PIN_ANALOG (STM32_PIN_AF(15) + 1)
19
Maxime Coquelinaceb16d2016-01-14 13:16:30 +010020struct stm32_desc_function {
21 const char *name;
22 const unsigned char num;
23};
24
25struct stm32_desc_pin {
26 struct pinctrl_pin_desc pin;
27 const struct stm32_desc_function *functions;
28};
29
30#define STM32_PIN(_pin, ...) \
31 { \
32 .pin = _pin, \
33 .functions = (struct stm32_desc_function[]){ \
34 __VA_ARGS__, { } }, \
35 }
36
37#define STM32_FUNCTION(_num, _name) \
38 { \
39 .num = _num, \
40 .name = _name, \
41 }
42
43struct stm32_pinctrl_match_data {
44 const struct stm32_desc_pin *pins;
45 const unsigned int npins;
46};
47
48int stm32_pctl_probe(struct platform_device *pdev);
49
50#endif /* __PINCTRL_STM32_H */
51