add chaos_calmer branch
[15.05/openwrt.git] / package / boot / uboot-lantiq / patches / 0036-MIPS-add-board-support-for-Arcadyan-Easybox-904.patch
1 From 60856fa8f9866f292df740ea98752a70738eb59a Mon Sep 17 00:00:00 2001
2 From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 Date: Fri, 9 Aug 2013 18:11:07 +0200
4 Subject: MIPS: add board support for Arcadyan Easybox 904
5
6 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
7
8 --- /dev/null
9 +++ b/board/arcadyan/easybox904/Makefile
10 @@ -0,0 +1,27 @@
11 +#
12 +# Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
13 +#
14 +# SPDX-License-Identifier:     GPL-2.0+
15 +#
16 +
17 +include $(TOPDIR)/config.mk
18 +
19 +LIB    = $(obj)lib$(BOARD).o
20 +
21 +COBJS  = $(BOARD).o
22 +
23 +SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
24 +OBJS   := $(addprefix $(obj),$(COBJS))
25 +SOBJS  := $(addprefix $(obj),$(SOBJS))
26 +
27 +$(LIB):        $(obj).depend $(OBJS) $(SOBJS)
28 +       $(call cmd_link_o_target, $(OBJS) $(SOBJS))
29 +
30 +#########################################################################
31 +
32 +# defines $(obj).depend target
33 +include $(SRCTREE)/rules.mk
34 +
35 +sinclude $(obj).depend
36 +
37 +#########################################################################
38 --- /dev/null
39 +++ b/board/arcadyan/easybox904/config.mk
40 @@ -0,0 +1,7 @@
41 +#
42 +# Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
43 +#
44 +# SPDX-License-Identifier:     GPL-2.0+
45 +#
46 +
47 +PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
48 --- /dev/null
49 +++ b/board/arcadyan/easybox904/ddr_settings.h
50 @@ -0,0 +1,68 @@
51 +/*
52 + * Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
53 + *
54 + * SPDX-License-Identifier:    GPL-2.0+
55 + */
56 +
57 +#define        MC_CCR00_VALUE  0x101
58 +#define        MC_CCR01_VALUE  0x1000100
59 +#define        MC_CCR02_VALUE  0x1010000
60 +#define        MC_CCR03_VALUE  0x101
61 +#define        MC_CCR04_VALUE  0x1000000
62 +#define        MC_CCR05_VALUE  0x1000101
63 +#define        MC_CCR06_VALUE  0x1000100
64 +#define        MC_CCR07_VALUE  0x1010000
65 +#define        MC_CCR08_VALUE  0x1000101
66 +#define        MC_CCR09_VALUE  0x1000000
67 +#define        MC_CCR10_VALUE  0x2000100
68 +#define        MC_CCR11_VALUE  0x2000300
69 +#define        MC_CCR12_VALUE  0x30000
70 +#define        MC_CCR13_VALUE  0x202
71 +#define        MC_CCR14_VALUE  0x7080A0F
72 +#define        MC_CCR15_VALUE  0x2040F
73 +#define        MC_CCR16_VALUE  0x40000
74 +#define        MC_CCR17_VALUE  0x70102
75 +#define        MC_CCR18_VALUE  0x4020002
76 +#define        MC_CCR19_VALUE  0x30302
77 +#define        MC_CCR20_VALUE  0x8000700
78 +#define        MC_CCR21_VALUE  0x40F020A
79 +#define        MC_CCR22_VALUE  0x0
80 +#define        MC_CCR23_VALUE  0xC020000
81 +#define        MC_CCR24_VALUE  0x4401503
82 +#define        MC_CCR25_VALUE  0x0
83 +#define        MC_CCR26_VALUE  0x0
84 +#define        MC_CCR27_VALUE  0x6420000
85 +#define        MC_CCR28_VALUE  0x0
86 +#define        MC_CCR29_VALUE  0x0
87 +#define        MC_CCR30_VALUE  0x798
88 +#define        MC_CCR31_VALUE  0x0
89 +#define        MC_CCR32_VALUE  0x0
90 +#define        MC_CCR33_VALUE  0x650000
91 +#define        MC_CCR34_VALUE  0x200C8
92 +#define        MC_CCR35_VALUE  0x1536B0
93 +#define        MC_CCR36_VALUE  0xC8
94 +#define        MC_CCR37_VALUE  0xC351
95 +#define        MC_CCR38_VALUE  0x0
96 +#define        MC_CCR39_VALUE  0x142404
97 +#define        MC_CCR40_VALUE  0x142604
98 +#define        MC_CCR41_VALUE  0x141B42
99 +#define        MC_CCR42_VALUE  0x141B42
100 +#define        MC_CCR43_VALUE  0x566504
101 +#define        MC_CCR44_VALUE  0x566504
102 +#define        MC_CCR45_VALUE  0x565F17
103 +#define        MC_CCR46_VALUE  0x565F17
104 +#define        MC_CCR47_VALUE  0x0
105 +#define        MC_CCR48_VALUE  0x0
106 +#define        MC_CCR49_VALUE  0x0
107 +#define        MC_CCR50_VALUE  0x0
108 +#define        MC_CCR51_VALUE  0x0
109 +#define        MC_CCR52_VALUE  0x133
110 +#define        MC_CCR53_VALUE  0xF3014B27
111 +#define        MC_CCR54_VALUE  0xF3014B27
112 +#define        MC_CCR55_VALUE  0xF3014B27
113 +#define        MC_CCR56_VALUE  0xF3014B27
114 +#define        MC_CCR57_VALUE  0x7C00301
115 +#define        MC_CCR58_VALUE  0x7C00301
116 +#define        MC_CCR59_VALUE  0x7C00301
117 +#define        MC_CCR60_VALUE  0x7C00301
118 +#define        MC_CCR61_VALUE  0x4
119 --- /dev/null
120 +++ b/board/arcadyan/easybox904/easybox904.c
121 @@ -0,0 +1,98 @@
122 +/*
123 + * Copyright (C) 2012-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
124 + *
125 + * SPDX-License-Identifier:    GPL-2.0+
126 + */
127 +
128 +#include <common.h>
129 +#include <spi.h>
130 +#include <asm/gpio.h>
131 +#include <asm/lantiq/eth.h>
132 +#include <asm/lantiq/chipid.h>
133 +#include <asm/lantiq/cpu.h>
134 +#include <asm/arch/gphy.h>
135 +
136 +#if defined(CONFIG_SPL_BUILD)
137 +#define do_gpio_init   1
138 +#define do_pll_init    1
139 +#define do_dcdc_init   0
140 +#elif defined(CONFIG_SYS_BOOT_RAM)
141 +#define do_gpio_init   1
142 +#define do_pll_init    0
143 +#define do_dcdc_init   1
144 +#else
145 +#define do_gpio_init   0
146 +#define do_pll_init    0
147 +#define do_dcdc_init   1
148 +#endif
149 +
150 +static inline void gpio_init(void)
151 +{
152 +       /* EBU.FL_CS1 as output for NAND CE */
153 +       gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
154 +       /* EBU.FL_A23 as output for NAND CLE */
155 +       gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
156 +       /* EBU.FL_A24 as output for NAND ALE */
157 +       gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
158 +       /* GPIO 3.0 as input for NAND Ready Busy */
159 +       gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
160 +       /* GPIO 3.1 as output for NAND Read */
161 +       gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
162 +}
163 +
164 +int board_early_init_f(void)
165 +{
166 +       if (do_gpio_init)
167 +               gpio_init();
168 +
169 +       if (do_pll_init)
170 +               ltq_pll_init();
171 +
172 +       if (do_dcdc_init)
173 +               ltq_dcdc_init(0x7F);
174 +
175 +       return 0;
176 +}
177 +
178 +int checkboard(void)
179 +{
180 +       puts("Board: " CONFIG_BOARD_NAME "\n");
181 +       ltq_chip_print_info();
182 +
183 +       return 0;
184 +}
185 +
186 +static const struct ltq_eth_port_config eth_port_config[] = {
187 +       /* GMAC0: ??? */
188 +       { 0, 0x0, LTQ_ETH_PORT_NONE, LTQ_ETH_PORT_NONE },
189 +       /* GMAC1: ??? */
190 +       { 1, 0x1, LTQ_ETH_PORT_NONE, LTQ_ETH_PORT_NONE },
191 +       /* GMAC2: ??? */
192 +       { 2, 0x11, LTQ_ETH_PORT_NONE, LTQ_ETH_PORT_NONE },
193 +       /* GMAC3: unused */
194 +       { 3, 0x0, LTQ_ETH_PORT_NONE, LTQ_ETH_PORT_NONE },
195 +       /* GMAC4: internal GPHY1 with 10/100/1000 firmware for WANoE port */
196 +       { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
197 +       /* GMAC5: ??? */
198 +       { 5, 0x5, LTQ_ETH_PORT_NONE, LTQ_ETH_PORT_NONE },
199 +};
200 +
201 +static const struct ltq_eth_board_config eth_board_config = {
202 +       .ports = eth_port_config,
203 +       .num_ports = ARRAY_SIZE(eth_port_config),
204 +};
205 +
206 +int board_eth_init(bd_t * bis)
207 +{
208 +       const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
209 +       const ulong fw_ge_addr = 0x80FE0000;
210 +
211 +       ltq_gphy_phy11g_a2x_load(fw_ge_addr);
212 +
213 +       ltq_cgu_gphy_clk_src(clk);
214 +
215 +       ltq_rcu_gphy_boot(0, fw_ge_addr);
216 +       ltq_rcu_gphy_boot(1, fw_ge_addr);
217 +
218 +       return ltq_eth_initialize(&eth_board_config);
219 +}
220 --- a/boards.cfg
221 +++ b/boards.cfg
222 @@ -529,6 +529,7 @@ Active  mips        mips32         incai
223  Active  mips        mips32         incaip      -               incaip              incaip_100MHz                        incaip:CPU_CLOCK_RATE=100000000                                                                                                   Wolfgang Denk <wd@denx.de>
224  Active  mips        mips32         incaip      -               incaip              incaip_133MHz                        incaip:CPU_CLOCK_RATE=133000000                                                                                                   Wolfgang Denk <wd@denx.de>
225  Active  mips        mips32         incaip      -               incaip              incaip_150MHz                        incaip:CPU_CLOCK_RATE=150000000                                                                                                   Wolfgang Denk <wd@denx.de>
226 +Active  mips        mips32         vrx200      arcadyan        easybox904          easybox904_ram                       easybox904:SYS_BOOT_RAM                                                                                                           Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
227  Active  mips        mips32         vrx200      avm             fb3370              fb3370_eva                           fb3370:SYS_BOOT_EVA                                                                                                               Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
228  Active  mips        mips32         vrx200      avm             fb3370              fb3370_ram                           fb3370:SYS_BOOT_RAM                                                                                                               Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
229  Active  mips        mips32         vrx200      avm             fb3370              fb3370_sfspl                         fb3370:SYS_BOOT_SFSPL                                                                                                             Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
230 --- /dev/null
231 +++ b/include/configs/easybox904.h
232 @@ -0,0 +1,45 @@
233 +/*
234 + * Copyright (C) 2012-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
235 + *
236 + * SPDX-License-Identifier:    GPL-2.0+
237 + */
238 +
239 +#ifndef __CONFIG_H
240 +#define __CONFIG_H
241 +
242 +#define CONFIG_MACH_TYPE       "EASYBOX904"
243 +#define CONFIG_IDENT_STRING    " "CONFIG_MACH_TYPE
244 +#define CONFIG_BOARD_NAME      "Arcadyan EasyBox 904"
245 +
246 +/* Configure SoC */
247 +#define CONFIG_LTQ_SUPPORT_UART                        /* Enable ASC and UART */
248 +
249 +#define CONFIG_LTQ_SUPPORT_ETHERNET            /* Enable ethernet */
250 +
251 +#define CONFIG_LTQ_SUPPORT_NAND_FLASH
252 +
253 +#define CONFIG_SYS_DRAM_PROBE
254 +
255 +/* Environment */
256 +#define CONFIG_ENV_IS_NOWHERE
257 +
258 +#define CONFIG_ENV_SIZE                        (8 * 1024)
259 +#define CONFIG_LOADADDR                        CONFIG_SYS_LOAD_ADDR
260 +
261 +/* Console */
262 +#define CONFIG_LTQ_ADVANCED_CONSOLE
263 +#define CONFIG_BAUDRATE                        115200
264 +#define CONFIG_CONSOLE_ASC             1
265 +#define CONFIG_CONSOLE_DEV             "ttyLTQ1"
266 +
267 +/* Pull in default board configs for Lantiq XWAY VRX200 */
268 +#include <asm/lantiq/config.h>
269 +#include <asm/arch/config.h>
270 +
271 +/* Pull in default OpenWrt configs for Lantiq SoC */
272 +#include "openwrt-lantiq-common.h"
273 +
274 +#define CONFIG_EXTRA_ENV_SETTINGS      \
275 +       CONFIG_ENV_LANTIQ_DEFAULTS
276 +
277 +#endif /* __CONFIG_H */