madera_gpio = devm_kzalloc(&pdev->dev, sizeof(*madera_gpio),
GFP_KERNEL); if (!madera_gpio) return -ENOMEM;
madera_gpio->madera = madera;
/* Construct suitable gpio_chip from the template in madera_gpio_chip */
madera_gpio->gpio_chip = madera_gpio_chip;
madera_gpio->gpio_chip.parent = pdev->dev.parent;
switch (madera->type) { case CS47L15:
madera_gpio->gpio_chip.ngpio = CS47L15_NUM_GPIOS; break; case CS47L35:
madera_gpio->gpio_chip.ngpio = CS47L35_NUM_GPIOS; break; case CS47L85: case WM1840:
madera_gpio->gpio_chip.ngpio = CS47L85_NUM_GPIOS; break; case CS47L90: case CS47L91:
madera_gpio->gpio_chip.ngpio = CS47L90_NUM_GPIOS; break; case CS42L92: case CS47L92: case CS47L93:
madera_gpio->gpio_chip.ngpio = CS47L92_NUM_GPIOS; break; default:
dev_err(&pdev->dev, "Unknown chip variant %d\n", madera->type); return -EINVAL;
}
/* We want to be usable on systems that don't use devicetree or acpi */ if (pdata->gpio_base)
madera_gpio->gpio_chip.base = pdata->gpio_base; else
madera_gpio->gpio_chip.base = -1;
ret = devm_gpiochip_add_data(&pdev->dev,
&madera_gpio->gpio_chip,
madera_gpio); if (ret < 0) {
dev_dbg(&pdev->dev, "Could not register gpiochip, %d\n", ret); return ret;
}
/* * This is part of a composite MFD device which can only be used with * the corresponding pinctrl driver. On all supported silicon the GPIO * to pinctrl mapping is fixed in the silicon, so we register it * explicitly instead of requiring a redundant gpio-ranges in the * devicetree. * In any case we also want to work on systems that don't use devicetree * or acpi.
*/
ret = gpiochip_add_pin_range(&madera_gpio->gpio_chip, "madera-pinctrl",
0, 0, madera_gpio->gpio_chip.ngpio); if (ret) {
dev_dbg(&pdev->dev, "Failed to add pin range (%d)\n", 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.