遇到一个问题,
关机之后进入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);