1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Copyright (C) 2016 IBM Corp. 4 */ 5 6 #ifndef PINCTRL_ASPEED 7 #define PINCTRL_ASPEED 8 9 #include <linux/pinctrl/pinctrl.h> 10 #include <linux/pinctrl/pinmux.h> 11 #include <linux/pinctrl/pinconf.h> 12 #include <linux/pinctrl/pinconf-generic.h> 13 #include <linux/regmap.h> 14 15 #include "pinmux-aspeed.h" 16 17 /** 18 * @param The pinconf parameter type 19 * @pins The pin range this config struct covers, [low, high] 20 * @reg The register housing the configuration bits 21 * @mask The mask to select the bits of interest in @reg 22 */ 23 struct aspeed_pin_config { 24 enum pin_config_param param; 25 unsigned int pins[2]; 26 unsigned int reg; 27 u8 bit; 28 u8 value; 29 }; 30 31 #define ASPEED_PINCTRL_PIN(name_) \ 32 [name_] = { \ 33 .number = name_, \ 34 .name = #name_, \ 35 .drv_data = (void *) &(PIN_SYM(name_)) \ 36 } 37 38 struct aspeed_pinctrl_data { 39 struct regmap *scu; 40 41 const struct pinctrl_pin_desc *pins; 42 const unsigned int npins; 43 44 const struct aspeed_pin_config *configs; 45 const unsigned int nconfigs; 46 47 struct aspeed_pinmux_data pinmux; 48 }; 49 50 /* Aspeed pinctrl helpers */ 51 int aspeed_pinctrl_get_groups_count(struct pinctrl_dev *pctldev); 52 const char *aspeed_pinctrl_get_group_name(struct pinctrl_dev *pctldev, 53 unsigned int group); 54 int aspeed_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, 55 unsigned int group, const unsigned int **pins, 56 unsigned int *npins); 57 void aspeed_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev, 58 struct seq_file *s, unsigned int offset); 59 int aspeed_pinmux_get_fn_count(struct pinctrl_dev *pctldev); 60 const char *aspeed_pinmux_get_fn_name(struct pinctrl_dev *pctldev, 61 unsigned int function); 62 int aspeed_pinmux_get_fn_groups(struct pinctrl_dev *pctldev, 63 unsigned int function, const char * const **groups, 64 unsigned int * const num_groups); 65 int aspeed_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned int function, 66 unsigned int group); 67 int aspeed_gpio_request_enable(struct pinctrl_dev *pctldev, 68 struct pinctrl_gpio_range *range, 69 unsigned int offset); 70 int aspeed_pinctrl_probe(struct platform_device *pdev, 71 struct pinctrl_desc *pdesc, 72 struct aspeed_pinctrl_data *pdata); 73 int aspeed_pin_config_get(struct pinctrl_dev *pctldev, unsigned int offset, 74 unsigned long *config); 75 int aspeed_pin_config_set(struct pinctrl_dev *pctldev, unsigned int offset, 76 unsigned long *configs, unsigned int num_configs); 77 int aspeed_pin_config_group_get(struct pinctrl_dev *pctldev, 78 unsigned int selector, 79 unsigned long *config); 80 int aspeed_pin_config_group_set(struct pinctrl_dev *pctldev, 81 unsigned int selector, 82 unsigned long *configs, 83 unsigned int num_configs); 84 85 #endif /* PINCTRL_ASPEED */ 86