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