2
0

100-29-board-mediatek-wire-up-NMBM-support.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. From 6792b57b3ba61ca6d69ea4a13a58bed65fc5da87 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Sun, 7 Aug 2022 04:04:46 +0200
  4. Subject: [PATCH] board: mediatek: wire-up NMBM support
  5. ---
  6. board/mediatek/mt7622/mt7622_rfb.c | 38 +++++++++++++++++++++
  7. board/mediatek/mt7629/mt7629_rfb.c | 38 +++++++++++++++++++++
  8. board/mediatek/mt7981/mt7981_rfb.c | 52 ++++++++++++++++++++++++++++
  9. board/mediatek/mt7986/mt7986_rfb.c | 54 ++++++++++++++++++++++++++++++
  10. 4 files changed, 182 insertions(+)
  11. --- a/board/mediatek/mt7622/mt7622_rfb.c
  12. +++ b/board/mediatek/mt7622/mt7622_rfb.c
  13. @@ -10,6 +10,11 @@
  14. #include <init.h>
  15. #include <asm/global_data.h>
  16. +#include <mtd.h>
  17. +#include <linux/mtd/mtd.h>
  18. +#include <nmbm/nmbm.h>
  19. +#include <nmbm/nmbm-mtd.h>
  20. +
  21. DECLARE_GLOBAL_DATA_PTR;
  22. int board_init(void)
  23. @@ -23,3 +28,36 @@ int board_late_init(void)
  24. env_relocate();
  25. return 0;
  26. }
  27. +
  28. +int board_nmbm_init(void)
  29. +{
  30. +#ifdef CONFIG_ENABLE_NAND_NMBM
  31. + struct mtd_info *lower, *upper;
  32. + int ret;
  33. +
  34. + printf("\n");
  35. + printf("Initializing NMBM ...\n");
  36. +
  37. + mtd_probe_devices();
  38. +
  39. + lower = get_mtd_device_nm("spi-nand0");
  40. + if (IS_ERR(lower) || !lower) {
  41. + printf("Lower MTD device 'spi-nand0' not found\n");
  42. + return 0;
  43. + }
  44. +
  45. + ret = nmbm_attach_mtd(lower,
  46. + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
  47. + CONFIG_NMBM_MAX_RATIO,
  48. + CONFIG_NMBM_MAX_BLOCKS, &upper);
  49. +
  50. + printf("\n");
  51. +
  52. + if (ret)
  53. + return 0;
  54. +
  55. + add_mtd_device(upper);
  56. +#endif
  57. +
  58. + return 0;
  59. +}
  60. --- a/board/mediatek/mt7629/mt7629_rfb.c
  61. +++ b/board/mediatek/mt7629/mt7629_rfb.c
  62. @@ -6,6 +6,11 @@
  63. #include <common.h>
  64. #include <asm/global_data.h>
  65. +#include <mtd.h>
  66. +#include <linux/mtd/mtd.h>
  67. +#include <nmbm/nmbm.h>
  68. +#include <nmbm/nmbm-mtd.h>
  69. +
  70. DECLARE_GLOBAL_DATA_PTR;
  71. int board_init(void)
  72. @@ -20,3 +25,36 @@ uint32_t spl_nand_get_uboot_raw_page(voi
  73. {
  74. return CONFIG_SPL_PAD_TO;
  75. }
  76. +
  77. +int board_nmbm_init(void)
  78. +{
  79. +#ifdef CONFIG_ENABLE_NAND_NMBM
  80. + struct mtd_info *lower, *upper;
  81. + int ret;
  82. +
  83. + printf("\n");
  84. + printf("Initializing NMBM ...\n");
  85. +
  86. + mtd_probe_devices();
  87. +
  88. + lower = get_mtd_device_nm("spi-nand0");
  89. + if (IS_ERR(lower) || !lower) {
  90. + printf("Lower MTD device 'spi-nand0' not found\n");
  91. + return 0;
  92. + }
  93. +
  94. + ret = nmbm_attach_mtd(lower,
  95. + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
  96. + CONFIG_NMBM_MAX_RATIO,
  97. + CONFIG_NMBM_MAX_BLOCKS, &upper);
  98. +
  99. + printf("\n");
  100. +
  101. + if (ret)
  102. + return 0;
  103. +
  104. + add_mtd_device(upper);
  105. +#endif
  106. +
  107. + return 0;
  108. +}
  109. --- a/board/mediatek/mt7981/mt7981_rfb.c
  110. +++ b/board/mediatek/mt7981/mt7981_rfb.c
  111. @@ -4,7 +4,58 @@
  112. * Author: Sam Shih <[email protected]>
  113. */
  114. +#include <common.h>
  115. +#include <config.h>
  116. +#include <env.h>
  117. +#include <init.h>
  118. +#include <asm/global_data.h>
  119. +
  120. +#include <mtd.h>
  121. +#include <linux/mtd/mtd.h>
  122. +#include <nmbm/nmbm.h>
  123. +#include <nmbm/nmbm-mtd.h>
  124. +
  125. +DECLARE_GLOBAL_DATA_PTR;
  126. +
  127. int board_init(void)
  128. {
  129. return 0;
  130. }
  131. +
  132. +int board_late_init(void)
  133. +{
  134. + gd->env_valid = 1; //to load environment variable from persistent store
  135. + env_relocate();
  136. + return 0;
  137. +}
  138. +
  139. +int board_nmbm_init(void)
  140. +{
  141. +#ifdef CONFIG_ENABLE_NAND_NMBM
  142. + struct mtd_info *lower, *upper;
  143. + int ret;
  144. +
  145. + printf("\n");
  146. + printf("Initializing NMBM ...\n");
  147. +
  148. + mtd_probe_devices();
  149. +
  150. + lower = get_mtd_device_nm("spi-nand0");
  151. + if (IS_ERR(lower) || !lower) {
  152. + printf("Lower MTD device 'spi-nand0' not found\n");
  153. + return 0;
  154. + }
  155. +
  156. + ret = nmbm_attach_mtd(lower, NMBM_F_CREATE, CONFIG_NMBM_MAX_RATIO,
  157. + CONFIG_NMBM_MAX_BLOCKS, &upper);
  158. +
  159. + printf("\n");
  160. +
  161. + if (ret)
  162. + return 0;
  163. +
  164. + add_mtd_device(upper);
  165. +#endif
  166. +
  167. + return 0;
  168. +}
  169. --- a/board/mediatek/mt7986/mt7986_rfb.c
  170. +++ b/board/mediatek/mt7986/mt7986_rfb.c
  171. @@ -4,7 +4,60 @@
  172. * Author: Sam Shih <[email protected]>
  173. */
  174. +#include <common.h>
  175. +#include <config.h>
  176. +#include <env.h>
  177. +#include <init.h>
  178. +#include <asm/global_data.h>
  179. +
  180. +#include <mtd.h>
  181. +#include <linux/mtd/mtd.h>
  182. +#include <nmbm/nmbm.h>
  183. +#include <nmbm/nmbm-mtd.h>
  184. +
  185. +DECLARE_GLOBAL_DATA_PTR;
  186. +
  187. int board_init(void)
  188. {
  189. return 0;
  190. }
  191. +
  192. +int board_late_init(void)
  193. +{
  194. + gd->env_valid = 1; //to load environment variable from persistent store
  195. + env_relocate();
  196. + return 0;
  197. +}
  198. +
  199. +int board_nmbm_init(void)
  200. +{
  201. +#ifdef CONFIG_ENABLE_NAND_NMBM
  202. + struct mtd_info *lower, *upper;
  203. + int ret;
  204. +
  205. + printf("\n");
  206. + printf("Initializing NMBM ...\n");
  207. +
  208. + mtd_probe_devices();
  209. +
  210. + lower = get_mtd_device_nm("spi-nand0");
  211. + if (IS_ERR(lower) || !lower) {
  212. + printf("Lower MTD device 'spi-nand0' not found\n");
  213. + return 0;
  214. + }
  215. +
  216. + ret = nmbm_attach_mtd(lower,
  217. + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
  218. + CONFIG_NMBM_MAX_RATIO,
  219. + CONFIG_NMBM_MAX_BLOCKS, &upper);
  220. +
  221. + printf("\n");
  222. +
  223. + if (ret)
  224. + return 0;
  225. +
  226. + add_mtd_device(upper);
  227. +#endif
  228. +
  229. + return 0;
  230. +}