/* AXP209 has GPIO3 status sharing the settings register */ if (offset == 3) {
ret = regmap_read(pctl->regmap, AXP20X_GPIO3_CTRL, &val); if (ret) return ret; return !!(val & BIT(0));
}
ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val); if (ret) return ret;
/* AXP209 GPIO3 settings have a different layout */ if (offset == 3) {
ret = regmap_read(pctl->regmap, AXP20X_GPIO3_CTRL, &val); if (ret) return ret; if (val & AXP20X_GPIO3_FUNCTION_INPUT) return GPIO_LINE_DIRECTION_IN;
return GPIO_LINE_DIRECTION_OUT;
}
reg = axp20x_gpio_get_reg(offset); if (reg < 0) return reg;
ret = regmap_read(pctl->regmap, reg, &val); if (ret) return ret;
/* * This shouldn't really happen if the pin is in use already, * or if it's not in use yet, it doesn't matter since we're * going to change the value soon anyway. Default to output.
*/ if ((val & AXP20X_GPIO_FUNCTIONS) > 2) return GPIO_LINE_DIRECTION_OUT;
/* * The GPIO directions are the three lowest values. * 2 is input, 0 and 1 are output
*/ if (val & 2) return GPIO_LINE_DIRECTION_IN;
staticint axp20x_gpio_set(struct gpio_chip *chip, unsignedint offset, int value)
{ struct axp20x_pctl *pctl = gpiochip_get_data(chip); int reg;
/* AXP209 has GPIO3 status sharing the settings register */ if (offset == 3) return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
AXP20X_GPIO3_FUNCTIONS,
value ?
AXP20X_GPIO3_FUNCTION_OUT_HIGH :
AXP20X_GPIO3_FUNCTION_OUT_LOW);
reg = axp20x_gpio_get_reg(offset); if (reg < 0) return reg;
return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
AXP20X_GPIO_FUNCTION_OUT_LOW);
}
/* * We let the regulator framework handle the LDO muxing as muxing bits * are basically also regulators on/off bits. It's better not to enforce * any state of the regulator when selecting LDO mux so that we don't * interfere with the regulator driver.
*/ if (function == AXP20X_FUNC_LDO) return 0;
staticint axp20x_build_funcs_groups(struct platform_device *pdev)
{ struct axp20x_pctl *pctl = platform_get_drvdata(pdev); int i, ret, pin, npins = pctl->desc->npins;
pctl->funcs[AXP20X_FUNC_GPIO_OUT].name = "gpio_out";
pctl->funcs[AXP20X_FUNC_GPIO_OUT].muxval = AXP20X_MUX_GPIO_OUT;
pctl->funcs[AXP20X_FUNC_GPIO_IN].name = "gpio_in";
pctl->funcs[AXP20X_FUNC_GPIO_IN].muxval = AXP20X_MUX_GPIO_IN;
pctl->funcs[AXP20X_FUNC_LDO].name = "ldo"; /* * Muxval for LDO is useless as we won't use it. * See comment in axp20x_pmx_set_mux.
*/
pctl->funcs[AXP20X_FUNC_ADC].name = "adc";
pctl->funcs[AXP20X_FUNC_ADC].muxval = pctl->desc->adc_mux;
/* Every pin supports GPIO_OUT and GPIO_IN functions */ for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) {
pctl->funcs[i].ngroups = npins;
pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
npins, sizeof(char *),
GFP_KERNEL); if (!pctl->funcs[i].groups) return -ENOMEM; for (pin = 0; pin < npins; pin++)
pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
}
ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->ldo_mask,
npins, &pctl->funcs[AXP20X_FUNC_LDO],
pctl->desc->pins); if (ret) return ret;
ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->adc_mask,
npins, &pctl->funcs[AXP20X_FUNC_ADC],
pctl->desc->pins); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.