1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -2383,6 +2383,12 @@ config MIPS_VPE_LOADER
4 Includes a loader for loading an elf relocatable object
5 onto another VPE and running it.
8 + bool "IFX APRP Extensions"
9 + depends on MIPS_VPE_LOADER
11 + IFX included extensions in APRP
13 config MIPS_VPE_LOADER_CMP
16 --- a/arch/mips/include/asm/vpe.h
17 +++ b/arch/mips/include/asm/vpe.h
18 @@ -126,4 +126,13 @@ void cleanup_tc(struct tc *tc);
20 int __init vpe_module_init(void);
21 void __exit vpe_module_exit(void);
23 +/* For the explanation of the APIs please refer the section "MT APRP Kernel
24 + * Programming" in AR9 SW Architecture Specification
26 +int32_t vpe1_sw_start(void *sw_start_addr, uint32_t tcmask, uint32_t flags);
27 +int32_t vpe1_sw_stop(uint32_t flags);
28 +uint32_t vpe1_get_load_addr(uint32_t flags);
29 +uint32_t vpe1_get_max_mem(uint32_t flags);
31 #endif /* _ASM_VPE_H */
32 --- a/arch/mips/kernel/vpe-mt.c
33 +++ b/arch/mips/kernel/vpe-mt.c
34 @@ -415,6 +415,8 @@ int __init vpe_module_init(void)
37 v->ntcs = hw_tcs - aprp_cpu_index();
38 + write_tc_c0_tcbind((read_tc_c0_tcbind() &
39 + ~TCBIND_CURVPE) | 1);
41 /* add the tc to the list of this vpe's tc's. */
42 list_add(&t->tc, &v->tc);
43 @@ -518,3 +520,47 @@ void __exit vpe_module_exit(void)
48 +#ifdef CONFIG_IFX_VPE_EXT
49 +int32_t vpe1_sw_start(void *sw_start_addr, uint32_t tcmask, uint32_t flags)
51 + enum vpe_state state;
52 + struct vpe *v = get_vpe(tclimit);
53 + struct vpe_notifications *not;
55 + if (tcmask || flags) {
56 + pr_warn("Currently tcmask and flags should be 0. Other values are not supported\n");
60 + state = xchg(&v->state, VPE_STATE_INUSE);
61 + if (state != VPE_STATE_UNUSED) {
64 + list_for_each_entry(not, &v->notify, list) {
69 + v->__start = (unsigned long)sw_start_addr;
72 + pr_debug("VPE loader: VPE1 running successfully\n");
77 +EXPORT_SYMBOL(vpe1_sw_start);
79 +int32_t vpe1_sw_stop(uint32_t flags)
81 + struct vpe *v = get_vpe(tclimit);
84 + pr_debug("RP Stopped\n");
89 +EXPORT_SYMBOL(vpe1_sw_stop);
91 --- a/arch/mips/kernel/vpe.c
92 +++ b/arch/mips/kernel/vpe.c
93 @@ -49,6 +49,41 @@ struct vpe_control vpecontrol = {
94 .tc_list = LIST_HEAD_INIT(vpecontrol.tc_list)
97 +#ifdef CONFIG_IFX_VPE_EXT
98 +unsigned int vpe1_load_addr;
100 +static int __init load_address(char *str)
102 + get_option(&str, &vpe1_load_addr);
105 +__setup("vpe1_load_addr=", load_address);
107 +static unsigned int vpe1_mem;
108 +static int __init vpe1mem(char *str)
110 + vpe1_mem = memparse(str, &str);
113 +__setup("vpe1_mem=", vpe1mem);
115 +uint32_t vpe1_get_load_addr(uint32_t flags)
117 + return vpe1_load_addr;
119 +EXPORT_SYMBOL(vpe1_get_load_addr);
121 +uint32_t vpe1_get_max_mem(uint32_t flags)
128 +EXPORT_SYMBOL(vpe1_get_max_mem);
132 /* get the vpe associated with this minor */
133 struct vpe *get_vpe(int minor)
135 --- a/arch/mips/lantiq/prom.c
136 +++ b/arch/mips/lantiq/prom.c
137 @@ -28,10 +28,14 @@ EXPORT_SYMBOL_GPL(ebu_lock);
139 static struct ltq_soc_info soc_info;
141 +/* for Multithreading (APRP), vpe.c will use it */
142 +unsigned long cp0_memsize;
144 const char *get_system_type(void)
146 return soc_info.sys_type;
148 +EXPORT_SYMBOL(ltq_soc_type);
150 int ltq_soc_type(void)
152 --- a/arch/mips/include/asm/mipsmtregs.h
153 +++ b/arch/mips/include/asm/mipsmtregs.h
155 #define read_c0_vpeconf1() __read_32bit_c0_register($1, 3)
156 #define write_c0_vpeconf1(val) __write_32bit_c0_register($1, 3, val)
158 +#define read_c0_vpeopt() __read_32bit_c0_register($1, 7)
159 +#define write_c0_vpeopt(val) __write_32bit_c0_register($1, 7, val)
161 #define read_c0_tcstatus() __read_32bit_c0_register($2, 1)
162 #define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val)
164 @@ -378,6 +381,8 @@ do { \
165 #define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
166 #define read_vpe_c0_vpeconf1() mftc0(1, 3)
167 #define write_vpe_c0_vpeconf1(val) mttc0(1, 3, val)
168 +#define read_vpe_c0_vpeopt() mftc0(1, 7)
169 +#define write_vpe_c0_vpeopt(val) mttc0(1, 7, val)
170 #define read_vpe_c0_count() mftc0(9, 0)
171 #define write_vpe_c0_count(val) mttc0(9, 0, val)
172 #define read_vpe_c0_status() mftc0(12, 0)