1 From 3f7be04a148d23cdb5fd320e0e2923983f8bd1f4 Mon Sep 17 00:00:00 2001
2 From: Luka Perkov <luka@openwrt.org>
3 Date: Tue, 6 Aug 2013 22:51:00 +0200
4 Subject: MIPS: add board support for ZyXEL P-2812HNU-Fx
6 Signed-off-by: Luka Perkov <luka@openwrt.org>
8 diff --git a/board/zyxel/p2812hnufx/Makefile b/board/zyxel/p2812hnufx/Makefile
10 index 0000000..3a547c2
12 +++ b/board/zyxel/p2812hnufx/Makefile
15 +# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
17 +# SPDX-License-Identifier: GPL-2.0+
20 +include $(TOPDIR)/config.mk
22 +LIB = $(obj)lib$(BOARD).o
26 +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
27 +OBJS := $(addprefix $(obj),$(COBJS))
28 +SOBJS := $(addprefix $(obj),$(SOBJS))
30 +$(LIB): $(obj).depend $(OBJS) $(SOBJS)
31 + $(call cmd_link_o_target, $(OBJS) $(SOBJS))
33 +#########################################################################
35 +# defines $(obj).depend target
36 +include $(SRCTREE)/rules.mk
38 +sinclude $(obj).depend
40 +#########################################################################
41 diff --git a/board/zyxel/p2812hnufx/config.mk b/board/zyxel/p2812hnufx/config.mk
43 index 0000000..9d33739
45 +++ b/board/zyxel/p2812hnufx/config.mk
48 +# Copyright (C) 2012-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
50 +# SPDX-License-Identifier: GPL-2.0+
53 +PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
54 diff --git a/board/zyxel/p2812hnufx/ddr_settings.h b/board/zyxel/p2812hnufx/ddr_settings.h
56 index 0000000..128c42e
58 +++ b/board/zyxel/p2812hnufx/ddr_settings.h
61 + * Copyright (C) 2013 Luka Perkov <luka@openwrt.org>
63 + * The values have been extracted from original ZyXEL U-Boot.
65 + * SPDX-License-Identifier: GPL-2.0+
68 +#define MC_CCR00_VALUE 0x101
69 +#define MC_CCR01_VALUE 0x1000100
70 +#define MC_CCR02_VALUE 0x1010000
71 +#define MC_CCR03_VALUE 0x101
72 +#define MC_CCR04_VALUE 0x1000000
73 +#define MC_CCR05_VALUE 0x1000101
74 +#define MC_CCR06_VALUE 0x1000100
75 +#define MC_CCR07_VALUE 0x1010000
76 +#define MC_CCR08_VALUE 0x1000101
77 +#define MC_CCR09_VALUE 0x0
78 +#define MC_CCR10_VALUE 0x2000100
79 +#define MC_CCR11_VALUE 0x2000300
80 +#define MC_CCR12_VALUE 0x30000
81 +#define MC_CCR13_VALUE 0x202
82 +#define MC_CCR14_VALUE 0x7080A0F
83 +#define MC_CCR15_VALUE 0x2040F
84 +#define MC_CCR16_VALUE 0x40000
85 +#define MC_CCR17_VALUE 0x70102
86 +#define MC_CCR18_VALUE 0x4020002
87 +#define MC_CCR19_VALUE 0x30302
88 +#define MC_CCR20_VALUE 0x8000700
89 +#define MC_CCR21_VALUE 0x40F020A
90 +#define MC_CCR22_VALUE 0x0
91 +#define MC_CCR23_VALUE 0xC020000
92 +#define MC_CCR24_VALUE 0x4401B04
93 +#define MC_CCR25_VALUE 0x0
94 +#define MC_CCR26_VALUE 0x0
95 +#define MC_CCR27_VALUE 0x6420000
96 +#define MC_CCR28_VALUE 0x0
97 +#define MC_CCR29_VALUE 0x0
98 +#define MC_CCR30_VALUE 0x798
99 +#define MC_CCR31_VALUE 0x0
100 +#define MC_CCR32_VALUE 0x0
101 +#define MC_CCR33_VALUE 0x650000
102 +#define MC_CCR34_VALUE 0x200C8
103 +#define MC_CCR35_VALUE 0x1D445D
104 +#define MC_CCR36_VALUE 0xC8
105 +#define MC_CCR37_VALUE 0xC351
106 +#define MC_CCR38_VALUE 0x0
107 +#define MC_CCR39_VALUE 0x141F04
108 +#define MC_CCR40_VALUE 0x142704
109 +#define MC_CCR41_VALUE 0x141B42
110 +#define MC_CCR42_VALUE 0x141B42
111 +#define MC_CCR43_VALUE 0x566504
112 +#define MC_CCR44_VALUE 0x566504
113 +#define MC_CCR45_VALUE 0x565F17
114 +#define MC_CCR46_VALUE 0x565F17
115 +#define MC_CCR47_VALUE 0x0
116 +#define MC_CCR48_VALUE 0x0
117 +#define MC_CCR49_VALUE 0x0
118 +#define MC_CCR50_VALUE 0x0
119 +#define MC_CCR51_VALUE 0x0
120 +#define MC_CCR52_VALUE 0x133
121 +#define MC_CCR53_VALUE 0xF3014B27
122 +#define MC_CCR54_VALUE 0xF3014B27
123 +#define MC_CCR55_VALUE 0xF3014B27
124 +#define MC_CCR56_VALUE 0xF3014B27
125 +#define MC_CCR57_VALUE 0x7800301
126 +#define MC_CCR58_VALUE 0x7800301
127 +#define MC_CCR59_VALUE 0x7800301
128 +#define MC_CCR60_VALUE 0x7800301
129 +#define MC_CCR61_VALUE 0x4
130 diff --git a/board/zyxel/p2812hnufx/p2812hnufx.c b/board/zyxel/p2812hnufx/p2812hnufx.c
132 index 0000000..cd2f819
134 +++ b/board/zyxel/p2812hnufx/p2812hnufx.c
137 + * Copyright (C) 2013 Luka Perkov <luka@openwrt.org>
139 + * SPDX-License-Identifier: GPL-2.0+
143 +#include <asm/gpio.h>
144 +#include <asm/lantiq/eth.h>
145 +#include <asm/lantiq/chipid.h>
146 +#include <asm/lantiq/cpu.h>
147 +#include <asm/arch/gphy.h>
149 +#if defined(CONFIG_SPL_BUILD)
150 +#define do_gpio_init 1
151 +#define do_pll_init 1
152 +#define do_dcdc_init 0
153 +#elif defined(CONFIG_SYS_BOOT_RAM)
154 +#define do_gpio_init 1
155 +#define do_pll_init 0
156 +#define do_dcdc_init 1
158 +#define do_gpio_init 0
159 +#define do_pll_init 0
160 +#define do_dcdc_init 1
163 +static void gpio_init(void)
165 + /* EBU.FL_CS1 as output for NAND CE */
166 + gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
167 + /* EBU.FL_A23 as output for NAND CLE */
168 + gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
169 + /* EBU.FL_A24 as output for NAND ALE */
170 + gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
171 + /* GPIO 3.0 as input for NAND Ready Busy */
172 + gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
173 + /* GPIO 3.1 as output for NAND Read */
174 + gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
177 +int board_early_init_f(void)
186 + ltq_dcdc_init(0x7F);
191 +int checkboard(void)
193 + puts("Board: " CONFIG_BOARD_NAME "\n");
194 + ltq_chip_print_info();
199 +static const struct ltq_eth_port_config eth_port_config[] = {
200 + /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
201 + { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
202 + /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
203 + { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
204 + /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
205 + { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
206 + /* GMAC3: unused */
207 + { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
208 + /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
209 + { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
210 + /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
211 + { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
214 +static const struct ltq_eth_board_config eth_board_config = {
215 + .ports = eth_port_config,
216 + .num_ports = ARRAY_SIZE(eth_port_config),
219 +int board_eth_init(bd_t * bis)
221 + const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
222 + const ulong fw_addr = 0x80FF0000;
224 + ltq_gphy_phy11g_a1x_load(fw_addr);
226 + ltq_cgu_gphy_clk_src(clk);
228 + ltq_rcu_gphy_boot(0, fw_addr);
229 + ltq_rcu_gphy_boot(1, fw_addr);
231 + return ltq_eth_initialize(ð_board_config);
233 diff --git a/boards.cfg b/boards.cfg
234 index 45c2aa0..0cbf756 100644
237 @@ -540,6 +540,8 @@ Active mips mips32 vrx200 lantiq easy80920
238 Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_nandspl zxhnh367n:SYS_BOOT_NANDSPL Luka Perkov <luka@openwrt.org>
239 Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_ram zxhnh367n:SYS_BOOT_RAM Luka Perkov <luka@openwrt.org>
240 Active mips mips32 vrx200 zte zxhnh367n zxhnh367n_zte zxhnh367n:SYS_BOOT_ZTE Luka Perkov <luka@openwrt.org>
241 +Active mips mips32 vrx200 zyxel p2812hnufx p2812hnufx_nandspl p2812hnufx:SYS_BOOT_NANDSPL Luka Perkov <luka@openwrt.org>
242 +Active mips mips32 vrx200 zyxel p2812hnufx p2812hnufx_ram p2812hnufx:SYS_BOOT_RAM Luka Perkov <luka@openwrt.org>
243 Active mips mips64 - - qemu-mips qemu_mips64 qemu-mips64:SYS_BIG_ENDIAN -
244 Active mips mips64 - - qemu-mips qemu_mips64el qemu-mips64:SYS_LITTLE_ENDIAN -
245 Active nds32 n1213 ag101 AndesTech adp-ag101 adp-ag101 - Andes <uboot@andestech.com>
246 diff --git a/include/configs/p2812hnufx.h b/include/configs/p2812hnufx.h
248 index 0000000..6806eb1
250 +++ b/include/configs/p2812hnufx.h
253 + * Copyright (C) 2013 Luka Perkov <luka@openwrt.org>
255 + * SPDX-License-Identifier: GPL-2.0+
261 +#define CONFIG_MACH_TYPE "P-2812HNU-Fx"
262 +#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
263 +#define CONFIG_BOARD_NAME "ZyXEL P-2812HNU-Fx"
266 +#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
268 +#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
270 +#define CONFIG_LTQ_SUPPORT_NAND_FLASH /* Have a K9F1G08U0D NAND flash */
272 +#define CONFIG_LTQ_SUPPORT_SPL_NAND_FLASH /* Build NAND flash SPL */
273 +#define CONFIG_LTQ_SPL_COMP_LZO /* Compress SPL with LZO */
274 +#define CONFIG_LTQ_SPL_CONSOLE /* Enable SPL console */
276 +#define CONFIG_SYS_NAND_PAGE_COUNT 64
277 +#define CONFIG_SYS_NAND_PAGE_SIZE 2048
278 +#define CONFIG_SYS_NAND_OOBSIZE 64
279 +#define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024)
280 +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS
281 +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x4000
283 +#define CONFIG_SYS_DRAM_PROBE
286 +#if defined(CONFIG_SYS_BOOT_NANDSPL)
287 +#define CONFIG_ENV_IS_IN_NAND
288 +#define CONFIG_ENV_OVERWRITE
289 +#define CONFIG_ENV_OFFSET (256 * 1024)
290 +#define CONFIG_ENV_SECT_SIZE (128 * 1024)
292 +#define CONFIG_ENV_IS_NOWHERE
295 +#define CONFIG_ENV_SIZE (8 * 1024)
296 +#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
299 +#define CONFIG_LTQ_ADVANCED_CONSOLE
300 +#define CONFIG_BAUDRATE 115200
301 +#define CONFIG_CONSOLE_ASC 1
302 +#define CONFIG_CONSOLE_DEV "ttyLTQ1"
304 +/* Pull in default board configs for Lantiq XWAY VRX200 */
305 +#include <asm/lantiq/config.h>
306 +#include <asm/arch/config.h>
308 +/* Pull in default OpenWrt configs for Lantiq SoC */
309 +#include "openwrt-lantiq-common.h"
311 +#define CONFIG_ENV_UPDATE_UBOOT_NAND \
312 + "update-uboot-nand=run load-uboot-nandspl-lzo write-uboot-nand\0"
314 +#define CONFIG_EXTRA_ENV_SETTINGS \
315 + CONFIG_ENV_LANTIQ_DEFAULTS \
316 + CONFIG_ENV_UPDATE_UBOOT_NAND
318 +#endif /* __CONFIG_H */