2013-08-03 14:40:59 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <minix/type.h>
|
2013-12-13 14:12:50 +01:00
|
|
|
#include <minix/board.h>
|
2013-08-03 14:40:59 +02:00
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
#include "kernel/kernel.h"
|
|
|
|
#include "kernel/proc.h"
|
|
|
|
#include "kernel/vm.h"
|
|
|
|
#include "kernel/proto.h"
|
|
|
|
#include "arch_proto.h"
|
2014-02-07 08:46:29 +01:00
|
|
|
#include "bsp_reset.h"
|
|
|
|
|
|
|
|
#include "omap_rtc.h"
|
2013-08-03 14:40:59 +02:00
|
|
|
|
2013-12-13 14:12:50 +01:00
|
|
|
#define AM335X_CM_BASE 0x44E00000
|
|
|
|
#define AM335X_CM_SIZE 0x1000
|
|
|
|
|
|
|
|
#define AM335X_PRM_DEVICE_OFFSET 0xf00
|
|
|
|
#define AM335X_PRM_RSTCTRL_REG 0x00
|
2014-02-24 09:40:30 +01:00
|
|
|
#define AM335X_RST_GLOBAL_WARM_SW_BIT 0
|
2013-12-13 14:12:50 +01:00
|
|
|
|
|
|
|
#define DM37XX_CM_BASE 0x48307000
|
|
|
|
#define DM37XX_CM_SIZE 0x1000
|
|
|
|
#define DM37XX_PRM_RSTCTRL_REG 0x250
|
|
|
|
#define DM37XX_RST_DPLL3_BIT 2
|
2013-08-03 14:40:59 +02:00
|
|
|
|
|
|
|
struct omap_reset
|
|
|
|
{
|
|
|
|
vir_bytes base;
|
|
|
|
vir_bytes size;
|
|
|
|
};
|
|
|
|
|
2013-12-13 14:12:50 +01:00
|
|
|
static struct omap_reset omap_reset;
|
2013-08-03 14:40:59 +02:00
|
|
|
|
|
|
|
static kern_phys_map reset_phys_map;
|
|
|
|
|
|
|
|
void
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_reset_init(void)
|
2013-08-03 14:40:59 +02:00
|
|
|
{
|
2014-02-24 09:40:30 +01:00
|
|
|
if (BOARD_IS_BBXM(machine.board_id)) {
|
2013-12-13 14:12:50 +01:00
|
|
|
omap_reset.base = DM37XX_CM_BASE;
|
|
|
|
omap_reset.size = DM37XX_CM_SIZE;
|
2014-02-24 09:40:30 +01:00
|
|
|
} else if (BOARD_IS_BB(machine.board_id)) {
|
2013-12-13 14:12:50 +01:00
|
|
|
omap_reset.base = AM335X_CM_BASE;
|
|
|
|
omap_reset.size = AM335X_CM_SIZE;
|
|
|
|
}
|
|
|
|
|
2014-02-24 09:47:13 +01:00
|
|
|
kern_phys_map_ptr(omap_reset.base, omap_reset.size,
|
|
|
|
VMMF_UNCACHED | VMMF_WRITE,
|
|
|
|
&reset_phys_map, (vir_bytes) & omap_reset.base);
|
2013-08-03 14:40:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_reset(void)
|
2013-08-03 14:40:59 +02:00
|
|
|
{
|
2014-02-24 09:40:30 +01:00
|
|
|
if (BOARD_IS_BBXM(machine.board_id)) {
|
|
|
|
mmio_set((omap_reset.base + DM37XX_PRM_RSTCTRL_REG),
|
|
|
|
(1 << DM37XX_RST_DPLL3_BIT));
|
|
|
|
} else if (BOARD_IS_BB(machine.board_id)) {
|
|
|
|
mmio_set((omap_reset.base + AM335X_PRM_DEVICE_OFFSET +
|
|
|
|
AM335X_PRM_RSTCTRL_REG),
|
|
|
|
(1 << AM335X_RST_GLOBAL_WARM_SW_BIT));
|
2013-12-13 14:12:50 +01:00
|
|
|
}
|
2013-08-03 14:40:59 +02:00
|
|
|
}
|
2014-02-07 08:46:29 +01:00
|
|
|
|
2014-02-24 09:40:30 +01:00
|
|
|
void
|
|
|
|
bsp_poweroff(void)
|
2014-02-07 08:46:29 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-02-24 09:40:30 +01:00
|
|
|
if (BOARD_IS_BB(machine.board_id)) {
|
|
|
|
/* rtc was frozen to prevent premature power-off, unfreeze it
|
|
|
|
* now */
|
|
|
|
omap3_rtc_run();
|
2014-02-07 08:46:29 +01:00
|
|
|
|
2014-02-24 09:40:30 +01:00
|
|
|
/* wait for the alarm to go off and PMIC to disable power to
|
|
|
|
* SoC */
|
|
|
|
while (1);
|
|
|
|
}
|
2014-02-07 08:46:29 +01:00
|
|
|
}
|