2019-11-27 22:17:46 +05:30
/* SPDX-License-Identifier: GPL-2.0 */
2016-01-14 13:16:30 +01:00
/*
* Copyright ( C ) Maxime Coquelin 2015
2017-11-30 09:46:48 +01:00
* Copyright ( C ) STMicroelectronics 2017
2016-01-14 13:16:30 +01:00
* Author : Maxime Coquelin < mcoquelin . stm32 @ gmail . com >
*/
# ifndef __PINCTRL_STM32_H
# define __PINCTRL_STM32_H
# include <linux/pinctrl/pinctrl.h>
# include <linux/pinctrl/pinconf-generic.h>
2016-02-08 18:57:38 +01:00
# define STM32_PIN_NO(x) ((x) << 8)
# define STM32_GET_PIN_NO(x) ((x) >> 8)
# define STM32_GET_PIN_FUNC(x) ((x) & 0xff)
# define STM32_PIN_GPIO 0
# define STM32_PIN_AF(x) ((x) + 1)
# define STM32_PIN_ANALOG (STM32_PIN_AF(15) + 1)
2022-05-02 17:25:24 +02:00
# define STM32_CONFIG_NUM (STM32_PIN_ANALOG + 1)
2016-02-08 18:57:38 +01:00
2019-04-10 13:30:22 +02:00
/* package information */
# define STM32MP_PKG_AA BIT(0)
# define STM32MP_PKG_AB BIT(1)
# define STM32MP_PKG_AC BIT(2)
# define STM32MP_PKG_AD BIT(3)
2023-05-24 15:33:57 +02:00
# define STM32MP_PKG_AI BIT(8)
# define STM32MP_PKG_AK BIT(10)
# define STM32MP_PKG_AL BIT(11)
2019-04-10 13:30:22 +02:00
2016-01-14 13:16:30 +01:00
struct stm32_desc_function {
const char * name ;
const unsigned char num ;
} ;
struct stm32_desc_pin {
struct pinctrl_pin_desc pin ;
2022-05-02 17:25:24 +02:00
const struct stm32_desc_function functions [ STM32_CONFIG_NUM ] ;
2019-04-10 13:30:21 +02:00
const unsigned int pkg ;
2016-01-14 13:16:30 +01:00
} ;
# define STM32_PIN(_pin, ...) \
{ \
. pin = _pin , \
2022-05-02 17:25:24 +02:00
. functions = { \
__VA_ARGS__ } , \
2016-01-14 13:16:30 +01:00
}
2019-04-10 13:30:21 +02:00
# define STM32_PIN_PKG(_pin, _pkg, ...) \
{ \
. pin = _pin , \
. pkg = _pkg , \
2022-05-02 17:25:24 +02:00
. functions = { \
__VA_ARGS__ } , \
2019-04-10 13:30:21 +02:00
}
2016-01-14 13:16:30 +01:00
# define STM32_FUNCTION(_num, _name) \
2022-05-02 17:25:24 +02:00
[ _num ] = { \
2016-01-14 13:16:30 +01:00
. num = _num , \
. name = _name , \
}
struct stm32_pinctrl_match_data {
const struct stm32_desc_pin * pins ;
const unsigned int npins ;
2022-05-02 17:31:14 +02:00
bool secure_control ;
2016-01-14 13:16:30 +01:00
} ;
2017-05-29 18:17:32 +02:00
struct stm32_gpio_bank ;
2016-01-14 13:16:30 +01:00
2017-05-29 18:17:32 +02:00
int stm32_pctl_probe ( struct platform_device * pdev ) ;
void stm32_pmx_get_mode ( struct stm32_gpio_bank * bank ,
int pin , u32 * mode , u32 * alt ) ;
2022-04-22 16:36:08 +02:00
int stm32_pinctrl_suspend ( struct device * dev ) ;
2019-05-10 09:42:29 +02:00
int stm32_pinctrl_resume ( struct device * dev ) ;
2016-01-14 13:16:30 +01:00
# endif /* __PINCTRL_STM32_H */