Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hao Zhang | d68bb7e | 2014-07-09 19:48:43 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Keystone EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Hao Zhang | d68bb7e | 2014-07-09 19:48:43 +0300 | [diff] [blame] | 7 | */ |
| 8 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 9 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Hao Zhang | d68bb7e | 2014-07-09 19:48:43 +0300 | [diff] [blame] | 11 | #include <asm/io.h> |
Hao Zhang | 58a0d66 | 2014-07-09 19:48:44 +0300 | [diff] [blame] | 12 | #include <asm/arch/psc_defs.h> |
| 13 | #include <asm/arch/hardware.h> |
Hao Zhang | d68bb7e | 2014-07-09 19:48:43 +0300 | [diff] [blame] | 14 | |
| 15 | /** |
| 16 | * cpu_to_bus - swap bytes of the 32-bit data if the device is BE |
| 17 | * @ptr - array of data |
| 18 | * @length - lenght of data array |
| 19 | */ |
| 20 | int cpu_to_bus(u32 *ptr, u32 length) |
| 21 | { |
| 22 | u32 i; |
| 23 | |
Khoronzhuk, Ivan | d5cb1bb | 2014-07-09 23:44:44 +0300 | [diff] [blame] | 24 | if (!(readl(KS2_DEVSTAT) & 0x1)) |
Hao Zhang | d68bb7e | 2014-07-09 19:48:43 +0300 | [diff] [blame] | 25 | for (i = 0; i < length; i++, ptr++) |
| 26 | *ptr = cpu_to_be32(*ptr); |
| 27 | |
Hao Zhang | 58a0d66 | 2014-07-09 19:48:44 +0300 | [diff] [blame] | 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | static void turn_off_all_dsps(int num_dsps) |
| 32 | { |
| 33 | int i; |
| 34 | |
| 35 | for (i = 0; i < num_dsps; i++) { |
| 36 | if (psc_disable_module(i + KS2_LPSC_GEM_0)) |
| 37 | printf("Cannot disable module for #%d DSP", i); |
| 38 | |
Suman Anna | e45cec2 | 2016-03-04 10:36:38 -0600 | [diff] [blame] | 39 | if (psc_disable_domain(i + KS2_GEM_0_PWR_DOMAIN)) |
Hao Zhang | 58a0d66 | 2014-07-09 19:48:44 +0300 | [diff] [blame] | 40 | printf("Cannot disable domain for #%d DSP", i); |
| 41 | } |
| 42 | } |
| 43 | |
Hao Zhang | 58a0d66 | 2014-07-09 19:48:44 +0300 | [diff] [blame] | 44 | int misc_init_r(void) |
| 45 | { |
| 46 | char *env; |
| 47 | long ks2_debug = 0; |
| 48 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 49 | env = env_get("ks2_debug"); |
Hao Zhang | 58a0d66 | 2014-07-09 19:48:44 +0300 | [diff] [blame] | 50 | |
| 51 | if (env) |
| 52 | ks2_debug = simple_strtol(env, NULL, 0); |
| 53 | |
| 54 | if ((ks2_debug & DBG_LEAVE_DSPS_ON) == 0) |
| 55 | turn_off_all_dsps(KS2_NUM_DSPS); |
| 56 | |
| 57 | return 0; |
| 58 | } |