blob: f5cadfbf6692f58e428554f5a8be5efd0673dd53 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vitaly Andrianovef509b92014-04-04 13:16:53 -04002/*
3 * MSMC controller utilities
4 *
5 * (C) Copyright 2012-2014
6 * Texas Instruments Incorporated, <www.ti.com>
Vitaly Andrianovef509b92014-04-04 13:16:53 -04007 */
8
9#include <common.h>
Hao Zhang20187fd2014-07-16 00:59:24 +030010#include <asm/arch/msmc.h>
Vitaly Andrianovef509b92014-04-04 13:16:53 -040011
12struct mpax {
13 u32 mpaxl;
14 u32 mpaxh;
15};
16
17struct 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 Zhang20187fd2014-07-16 00:59:24 +030058void msmc_share_all_segments(int priv_id)
Vitaly Andrianovef509b92014-04-04 13:16:53 -040059{
Khoronzhuk, Ivan3d315382014-07-09 23:44:44 +030060 struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE;
Vitaly Andrianovef509b92014-04-04 13:16:53 -040061 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 Andrianov079da2d2014-10-22 17:47:57 +030068
69void 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
79void 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
87void 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}