rk3288-android8-power的关机方法

遇到一个问题,

关机之后进入uboot状态,由于复用了UART2的打印口导致IO状态不对

1.解决方法:修改uboot是指UART2状态正常

2.修改关机状态,使之关机模式为真关机,让RK808来控制power开机

解决方法1:

\u-boot\arch\arm\cpu\armv7\rk32xx\iomux-rk3288.c

使能使IO能操作

static void rk_uart_iomux_config(int uart_id)
{
	switch (uart_id) {
	case RK_UART_BT_IOMUX:
		grf_writel((0x5 << 16) | 0x5, GRF_GPIO4C_IOMUX);
		break;
	case RK_UART_BB_IOMUX:
		grf_writel((0xf << 16) | 0x05, GRF_GPIO5B_IOMUX);
		break;
	case RK_UART_DBG_IOMUX:
- //		grf_writel((3 << 28) | (3 << 24) | (1 << 12) | (1 << 8), GRF_GPIO7CH_IOMUX);
+ 		    grf_writel((3 << 28) | (3 << 24) | (0 << 12) | (0 << 8), GRF_GPIO7CH_IOMUX);
		break;
	case RK_UART_GPS_IOMUX:
		grf_writel((0x3 << 30) | (0x1 << 14), GRF_GPIO7A_IOMUX);
		grf_writel((0x3 << 16) | (0x1 << 0), GRF_GPIO7B_IOMUX);
		break;
	case RK_UART_EXP_IOMUX:
		grf_writel((0xff << 24) | (0xff << 8), GRF_GPIO5B_IOMUX);
		break;
	default:
		debug("uart id = %d iomux error!\n", uart_id);
		break;
	}
}

u-boot\drivers\power\pmic\pmic_rk808.c 

把IO拉低

void rtc_check_onoff(void){

	unsigned long on_time,off_min,temp;
	off_min=rtc_get_off_min();
	off_min*=60;
	
	on_time=read_rtc()+off_min;

	int frt,key;

+   gpio_direction_output((GPIO_BANK7 | GPIO_C6),0);   
+   gpio_direction_output((GPIO_BANK7 | GPIO_C7),0);   

	while(1){

	if(b_auto_onoff_falg)	{
        temp=read_rtc();
		
         if(temp<on_time){

			long t=on_time-temp;
			int day=t/(24*60*60);
			t%=(24*60*60);
			int hour =t/(60*60);
			t%=60*60;
			int min=t/60;
			t%=60;
			int sec=t;
            printf("power sec=%d day=%d hour=%d min=%d sec=%d \n",(on_time-temp),day,hour,min,sec);
		 
	 }
	else break;	 
		}

	frt = board_fbt_key_pressed();

	if(frt==FASTBOOT_REBOOT_NORMAL) {

		break;

	}
	key=gpio_get_value(GPIO_BANK0 | GPIO_A5); // power key
	if(key==0){
                udelay(10*1000);
		 key=gpio_get_value(GPIO_BANK0 | GPIO_A5); // power key
               if(key==0) break;
	}
   gpio_direction_output((GPIO_BANK6 | GPIO_A5),1);
   gpio_direction_output((GPIO_BANK6 | GPIO_A7),1);  
	printf("keypower====%d \n",key);
	
         udelay(1000*1000);
		 
	}
	

}

参考补丁:

 

 修改后重新编译后实现uboot关机IO为低电平

方法二:

 

 sdk\kernel-\kernel\reboot.c

#include <linux/ctype.h>
#include <linux/export.h>
#include <linux/kexec.h>
#include <linux/kmod.h>
#include <linux/kmsg_dump.h>
#include <linux/reboot.h>
#include <linux/suspend.h>
#include <linux/syscalls.h>
#include <linux/syscore_ops.h>
#include <linux/uaccess.h>
- #include <linux/gpio.h>
- #include <linux/of_gpio.h>

/*
 * this indicates whether you can reboot with ctrl-alt-del: the default is yes
 */

int C_A_D = 1;
struct pid *cad_pid;
EXPORT_SYMBOL(cad_pid);

#if defined(CONFIG_ARM) || defined(CONFIG_UNICORE32)
#define DEFAULT_REBOOT_MODE		= REBOOT_HARD
#else
#define DEFAULT_REBOOT_MODE
#endif
enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;

 


void kernel_power_off(void)
{

 -     printk("fan kernel_power_off\n");
 -	   gpio_direction_output(160,0);
 -     gpio_direction_output(161,1);
 -     kernel_restart("charge");

	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
	if (pm_power_off_prepare)
		pm_power_off_prepare();
	migrate_to_reboot_cpu();
	syscore_shutdown();
	pr_emerg("Power down\n");
	kmsg_dump(KMSG_DUMP_POWEROFF);
	machine_power_off();
}
EXPORT_SYMBOL_GPL(kernel_power_off);

static DEFINE_MUTEX(reboot_mutex);

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

旋风旋风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值