We're no longer updating This wiki!!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:c2_gpio_key_wakeup [2017/03/03 10:34]
joy.cho [Power Off and Wake Up using GPIO Key Button]
en:c2_gpio_key_wakeup [2017/07/24 18:07] (current)
joy.cho [2. Available Keys]
Line 1: Line 1:
 ====== Power Off and Wake Up using GPIO Key Button ====== ====== Power Off and Wake Up using GPIO Key Button ======
 +This section describes how to set up GPIO key button for power off and wake up purpose.\\
 +  - [[en:​c2_gpio_key_wakeup&#​hardware_set-up|Hardware Set-up]]
 +  - [[en:​c2_gpio_key_wakeup&#​available_keys|Available Keys]]
 +  - [[en:​c2_gpio_key_wakeup&#​sw_set-up_1_-_ubuntu|SW Set-up (1) Ubuntu]]
 +  - [[en:​c2_gpio_key_wakeup&#​sw_set-up_2_-_android|SW Set-up (2) Android]]
 +  - [[en:​c2_gpio_key_wakeup&#​troubleshooting|Troubleshooting]]
  
-<WRAP center round important>​ +The brief set-up flow is as following.\\ 
-This functionality ​is available with following ​version+  ​- Connect a tab button to the pin port you want to use 
-  ​* Ubuntu ​The release version should be 3.14.79-107 (Feb 262017) or higher+  - Set GPIO number using boot.ini 
-  Android : It will be included in the next version. +  - Compiling and flash the modified kernel dts This part is only needed on ANDROID. 
-</​WRAP>​+==== 1Hardware Set-Up ==== 
 +FirstYou need to prepare a tab switch that are connected to two lines.\\ 
 +Red line is for **Power Button** and another Gray line is for the active level line (Ground or 3.3V Power).\\
  
-The basic working flow is as following.\\+{{:​en:​gpio_wakeup_2.png?400}}
  
-**[Set-up Flow]**\\ +For example, we will use **Pin#29** of 40pin expansion connector.\\
-  - Connect a tab button to the pin port you want to use. (Please refer to the available key table in the end part of this wiki page.) +
-  - Setting GPIO number using boot.ini +
-  - Run reboot+
  
-**[Basic Working Scenario]**\\ +The pin is assigned to **GPIOX.BIT0** and its GPIO number is **#228**.\\ 
-  * After booting, based on the GPIO number ​that is described in boot.ini, gpio_keypad driver will generate KEY_POWER event when you push tab button, and it will make the system power off+Connect ​the red line to **Pin#29**. \\
-  * After power off is done, bl301 will check the GPIO status periodically based on the GPIO number that is reported from kernel, and when you push the button, board will wake up. +
-  ​For the key wake up, the key chattering time is __300ms__.+
  
-<​code>​ +Its default pin pulled status is high and switch active will be **Low**, so you should connect the gray line of tab switch to Ground (GND), **Pin#​30**.\\
----->>>​ Power Key Event +
  
-root@odroid64:​~# ​ +^  Pin Number\\ (Red Line)  ^  GPIO Number ​ ^  Active Level \\ (Gray Line)  ^ 
-[   ​84.515844] reboot: Power down +|  29                       ​|  ​GPIO#228     ​| ​ Active Low (Pin 30         |
-..... +
-ERprocess cCEC cfg:0x2f +
-WAKEUP ​GPIO cfg:​0x000000d6 +
-set vddee to 0x0352mv +
-06f1932000000000 +
-(Holding here...)+
  
---->>>​ Power Key Event 
  
-exit_reason:​0x09 
-set vddee to 0x042emv 
-BL1:​08GXBB:​BL1:​08dafd:​0a8993;​FEAT:​EDFC318C;​POC:​3;​RCY:​0;​EMMC:​800;​NAND:​81;​SD:​0;​READ:​0;​CHK:​0;​ 
-TE: 321463 
  
-BL2 Built : 11:44:26, Nov 25 2015.  +==== 2Available Keys ==== 
-..... +Here are the available key examples using 40-pin connector and 7-pin connector.\\ 
-..... +You can find the pin assign examples for Red Line and Gray Line.
-secure task start! +
-high task start! +
-low task start! +
-..... +
-U-Boot 2015.01-00187-g3eb97d4-dirty (Feb 22 2017 - 14:25:18)+
  
-</code>+** (1) J2 - 2x20 pins** 
 +^  Active Level \\ (Gray Line) ^                            GPIO Number ^  Pin Number\\ (Red Line)  ^  Pin Number\\ (Red Line)  ^ GPIO Number ​                       ^ Active Level\\ (Gray Line)  ^ 
 +|                            - |  <color #​7092be>//​3.3V Power//</​color>​ |  1                        |  2                        | -                                  | -                           | 
 +|                            - |                                      - |  3                        |  4                        | -                                  | -                           | 
 +|                            - |                                      - |  5                        |  6                        | <color #​7092be>//​Ground//</​color> ​ | -                           | 
 +|           ​Active Low (Pin 9) |                               ​GPIO#​249 |  7                        |  8                        | -                                  | -                           | 
 +|                            - |      <color #​7092be>//​Ground//</​color>​ |  9                        |  10                       | -                                  | -                           | 
 +|          Active Low (Pin 14) |                               ​GPIO#​247 |  11                       ​| ​ 12                       | GPIO#​238 ​                          | Active Low (Pin 14)         | 
 +|          Active Low (Pin 14) |                               ​GPIO#​239 |  13                       ​| ​ 14                       | <color #​7092be>//​Ground//</​color> ​ | -                           | 
 +|          Active Low (Pin 14) |                               ​GPIO#​237 |  15                       ​| ​ 16                       | GPIO#​236 ​                          | Active Low (Pin 14)         | 
 +|                            - |  <color #​7092be>//​3.3V Power//</​color>​ |  17                       ​| ​ 18                       | GPIO#​233 ​                          | Active Low (Pin 20)         | 
 +|          Active Low (Pin 20) |                               ​GPIO#​235 |  19                       ​| ​ 20                       | <color #​7092be>//​Ground//</​color> ​ | -                           | 
 +|          Active Low (Pin 20) |                               ​GPIO#​232 |  21                       ​| ​ 22                       | GPIO#​231 ​                          | Active Low (Pin 20)         | 
 +|          Active Low (Pin 25) |                               ​GPIO#​230 |  23                       ​| ​ 24                       | GPIO#​229 ​                          | Active Low (Pin 25)         | 
 +| -                            |      <color #​7092be>//​Ground//</​color>​ |  25                       ​| ​ 26                       | GPIO#​225 ​                          | Active High (Pin 17)        | 
 +| -                            |                                      - |  27                       ​| ​ 28                       | -                                  | -                           | 
 +|          Active Low (Pin 30) |                               ​GPIO#​228 |  29                       ​| ​ 30                       | <color #​7092be>//​Ground//</​color> ​ | -                           | 
 +|          Active Low (Pin 30) |                               ​GPIO#​219 |  31                       ​| ​ 32                       | GPIO#​224 ​                          | Active Low (Pin 34)         | 
 +|         ​Active High (Pin 17) |                               ​GPIO#​234 |  33                       ​| ​ 34                       | <color #​7092be>//​Ground//</​color> ​ |                             | 
 +|          Active Low (Pin 34) |                               ​GPIO#​214 |  35                       ​| ​ 36                       | GPIO#​218 ​                          | Active Low (Pin 34)         | 
 +| -                            |                                      - |  37                       ​| ​ 38                       | -                                  | -                           | 
 +| -                            |      <color #​7092be>//​Ground//​</color|  39                       ​| ​ 40                       | -                                  | -                           |
  
-==== Hardware Example ​ ==== +** (2) J7 - 1x7 pins** 
-For example, we will use **Pin#35** of 40pin expansion connector.\\ +^ Pin Number\\ (Red Line)  ^ GPIO Number ​                           ^ Active Level\\ (Gray Line)  ^ 
-The pin is assigned to **GPIOY.BIT3** and its GPIO number is **#214**.\\+| 1                        | <color #​7092be>//​Ground//</​color> ​     | -                           | 
 +| 2                        | GPIO#128                               | Active Low (Pin 1)          | 
 +| 3                        | <color #​7092be>//​5.0V Power//</​color> ​ | -                           | 
 +| 4                        | GPIO#​130 ​                              | Active Low (Pin 1)          | 
 +| 5                        | GPIO#​132 ​                              | Active Low (Pin 1)          | 
 +| 6                        | GPIO#​131 ​                              | Active Low (Pin 1)          | 
 +| 7                        | GPIO#​133 ​                              | Active Low (Pin 1)          |
  
-Its default ​pin pulled status is UP (High) ​and switch active will be **Low**,\\ +You can find the detailed information about 40-pin and 7-pin connectors in the following link.\\ 
-so you should connect another port of tab switch to Ground (GND), **Pin#39**.+[[en:​c2_hardware&​#expansion_connectors|Expansion Connectors]]\\
  
-{{:en:​gpio_wakeup_2.png?400}}+==== 3. SW Set-up (1) - Ubuntu ==== 
 +<WRAP center round important>​ 
 +  * Ubuntu ​The release version should be 3.14.79-107 (Feb 26, 2017) or higher. 
 +</​WRAP>​
  
-===Setting boot.ini ​ ====+=== (1) Setting boot.ini ===
  
 You can assign GPIO number with env **gpiopower** in boot.ini. You can assign GPIO number with env **gpiopower** in boot.ini.
  
-<​code>​ +<​code ​ini target
-# gpio power key : J2 (2x20) Pin#35 GPIOY.BIT3 +## gpio power key : J2 (2x20) Pin#29 GPIOX.BIT0 
-setenv gpiopower "214"+setenv gpiopower "228"
 ... ...
 ... ...
-setenv bootargs ${bootargs} gpiopower=${gpiopower} 
-</​code>​ 
  
 +## Add gpiopower like "​setenv bootargs ${bootargs} gpiopower=${gpiopower}"​
 +setenv bootargs "​root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro ${condev} no_console_suspend hdmimode=${m} ${cmode} m_bpp=${m_bpp} vout=${vout} fsck.repair=yes net.ifnames=0 elevator=noop disablehpd=${hpd} max_freq=${max_freq} maxcpus=${maxcpus} monitor_onoff=${monitor_onoff} disableuhs=${disableuhs} mmc_removable=${mmc_removable} usbmulticam=${usbmulticam} ${hid_quirks} gpiopower=${gpiopower}"​
  
-===Setting Power Button Action for Power Off ====+</​code>​ 
 + 
 +=== (2) Setting Power Button Action for Power Off ===
  
-=== Ubuntu === +When you turn the board off using power button, you need to change ​the power key action pattern.\\
-When you turn the board off using power button, you need to change power key action pattern.\\+
  
 - Open Power Management Preferences : [System] -> [Preferences] -> [Hardware] -> [Power Management] \\ - Open Power Management Preferences : [System] -> [Preferences] -> [Hardware] -> [Power Management] \\
Line 81: Line 98:
 {{:​en:​gpio_wakeup_1.png?​400}} {{:​en:​gpio_wakeup_1.png?​400}}
  
-=== Android === +=== (3) Wake up Action === 
-In case of Android, one short power key event is used for sleep and with long key event, you can handle options of power off/reboot.\\ +To wake-up after power off, long-pressing over 2 seconds is needed. 
-With Android ​Marshmallow v2.4 or higher versionit's available ​to enter power off sequence using **long-pressing (5 sec)**+ 
-==== Available Key Numbers ​ ====+==== 4. SW Set-up (2) - Android ​ ​==== 
 +<WRAP center round important>​ 
 +  * Android : You have to modify the dts file in Android Marshmallow (v2.4) and higher version to using this functionality. 
 +</​WRAP>​ 
 +=== (1) Modifying and Flashing Kernel dts === 
 +In case of Android, you have to modify the dts file to activate gpio key functionality.\\ 
 + 
 +[[https://​github.com/​hardkernel/​linux/​blob/​odroidc2-3.14.y-android/​arch/​arm64/​boot/​dts/​meson64_odroidc2.dts|C2 ​Android ​DTS]]\\ 
 + 
 +<​kernel_path>/​arch/​arm64/​boot/​dts/​meson64_odroidc2.dts 
 +<​code>​ 
 +... 
 +gpio_keypad{ 
 +    . 
 +    status = "​okay";​ 
 +    . 
 +}; 
 +... 
 +</​code>​ 
 + 
 +After compiling the dts fileyou can flash the dtb file to the board. 
 + 
 +In kernel: 
 +<code bash target>​ 
 +$ make odroidc2_defconfig 
 +$ make dtbs 
 +$ fastboot flash dtb arch/​arm64/​boot/​dts/​meson64_odroidc2.dtb 
 +$ fastboot reboot 
 +</​code>​ 
 + 
 +You have to flash dtbs file when board it is in u-boot fastboot mode. 
 + 
 +In board: 
 +<code bash target>​ 
 +$ reboot fastboot 
 +</​code>​ 
 + 
 +=== (2) Setting boot.ini ​=== 
 +In Android boot.ini, you can find a "​gpiopower"​ example. 
 +Uncomment "​gpiopower"​ part and modify the number with the number you want to use. 
 +<code ini target>​ 
 +## gpio power key : J2 (2x20) Pin#29 , GPIOX.BIT0 
 +setenv gpiopower "​228"​ 
 +</​code>​
  
-**1. J2 - 2x20 pins** +=== (3) Setting ​Power Button Action for Power Off === 
-^ Pin Number ^ Net Name ^ GPIO Number ^ Active Level ^ Pin Number ^ Net Name ^ GPIO Number ^ Active Level ^ +In Android, you don't need to set any menu for power button actions but it's already defined as following.\\
-|  1  |3.3V Power|  | |  2  |5.0V Power| | | +
-|  3  |I2CA_SDA|N/​A| |  4  |5.0V Power| | | +
-|  5  |I2CA_SCL|N/​A| |  6  |Ground| | | +
-|  7  |GPIOX.BIT21|GPIO#​249| High -> Low |  8  |TXD1|N/A| | +
-|  9  |Ground| | |  10  |RXD1|N/A| | +
-|  11  |GPIOX.BIT19|GPIO#​247|High -> Low|  12  |GPIOX.BIT10|GPIO#​238|High -> Low| +
-|  13  |GPIOX.BIT11|GPIO#​239|High -> Low|  14  |Ground| | | +
-|  15  |GPIOX.BIT9|GPIO#​237|High -> Low|  16  |GPIOX.BIT8|GPIO#​236|High -> Low| +
-|  17  |3.3V Power| | |  18  |GPIOX.BIT5|GPIO#​233|High -> Low| +
-|  19  |GPIOX.BIT7|GPIO#​235|High -> Low|  20  |Ground| | | +
-|  21  |GPIOX.BIT4|GPIO#​232|High -> Low|  22  |GPIOX.BIT3|GPIO#​231|High -> Low| +
-|  23  |GPIOX.BIT2|GPIO#​230|High -> Low|  24  |GPIOX.BIT1|GPIO#​229|High -> Low| +
-|  25  |Ground| | |  26  |GPIOY.BIT14|GPIO#​225|Low -> High| +
-|  27  |I2CB_SDA|N/​A| |  28  |I2CB_SCL|N/​A| | +
-|  29  |GPIOX.BIT0|GPIO#​228|High -> Low|  30  |Ground| | | +
-|  31  |GPIOY.BIT8|GPIO#​219|High -> Low|  32  |GPIOY.BIT13|GPIO#​224|High -> Low| +
-|  33  |GPIOX.BIT6|GPIO#​234|Low -> High|  34  |Ground| | | +
-|  35  |GPIOY.BIT3|GPIO#​214|High -> Low|  36  |GPIOY.BIT7|GPIO#​218|High -> Low| +
-|  37  |ADC.AIN1|N/​A| |  38  |1.8V Power|N/A| | +
-|  39  |Ground| | |  40  |ADC.AIN0|N/A| |+
  
 +One short power key event is used for sleep, and with long key event, you can handle options of power off/​reboot.\\
 +With Android Marshmallow v2.4 or higher version, it's available to enter power off using **long-pressing (5 sec)**.
  
-**2. J7 - 1x7 pins** +=== (4) Wake up Action === 
-^ Pin Number ^ Net Name ^ GPIO Number ^ Active Level ^ +And to wake-up after power off, long-pressing over 2 seconds is needed.
-|  1  |Ground| ​ | | +
-|  2  |GPIOAO.BIT6|GPIO#​128|High -> Low| +
-|  3  |P5V0|5.0V Power| | +
-|  ​ ​|GPIOAO.BIT8|GPIO#​130|High -> Low| +
-|  5  |GPIOAO.BIT10|GPIO#​132|High ​-> Low| +
-|  6  |GPIOAO.BIT9|GPIO#​131|High ​-> Low| +
-|  7  |GPIOAO.BIT11|GPIO#​133|High -> Low|+
  
-**3SW1**+==== 5Troubleshooting ​ ==== 
 +https://​forum.odroid.com/​viewtopic.php?​f=137&​t=27602#​p195995 \\
  
-{{:en:​gpio_wakeup_3.png?400}} \\ +https://forum.odroid.com/viewtopic.php?​f=136&​t=27636
-^ Pin Number ^ Net Name ^ GPIO Number ^ Active Level ^ +
-|  1  |NC|N/A  | | +
-|  2  |GPIOY.BIT5|GPIO#​216|High -> Low| +
-|  3  |GND|Ground| |+
  
  
en/c2_gpio_key_wakeup.1488506680.txt.gz · Last modified: 2017/03/03 10:34 by joy.cho
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0