Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Maxim MAX96752F pin control driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2022 Rockchip Electronics Co. Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/pinctrl/pinctrl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/pinctrl/pinconf-generic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/pinctrl/pinconf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/pinctrl/pinmux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/mfd/max96752f.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "pinconf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include "pinmux.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct max96752f_pinctrl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct pinctrl_dev *pctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct config_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	u16 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u8 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u8 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct max96752f_group_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	const struct config_desc *configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int num_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) struct max96752f_function_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u8 gpio_out_dis:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	u8 gpio_tx_en:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	u8 gpio_rx_en:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	u8 gpio_tx_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u8 gpio_rx_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) static int max96752f_pinmux_set_mux(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 				    unsigned int function, unsigned int group)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct max96752f_pinctrl *mpctl = pinctrl_dev_get_drvdata(pctldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct function_desc *func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct group_desc *grp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	func = pinmux_generic_get_function(pctldev, function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (!func)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	grp = pinctrl_generic_get_group(pctldev, group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (!grp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (func->data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		struct max96752f_function_data *fdata = func->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		for (i = 0; i < grp->num_pins; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			regmap_update_bits(mpctl->regmap, GPIO_A_REG(grp->pins[i]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 					   GPIO_OUT_DIS | GPIO_RX_EN | GPIO_TX_EN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 					   FIELD_PREP(GPIO_OUT_DIS, fdata->gpio_out_dis) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 					   FIELD_PREP(GPIO_RX_EN, fdata->gpio_rx_en) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 					   FIELD_PREP(GPIO_TX_EN, fdata->gpio_tx_en));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			if (fdata->gpio_tx_en)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				regmap_update_bits(mpctl->regmap, GPIO_B_REG(grp->pins[i]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 						   GPIO_TX_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 						   FIELD_PREP(GPIO_TX_ID, fdata->gpio_tx_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			if (fdata->gpio_rx_en)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				regmap_update_bits(mpctl->regmap, GPIO_C_REG(grp->pins[i]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 						   GPIO_RX_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 						   FIELD_PREP(GPIO_RX_ID, fdata->gpio_rx_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (grp->data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		struct max96752f_group_data *gdata = grp->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		for (i = 0; i < gdata->num_configs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			const struct config_desc *config = &gdata->configs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			regmap_update_bits(mpctl->regmap, config->reg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 					   config->mask, config->val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	dev_info(mpctl->dev, "enable function %s group %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		 func->name, grp->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define PIN_CONFIG_OLDI_SPL_EN		(PIN_CONFIG_END + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define PIN_CONFIG_OLDI_SWAP_AB		(PIN_CONFIG_END + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static const struct pinconf_generic_params max96752f_custom_params[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	{ "oldi-spl-en", PIN_CONFIG_OLDI_SPL_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	{ "oldi-swap-ab", PIN_CONFIG_OLDI_SWAP_AB, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static const struct pin_config_item
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) max96752f_custom_conf_items[ARRAY_SIZE(max96752f_custom_params)] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	PCONFDUMP(PIN_CONFIG_OLDI_SPL_EN, "OLDI Splitter Enable", NULL, false),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	PCONFDUMP(PIN_CONFIG_OLDI_SWAP_AB, "Swaps OLDI ports A and B", NULL, false),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static int max96752f_pinconf_get(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 				 unsigned int pin, unsigned long *config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct max96752f_pinctrl *mpctl = pinctrl_dev_get_drvdata(pctldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	unsigned int param = pinconf_to_config_param(*config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	unsigned int gpio_a_reg, gpio_b_reg, oldi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	u16 arg = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	regmap_read(mpctl->regmap, GPIO_A_REG(pin), &gpio_a_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	regmap_read(mpctl->regmap, GPIO_B_REG(pin), &gpio_b_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (pin == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		regmap_read(mpctl->regmap, OLDI_REG(1), &oldi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	switch (param) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		if (FIELD_GET(OUT_TYPE, gpio_b_reg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	case PIN_CONFIG_DRIVE_PUSH_PULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		if (!FIELD_GET(OUT_TYPE, gpio_b_reg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	case PIN_CONFIG_BIAS_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		if (FIELD_GET(PULL_UPDN_SEL, gpio_b_reg) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	case PIN_CONFIG_BIAS_PULL_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		if (FIELD_GET(PULL_UPDN_SEL, gpio_b_reg) != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		switch (FIELD_GET(RES_CFG, gpio_a_reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			arg = 40000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			arg = 10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	case PIN_CONFIG_BIAS_PULL_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		if (FIELD_GET(PULL_UPDN_SEL, gpio_b_reg) != 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		switch (FIELD_GET(RES_CFG, gpio_a_reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			arg = 40000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			arg = 10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	case PIN_CONFIG_OUTPUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		if (FIELD_GET(GPIO_OUT_DIS, gpio_a_reg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		arg = FIELD_GET(GPIO_OUT, gpio_a_reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	case PIN_CONFIG_OLDI_SPL_EN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		if (pin > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		if (!FIELD_GET(OLDI_SPL_EN, oldi))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	case PIN_CONFIG_OLDI_SWAP_AB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		if (pin > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		if (!FIELD_GET(OLDI_SWAP_AB, oldi))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	*config = pinconf_to_config_packed(param, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static int max96752f_pinconf_set(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				 unsigned int pin, unsigned long *configs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				 unsigned int num_configs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	struct max96752f_pinctrl *mpctl = pinctrl_dev_get_drvdata(pctldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	unsigned int param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	u32 arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	u8 res_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	for (i = 0; i < num_configs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		param = pinconf_to_config_param(configs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		arg = pinconf_to_config_argument(configs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		switch (param) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			regmap_update_bits(mpctl->regmap, GPIO_B_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 					   OUT_TYPE, FIELD_PREP(OUT_TYPE, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		case PIN_CONFIG_DRIVE_PUSH_PULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			regmap_update_bits(mpctl->regmap, GPIO_B_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					   OUT_TYPE, FIELD_PREP(OUT_TYPE, 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		case PIN_CONFIG_BIAS_DISABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			regmap_update_bits(mpctl->regmap, GPIO_C_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					   PULL_UPDN_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					   FIELD_PREP(PULL_UPDN_SEL, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		case PIN_CONFIG_BIAS_PULL_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			switch (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			case 40000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				res_cfg = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			case 1000000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				res_cfg = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			regmap_update_bits(mpctl->regmap, GPIO_A_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					   RES_CFG, FIELD_PREP(RES_CFG, res_cfg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			regmap_update_bits(mpctl->regmap, GPIO_C_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 					   PULL_UPDN_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 					   FIELD_PREP(PULL_UPDN_SEL, 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		case PIN_CONFIG_BIAS_PULL_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			switch (arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			case 40000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 				res_cfg = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			case 1000000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				res_cfg = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			regmap_update_bits(mpctl->regmap, GPIO_A_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 					   RES_CFG, FIELD_PREP(RES_CFG, res_cfg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			regmap_update_bits(mpctl->regmap, GPIO_C_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 					   PULL_UPDN_SEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 					   FIELD_PREP(PULL_UPDN_SEL, 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		case PIN_CONFIG_OUTPUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			regmap_update_bits(mpctl->regmap, GPIO_A_REG(pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 					   GPIO_OUT_DIS | GPIO_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 					   FIELD_PREP(GPIO_OUT_DIS, 0) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 					   FIELD_PREP(GPIO_OUT, arg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		case PIN_CONFIG_OLDI_SPL_EN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			if (pin > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			regmap_update_bits(mpctl->regmap, OLDI_REG(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 					   OLDI_SPL_EN | OLDI_SPL_POL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 					   FIELD_PREP(OLDI_SPL_EN, 1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 					   FIELD_PREP(OLDI_SPL_POL, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		case PIN_CONFIG_OLDI_SWAP_AB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			if (pin > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 				return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			regmap_update_bits(mpctl->regmap, OLDI_REG(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 					   OLDI_SWAP_AB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 					   FIELD_PREP(OLDI_SWAP_AB, 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static const struct pinconf_ops max96752f_pinconf_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	.is_generic = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	.pin_config_get = max96752f_pinconf_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	.pin_config_set = max96752f_pinconf_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static const struct pinmux_ops max96752f_pinmux_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	.get_functions_count = pinmux_generic_get_function_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	.get_function_name = pinmux_generic_get_function_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	.get_function_groups = pinmux_generic_get_function_groups,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	.set_mux = max96752f_pinmux_set_mux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static const struct pinctrl_ops max96752f_pinctrl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	.get_groups_count = pinctrl_generic_get_group_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	.get_group_name = pinctrl_generic_get_group_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	.get_group_pins = pinctrl_generic_get_group_pins,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	.dt_free_map = pinconf_generic_dt_free_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static const struct pinctrl_pin_desc max96752f_pins_desc[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	PINCTRL_PIN(0, "oldi"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	PINCTRL_PIN(1, "gpio1"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	PINCTRL_PIN(2, "gpio2"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	PINCTRL_PIN(3, "gpio3"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	PINCTRL_PIN(4, "gpio4"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	PINCTRL_PIN(5, "gpio5"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	PINCTRL_PIN(6, "gpio6"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	PINCTRL_PIN(7, "gpio7"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	PINCTRL_PIN(8, "gpio8"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	PINCTRL_PIN(9, "gpio9"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	PINCTRL_PIN(10, "gpio10"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	PINCTRL_PIN(11, "gpio11"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	PINCTRL_PIN(12, "gpio12"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	PINCTRL_PIN(13, "gpio13"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	PINCTRL_PIN(14, "gpio14"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	PINCTRL_PIN(15, "gpio15"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static int oldi_pins[] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) static int gpio1_pins[] = {1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static int gpio2_pins[] = {2};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static int gpio3_pins[] = {3};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static int gpio4_pins[] = {4};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) static int gpio5_pins[] = {5};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) static int gpio6_pins[] = {6};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static int gpio7_pins[] = {7};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static int gpio8_pins[] = {8};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static int gpio9_pins[] = {9};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static int gpio10_pins[] = {10};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static int gpio11_pins[] = {11};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static int gpio12_pins[] = {12};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int gpio13_pins[] = {13};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static int gpio14_pins[] = {14};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static int gpio15_pins[] = {15};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) static int aud_rx_pins[] = {6, 7, 8};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static int aud_tx_pins[] = {11, 12, 13};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static int i2c_pins[] = {14, 15};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static int uart_pins[] = {14, 15};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) #define GROUP_DESC(nm) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	.name = #nm, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	.pins = nm ## _pins, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	.num_pins = ARRAY_SIZE(nm ## _pins), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) #define GROUP_DESC_CONFIG(nm) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	.name = #nm, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	.pins = nm ## _pins, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	.num_pins = ARRAY_SIZE(nm ## _pins), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	.data = (void *)(const struct max96752f_group_data []) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		{ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			.configs = nm ## _configs, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			.num_configs = ARRAY_SIZE(nm ## _configs), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	}, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) static const struct config_desc gpio6_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	{ 0x0001, IIC_2_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	{ 0x0002, AUD_TX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) static const struct config_desc gpio7_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	{ 0x0002, AUD_TX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static const struct config_desc gpio8_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	{ 0x0001, IIC_2_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	{ 0x0002, AUD_TX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) static const struct config_desc gpio11_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	{ 0x0140, AUD_RX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) static const struct config_desc gpio12_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	{ 0x0140, AUD_RX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) static const struct config_desc gpio13_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	{ 0x0140, AUD_RX_EN, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static const struct config_desc gpio14_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	{ 0x0002, DIS_LOCAL_CC, DIS_LOCAL_CC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) static const struct config_desc gpio15_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	{ 0x0002, DIS_LOCAL_CC, DIS_LOCAL_CC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) static const struct config_desc aud_tx_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	{ 0x0002, AUD_TX_EN, AUD_TX_EN },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) static const struct config_desc aud_rx_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	{ 0x0140, AUD_RX_EN, AUD_RX_EN },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static const struct config_desc i2c_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	{ 0x0002, DIS_LOCAL_CC, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	{ 0x0003, I2CSEL, I2CSEL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) static const struct config_desc uart_configs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	{ 0x0002, DIS_LOCAL_CC, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	{ 0x0003, I2CSEL, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) static const struct group_desc max96752f_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	GROUP_DESC(gpio1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	GROUP_DESC(gpio2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	GROUP_DESC(gpio3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	GROUP_DESC(gpio4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	GROUP_DESC(gpio5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	GROUP_DESC_CONFIG(gpio6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	GROUP_DESC_CONFIG(gpio7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	GROUP_DESC_CONFIG(gpio8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	GROUP_DESC(gpio9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	GROUP_DESC(gpio10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	GROUP_DESC_CONFIG(gpio11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	GROUP_DESC_CONFIG(gpio12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	GROUP_DESC_CONFIG(gpio13),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	GROUP_DESC_CONFIG(gpio14),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	GROUP_DESC_CONFIG(gpio15),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	GROUP_DESC_CONFIG(aud_rx),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	GROUP_DESC_CONFIG(aud_tx),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	GROUP_DESC_CONFIG(i2c),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	GROUP_DESC_CONFIG(uart),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	GROUP_DESC(oldi),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) static const char *gpio_groups[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	"reserved", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	"gpio6", "gpio7", "gpio8", "gpio9", "gpio10",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	"gpio11", "gpio12", "gpio13", "gpio14", "gpio15",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) static const char *aud_rx_groups[] = { "aud_rx" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static const char *aud_tx_groups[] = { "aud_tx" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static const char *i2c_groups[] = { "i2c" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static const char *uart_groups[] = { "uart" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static const char *oldi_groups[] = { "oldi" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) #define FUNCTION_DESC(fname, gname) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	.name = #fname, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	.group_names = gname##_groups, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	.num_group_names = ARRAY_SIZE(gname##_groups), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) #define FUNCTION_DESC_GPIO() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	.name = "GPIO", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	.group_names = gpio_groups, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	.num_group_names = ARRAY_SIZE(gpio_groups), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	.data = (void *)(const struct max96752f_function_data []) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		{ } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) #define FUNCTION_DESC_GPIO_RX(id) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	.name = "GPIO_RX_"#id, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	.group_names = gpio_groups, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	.num_group_names = ARRAY_SIZE(gpio_groups), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	.data = (void *)(const struct max96752f_function_data []) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		{ .gpio_rx_en = 1, .gpio_rx_id = id } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	}, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #define FUNCTION_DESC_GPIO_TX(id) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	.name = "GPIO_TX_"#id, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	.group_names = gpio_groups, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	.num_group_names = ARRAY_SIZE(gpio_groups), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	.data = (void *)(const struct max96752f_function_data []) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		{ .gpio_out_dis = 1, .gpio_tx_en = 1, .gpio_tx_id = id } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	}, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) static const struct function_desc max96752f_functions[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	FUNCTION_DESC_GPIO_TX(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	FUNCTION_DESC_GPIO_TX(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	FUNCTION_DESC_GPIO_TX(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	FUNCTION_DESC_GPIO_TX(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	FUNCTION_DESC_GPIO_TX(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	FUNCTION_DESC_GPIO_TX(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	FUNCTION_DESC_GPIO_TX(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	FUNCTION_DESC_GPIO_TX(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	FUNCTION_DESC_GPIO_TX(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	FUNCTION_DESC_GPIO_TX(9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	FUNCTION_DESC_GPIO_TX(10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	FUNCTION_DESC_GPIO_TX(11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	FUNCTION_DESC_GPIO_TX(12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	FUNCTION_DESC_GPIO_TX(13),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	FUNCTION_DESC_GPIO_TX(14),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	FUNCTION_DESC_GPIO_TX(15),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	FUNCTION_DESC_GPIO_TX(16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	FUNCTION_DESC_GPIO_TX(17),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	FUNCTION_DESC_GPIO_TX(18),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	FUNCTION_DESC_GPIO_TX(19),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	FUNCTION_DESC_GPIO_TX(20),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	FUNCTION_DESC_GPIO_TX(21),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	FUNCTION_DESC_GPIO_TX(22),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	FUNCTION_DESC_GPIO_TX(23),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	FUNCTION_DESC_GPIO_TX(24),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	FUNCTION_DESC_GPIO_TX(25),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	FUNCTION_DESC_GPIO_TX(26),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	FUNCTION_DESC_GPIO_TX(27),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	FUNCTION_DESC_GPIO_TX(28),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	FUNCTION_DESC_GPIO_TX(29),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	FUNCTION_DESC_GPIO_TX(30),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	FUNCTION_DESC_GPIO_TX(31),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	FUNCTION_DESC_GPIO_RX(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	FUNCTION_DESC_GPIO_RX(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	FUNCTION_DESC_GPIO_RX(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	FUNCTION_DESC_GPIO_RX(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	FUNCTION_DESC_GPIO_RX(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	FUNCTION_DESC_GPIO_RX(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	FUNCTION_DESC_GPIO_RX(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	FUNCTION_DESC_GPIO_RX(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	FUNCTION_DESC_GPIO_RX(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	FUNCTION_DESC_GPIO_RX(9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	FUNCTION_DESC_GPIO_RX(10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	FUNCTION_DESC_GPIO_RX(11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	FUNCTION_DESC_GPIO_RX(12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	FUNCTION_DESC_GPIO_RX(13),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	FUNCTION_DESC_GPIO_RX(14),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	FUNCTION_DESC_GPIO_RX(15),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	FUNCTION_DESC_GPIO_RX(16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	FUNCTION_DESC_GPIO_RX(17),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	FUNCTION_DESC_GPIO_RX(18),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	FUNCTION_DESC_GPIO_RX(19),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	FUNCTION_DESC_GPIO_RX(20),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	FUNCTION_DESC_GPIO_RX(21),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	FUNCTION_DESC_GPIO_RX(22),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	FUNCTION_DESC_GPIO_RX(23),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	FUNCTION_DESC_GPIO_RX(24),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	FUNCTION_DESC_GPIO_RX(25),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	FUNCTION_DESC_GPIO_RX(26),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	FUNCTION_DESC_GPIO_RX(27),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	FUNCTION_DESC_GPIO_RX(28),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	FUNCTION_DESC_GPIO_RX(29),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	FUNCTION_DESC_GPIO_RX(30),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	FUNCTION_DESC_GPIO_RX(31),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	FUNCTION_DESC_GPIO(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	FUNCTION_DESC(AUD_RX, aud_rx),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	FUNCTION_DESC(AUD_TX, aud_tx),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	FUNCTION_DESC(I2C, i2c),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	FUNCTION_DESC(UART, uart),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	FUNCTION_DESC(OLDI, oldi),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static int max96752f_pinctrl_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	struct max96752f_pinctrl *mpctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	struct pinctrl_desc *pctl_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	mpctl = devm_kzalloc(dev, sizeof(*mpctl), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	if (!mpctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	mpctl->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	platform_set_drvdata(pdev, mpctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	mpctl->regmap = dev_get_regmap(dev->parent, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	if (!mpctl->regmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		return dev_err_probe(dev, -ENODEV, "failed to get regmap\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	pctl_desc = devm_kzalloc(dev, sizeof(*pctl_desc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	if (!pctl_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	pctl_desc->name = dev_name(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	pctl_desc->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	pctl_desc->pctlops = &max96752f_pinctrl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	pctl_desc->pmxops = &max96752f_pinmux_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	pctl_desc->confops = &max96752f_pinconf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	pctl_desc->pins = max96752f_pins_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	pctl_desc->npins = ARRAY_SIZE(max96752f_pins_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	pctl_desc->custom_params = max96752f_custom_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	pctl_desc->num_custom_params = ARRAY_SIZE(max96752f_custom_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	pctl_desc->custom_conf_items = max96752f_custom_conf_items,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	ret = devm_pinctrl_register_and_init(dev, pctl_desc, mpctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 					     &mpctl->pctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 		return dev_err_probe(dev, ret, "failed to register pinctrl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	for (i = 0; i < ARRAY_SIZE(max96752f_groups); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 		const struct group_desc *group = &max96752f_groups[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 		ret = pinctrl_generic_add_group(mpctl->pctl, group->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 						group->pins, group->num_pins,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 						group->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 			return dev_err_probe(dev, ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 					     "failed to register group %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 					     group->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	for (i = 0; i < ARRAY_SIZE(max96752f_functions); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		const struct function_desc *func = &max96752f_functions[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 		ret = pinmux_generic_add_function(mpctl->pctl, func->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 						  func->group_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 						  func->num_group_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 						  func->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 			return dev_err_probe(dev, ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 					     "failed to register function %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 					     func->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	return pinctrl_enable(mpctl->pctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) static const struct of_device_id max96752f_pinctrl_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	{ .compatible = "maxim,max96752f-pinctrl" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) MODULE_DEVICE_TABLE(of, max96752f_pinctrl_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static struct platform_driver max96752f_pinctrl_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		.name = "max96752f-pinctrl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		.of_match_table = max96752f_pinctrl_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 	.probe = max96752f_pinctrl_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) module_platform_driver(max96752f_pinctrl_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) MODULE_AUTHOR("Wyon Bi <bivvy.bi@rock-chips.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) MODULE_DESCRIPTION("Maxim MAX96752F pin control driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) MODULE_LICENSE("GPL");