• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * MSMC controller utilities
4  *
5  * (C) Copyright 2012-2014
6  *     Texas Instruments Incorporated, <www.ti.com>
7  */
8 
9 #include <common.h>
10 #include <asm/arch/msmc.h>
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 
msmc_share_all_segments(int priv_id)58 void msmc_share_all_segments(int priv_id)
59 {
60 	struct msms_regs *msmc = (struct msms_regs *)KS2_MSMC_CTRL_BASE;
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 }
68 
msmc_map_ses_segment(int priv_id,int ses_pair,u32 src_pfn,u32 dst_pfn,enum mpax_seg_size size)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 
msmc_get_ses_mpax(int priv_id,int ses_pair,u32 * mpax)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 
msmc_set_ses_mpax(int priv_id,int ses_pair,u32 * mpax)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 }
94