drivers/gpio/gpiolib-of.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpiolib-of.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpiolib-of.c- Extension
.c- Size
- 31288 bytes
- Lines
- 1099
- Domain
- Driver Families
- Bucket
- drivers/gpio
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/err.hlinux/errno.hlinux/fwnode.hlinux/io.hlinux/module.hlinux/of.hlinux/of_address.hlinux/pinctrl/pinctrl.hlinux/slab.hlinux/string.hlinux/gpio/consumer.hlinux/gpio/machine.hgpiolib.hgpiolib-of.h
Detected Declarations
enum of_gpio_flagsfunction of_gpio_named_countfunction of_gpio_spi_cs_get_countfunction of_gpio_countfunction for_each_gpio_property_namefunction of_gpiochip_match_node_and_xlatefunction of_find_gpio_device_by_xlatefunction of_gpio_quirk_polarityfunction of_gpio_try_fixup_polarityfunction of_gpio_set_polarity_by_propertyfunction of_gpio_flags_quirksfunction of_device_is_compatiblefunction of_property_presentfunction for_each_child_of_node_scopedfunction of_get_named_gpiod_flagsfunction of_convert_gpio_flagsfunction of_gpiochip_get_lflagsfunction of_gpiochip_remove_hogfunction of_gpiochip_match_nodefunction of_gpio_notifyfunction ngpiosfunction numberfunction of_gpiochip_add_pin_rangefunction of_gpiochip_add_pin_rangefunction of_gpiochip_addfunction of_gpiochip_removefunction for_each_child_of_node_scopedfunction of_gpiochip_instance_match
Annotated Snippet
if (*flags & OF_GPIO_ACTIVE_LOW) {
pr_warn("%s GPIO handle specifies active low - ignored\n",
of_node_full_name(np));
*flags &= ~OF_GPIO_ACTIVE_LOW;
}
} else {
if (!(*flags & OF_GPIO_ACTIVE_LOW))
pr_info("%s enforce active low on GPIO handle\n",
of_node_full_name(np));
*flags |= OF_GPIO_ACTIVE_LOW;
}
}
/*
* This quirk does static polarity overrides in cases where existing
* DTS specified incorrect polarity.
*/
static void of_gpio_try_fixup_polarity(const struct device_node *np,
const char *propname,
enum of_gpio_flags *flags)
{
static const struct {
const char *compatible;
const char *propname;
bool active_high;
} gpios[] = {
#if IS_ENABLED(CONFIG_LCD_HX8357)
/*
* Himax LCD controllers used incorrectly named
* "gpios-reset" property and also specified wrong
* polarity.
*/
{ "himax,hx8357", "gpios-reset", false },
{ "himax,hx8369", "gpios-reset", false },
#endif
#if IS_ENABLED(CONFIG_MTD_NAND_JZ4780)
/*
* The rb-gpios semantics was undocumented and qi,lb60 (along with
* the ingenic driver) got it wrong. The active state encodes the
* NAND ready state, which is high level. Since there's no signal
* inverter on this board, it should be active-high. Let's fix that
* here for older DTs so we can re-use the generic nand_gpio_waitrdy()
* helper, and be consistent with what other drivers do.
*/
{ "qi,lb60", "rb-gpios", true },
#endif
#if IS_ENABLED(CONFIG_IEEE802154_CA8210)
/*
* According to the datasheet, the NRST pin 27 is an active-low
* signal. However, the device tree schema and admittedly
* the out-of-tree implementations have been used for a long
* time incorrectly by describing reset GPIO as active-high.
*/
{ "cascoda,ca8210", "reset-gpio", false },
#endif
#if IS_ENABLED(CONFIG_PCI_LANTIQ)
/*
* According to the PCI specification, the RST# pin is an
* active-low signal. However, most of the device trees that
* have been widely used for a long time incorrectly describe
* reset GPIO as active-high, and were also using wrong name
* for the property.
*/
{ "lantiq,pci-xway", "gpio-reset", false },
#endif
#if IS_ENABLED(CONFIG_REGULATOR_S5M8767)
/*
* According to S5M8767, the DVS and DS pin are
* active-high signals. However, exynos5250-spring.dts use
* active-low setting.
*/
{ "samsung,s5m8767-pmic", "s5m8767,pmic-buck-dvs-gpios", true },
{ "samsung,s5m8767-pmic", "s5m8767,pmic-buck-ds-gpios", true },
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2005)
/*
* DTS for Nokia N900 incorrectly specified "active high"
* polarity for the reset line, while the chip actually
* treats it as "active low".
*/
{ "ti,tsc2005", "reset-gpios", false },
#endif
#if IS_ENABLED(CONFIG_SND_SOC_WSA881X)
/*
* WSA881 powerdown is always active low, but some device trees
* missed this when first contributed. It also has a very strange
* compatible.
*/
{ "sdw10217201000", "powerdown-gpios", false },
#endif
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/fwnode.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `enum of_gpio_flags`, `function of_gpio_named_count`, `function of_gpio_spi_cs_get_count`, `function of_gpio_count`, `function for_each_gpio_property_name`, `function of_gpiochip_match_node_and_xlate`, `function of_find_gpio_device_by_xlate`, `function of_gpio_quirk_polarity`, `function of_gpio_try_fixup_polarity`, `function of_gpio_set_polarity_by_property`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.