/* * FIXME: convert this singleton driver to use the state container * design pattern, see Documentation/driver-api/driver-model/design-patterns.rst
*/ staticstruct cs5535_gpio_chip { struct gpio_chip chip;
resource_size_t base;
/* * The CS5535/CS5536 GPIOs support a number of extra features not defined * by the gpio_chip API, so these are exported. For a full list of the * registers, see include/linux/cs5535.h.
*/
/* * According to the CS5536 errata (#36), after suspend * a write to the high bank GPIO register will clear all * non-selected bits; the recommended workaround is a * read-modify-write operation. * * Don't apply this errata to the edge status GPIOs, as writing * to their lower bits will clear them.
*/ if (reg != GPIO_POSITIVE_EDGE_STS && reg != GPIO_NEGATIVE_EDGE_STS) { if (val & 0xffff)
val |= (inl(addr) & 0xffff); /* ignore the high bits */ else
val |= (inl(addr) ^ (val >> 16));
}
outl(val, addr);
}
staticvoid __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset, unsignedint reg)
{ if (offset < 16) /* low bank register */
outl(1 << offset, chip->base + reg); else /* high bank register */
errata_outl(chip, 1 << (offset - 16), reg);
}
/* check if this pin is available */ if ((mask & (1 << offset)) == 0) {
dev_info(&chip->pdev->dev, "pin %u is not available (check mask)\n", offset);
spin_unlock_irqrestore(&chip->lock, flags); return -EINVAL;
}
/* disable output aux 1 & 2 on this pin */
__cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX1);
__cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX2);
/* disable input aux 1 on this pin */
__cs5535_gpio_clear(chip, offset, GPIO_INPUT_AUX1);
/* There are two ways to get the GPIO base address; one is by * fetching it from MSR_LBAR_GPIO, the other is by reading the * PCI BAR info. The latter method is easier (especially across * different architectures), so we'll stick with that for now. If * it turns out to be unreliable in the face of crappy BIOSes, we
* can always go back to using MSRs.. */
res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) {
dev_err(&pdev->dev, "can't fetch device resource info\n"); return err;
}
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.