Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 2 | /* |
| 3 | * MSMC controller utilities |
| 4 | * |
| 5 | * (C) Copyright 2012-2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Hao Zhang | bccf0b7 | 2014-07-16 00:59:24 +0300 | [diff] [blame] | 10 | #include <asm/arch/msmc.h> |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 11 | |
| 12 | struct mpax { |
| 13 | u32 mpaxl; |
| 14 | u32 mpaxh; |
| 15 | }; |
| 16 | |
| 17 | struct msms_regs { |
| 18 | u32 pid; |
| 19 | u32 _res_04; |
| 20 | u32 smcerrar; |
| 21 | u32 smcerrxr; |
| 22 | u32 smedcc; |
| 23 | u32 smcea; |
| 24 | u32 smsecc; |
| 25 | u32 smpfar; |
| 26 | u32 smpfxr; |
| 27 | u32 smpfr; |
| 28 | u32 smpfcr; |
| 29 | u32 _res_2c; |
| 30 | u32 sbndc[8]; |
| 31 | u32 sbndm; |
| 32 | u32 sbnde; |
| 33 | u32 _res_58; |
| 34 | u32 cfglck; |
| 35 | u32 cfgulck; |
| 36 | u32 cfglckstat; |
| 37 | u32 sms_mpax_lck; |
| 38 | u32 sms_mpax_ulck; |
| 39 | u32 sms_mpax_lckstat; |
| 40 | u32 ses_mpax_lck; |
| 41 | u32 ses_mpax_ulck; |
| 42 | u32 ses_mpax_lckstat; |
| 43 | u32 smestat; |
| 44 | u32 smirstat; |
| 45 | u32 smirc; |
| 46 | u32 smiestat; |
| 47 | u32 smiec; |
| 48 | u32 _res_94_c0[12]; |
| 49 | u32 smncerrar; |
| 50 | u32 smncerrxr; |
| 51 | u32 smncea; |
| 52 | u32 _res_d0_1fc[76]; |
| 53 | struct mpax sms[16][8]; |
| 54 | struct mpax ses[16][8]; |
| 55 | }; |
| 56 | |
| 57 | |
Hao Zhang | bccf0b7 | 2014-07-16 00:59:24 +0300 | [diff] [blame] | 58 | void msmc_share_all_segments(int priv_id) |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 59 | { |
Khoronzhuk, Ivan | d5cb1bb | 2014-07-09 23:44:44 +0300 | [diff] [blame] | 60 | struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE; |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 61 | int j; |
| 62 | |
| 63 | for (j = 0; j < 8; j++) { |
| 64 | msmc->sms[priv_id][j].mpaxh &= 0xffffff7ful; |
| 65 | msmc->ses[priv_id][j].mpaxh &= 0xffffff7ful; |
| 66 | } |
| 67 | } |
Vitaly Andrianov | 5184ff9 | 2014-10-22 17:47:57 +0300 | [diff] [blame] | 68 | |
| 69 | void msmc_map_ses_segment(int priv_id, int ses_pair, |
| 70 | u32 src_pfn, u32 dst_pfn, enum mpax_seg_size size) |
| 71 | { |
| 72 | struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE; |
| 73 | |
| 74 | msmc->ses[priv_id][ses_pair].mpaxh = src_pfn << 12 | |
| 75 | (size & 0x1f) | 0x80; |
| 76 | msmc->ses[priv_id][ses_pair].mpaxl = dst_pfn << 8 | 0x3f; |
| 77 | } |
| 78 | |
| 79 | void msmc_get_ses_mpax(int priv_id, int ses_pair, u32 *mpax) |
| 80 | { |
| 81 | struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE; |
| 82 | |
| 83 | *mpax++ = msmc->ses[priv_id][ses_pair].mpaxl; |
| 84 | *mpax = msmc->ses[priv_id][ses_pair].mpaxh; |
| 85 | } |
| 86 | |
| 87 | void msmc_set_ses_mpax(int priv_id, int ses_pair, u32 *mpax) |
| 88 | { |
| 89 | struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE; |
| 90 | |
| 91 | msmc->ses[priv_id][ses_pair].mpaxl = *mpax++; |
| 92 | msmc->ses[priv_id][ses_pair].mpaxh = *mpax; |
| 93 | } |