Nx32926 命令关机

一. poweroff关机命令

~ # poweroff
~ # baud=115200, quot=102
w-config: 8bits/char
umount: devtmpfs busy - remounted read-only
Cannot open value file.
umount: can‘t remount rootfs reabaud=115200, quot=102
w-config: 8bits/char
d-only
cannot run ‘/sbin/swapoff‘: No such file or dirRTL871X: rtw_cmd_thread(wlan0) _rtw_down_sema(&pcmdpriv->cmd_queue_sema) return _FAIL, break
ectory
The system is going down NOW!
Sent SIGTERM to all processes
videoin_close
Sensor power down
Sensor power down
I2C removed
Sent SIGKILL toPower down.
enter to w55fa92_poweroff()

二、内核代码

void w55fa92_poweroff(void)
{
    unsigned long volatile flags;
#if defined(CONFIG_RTC_DRV_W55FA92)
    int rtc_time_out;
#endif

    printk("enter to w55fa92_poweroff()\n");
    msleep(10);

    // disable LVR
    __raw_writel(__raw_readl(REG_MISCR) & ~(LVR_RDY | LVR_EN), REG_MISCR);

    // turn off speaker
#if defined(CONFIG_GIANTPLUS_GPM1006D0_320X240)
    __raw_writel(__raw_readl(REG_GPIOE_OMD) | (1 << 1), REG_GPIOE_OMD);
    __raw_writel(__raw_readl(REG_GPIOE_DOUT) & ~(1 << 1), REG_GPIOE_DOUT);
#endif

    // turn off video out
    __raw_writel((__raw_readl(REG_LCM_TVCtl) & ~TVCtl_LCDSrc) | 0x800, REG_LCM_TVCtl);

    // disable system interrupts
    local_irq_save(flags);

#if defined(CONFIG_RTC_DRV_W55FA92)
    __raw_writel(__raw_readl(REG_APBCLK) | RTC_CKE, REG_APBCLK);
    while (1) {
        rtc_time_out = 0;
        // enable long time press power disable
        if ((__raw_readl(REG_RTC_AER) & 0x10000) == 0x0) {
            // set RTC register access enable password
            __raw_writel(0xA965, REG_RTC_AER);
            // make sure RTC register read/write enable
            while ((__raw_readl(REG_RTC_AER) & 0x10000) == 0x0) {
                rtc_time_out++;
                if (rtc_time_out > 0xFFFFFF) {
                    printk("RTC Access Eanble Fail\n");
                    break;
                }
            }

            rtc_wait_ready();

            if ((__raw_readl(REG_RTC_AER) & 0x10000) == 0x10000)
                break;
        }
        else
            break;
    }

    // RTC will power off
    __raw_writel((__raw_readl(REG_RTC_PWRON) & ~0x5) | 0x2, REG_RTC_PWRON);
#else
    // turn off power
    __raw_writel(__raw_readl(REG_GPIOE_OMD) | (1<<9), REG_GPIOE_OMD);
    __raw_writel(__raw_readl(REG_GPIOE_DOUT) & ~(1<<9), REG_GPIOE_DOUT);
#endif

    // enable system interrupts
    local_irq_restore(flags);

    // stop CPU clock
    //__raw_writel(__raw_readl(REG_AHBCLK) & ~CPU_CKE, REG_AHBCLK);
    // fix RTC may wakeup fail issue
    __raw_writel(0x0, REG_AHBCLK);

    // wait system enter power off
    while (1) ;
}

void w55fa92_reboot(void)
{
    unsigned long volatile flags;

    local_irq_save(flags);
    printk("enter to w55fa92_reboot()\n");

    // turn off speaker
#if defined(CONFIG_GIANTPLUS_GPM1006D0_320X240)
    __raw_writel(__raw_readl(REG_GPIOE_OMD) | (1 << 1), REG_GPIOE_OMD);
    __raw_writel(__raw_readl(REG_GPIOE_DOUT) & ~(1 << 1), REG_GPIOE_DOUT);
#endif

    // turn off video out
    __raw_writel((__raw_readl(REG_LCM_TVCtl) & ~TVCtl_LCDSrc) | 0x800, REG_LCM_TVCtl);

    // close NAND and SIC engine clock
    __raw_writel(__raw_readl(REG_AHBCLK) & ~(NAND_CKE|SIC_CKE), REG_AHBCLK);

    // watchdog reset
    __raw_writel((__raw_readl(REG_WTCR) & ~(3<<4|1<<10))|0x2C2, REG_WTCR);

    // wait system enter power off
    while (1) ;
    local_irq_restore(flags);
}

