2012-10-08 03:38:03 +02:00
|
|
|
|
|
|
|
#include "kernel/kernel.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <machine/vm.h>
|
2013-08-02 16:10:55 +02:00
|
|
|
#include <io.h>
|
2012-10-08 03:38:03 +02:00
|
|
|
|
2013-08-02 16:10:55 +02:00
|
|
|
#include <minix/reboot.h>
|
2012-10-08 03:38:03 +02:00
|
|
|
#include <minix/u64.h>
|
|
|
|
|
|
|
|
#include "archconst.h"
|
|
|
|
#include "arch_proto.h"
|
|
|
|
#include "serial.h"
|
2013-08-02 16:10:55 +02:00
|
|
|
#include "omap_rtc.h"
|
2013-08-26 18:43:05 +02:00
|
|
|
#include "omap_reset.h"
|
2012-10-08 03:38:03 +02:00
|
|
|
#include "kernel/proc.h"
|
|
|
|
#include "kernel/debug.h"
|
|
|
|
#include "direct_utils.h"
|
|
|
|
#include <machine/multiboot.h>
|
|
|
|
|
2012-10-18 12:03:34 +02:00
|
|
|
void
|
|
|
|
halt_cpu(void)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2012-10-18 12:03:34 +02:00
|
|
|
asm volatile("dsb");
|
|
|
|
asm volatile("cpsie i");
|
|
|
|
asm volatile("wfi");
|
2013-02-15 01:07:04 +01:00
|
|
|
asm volatile("cpsid i");
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
reset(void)
|
|
|
|
{
|
2013-08-03 14:40:59 +02:00
|
|
|
omap3_reset();
|
|
|
|
direct_print("Reset not supported.");
|
|
|
|
while (1);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 16:10:55 +02:00
|
|
|
void
|
|
|
|
poweroff(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The am335x can signal an external power management chip to cut the power
|
|
|
|
* by toggling the PMIC_POWER_EN pin. It might fail if there isn't an
|
|
|
|
* external PMIC or if the PMIC hasn't been configured to respond to toggles.
|
|
|
|
* The only way to pull the pin low is via ALARM2 (see TRM 20.3.3.8).
|
|
|
|
* At this point PM should have already signaled readclock to set the alarm.
|
|
|
|
*/
|
|
|
|
#ifdef AM335X
|
|
|
|
|
|
|
|
/* Powers down the SoC within 3 seconds */
|
|
|
|
direct_print("PMIC Power-Off in 3 Seconds\n");
|
|
|
|
|
|
|
|
/* rtc was frozen to prevent premature power-off, unfreeze it now */
|
|
|
|
omap3_rtc_run();
|
|
|
|
|
|
|
|
/* wait for the alarm to go off and PMIC to disable power to SoC */
|
|
|
|
while (1);
|
|
|
|
|
|
|
|
#endif /* AM335X */
|
|
|
|
|
|
|
|
/* fallback option: hang */
|
|
|
|
direct_print("Unable to power-off this device.");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
2012-10-18 12:03:34 +02:00
|
|
|
__dead void
|
|
|
|
arch_shutdown(int how)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2013-08-02 16:10:55 +02:00
|
|
|
switch (how) {
|
2013-08-03 14:40:59 +02:00
|
|
|
case RBT_HALT:
|
|
|
|
/* Hang */
|
|
|
|
for (; ; ) halt_cpu();
|
|
|
|
NOT_REACHABLE;
|
2013-08-02 16:10:55 +02:00
|
|
|
|
|
|
|
case RBT_POWEROFF:
|
|
|
|
/* Power off if possible, hang otherwise */
|
|
|
|
poweroff();
|
|
|
|
NOT_REACHABLE;
|
|
|
|
|
|
|
|
default:
|
2013-08-03 14:40:59 +02:00
|
|
|
case RBT_DEFAULT:
|
|
|
|
case RBT_REBOOT:
|
|
|
|
case RBT_RESET:
|
|
|
|
/* Reset the system */
|
|
|
|
reset();
|
|
|
|
NOT_REACHABLE;
|
2013-08-02 16:10:55 +02:00
|
|
|
}
|
2012-10-18 12:03:34 +02:00
|
|
|
while (1);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
2012-10-18 12:03:34 +02:00
|
|
|
void
|
|
|
|
ser_putc(char c)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2012-10-18 12:03:34 +02:00
|
|
|
omap3_ser_putc(c);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|