linux-stable/include
Dmitry Torokhov e7f9ff5dc9 gpiolib: add support for software nodes
Now that static device properties understand notion of child nodes and
references, let's teach gpiolib to handle them:

- GPIOs are represented as a references to software nodes representing
  gpiochip
- references must have 2 arguments - GPIO number within the chip and
  GPIO flags (GPIO_ACTIVE_LOW/GPIO_ACTIVE_HIGH, etc)
- a new PROPERTY_ENTRY_GPIO() macro is supplied to ensure the above
- name of the software node representing gpiochip must match label of
  the gpiochip, as we use it to locate gpiochip structure at runtime

The following illustrates use of software nodes to describe a "System"
button that is currently specified via use of gpio_keys_platform_data
in arch/mips/alchemy/board-mtx1.c. It follows bindings specified in
Documentation/devicetree/bindings/input/gpio-keys.yaml.

static const struct software_node mxt1_gpiochip2_node = {
	.name = "alchemy-gpio2",
};

static const struct property_entry mtx1_gpio_button_props[] = {
	PROPERTY_ENTRY_U32("linux,code", BTN_0),
	PROPERTY_ENTRY_STRING("label", "System button"),
	PROPERTY_ENTRY_GPIO("gpios", &mxt1_gpiochip2_node, 7, GPIO_ACTIVE_LOW),
	{ }
};

Similarly, arch/arm/mach-tegra/board-paz00.c can be converted to:

static const struct software_node tegra_gpiochip_node = {
	.name = "tegra-gpio",
};

static struct property_entry wifi_rfkill_prop[] __initdata = {
	PROPERTY_ENTRY_STRING("name", "wifi_rfkill"),
	PROPERTY_ENTRY_STRING("type", "wlan"),
	PROPERTY_ENTRY_GPIO("reset-gpios",
			    &tegra_gpiochip_node, 25, GPIO_ACTIVE_HIGH);
	PROPERTY_ENTRY_GPIO("shutdown-gpios",
			    &tegra_gpiochip_node, 85, GPIO_ACTIVE_HIGH);
	{ },
};

static struct platform_device wifi_rfkill_device = {
	.name	= "rfkill_gpio",
	.id	= -1,
};

...

	software_node_register(&tegra_gpiochip_node);
	device_create_managed_software_node(&wifi_rfkill_device.dev,
					    wifi_rfkill_prop, NULL);

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2022-11-15 11:21:43 +01:00
..
acpi platform-drivers-x86 for v6.1-1 2022-10-05 10:38:24 -07:00
asm-generic gpiolib: Get rid of ARCH_NR_GPIOS 2022-10-17 11:03:09 +02:00
clocksource
crypto
drm Driver core changes for 6.1-rc1 2022-10-07 17:04:10 -07:00
dt-bindings These are the pin control changes for the v6.1 kernel cycle: 2022-10-11 10:59:59 -07:00
keys
kunit kunit: declare kunit_assert structs as const 2022-10-07 10:19:18 -06:00
kvm
linux gpiolib: add support for software nodes 2022-11-15 11:21:43 +01:00
math-emu
media USB/Thunderbolt changes for 6.1-rc1 2022-10-07 16:48:26 -07:00
memory
misc
net Random number generator fixes for Linux 6.1-rc1. 2022-10-16 15:27:07 -07:00
pcmcia
ras
rdma
rv
scsi SCSI misc on 20221007 2022-10-07 12:33:18 -07:00
soc RISC-V Patches for the 6.1 Merge Window, Part 2 2022-10-14 11:21:11 -07:00
sound ALSA: hda: Update register polling macros 2022-10-09 12:34:32 +02:00
target
trace f2fs-for-6.1-rc1 2022-10-10 20:28:41 -07:00
uapi This pull request contains updates for UBI and UBIFS 2022-10-14 18:23:23 -07:00
ufs SCSI misc on 20221007 2022-10-07 12:33:18 -07:00
vdso
video
xen xen/virtio: enable grant based virtio on x86 2022-10-10 14:31:26 +02:00