Op 10 nov. 2012, om 01:17 heeft Lennart Poettering <[email protected]> het volgende geschreven:
> On Fri, 02.11.12 09:56, Pawel Pastuszak ([email protected]) wrote: > >> Hi all, >> >> I was wondering if there is an way to attach an GPIO line to reboot the >> system. I am currently working on an Embedded device that has an GPIO line >> which needs to act as an reboot button this GPIO comes up as an >> /sys/class/gpio/gpio103/ which i want to have it trigger when it switches >> state to low and do an system soft reboot. Does systemd allow any >> functionally like this? > > No. We only look for input devices marked with the "power-switch" > tag. > > The kernel can create input devices for GPIO lines > (CONFIG_KEYBOARD_GPIO), IIRC? Maybe that's useful to achieve this? It should be a matter of: static struct gpio_keys_button my_awesome_gpio_keys[] = { { .code = KEY_POWER, .gpio = GPIO_TO_PIN(1, 16), .active_low = true, .desc = "left", .type = EV_KEY, .wakeup = 1, }, }; static struct gpio_keys_platform_data my_awesome_gpio_key_info = { .buttons = my_awesome_gpio_keys, .nbuttons = ARRAY_SIZE(my_awesome_gpio_keys), }; static struct platform_device my_awesome_keys = { .name = "gpio-keys", .id = -1, .dev = { .platform_data = &my_awesome_gpio_key_info, }, }; Or with devicetree: gpio_keys { compatible = "gpio-keys"; pinctrl-names = "default"; pinctrl-0 = <&bone_lcd3_cape_keys_00A0_pins>; // add a pinctrl section about if needed, otherwise delete these 2 lines #address-cells = <1>; #size-cells = <0>; button@1 { debounce_interval = <50>; linux,code = <105>; // replace with proper KEY_POWER code label = "left"; gpios = <&gpio2 16 0x0>; gpio-key,wakeup; autorepeat; }; }; That will give you a native evdev device that emits KEY_POWER when you toggle the GPIO. regards, Koen _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
