0152-lantiq-VPE.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. From 4d48a3d1ef6f8d036bd926e3c1f70b56fcc679b2 Mon Sep 17 00:00:00 2001
  2. From: Stefan Koch <[email protected]>
  3. Date: Thu, 20 Oct 2016 21:32:00 +0200
  4. Subject: [PATCH] lantiq: vpe
  5. Signed-off-by: Stefan Koch <[email protected]>
  6. ---
  7. arch/mips/Kconfig | 6 ++++
  8. arch/mips/include/asm/mipsmtregs.h | 5 ++++
  9. arch/mips/include/asm/vpe.h | 9 ++++++
  10. arch/mips/kernel/vpe-mt.c | 47 ++++++++++++++++++++++++++++++
  11. arch/mips/kernel/vpe.c | 35 ++++++++++++++++++++++
  12. arch/mips/lantiq/prom.c | 4 +++
  13. 6 files changed, 106 insertions(+)
  14. --- a/arch/mips/Kconfig
  15. +++ b/arch/mips/Kconfig
  16. @@ -2433,6 +2433,12 @@ config MIPS_VPE_LOADER
  17. Includes a loader for loading an elf relocatable object
  18. onto another VPE and running it.
  19. +config IFX_VPE_EXT
  20. + bool "IFX APRP Extensions"
  21. + depends on MIPS_VPE_LOADER
  22. + help
  23. + IFX included extensions in APRP
  24. +
  25. config MIPS_VPE_LOADER_CMP
  26. bool
  27. default "y"
  28. --- a/arch/mips/include/asm/mipsmtregs.h
  29. +++ b/arch/mips/include/asm/mipsmtregs.h
  30. @@ -32,6 +32,9 @@
  31. #define read_c0_vpeconf1() __read_32bit_c0_register($1, 3)
  32. #define write_c0_vpeconf1(val) __write_32bit_c0_register($1, 3, val)
  33. +#define read_c0_vpeopt() __read_32bit_c0_register($1, 7)
  34. +#define write_c0_vpeopt(val) __write_32bit_c0_register($1, 7, val)
  35. +
  36. #define read_c0_tcstatus() __read_32bit_c0_register($2, 1)
  37. #define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val)
  38. @@ -378,6 +381,8 @@ do { \
  39. #define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
  40. #define read_vpe_c0_vpeconf1() mftc0(1, 3)
  41. #define write_vpe_c0_vpeconf1(val) mttc0(1, 3, val)
  42. +#define read_vpe_c0_vpeopt() mftc0(1, 7)
  43. +#define write_vpe_c0_vpeopt(val) mttc0(1, 7, val)
  44. #define read_vpe_c0_count() mftc0(9, 0)
  45. #define write_vpe_c0_count(val) mttc0(9, 0, val)
  46. #define read_vpe_c0_status() mftc0(12, 0)
  47. --- a/arch/mips/include/asm/vpe.h
  48. +++ b/arch/mips/include/asm/vpe.h
  49. @@ -123,4 +123,13 @@ void cleanup_tc(struct tc *tc);
  50. int __init vpe_module_init(void);
  51. void __exit vpe_module_exit(void);
  52. +
  53. +/* For the explanation of the APIs please refer the section "MT APRP Kernel
  54. + * Programming" in AR9 SW Architecture Specification
  55. + */
  56. +int32_t vpe1_sw_start(void *sw_start_addr, uint32_t tcmask, uint32_t flags);
  57. +int32_t vpe1_sw_stop(uint32_t flags);
  58. +uint32_t vpe1_get_load_addr(uint32_t flags);
  59. +uint32_t vpe1_get_max_mem(uint32_t flags);
  60. +
  61. #endif /* _ASM_VPE_H */
  62. --- a/arch/mips/kernel/vpe-mt.c
  63. +++ b/arch/mips/kernel/vpe-mt.c
  64. @@ -415,6 +415,8 @@ int __init vpe_module_init(void)
  65. }
  66. v->ntcs = hw_tcs - aprp_cpu_index();
  67. + write_tc_c0_tcbind((read_tc_c0_tcbind() &
  68. + ~TCBIND_CURVPE) | 1);
  69. /* add the tc to the list of this vpe's tc's. */
  70. list_add(&t->tc, &v->tc);
  71. @@ -518,3 +520,47 @@ void __exit vpe_module_exit(void)
  72. release_vpe(v);
  73. }
  74. }
  75. +
  76. +#ifdef CONFIG_IFX_VPE_EXT
  77. +int32_t vpe1_sw_start(void *sw_start_addr, uint32_t tcmask, uint32_t flags)
  78. +{
  79. + enum vpe_state state;
  80. + struct vpe *v = get_vpe(tclimit);
  81. + struct vpe_notifications *not;
  82. +
  83. + if (tcmask || flags) {
  84. + pr_warn("Currently tcmask and flags should be 0. Other values are not supported\n");
  85. + return -1;
  86. + }
  87. +
  88. + state = xchg(&v->state, VPE_STATE_INUSE);
  89. + if (state != VPE_STATE_UNUSED) {
  90. + vpe_stop(v);
  91. +
  92. + list_for_each_entry(not, &v->notify, list) {
  93. + not->stop(tclimit);
  94. + }
  95. + }
  96. +
  97. + v->__start = (unsigned long)sw_start_addr;
  98. +
  99. + if (!vpe_run(v)) {
  100. + pr_debug("VPE loader: VPE1 running successfully\n");
  101. + return 0;
  102. + }
  103. + return -1;
  104. +}
  105. +EXPORT_SYMBOL(vpe1_sw_start);
  106. +
  107. +int32_t vpe1_sw_stop(uint32_t flags)
  108. +{
  109. + struct vpe *v = get_vpe(tclimit);
  110. +
  111. + if (!vpe_free(v)) {
  112. + pr_debug("RP Stopped\n");
  113. + return 0;
  114. + } else
  115. + return -1;
  116. +}
  117. +EXPORT_SYMBOL(vpe1_sw_stop);
  118. +#endif
  119. --- a/arch/mips/kernel/vpe.c
  120. +++ b/arch/mips/kernel/vpe.c
  121. @@ -49,6 +49,41 @@ struct vpe_control vpecontrol = {
  122. .tc_list = LIST_HEAD_INIT(vpecontrol.tc_list)
  123. };
  124. +#ifdef CONFIG_IFX_VPE_EXT
  125. +unsigned int vpe1_load_addr;
  126. +
  127. +static int __init load_address(char *str)
  128. +{
  129. + get_option(&str, &vpe1_load_addr);
  130. + return 1;
  131. +}
  132. +__setup("vpe1_load_addr=", load_address);
  133. +
  134. +static unsigned int vpe1_mem;
  135. +static int __init vpe1mem(char *str)
  136. +{
  137. + vpe1_mem = memparse(str, &str);
  138. + return 1;
  139. +}
  140. +__setup("vpe1_mem=", vpe1mem);
  141. +
  142. +uint32_t vpe1_get_load_addr(uint32_t flags)
  143. +{
  144. + return vpe1_load_addr;
  145. +}
  146. +EXPORT_SYMBOL(vpe1_get_load_addr);
  147. +
  148. +uint32_t vpe1_get_max_mem(uint32_t flags)
  149. +{
  150. + if (!vpe1_mem)
  151. + return P_SIZE;
  152. + else
  153. + return vpe1_mem;
  154. +}
  155. +EXPORT_SYMBOL(vpe1_get_max_mem);
  156. +
  157. +#endif
  158. +
  159. /* get the vpe associated with this minor */
  160. struct vpe *get_vpe(int minor)
  161. {
  162. --- a/arch/mips/lantiq/prom.c
  163. +++ b/arch/mips/lantiq/prom.c
  164. @@ -28,10 +28,14 @@ EXPORT_SYMBOL_GPL(ebu_lock);
  165. */
  166. static struct ltq_soc_info soc_info;
  167. +/* for Multithreading (APRP), vpe.c will use it */
  168. +unsigned long cp0_memsize;
  169. +
  170. const char *get_system_type(void)
  171. {
  172. return soc_info.sys_type;
  173. }
  174. +EXPORT_SYMBOL(ltq_soc_type);
  175. int ltq_soc_type(void)
  176. {