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