static ssize_t
write_clk(struct device *dev, struct device_attribute *attr,
      const char *buffer, size_t count)
{
    int i;

    // power down mode
    if (buffer[0] == ‘p‘ && buffer[1] == ‘d‘) {
        w55fa92_pm_suspend(1);
    }

#if 0
    // idle mode or memory idle mode
    else if ((buffer[0] == ‘i‘ && buffer[1] == ‘d‘) || (buffer[0] == ‘m‘ && buffer[1] == ‘i‘)) {
        w55fa92_pm_idle();
    }
#endif

#if defined(CONFIG_RTC_DRV_W55FA92)
    // RTC power off mode
    else if (buffer[0] == ‘r‘ && buffer[1] == ‘p‘ && buffer[2] == ‘o‘) {
        w55fa92_poweroff();
    }
#else
    // power off mode
    else if (buffer[0] == ‘p‘ && buffer[1] == ‘o‘) {
        w55fa92_poweroff();
    }
#endif

    // power reset mode
    else if (buffer[0] == ‘p‘ && buffer[1] == ‘r‘) {
        w55fa92_reboot();
    }

    // CPU:PLL clock change
    else {
        u32 pll_clock, sys_clock, cpu_clock, apb_clock, vpost_clock;
        u8 vpost_div_N0, vpost_div_N1;
        char clock_buf[64];
        char *clock1, *clock2, *next;

        strncpy(clock_buf, buffer, count);
        next = &clock_buf[0];
        pll_clock = w55fa92_upll_clock;
        clock1 = strsep(&next, ":");
        //printk("clock1 = %s\n", clock1);
        cpu_clock = simple_strtol(clock1, NULL, 10) * 1000;
        if (cpu_clock == 0) {
            printk("Command \"%s\" does not support !!\n", clock1);
            return -1;
        }
        if (next) {
            clock2 = strsep(&next, ":");
            //printk("clock2 = %s\n", clock2);
            pll_clock = simple_strtol(clock2, NULL, 10) * 1000;
            if (pll_clock == 0) {
                printk("Command \"%s\" does not support !!\n", clock2);
                return -1;
            }
        }

        if (pll_clock % cpu_clock) {
            printk("UPLL clock(%d) is not a multiple of CPU clock(%d) !!\n",
                pll_clock, cpu_clock);
            return -1;
        }

#if defined(CONFIG_FB_W55FA92)
        vpost_div_N0 = (__raw_readl(REG_CLKDIV1) & VPOST_N0) + 1;
        vpost_div_N1 = ((__raw_readl(REG_CLKDIV1) & VPOST_N1) >> 8) + 1;
        vpost_clock = pll_clock / (vpost_div_N0 * vpost_div_N1);
        if (cpu_clock > vpost_clock*2) {
            sys_clock = cpu_clock;
        } else {
            for (i = 1; ; i++) {
                sys_clock = cpu_clock * i * 2;
                if ((i > 8) || (sys_clock > pll_clock)) {
                    printk("Cannot get valid System clock !!\n");
                    return -1;
                }
                if ((sys_clock>(vpost_clock*2)) && ((pll_clock%sys_clock)==0))
                    break;
            }
        }
#else
        sys_clock = cpu_clock;
#endif
        apb_clock = (cpu_clock == sys_clock) ? cpu_clock/4 : cpu_clock/2;
#if CPU_DEBUG
        printk("vpost_clock = %d\n", vpost_clock);
        printk("pll_clock = %d\n", pll_clock);
        printk("sys_clock = %d\n", sys_clock);
        printk("cpu_clock = %d\n", cpu_clock);
        printk("apb_clock = %d\n", apb_clock);
#endif

        // PLL:SYS:CPU:AHB:APB = pll_clock:sys_clock:cpu_clock:sys_clock/2:apb_clock
        set_system_clocks(pll_clock, sys_clock, cpu_clock, apb_clock);
    }

    return count;
}

/* Attach the sysfs write method */
DEVICE_ATTR(clock, 0644, read_clk, write_clk);

/* Attribute Descriptor */
static struct attribute *clk_attrs[] = {
    &dev_attr_clock.attr,
    NULL
};

/* Attribute group */
static struct attribute_group clk_attr_group = {
    .attrs = clk_attrs,
};

