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.

Dependency Surface

Detected Declarations

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

Implementation Notes