0031-MIPS-add-board-support-for-ZTE-ZXHN-H367N.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. From 0597056e2ba19ea783ef5c3d14c75c4722740e48 Mon Sep 17 00:00:00 2001
  2. From: Luka Perkov <[email protected]>
  3. Date: Sun, 10 Mar 2013 17:59:56 +0100
  4. Subject: MIPS: add board support for ZTE ZXHN H367N
  5. Signed-off-by: Luka Perkov <[email protected]>
  6. diff --git a/board/zte/zxhnh367n/Makefile b/board/zte/zxhnh367n/Makefile
  7. new file mode 100644
  8. index 0000000..3a547c2
  9. --- /dev/null
  10. +++ b/board/zte/zxhnh367n/Makefile
  11. @@ -0,0 +1,27 @@
  12. +#
  13. +# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, [email protected]
  14. +#
  15. +# SPDX-License-Identifier: GPL-2.0+
  16. +#
  17. +
  18. +include $(TOPDIR)/config.mk
  19. +
  20. +LIB = $(obj)lib$(BOARD).o
  21. +
  22. +COBJS = $(BOARD).o
  23. +
  24. +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
  25. +OBJS := $(addprefix $(obj),$(COBJS))
  26. +SOBJS := $(addprefix $(obj),$(SOBJS))
  27. +
  28. +$(LIB): $(obj).depend $(OBJS) $(SOBJS)
  29. + $(call cmd_link_o_target, $(OBJS) $(SOBJS))
  30. +
  31. +#########################################################################
  32. +
  33. +# defines $(obj).depend target
  34. +include $(SRCTREE)/rules.mk
  35. +
  36. +sinclude $(obj).depend
  37. +
  38. +#########################################################################
  39. diff --git a/board/zte/zxhnh367n/config.mk b/board/zte/zxhnh367n/config.mk
  40. new file mode 100644
  41. index 0000000..9d33739
  42. --- /dev/null
  43. +++ b/board/zte/zxhnh367n/config.mk
  44. @@ -0,0 +1,7 @@
  45. +#
  46. +# Copyright (C) 2012-2013 Daniel Schwierzeck, [email protected]
  47. +#
  48. +# SPDX-License-Identifier: GPL-2.0+
  49. +#
  50. +
  51. +PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
  52. diff --git a/board/zte/zxhnh367n/ddr_settings.h b/board/zte/zxhnh367n/ddr_settings.h
  53. new file mode 100644
  54. index 0000000..b3f81de
  55. --- /dev/null
  56. +++ b/board/zte/zxhnh367n/ddr_settings.h
  57. @@ -0,0 +1,70 @@
  58. +/*
  59. + * Copyright (C) 2013 Luka Perkov <[email protected]>
  60. + *
  61. + * The values have been extracted from original ZTE U-Boot.
  62. + *
  63. + * SPDX-License-Identifier: GPL-2.0+
  64. + */
  65. +
  66. +#define MC_CCR00_VALUE 0x101
  67. +#define MC_CCR01_VALUE 0x1000101
  68. +#define MC_CCR02_VALUE 0x1010000
  69. +#define MC_CCR03_VALUE 0x100
  70. +#define MC_CCR04_VALUE 0x1000000
  71. +#define MC_CCR05_VALUE 0x1000101
  72. +#define MC_CCR06_VALUE 0x1000100
  73. +#define MC_CCR07_VALUE 0x1010000
  74. +#define MC_CCR08_VALUE 0x1000101
  75. +#define MC_CCR09_VALUE 0x0
  76. +#define MC_CCR10_VALUE 0x2000100
  77. +#define MC_CCR11_VALUE 0x2000401
  78. +#define MC_CCR12_VALUE 0x30000
  79. +#define MC_CCR13_VALUE 0x202
  80. +#define MC_CCR14_VALUE 0x7080A0F
  81. +#define MC_CCR15_VALUE 0x2040F
  82. +#define MC_CCR16_VALUE 0x40000
  83. +#define MC_CCR17_VALUE 0x70102
  84. +#define MC_CCR18_VALUE 0x4020002
  85. +#define MC_CCR19_VALUE 0x30302
  86. +#define MC_CCR20_VALUE 0x8000700
  87. +#define MC_CCR21_VALUE 0x40F020A
  88. +#define MC_CCR22_VALUE 0x0
  89. +#define MC_CCR23_VALUE 0xC020000
  90. +#define MC_CCR24_VALUE 0x4401B04
  91. +#define MC_CCR25_VALUE 0x0
  92. +#define MC_CCR26_VALUE 0x0
  93. +#define MC_CCR27_VALUE 0x6420000
  94. +#define MC_CCR28_VALUE 0x0
  95. +#define MC_CCR29_VALUE 0x0
  96. +#define MC_CCR30_VALUE 0x798
  97. +#define MC_CCR31_VALUE 0x0
  98. +#define MC_CCR32_VALUE 0x0
  99. +#define MC_CCR33_VALUE 0x650000
  100. +#define MC_CCR34_VALUE 0x200C8
  101. +#define MC_CCR35_VALUE 0x1D445D
  102. +#define MC_CCR36_VALUE 0xC8
  103. +#define MC_CCR37_VALUE 0xC351
  104. +#define MC_CCR38_VALUE 0x0
  105. +#define MC_CCR39_VALUE 0x141F04
  106. +#define MC_CCR40_VALUE 0x142704
  107. +#define MC_CCR41_VALUE 0x141B42
  108. +#define MC_CCR42_VALUE 0x141B42
  109. +#define MC_CCR43_VALUE 0x566504
  110. +#define MC_CCR44_VALUE 0x566504
  111. +#define MC_CCR45_VALUE 0x565F17
  112. +#define MC_CCR46_VALUE 0x565F17
  113. +#define MC_CCR47_VALUE 0x0
  114. +#define MC_CCR48_VALUE 0x0
  115. +#define MC_CCR49_VALUE 0x0
  116. +#define MC_CCR50_VALUE 0x0
  117. +#define MC_CCR51_VALUE 0x0
  118. +#define MC_CCR52_VALUE 0x133
  119. +#define MC_CCR53_VALUE 0xF3014B27
  120. +#define MC_CCR54_VALUE 0xF3014B27
  121. +#define MC_CCR55_VALUE 0xF3014B27
  122. +#define MC_CCR56_VALUE 0xF3014B27
  123. +#define MC_CCR57_VALUE 0x7800301
  124. +#define MC_CCR58_VALUE 0x7800301
  125. +#define MC_CCR59_VALUE 0x7800301
  126. +#define MC_CCR60_VALUE 0x7800301
  127. +#define MC_CCR61_VALUE 0x4
  128. diff --git a/board/zte/zxhnh367n/zxhnh367n.c b/board/zte/zxhnh367n/zxhnh367n.c
  129. new file mode 100644
  130. index 0000000..f64f105
  131. --- /dev/null
  132. +++ b/board/zte/zxhnh367n/zxhnh367n.c
  133. @@ -0,0 +1,97 @@
  134. +/*
  135. + * Copyright (C) 2013 Luka Perkov <[email protected]>
  136. + *
  137. + * SPDX-License-Identifier: GPL-2.0+
  138. + */
  139. +
  140. +#include <common.h>
  141. +#include <asm/gpio.h>
  142. +#include <asm/lantiq/eth.h>
  143. +#include <asm/lantiq/chipid.h>
  144. +#include <asm/lantiq/cpu.h>
  145. +#include <asm/arch/gphy.h>
  146. +
  147. +#if defined(CONFIG_SPL_BUILD)
  148. +#define do_gpio_init 1
  149. +#define do_pll_init 1
  150. +#define do_dcdc_init 0
  151. +#elif defined(CONFIG_SYS_BOOT_RAM)
  152. +#define do_gpio_init 1
  153. +#define do_pll_init 0
  154. +#define do_dcdc_init 1
  155. +#else
  156. +#define do_gpio_init 0
  157. +#define do_pll_init 0
  158. +#define do_dcdc_init 1
  159. +#endif
  160. +
  161. +static void gpio_init(void)
  162. +{
  163. + /* EBU.FL_CS1 as output for NAND CE */
  164. + gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  165. + /* EBU.FL_A23 as output for NAND CLE */
  166. + gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  167. + /* EBU.FL_A24 as output for NAND ALE */
  168. + gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  169. + /* GPIO 3.0 as input for NAND Ready Busy */
  170. + gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
  171. + /* GPIO 3.1 as output for NAND Read */
  172. + gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  173. +}
  174. +
  175. +int board_early_init_f(void)
  176. +{
  177. + if (do_gpio_init)
  178. + gpio_init();
  179. +
  180. + if (do_pll_init)
  181. + ltq_pll_init();
  182. +
  183. + if (do_dcdc_init)
  184. + ltq_dcdc_init(0x7F);
  185. +
  186. + return 0;
  187. +}
  188. +
  189. +int checkboard(void)
  190. +{
  191. + puts("Board: " CONFIG_BOARD_NAME "\n");
  192. + ltq_chip_print_info();
  193. +
  194. + return 0;
  195. +}
  196. +
  197. +static const struct ltq_eth_port_config eth_port_config[] = {
  198. + /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
  199. + { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
  200. + /* GMAC1: unused */
  201. + { 1, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
  202. + /* GMAC2: internal GPHY0 with 10/100 firmware for LAN port 1 */
  203. + { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
  204. + /* GMAC3: internal GPHY0 with 10/100 firmware for LAN port 2 */
  205. + { 3, 0x12, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
  206. + /* GMAC4: internal GPHY1 with 10/100 firmware for LAN port 3 */
  207. + { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
  208. + /* GMAC5: internal GPHY1 with 10/100 firmware for LAN port 4 */
  209. + { 5, 0x14, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_MII },
  210. +};
  211. +
  212. +static const struct ltq_eth_board_config eth_board_config = {
  213. + .ports = eth_port_config,
  214. + .num_ports = ARRAY_SIZE(eth_port_config),
  215. +};
  216. +
  217. +int board_eth_init(bd_t * bis)
  218. +{
  219. + const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
  220. + const ulong fw_addr = 0x80FF0000;
  221. +
  222. + ltq_gphy_phy22f_a2x_load(fw_addr);
  223. +
  224. + ltq_cgu_gphy_clk_src(clk);
  225. +
  226. + ltq_rcu_gphy_boot(0, fw_addr);
  227. + ltq_rcu_gphy_boot(1, fw_addr);
  228. +
  229. + return ltq_eth_initialize(&eth_board_config);
  230. +}
  231. diff --git a/boards.cfg b/boards.cfg
  232. index 2163cdb..4b18a26 100644
  233. --- a/boards.cfg
  234. +++ b/boards.cfg
  235. @@ -527,6 +527,9 @@ Active mips mips32 vrx200 lantiq easy80920
  236. Active mips mips32 vrx200 lantiq easy80920 easy80920_norspl easy80920:SYS_BOOT_NORSPL Daniel Schwierzeck <[email protected]>
  237. Active mips mips32 vrx200 lantiq easy80920 easy80920_ram easy80920:SYS_BOOT_RAM Daniel Schwierzeck <[email protected]>
  238. Active mips mips32 vrx200 lantiq easy80920 easy80920_sfspl easy80920:SYS_BOOT_SFSPL Daniel Schwierzeck <[email protected]>
  239. +Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_nandspl zxhnh367n:SYS_BOOT_NANDSPL Luka Perkov <[email protected]>
  240. +Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_ram zxhnh367n:SYS_BOOT_RAM Luka Perkov <[email protected]>
  241. +Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_zte zxhnh367n:SYS_BOOT_ZTE Luka Perkov <[email protected]>
  242. Active mips mips64 - - qemu-mips qemu_mips64 qemu-mips64:SYS_BIG_ENDIAN -
  243. Active mips mips64 - - qemu-mips qemu_mips64el qemu-mips64:SYS_LITTLE_ENDIAN -
  244. Active nds32 n1213 ag101 AndesTech adp-ag101 adp-ag101 - Andes <[email protected]>
  245. diff --git a/include/configs/zxhnh367n.h b/include/configs/zxhnh367n.h
  246. new file mode 100644
  247. index 0000000..55d2e2a
  248. --- /dev/null
  249. +++ b/include/configs/zxhnh367n.h
  250. @@ -0,0 +1,72 @@
  251. +/*
  252. + * Copyright (C) 2013 Luka Perkov <[email protected]>
  253. + *
  254. + * SPDX-License-Identifier: GPL-2.0+
  255. + */
  256. +
  257. +#ifndef __CONFIG_H
  258. +#define __CONFIG_H
  259. +
  260. +#define CONFIG_MACH_TYPE "ZXHN H367N"
  261. +#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
  262. +#define CONFIG_BOARD_NAME "ZTE ZXHN H367N"
  263. +
  264. +/* Configure SoC */
  265. +#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
  266. +
  267. +#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
  268. +
  269. +#define CONFIG_LTQ_SUPPORT_NAND_FLASH /* Have a NAND flash */
  270. +
  271. +#define CONFIG_LTQ_SUPPORT_SPL_NAND_FLASH /* Build NAND flash SPL */
  272. +#define CONFIG_LTQ_SPL_COMP_LZO /* Compress SPL with LZO */
  273. +#define CONFIG_LTQ_SPL_CONSOLE /* Enable SPL console */
  274. +
  275. +#define CONFIG_SYS_NAND_PAGE_COUNT 128
  276. +#define CONFIG_SYS_NAND_PAGE_SIZE 2048
  277. +#define CONFIG_SYS_NAND_OOBSIZE 64
  278. +#define CONFIG_SYS_NAND_BLOCK_SIZE (256 * 1024)
  279. +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS
  280. +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x4000
  281. +
  282. +#define CONFIG_SYS_DRAM_PROBE
  283. +
  284. +/* Environment */
  285. +#if defined(CONFIG_SYS_BOOT_NANDSPL)
  286. +#define CONFIG_ENV_IS_IN_NAND
  287. +#define CONFIG_ENV_OVERWRITE
  288. +#define CONFIG_ENV_OFFSET (256 * 1024)
  289. +#define CONFIG_ENV_SECT_SIZE (256 * 1024)
  290. +#else
  291. +#define CONFIG_ENV_IS_NOWHERE
  292. +#endif
  293. +
  294. +#define CONFIG_ENV_SIZE (8 * 1024)
  295. +#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
  296. +
  297. +#if defined(CONFIG_SYS_BOOT_ZTE)
  298. +#define CONFIG_SYS_TEXT_BASE 0x80800000
  299. +#define CONFIG_SKIP_LOWLEVEL_INIT
  300. +#endif
  301. +
  302. +/* Console */
  303. +#define CONFIG_LTQ_ADVANCED_CONSOLE
  304. +#define CONFIG_BAUDRATE 115200
  305. +#define CONFIG_CONSOLE_ASC 1
  306. +#define CONFIG_CONSOLE_DEV "ttyLTQ1"
  307. +
  308. +/* Pull in default board configs for Lantiq XWAY VRX200 */
  309. +#include <asm/lantiq/config.h>
  310. +#include <asm/arch/config.h>
  311. +
  312. +/* Pull in default OpenWrt configs for Lantiq SoC */
  313. +#include "openwrt-lantiq-common.h"
  314. +
  315. +#define CONFIG_ENV_UPDATE_UBOOT_NAND \
  316. + "update-uboot-nand=run load-uboot-nandspl-lzo write-uboot-nand\0"
  317. +
  318. +#define CONFIG_EXTRA_ENV_SETTINGS \
  319. + CONFIG_ENV_LANTIQ_DEFAULTS \
  320. + CONFIG_ENV_UPDATE_UBOOT_NAND
  321. +
  322. +#endif /* __CONFIG_H */
  323. --
  324. 1.8.3.2