blob: 11a9357db4140d3dec56e01246c1a3615e13c834 [file] [log] [blame]
Hao Zhang4984bce2014-07-09 19:48:43 +03001/*
2 * Keystone EVM : Board initialization
3 *
4 * (C) Copyright 2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
11#include <asm/io.h>
Hao Zhang7b26c1f2014-07-09 19:48:44 +030012#include <asm/arch/mon.h>
13#include <asm/arch/psc_defs.h>
14#include <asm/arch/hardware.h>
Hao Zhang4984bce2014-07-09 19:48:43 +030015#include <asm/arch/hardware.h>
16
17/**
18 * cpu_to_bus - swap bytes of the 32-bit data if the device is BE
19 * @ptr - array of data
20 * @length - lenght of data array
21 */
22int cpu_to_bus(u32 *ptr, u32 length)
23{
24 u32 i;
25
Khoronzhuk, Ivan3d315382014-07-09 23:44:44 +030026 if (!(readl(KS2_DEVSTAT) & 0x1))
Hao Zhang4984bce2014-07-09 19:48:43 +030027 for (i = 0; i < length; i++, ptr++)
28 *ptr = cpu_to_be32(*ptr);
29
30 return 0;
31}
Hao Zhang7b26c1f2014-07-09 19:48:44 +030032
33static int turn_off_myself(void)
34{
35 printf("Turning off ourselves\r\n");
36 mon_power_off(0);
37
38 psc_disable_module(KS2_LPSC_TETRIS);
39 psc_disable_domain(KS2_TETRIS_PWR_DOMAIN);
40
41 asm volatile ("isb\n"
42 "dsb\n"
43 "wfi\n");
44
45 printf("What! Should not see that\n");
46 return 0;
47}
48
49static void turn_off_all_dsps(int num_dsps)
50{
51 int i;
52
53 for (i = 0; i < num_dsps; i++) {
54 if (psc_disable_module(i + KS2_LPSC_GEM_0))
55 printf("Cannot disable module for #%d DSP", i);
56
57 if (psc_disable_domain(i + 8))
58 printf("Cannot disable domain for #%d DSP", i);
59 }
60}
61
62int do_killme_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
63{
64 return turn_off_myself();
65}
66
67U_BOOT_CMD(
68 killme, 1, 0, do_killme_cmd,
69 "turn off main ARM core",
70 "turn off main ARM core. Should not live after that :(\n"
71);
72
73int misc_init_r(void)
74{
75 char *env;
76 long ks2_debug = 0;
77
78 env = getenv("ks2_debug");
79
80 if (env)
81 ks2_debug = simple_strtol(env, NULL, 0);
82
83 if ((ks2_debug & DBG_LEAVE_DSPS_ON) == 0)
84 turn_off_all_dsps(KS2_NUM_DSPS);
85
86 return 0;
87}