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