blob: efaabca5a7e77eb02888399dcc182e49f2217bc4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Hao Zhang4984bce2014-07-09 19:48:43 +03002/*
3 * Keystone EVM : Board initialization
4 *
5 * (C) Copyright 2014
6 * Texas Instruments Incorporated, <www.ti.com>
Hao Zhang4984bce2014-07-09 19:48:43 +03007 */
8
9#include <common.h>
Simon Glass09140112020-05-10 11:40:03 -060010#include <env.h>
Simon Glass691d7192020-05-10 11:40:02 -060011#include <init.h>
Hao Zhang4984bce2014-07-09 19:48:43 +030012#include <asm/io.h>
Hao Zhang7b26c1f2014-07-09 19:48:44 +030013#include <asm/arch/psc_defs.h>
14#include <asm/arch/hardware.h>
Hao Zhang4984bce2014-07-09 19:48:43 +030015
16/**
17 * cpu_to_bus - swap bytes of the 32-bit data if the device is BE
18 * @ptr - array of data
19 * @length - lenght of data array
20 */
21int cpu_to_bus(u32 *ptr, u32 length)
22{
23 u32 i;
24
Khoronzhuk, Ivan3d315382014-07-09 23:44:44 +030025 if (!(readl(KS2_DEVSTAT) & 0x1))
Hao Zhang4984bce2014-07-09 19:48:43 +030026 for (i = 0; i < length; i++, ptr++)
27 *ptr = cpu_to_be32(*ptr);
28
29 return 0;
30}
Hao Zhang7b26c1f2014-07-09 19:48:44 +030031
Hao Zhang7b26c1f2014-07-09 19:48:44 +030032static void turn_off_all_dsps(int num_dsps)
33{
34 int i;
35
36 for (i = 0; i < num_dsps; i++) {
37 if (psc_disable_module(i + KS2_LPSC_GEM_0))
38 printf("Cannot disable module for #%d DSP", i);
39
Suman Anna4ed8b2c2016-03-04 10:36:38 -060040 if (psc_disable_domain(i + KS2_GEM_0_PWR_DOMAIN))
Hao Zhang7b26c1f2014-07-09 19:48:44 +030041 printf("Cannot disable domain for #%d DSP", i);
42 }
43}
44
Hao Zhang7b26c1f2014-07-09 19:48:44 +030045int misc_init_r(void)
46{
47 char *env;
48 long ks2_debug = 0;
49
Simon Glass00caae62017-08-03 12:22:12 -060050 env = env_get("ks2_debug");
Hao Zhang7b26c1f2014-07-09 19:48:44 +030051
52 if (env)
53 ks2_debug = simple_strtol(env, NULL, 0);
54
55 if ((ks2_debug & DBG_LEAVE_DSPS_ON) == 0)
56 turn_off_all_dsps(KS2_NUM_DSPS);
57
58 return 0;
59}