Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-keystone / keystone.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Keystone EVM : Board initialization
4  *
5  * (C) Copyright 2014
6  *     Texas Instruments Incorporated, <www.ti.com>
7  */
8
9 #include <common.h>
10 #include <env.h>
11 #include <init.h>
12 #include <asm/io.h>
13 #include <asm/arch/psc_defs.h>
14 #include <asm/arch/hardware.h>
15
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  */
21 int cpu_to_bus(u32 *ptr, u32 length)
22 {
23         u32 i;
24
25         if (!(readl(KS2_DEVSTAT) & 0x1))
26                 for (i = 0; i < length; i++, ptr++)
27                         *ptr = cpu_to_be32(*ptr);
28
29         return 0;
30 }
31
32 static 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
40                 if (psc_disable_domain(i + KS2_GEM_0_PWR_DOMAIN))
41                         printf("Cannot disable domain for #%d DSP", i);
42         }
43 }
44
45 int misc_init_r(void)
46 {
47         char *env;
48         long ks2_debug = 0;
49
50         env = env_get("ks2_debug");
51
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 }