2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
37 #include <mips/nlm/hal/mips-extns.h>
39 static __inline__ uint32_t
40 nlm_read_c0_config6(void)
44 __asm__ __volatile__ (
54 static __inline__ void
55 nlm_write_c0_config6(uint32_t value)
57 __asm__ __volatile__ (
65 static __inline__ uint32_t
66 nlm_read_c0_config7(void)
70 __asm__ __volatile__ (
80 static __inline__ void
81 nlm_write_c0_config7(uint32_t value)
83 __asm__ __volatile__ (
91 * On power on reset, XLP comes up with 64 TLBs.
92 * Large-variable-tlb's (ELVT) and extended TLB is disabled.
93 * Enabling large-variable-tlb's sets up the standard
94 * TLB size from 64 to 128 TLBs.
95 * Enabling fixed TLB (EFT) sets up an additional 2048 tlbs.
96 * ELVT + EFT = 128 + 2048 = 2176 TLB entries.
97 * threads 64-entry-standard-tlb 128-entry-standard-tlb
98 * per std-tlb-only| std+EFT | std-tlb-only| std+EFT
100 * --------------------------------------------------------
101 * 1 64 64+2048 128 128+2048
102 * 2 64 64+1024 64 64+1024
103 * 4 32 32+512 32 32+512
105 * 1(G) 64 64+2048 128 128+2048
106 * 2(G) 128 128+2048 128 128+2048
107 * 4(G) 128 128+2048 128 128+2048
115 static __inline__ void nlm_large_variable_tlb_en (int en)
119 val = nlm_read_c0_config6();
121 nlm_write_c0_config6(val);
128 static __inline__ void nlm_pagewalker_en(int en)
132 val = nlm_read_c0_config6();
134 nlm_write_c0_config6(val);
141 static __inline__ void nlm_extended_tlb_en(int en)
145 val = nlm_read_c0_config6();
147 nlm_write_c0_config6(val);
151 static __inline__ int nlm_get_num_combined_tlbs(void)
153 return (((nlm_read_c0_config6() >> 16) & 0xffff) + 1);
156 /* get number of variable TLB entries */
157 static __inline__ int nlm_get_num_vtlbs(void)
159 return (((nlm_read_c0_config6() >> 6) & 0x3ff) + 1);
162 static __inline__ void nlm_setup_extended_pagemask(int mask)
164 nlm_write_c0_config7(mask);