文章目錄
Power按鍵
~短按休眠和長按關(guān)機(jī)
關(guān)機(jī)命令
~poweroff命令關(guān)機(jī)
OK3399-C平臺(tái)采用RK3399 主CPU芯片設(shè)計(jì),支持底板Power按鍵休眠喚醒以及關(guān)機(jī)功能,Linux命令行也可以通過命令進(jìn)行關(guān)機(jī),下面對(duì)這兩種方式進(jìn)行簡單的解析。
Power按鍵
Power按鍵的休眠喚醒功能一般是與PMIC芯片和CPU相關(guān)的,硬件上該按鍵會(huì)連接到PMIC的PWRON引腳和CPU對(duì)應(yīng)的引腳上。
先來看power按鍵在PMIC側(cè)的響應(yīng)機(jī)制,POWER鍵按下以后,經(jīng)過TdbPWRONF時(shí)間以后,INT引腳變?yōu)榈碗娖剑|發(fā)中斷。內(nèi)核驅(qū)動(dòng)響應(yīng)中斷,執(zhí)行休眠程序。
如果PWRON繼續(xù)保持低電平超過TdPWRONLP,PMIC就會(huì)響應(yīng),RK3399板卡將進(jìn)行關(guān)機(jī)。
RK3399短按休眠和長按關(guān)機(jī)
Log信息:
[ 10.250531] PM: Syncing filesystems ... done. [ 10.255148] test message. //加入的測(cè)試信息 [ 10.256842] Freezing user space processes ... (elapsed 0.003 seconds) done. [ 10.260770] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 10.263308] Suspending console(s) (use no_console_suspend to debug) INFO: sleep mode config[0xde]: INFO: AP_PWROFF INFO: SLP_ARMPD INFO: SLP_PLLPD INFO: DDR_RET INFO: SLP_CENTER_PD INFO: wakeup source config[0x804]: INFO:
GPIO
interrupt can wakeup system INFO: PWM interrupt can wakeup system INFO: PWM CONFIG[0x4]: INFO: PWM: PWM2D_REGULATOR_EN INFO: APIOS info[0x0]: INFO: not config INFO: GPIO POWER INFO: INFO: GPIO1_C1 INFO: GPIO1_B6 INFO: PMU_MODE_CONG: 0x1477bf51
涉及驅(qū)動(dòng)文件
kernel/kernel/power/suspend.c/** * enter_state - Do common work needed to enter system sleep state. * @state: System sleep state to enter. * * Make sure that no one else is trying to put the system into a sleep state. * Fail if that's not the case. Otherwise, prepare for system suspend, make the * system enter the given sleep state and clean up after wakeup. */ static int enter_state(suspend_state_t state) { int error; trace_suspend_resume(TPS("suspend_enter"), state, true); if (state == PM_SUSPEND_FREEZE) { #ifdef CONFIG_PM_DEBUG if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) { ? ? ? ? ? ? ? ? ? ? ? ?pr_warning("PM: Unsupported test mode for suspend to idle," ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "please choose none/freezer/devices/platform.\n"); ? ? ? ? ? ? ? ? ? ? ? ?return -EAGAIN; ? ? ? ? ? ? ? ?} #endif ? ? ? ?} else if (!valid_state(state)) { ? ? ? ? ? ? ? ?return -EINVAL; ? ? ? ?} ? ? ? ?if (!mutex_trylock(&pm_mutex)) ? ? ? ? ? ? ? ?return -EBUSY; ? ? ? ?if (state == PM_SUSPEND_FREEZE) ? ? ? ? ? ? ? ?freeze_begin(); #ifndef CONFIG_SUSPEND_SKIP_SYNC ? ? ? ?trace_suspend_resume(TPS("sync_filesystems"), 0, true); ? ? ? ?printk(KERN_INFO "PM: Syncing filesystems ... "); ? ? ? ?sys_sync(); ? ? ? ?printk("done.\n"); ? ? ? ?trace_suspend_resume(TPS("sync_filesystems"), 0, false); #endif ? ? ? ?pr_debug("PM: Preparing system for sleep (%s)\n", pm_states[state]); ? ? ? ?pm_suspend_clear_flags(); ? ? ? ?error = suspend_prepare(state); ? ? ? ?if (error) ? ? ? ? ? ? ? ?goto Unlock; ? ? ? ?if (suspend_test(TEST_FREEZER)) ? ? ? ? ? ? ? ?goto Finish; ? ? ? ?trace_suspend_resume(TPS("suspend_enter"), state, false); ? ? ? ?pr_debug("PM: Suspending system (%s)\n", pm_states[state]); ? ? ? ?pm_restrict_gfp_mask(); ? ? ? ?error = suspend_devices_and_enter(state); ? ? ? ?pm_restore_gfp_mask(); Finish: ? ? ? ?pr_debug("PM: Finishing wakeup.\n"); ? ? ? ?suspend_finish(); Unlock: ? ? ? ?mutex_unlock(&pm_mutex); ? ? ? ?return error; }
通過代碼可知,Power按鍵觸發(fā)的休眠和關(guān)機(jī)會(huì)執(zhí)行sys_sync函數(shù),進(jìn)行系統(tǒng)數(shù)據(jù)的保存,這與突然掉電導(dǎo)致的異常關(guān)機(jī)是有很大區(qū)別的。
RK3399關(guān)機(jī)命令
RK3399 平臺(tái)Linux下的關(guān)機(jī)命令有shutdown、halt、poweroff命令等.
Poweroff命令關(guān)機(jī)
Log信息:
[root@rk3399:/]# poweroff [root@rk3399:/]# stop finishedStopping input-event-daemon: done stop auto-reboot finished Stopping dnsmasq: OK Stopping vsftpd: stopped vsftpd (pid 1072) OK [ 20.099392] [BT_RFKILL]: bt shut off power [ 20.132245] configfs-gadget gadget: unbind function 'Function FS Gadget'/ffffffc07b025a38 Stopping sshd: OK Stopping lighttpd: OK Gracefully shutting down php-fpm . done Stopping dhcpcd... stopped /sbin/dhcpcd (pid 924) killall: rkisp_3A_server: no process killed Stopping network: OK stop finishedStopping system message bus: done Saving random seed... done. Stopping logging: OK umount: can't remount adb read-only umount: devtmpfs busy - remounted read-only [ 21.589884] EXT4-fs (mmcblk2p8): re-mounted. Opts: (null) The system is going down NOW! Sent SIGTERM to all processes Sent SIGKILL to all processes Requesting system poweroff [ 23.597578] cpu cpu4: min=816000, max=816000 [ 23.598572] cpu cpu0: min=816000, max=816000 [ 23.669985] I : [File] : drivers/gpu/arm/midgard_for_linux/platform/rk/mali_kbase_config_rk.c; [Line] : 274; [Func] : kbase_platform_rk_shutdown(); to make vdd_gpu enabled for turning off pd_gpu in pm_framework. [ 23.671701] rk-vcodec ff660000.rkvdec: shutdown [ 23.672132] rk-vcodec ff650000.vpu_service: shutdown [ 23.673046] rk808 0-001b: System power off [ 23.673419] rk808 0-001b: test message //加入的測(cè)試信息 [root@rk3399:/]# poweroff --help BusyBox v1.27.2 (2020-03-19 09:39:13 UTC) multi-call binary. Usage: poweroff [-d DELAY] [-n] [-f] Halt and shut off power -d SEC Delay interval -n Do not sync -f Force (don't go through init)
Poweroff命令做的事可以從打印信息上看出來,其實(shí)可以分為兩部分,一是配置系統(tǒng),停止當(dāng)前的服務(wù),進(jìn)行數(shù)據(jù)保存。二是調(diào)用電源管理驅(qū)動(dòng)對(duì)應(yīng)的接口,完成電源配置,RK3399 主板進(jìn)行關(guān)機(jī)。
涉及驅(qū)動(dòng)文件
kernel/drivers/mfd/rk808.cstatic void rk808_syscore_shutdown(void) { int ret; struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); if (!rk808) { dev_warn(&rk808_i2c_client->dev, "have no rk808, so do nothing here\n"); return; } /* close rtc int when power off */ regmap_update_bits(rk808->regmap, RK808_INT_STS_MSK_REG1, (0x3 << 5), (0x3 << 5)); ? ? ? ?regmap_update_bits(rk808->regmap, RK808_
RTC
_INT_REG, (0x3 << 2), (0x0 << 2)); ? ? ? ?/* ? ? ? ? * For PMIC that power off supplies by write register via i2c bus, ? ? ? ? * it's better to do power off at syscore shutdown here. ? ? ? ? * ? ? ? ? * Because when run to kernel's "pm_power_off" call, i2c may has ? ? ? ? * been stopped or PMIC may not be able to get i2c transfer while ? ? ? ? * there are too many devices are competiting. ? ? ? ? */ ? ? ? ? if (system_state == SYSTEM_POWER_OFF) { ? ? ? ? ? ? ? ?/* power off supplies ! */ ? ? ? ? ? ? ? ?if (pm_shutdown) { ? ? ? ? ? ? ? ? ? ? ? ?dev_info(&rk808_i2c_client->dev, "System power off\n"); ret = pm_shutdown(rk808->regmap); if (ret) dev_err(&rk808_i2c_client->dev, "System power off error!\n"); mdelay(10); dev_info(&rk808_i2c_client->dev, "Cpu should never reach here, stop!\n"); while (1) ; } } }#define DEV_OFF_RST BIT(3) static int rk808_shutdown(struct regmap *regmap) { int ret; ret = regmap_update_bits(regmap, RK808_DEVCTRL_REG, DEV_OFF_RST, DEV_OFF_RST); return ret; }
最終調(diào)用的的rk808shutdown接口函數(shù),對(duì)RK808DEVCTRLREG寄存器寫入DEVOFF_RST,觸發(fā)RK3399主板關(guān)機(jī)。
進(jìn)入飛凌嵌入式官網(wǎng)>>了解關(guān)于OK3399-C開發(fā)板的更多信息。
-
RK3399
+關(guān)注
關(guān)注
2文章
212瀏覽量
25157 -
瑞芯微RK3399
+關(guān)注
關(guān)注
1文章
21瀏覽量
5747
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
RK3399處理器:高性能多核異構(gòu)計(jì)算平臺(tái)
Linux系統(tǒng)更換開機(jī)logo方法教程,觸覺智能RK3562開發(fā)板演示

高清電視盒子方案分享,紅外遙控適配過程全解析

RK3576單板發(fā)布倒計(jì)時(shí):RK3399與RK3576對(duì)比

玩轉(zhuǎn)RK3588開發(fā)板基于connector-split 功能實(shí)現(xiàn)多屏聯(lián)動(dòng)

瑞芯微RK3399開發(fā)板Android7.1修改網(wǎng)絡(luò)優(yōu)先級(jí)方法,觸覺智能SBC3968開發(fā)板演示

慧視Viztra-ME025圖像處理板 中端性能的RK3399Pro板卡

【OpenHarmony鴻蒙實(shí)戰(zhàn)】在RK3399開發(fā)板實(shí)現(xiàn)智能門禁人臉識(shí)別

評(píng)論