On an arm Ubuntu system, the shutdown operation can be implemented by command: Poweroff or shutdown, but without an end device or keyboard, you cannot use the command line, which uses the ACPI mechanism, ACPI listener power events, to the operating system.
Implementation steps:
1, the driving part, the first to implement the Gpio-keys device, the POWER key is specified, is to use an interrupt pin, the code type is defined as "Key_power"
Like what:
/* GPIO KEYS */static struct Gpio_keys_button smdk4412_button[] = {{<span style= "color: #ff0000;" >.code = Key_power,</span>.gpio = exynos4_gpx0 (1),. desc = "Gpio-keys:key_power",. Type = Ev_key,.active_low = 1, . Debounce_interval = 1,.wakeup = 1,}, {. Code = Key_volumeup,//.code = Key_left,.gpio = exynos4_gpx1 (0),. desc = "Gpio-keys: Key_volumeup ",. Type = Ev_key,.active_low = 1,.debounce_interval = Ten,}, {. Code = Key_volumedown,//.code = Key_down,.gpio = EXYNOS4_GPX1 (1),. desc = "Gpio-keys:key_volumedown",. Type = Ev_key,.active_low = 1,.debounce_interval = Ten,},};static struct Gpio_keys_platform_data smdk4x12_gpio_keys_data = {. buttons= smdk4412_button,.nbuttons= ARRAY_SIZE (smdk4412_ button),. rep= 1,.poll_interval= 100,};static struct Platform_device smdk4x12_gpio_keys = {. Name= "Gpio-keys",. dev= {. Platform_data= &smdk4x12_gpio_keys_data,},};
Red flag. Code=key_power, which is the event type of the power key, is triggered by using gpx0_1 as the interrupt source, and the following two is the Volume key event type, which can achieve the volume adjustment.
After the driver is configured, you can use cat/proc/interrupts in the system to check if the key trigger is OK
417: 0 0 0 exynos-eint gpio-keys:key_power
After testing, my board, interrupted no problem ^ ^.
2, the driver is done, you can install ACPI,
To run the command:
sudo apt-get update
sudo apt-get install Apcid
Backup/etc/acpi/powerbtn.sh
Cp/etc/acpi/powerbtn.sh/etc/acpi/powerbtn.sh_bk
Modify/etc/acpi/powerbtn.sh
Keep only the following sections
#!/bin/sh#/etc/acpi/powerbtn.sh# initiates a shutdown when the power button had been# pressed./sbin/shutdown-h now "Powe R button Pressed "
Restart Apcid Service
Service Acpid StopService acpid start
3, press the power button, try it
Broadcast message from [e-mail protected] (unknown) at 20:20 ... The system is going down for halt now! Power button pressedwait-for-state stop/waiting * stopping rsync daemon rsync [ OK] * Stopping NTP server ntpd [OK] * asking all remaining processes to TE Rminate ... [OK] * All processes ended within 1 seconds ... [OK] MODEMMANAGER[667]: <warn> Could not acquire the ' org.freedesktop.ModemManager1 ' service namemodemmanager[667]: & Lt;info> Modemmanager is shut down * unmounting temporary filesystems ... [OK] * deactivating swap ... [OK] * unmounting local filesystems ... [OK] * would now halt[37.468376] exynos4-reboot:notifier called[38.132085] Power down. [38.1330? Ok
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Implementation of ARM Ubuntu key off