static int __init w55fa92_system_clock_init(void)
{
    /* Register a platform device */
    printk("register clock device\n");
  ///sys/devices/w55fa92-clk
    sys_clk = platform_device_register_simple("w55fa92-clk", -1, NULL, 0);
    if (sys_clk == NULL)
        printk("register failed\n");
    sysfs_create_group(&sys_clk->dev.kobj, &clk_attr_group);
    sram_vaddr = ioremap(0xFF000000, 4*1024);

    return 0;
}

module_init(w55fa92_system_clock_init);
时间: 2024-10-08 05:26:34

Nx32926 命令关机的相关文章

windows命令关机

不知道为啥,远程连接的window服务器没有关机命令,感觉是不是管理员权限导致的,所以找了下用命令关机,如下 shutdown -s -t 5 #5秒内关机 shutdown -r -t 5 #5秒内重启

桌面支持--win8命令关机重启

win8命令关机重启 当然,下面的代码也同时适用上面两个方法. 关机:shutdown.exe –s –t 00 重新启动:shutdown.exe –r –t 00 休眠:rundll32.exe PowrProf.dll,SetSuspendState 睡眠:rundll32.exe powrprof.dll,SetSuspendState 0,1,0 锁定:Rundll32.exe User32.dll,LockWorkStation

linux常用命令-关机、重启

常用命令-关机.重启 命令 含义 reboot 重新启动操作系 shutdown –r now 重新启动操作系统,shutdown会给别的用户提示 shutdown -h now 立刻关机,其中now相当于时间为0的状态 shutdown -h 20:25 系统在今天的20:25 会关机 shutdown -h +10 系统再过十分钟后自动关机 原文地址:https://www.cnblogs.com/xuchuankun/p/9317809.html

Linux常用命令-关机重启命令

关机重启命令 shutdown命令 语法:shutdown [选项] 时间 -c:取消前一个关机命令:-h:关机:-r:重启: 例:shutdown -h now shutdown -h 20:30(八点半关机) 关机命令:halt;   poweroff; init 0; 重启命令:reboot; init 6 系统运行级别(init) init进程配置文件路径:/etc/inittab 0:关机 1:单用户 2:不完全多用户,不含NFS服务(NFS:network file system 网

Linux 命令 - 关机重启命令 shutdown

shutdown [选项] 时间 (关机重启更安全) -c 取消前一个关机命令 -h 关机 -r 重启 例如:&表示在后台运行 [email protected]:~# shutdown -r 05:30 & [1] 1805 [email protected]:~# Shutdown scheduled for Fri 2015-08-21 05:30:00 PDT, use 'shutdown -c' to cancel. [1]+ Done shutdown -r 05:30 [em

shutdown reboot init &nbsp; 重启命令 关机命令 简单介绍

Linux centos重启命令: 1.reboot 2.shutdown -r now 立刻重启(root用户使用) 3.shutdown -r 10 过10分钟自动重启(root用户使用) 4.shutdown -r 20:35 在时间为20:35时候重启(root用户使用) 如果是通过shutdown命令设置重启的话,可以用shutdown -c命令取消重启 Linux centos关机命令: 1.halt 立刻关机 2.poweroff 立刻关机 3.shutdown -h now 立刻

WIN7 shutdown 定时/倒计时 命令关机

解决方案: 一.可以通过DOS命令shutdown来解决 在 Win7 中,shutdown实现自动关机的方法如下: 开始->运行->cmd 运行"shutdown -s -t 3600", 其中"3600"为离关机的时间秒数,运行 "shutdown -a"取消定时关机! 或是编写批处理文件:关机一分钟前提醒即将关机,可自行修改定时关机时间. @echo off at 22:50 every:M,T,W,Th,F,S,Su shut

Python利用多线程定时执行cmd命令关机

利用os模块可以执行cmd命令,利用这一点可以实现定时关机,然而在等待关机的过程中也不能啥都不干,于是多线程派上了用场. #! /usr/bin/env python #coding=utf-8 #这里需要引入三个模块 import time, os, sched, easygui, thread # 第一个参数确定任务的时间,返回从某个特定的时间到现在经历的秒数 # 第二个参数以某种人为的方式衡量时间 schedule = sched.scheduler(time.time, time.sle

Linux命令-关机命令:shutdown

shutdown -h now 现在马上关机 shutdown -h 20:30 晚上8:30定时关机shutdown -r now 现在马上重起shutdown -r 20:30 晚上8:30定时重起