blob: a20e0c98865c591c8d4a23e303d26bd672510274 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -04002/*
3 * MSMC controller utilities
4 *
5 * (C) Copyright 2012-2014
6 * Texas Instruments Incorporated, <www.ti.com>
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -04007 */
8
Hao Zhangbccf0b72014-07-16 00:59:24 +03009#include <asm/arch/msmc.h>
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040010
11struct mpax {
12 u32 mpaxl;
13 u32 mpaxh;
14};
15
16struct 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 Zhangbccf0b72014-07-16 00:59:24 +030057void msmc_share_all_segments(int priv_id)
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040058{
Khoronzhuk, Ivand5cb1bb2014-07-09 23:44:44 +030059 struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE;
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040060 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 Andrianov5184ff92014-10-22 17:47:57 +030067
68void 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
78void 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
86void 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}