通过引脚来控制整版电源,控制方式如下图:
1) GPIO_19 做开关机按键检测
2) GPIO6_31做电源的控制IO
开机思路:当按下按键后mos4459的第四个引脚被拉低->管子导通->整版上电->系统启动->加载内核->内核中编写 驱动把GPIO6_31拉高->npn三极管8050导通->第四个IO继续被拉低,此时就可以松开送。大概就三四秒钟。
关机思路:开机后长按GPIO_19按键,这个按键会持续向上层发生关机信号,android会弹出关机提示,然后系统会一层层的关闭,最后切断电源即控制GPIO6_31拉低。
先讲下关机的实现,先看一个函数,Kernel_imx/kernel/reboot.c中:
SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
void __user *, arg)
{
struct pid_namespace *pid_ns = task_active_pid_ns(current);
char buffer[256];
int ret = 0;
/* We only trust the superuser with rebooting the system. */
if (!ns_capable(pid_ns->user_ns, CAP_SYS_BOOT))
return -EPERM;
/* For safety, we require "magic" arguments. */
if (magic1 != LINUX_REBOOT_MAGIC1 ||
(magic2 != LINUX_REBOOT_MAGIC2 &&
magic2 != LINUX_REBOOT_MAGIC2A &&
magic2 != LINUX_REBOOT_MAGIC2B &&
magic2 != LINUX_REBOOT_MAGIC2C))
return -EINVAL;
/*
* If pid namespaces are enabled and the current task is in a child
* pid_namespace, the command is handled by reboot_pid_ns() which will
* call do_exit().
*/
ret = reboot_pid_ns(pid_ns, cmd);
if (ret)
return ret;
/* Instead of trying to mak