Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) Maxime Coquelin 2015
0004  * Copyright (C) STMicroelectronics 2017
0005  * Author:  Maxime Coquelin <mcoquelin.stm32@gmail.com>
0006  */
0007 #ifndef __PINCTRL_STM32_H
0008 #define __PINCTRL_STM32_H
0009 
0010 #include <linux/pinctrl/pinctrl.h>
0011 #include <linux/pinctrl/pinconf-generic.h>
0012 
0013 #define STM32_PIN_NO(x) ((x) << 8)
0014 #define STM32_GET_PIN_NO(x) ((x) >> 8)
0015 #define STM32_GET_PIN_FUNC(x) ((x) & 0xff)
0016 
0017 #define STM32_PIN_GPIO      0
0018 #define STM32_PIN_AF(x)     ((x) + 1)
0019 #define STM32_PIN_ANALOG    (STM32_PIN_AF(15) + 1)
0020 #define STM32_CONFIG_NUM    (STM32_PIN_ANALOG + 1)
0021 
0022 /*  package information */
0023 #define STM32MP_PKG_AA      BIT(0)
0024 #define STM32MP_PKG_AB      BIT(1)
0025 #define STM32MP_PKG_AC      BIT(2)
0026 #define STM32MP_PKG_AD      BIT(3)
0027 
0028 struct stm32_desc_function {
0029     const char *name;
0030     const unsigned char num;
0031 };
0032 
0033 struct stm32_desc_pin {
0034     struct pinctrl_pin_desc pin;
0035     const struct stm32_desc_function functions[STM32_CONFIG_NUM];
0036     const unsigned int pkg;
0037 };
0038 
0039 #define STM32_PIN(_pin, ...)                    \
0040     {                           \
0041         .pin = _pin,                    \
0042         .functions = {  \
0043             __VA_ARGS__},           \
0044     }
0045 
0046 #define STM32_PIN_PKG(_pin, _pkg, ...)                  \
0047     {                           \
0048         .pin = _pin,                    \
0049         .pkg  = _pkg,               \
0050         .functions = {  \
0051             __VA_ARGS__},           \
0052     }
0053 #define STM32_FUNCTION(_num, _name)     \
0054     [_num] = {                      \
0055         .num = _num,                    \
0056         .name = _name,                  \
0057     }
0058 
0059 struct stm32_pinctrl_match_data {
0060     const struct stm32_desc_pin *pins;
0061     const unsigned int npins;
0062     bool secure_control;
0063 };
0064 
0065 struct stm32_gpio_bank;
0066 
0067 int stm32_pctl_probe(struct platform_device *pdev);
0068 void stm32_pmx_get_mode(struct stm32_gpio_bank *bank,
0069             int pin, u32 *mode, u32 *alt);
0070 int stm32_pinctrl_suspend(struct device *dev);
0071 int stm32_pinctrl_resume(struct device *dev);
0072 
0073 #endif /* __PINCTRL_STM32_H */
0074