0105-MIPS-add-board-support-for-AVM-FritzBox-3370.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. From 37a95ae4ba75407a26862ece6f48fa68aa6c5c78 Mon Sep 17 00:00:00 2001
  2. From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  3. Date: Sat, 2 Mar 2013 23:34:00 +0100
  4. Subject: MIPS: add board support for AVM FritzBox 3370
  5. Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  6. --- /dev/null
  7. +++ b/board/avm/fb3370/Makefile
  8. @@ -0,0 +1,28 @@
  9. +#
  10. +# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
  11. +# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
  12. +#
  13. +# SPDX-License-Identifier: GPL-2.0+
  14. +#
  15. +
  16. +include $(TOPDIR)/config.mk
  17. +
  18. +LIB = $(obj)lib$(BOARD).o
  19. +
  20. +COBJS = $(BOARD).o
  21. +
  22. +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
  23. +OBJS := $(addprefix $(obj),$(COBJS))
  24. +SOBJS := $(addprefix $(obj),$(SOBJS))
  25. +
  26. +$(LIB): $(obj).depend $(OBJS) $(SOBJS)
  27. + $(call cmd_link_o_target, $(OBJS) $(SOBJS))
  28. +
  29. +#########################################################################
  30. +
  31. +# defines $(obj).depend target
  32. +include $(SRCTREE)/rules.mk
  33. +
  34. +sinclude $(obj).depend
  35. +
  36. +#########################################################################
  37. --- /dev/null
  38. +++ b/board/avm/fb3370/config.mk
  39. @@ -0,0 +1,7 @@
  40. +#
  41. +# Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
  42. +#
  43. +# SPDX-License-Identifier: GPL-2.0+
  44. +#
  45. +
  46. +PLATFORM_CPPFLAGS += -I$(TOPDIR)/board/$(BOARDDIR)
  47. --- /dev/null
  48. +++ b/board/avm/fb3370/ddr_settings.h
  49. @@ -0,0 +1,69 @@
  50. +/*
  51. + * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
  52. + * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.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 0x0
  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 0x4401B04
  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 0x1D445D
  93. +#define MC_CCR36_VALUE 0xC8
  94. +#define MC_CCR37_VALUE 0xC351
  95. +#define MC_CCR38_VALUE 0x0
  96. +#define MC_CCR39_VALUE 0x141F04
  97. +#define MC_CCR40_VALUE 0x142704
  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 0x7800301
  115. +#define MC_CCR58_VALUE 0x7800301
  116. +#define MC_CCR59_VALUE 0x7800301
  117. +#define MC_CCR60_VALUE 0x7800301
  118. +#define MC_CCR61_VALUE 0x4
  119. --- /dev/null
  120. +++ b/board/avm/fb3370/fb3370.c
  121. @@ -0,0 +1,138 @@
  122. +/*
  123. + * Copyright (C) 2011 Daniel Schwierzeck, daniel.schwierzeck@googlemail.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. +#elif defined(CONFIG_SYS_BOOT_NOR)
  145. +#define do_gpio_init 1
  146. +#define do_pll_init 1
  147. +#define do_dcdc_init 1
  148. +#else
  149. +#define do_gpio_init 0
  150. +#define do_pll_init 0
  151. +#define do_dcdc_init 1
  152. +#endif
  153. +
  154. +static void gpio_init(void)
  155. +{
  156. + /* SPI CS 0.4 to serial flash */
  157. + gpio_direction_output(10, 1);
  158. +
  159. + /* EBU.FL_CS1 as output for NAND CE */
  160. + gpio_set_altfunc(23, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  161. + /* EBU.FL_A23 as output for NAND CLE */
  162. + gpio_set_altfunc(24, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  163. + /* EBU.FL_A24 as output for NAND ALE */
  164. + gpio_set_altfunc(13, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  165. + /* GPIO 3.0 as input for NAND Ready Busy */
  166. + gpio_set_altfunc(48, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_IN);
  167. + /* GPIO 3.1 as output for NAND Read */
  168. + gpio_set_altfunc(49, GPIO_ALTSEL_SET, GPIO_ALTSEL_CLR, GPIO_DIR_OUT);
  169. +}
  170. +
  171. +int board_early_init_f(void)
  172. +{
  173. + if (do_gpio_init)
  174. + gpio_init();
  175. +
  176. + if (do_pll_init)
  177. + ltq_pll_init();
  178. +
  179. + if (do_dcdc_init)
  180. + ltq_dcdc_init(0x7F);
  181. +
  182. + return 0;
  183. +}
  184. +
  185. +int checkboard(void)
  186. +{
  187. + puts("Board: " CONFIG_BOARD_NAME "\n");
  188. + ltq_chip_print_info();
  189. +
  190. + return 0;
  191. +}
  192. +
  193. +static const struct ltq_eth_port_config eth_port_config[] = {
  194. + /* GMAC0: external Lantiq PEF7071 10/100/1000 PHY for LAN port 0 */
  195. + { 0, 0x0, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
  196. + /* GMAC1: external Lantiq PEF7071 10/100/1000 PHY for LAN port 1 */
  197. + { 1, 0x1, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
  198. + /* GMAC2: internal GPHY0 with 10/100/1000 firmware for LAN port 2 */
  199. + { 2, 0x11, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
  200. + /* GMAC3: unused */
  201. + { 3, 0x0, LTQ_ETH_PORT_NONE, PHY_INTERFACE_MODE_NONE },
  202. + /* GMAC4: internal GPHY1 with 10/100/1000 firmware for LAN port 3 */
  203. + { 4, 0x13, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_GMII },
  204. + /* GMAC5: external Lantiq PEF7071 10/100/1000 PHY for WANoE port */
  205. + { 5, 0x5, LTQ_ETH_PORT_PHY, PHY_INTERFACE_MODE_RGMII },
  206. +};
  207. +
  208. +static const struct ltq_eth_board_config eth_board_config = {
  209. + .ports = eth_port_config,
  210. + .num_ports = ARRAY_SIZE(eth_port_config),
  211. +};
  212. +
  213. +int board_eth_init(bd_t * bis)
  214. +{
  215. + const enum ltq_gphy_clk clk = LTQ_GPHY_CLK_25MHZ_PLL0;
  216. + const ulong fw_addr = 0x80FF0000;
  217. +
  218. + ltq_gphy_phy11g_a1x_load(fw_addr);
  219. +
  220. + ltq_cgu_gphy_clk_src(clk);
  221. +
  222. + ltq_rcu_gphy_boot(0, fw_addr);
  223. + ltq_rcu_gphy_boot(1, fw_addr);
  224. +
  225. + return ltq_eth_initialize(&eth_board_config);
  226. +}
  227. +
  228. +int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  229. +{
  230. + if (bus)
  231. + return 0;
  232. +
  233. + if (cs == 4)
  234. + return 1;
  235. +
  236. + return 0;
  237. +}
  238. +
  239. +void spi_cs_activate(struct spi_slave *slave)
  240. +{
  241. + switch (slave->cs) {
  242. + case 4:
  243. + gpio_set_value(10, 0);
  244. + break;
  245. + default:
  246. + break;
  247. + }
  248. +}
  249. +
  250. +void spi_cs_deactivate(struct spi_slave *slave)
  251. +{
  252. + switch (slave->cs) {
  253. + case 4:
  254. + gpio_set_value(10, 1);
  255. + break;
  256. + default:
  257. + break;
  258. + }
  259. +}
  260. --- a/boards.cfg
  261. +++ b/boards.cfg
  262. @@ -517,6 +517,9 @@ Active mips mips32 incai
  263. Active mips mips32 incaip - incaip incaip_100MHz incaip:CPU_CLOCK_RATE=100000000 Wolfgang Denk <wd@denx.de>
  264. Active mips mips32 incaip - incaip incaip_133MHz incaip:CPU_CLOCK_RATE=133000000 Wolfgang Denk <wd@denx.de>
  265. Active mips mips32 incaip - incaip incaip_150MHz incaip:CPU_CLOCK_RATE=150000000 Wolfgang Denk <wd@denx.de>
  266. +Active mips mips32 vrx200 avm fb3370 fb3370_eva fb3370:SYS_BOOT_EVA Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  267. +Active mips mips32 vrx200 avm fb3370 fb3370_ram fb3370:SYS_BOOT_RAM Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  268. +Active mips mips32 vrx200 avm fb3370 fb3370_sfspl fb3370:SYS_BOOT_SFSPL Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  269. Active mips mips32 vrx200 lantiq easy80920 easy80920_nandspl easy80920:SYS_BOOT_NANDSPL Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  270. Active mips mips32 vrx200 lantiq easy80920 easy80920_nor easy80920:SYS_BOOT_NOR Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  271. Active mips mips32 vrx200 lantiq easy80920 easy80920_norspl easy80920:SYS_BOOT_NORSPL Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
  272. --- /dev/null
  273. +++ b/include/configs/fb3370.h
  274. @@ -0,0 +1,80 @@
  275. +/*
  276. + * Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@googlemail.com
  277. + *
  278. + * SPDX-License-Identifier: GPL-2.0+
  279. + */
  280. +
  281. +#ifndef __CONFIG_H
  282. +#define __CONFIG_H
  283. +
  284. +#define CONFIG_MACH_TYPE "FB3370"
  285. +#define CONFIG_IDENT_STRING " "CONFIG_MACH_TYPE
  286. +#define CONFIG_BOARD_NAME "AVM FritzBox 3370"
  287. +
  288. +/* Configure SoC */
  289. +#define CONFIG_LTQ_SUPPORT_UART /* Enable ASC and UART */
  290. +
  291. +#define CONFIG_LTQ_SUPPORT_ETHERNET /* Enable ethernet */
  292. +
  293. +#define CONFIG_LTQ_SUPPORT_SPI_FLASH
  294. +#define CONFIG_SPI_FLASH_MACRONIX /* Have a MX29LV620 serial flash */
  295. +
  296. +#define CONFIG_LTQ_SUPPORT_NAND_FLASH
  297. +
  298. +#define CONFIG_LTQ_SUPPORT_SPL_SPI_FLASH /* Build SPI flash SPL */
  299. +#define CONFIG_LTQ_SPL_COMP_LZO /* Compress SPL with LZO */
  300. +#define CONFIG_LTQ_SPL_CONSOLE /* Enable SPL console */
  301. +
  302. +#define CONFIG_SPL_SPI_BUS 0
  303. +#define CONFIG_SPL_SPI_CS 4
  304. +#define CONFIG_SPL_SPI_MAX_HZ 25000000
  305. +#define CONFIG_SPL_SPI_MODE 0
  306. +
  307. +#define CONFIG_SYS_DRAM_PROBE
  308. +
  309. +#define CONFIG_SYS_BOOTM_LEN 0x1000000 /* 16 MB */
  310. +
  311. +/* Environment */
  312. +#define CONFIG_ENV_SPI_BUS CONFIG_SPL_SPI_BUS
  313. +#define CONFIG_ENV_SPI_CS CONFIG_SPL_SPI_CS
  314. +#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SPL_SPI_MAX_HZ
  315. +#define CONFIG_ENV_SPI_MODE CONFIG_SPL_SPI_MODE
  316. +
  317. +#if defined(CONFIG_SYS_BOOT_SFSPL)
  318. +#define CONFIG_ENV_IS_IN_SPI_FLASH
  319. +#define CONFIG_ENV_OVERWRITE
  320. +#define CONFIG_ENV_OFFSET (192 * 1024)
  321. +#define CONFIG_ENV_SECT_SIZE (64 * 1024)
  322. +#else
  323. +#define CONFIG_ENV_IS_NOWHERE
  324. +#endif
  325. +
  326. +#define CONFIG_ENV_SIZE (8 * 1024)
  327. +#define CONFIG_LOADADDR CONFIG_SYS_LOAD_ADDR
  328. +
  329. +#if defined(CONFIG_SYS_BOOT_EVA)
  330. +#define CONFIG_SYS_TEXT_BASE 0x80100000
  331. +#define CONFIG_SKIP_LOWLEVEL_INIT
  332. +#endif
  333. +
  334. +/* Console */
  335. +#define CONFIG_LTQ_ADVANCED_CONSOLE
  336. +#define CONFIG_BAUDRATE 115200
  337. +#define CONFIG_CONSOLE_ASC 1
  338. +#define CONFIG_CONSOLE_DEV "ttyLTQ1"
  339. +
  340. +/* Pull in default board configs for Lantiq XWAY VRX200 */
  341. +#include <asm/lantiq/config.h>
  342. +#include <asm/arch/config.h>
  343. +
  344. +/* Pull in default OpenWrt configs for Lantiq SoC */
  345. +#include "openwrt-lantiq-common.h"
  346. +
  347. +#define CONFIG_ENV_UPDATE_UBOOT_SF \
  348. + "update-uboot-sf=run load-uboot-sfspl-lzo write-uboot-sf\0"
  349. +
  350. +#define CONFIG_EXTRA_ENV_SETTINGS \
  351. + CONFIG_ENV_LANTIQ_DEFAULTS \
  352. + CONFIG_ENV_UPDATE_UBOOT_SF
  353. +
  354. +#endif /* __CONFIG_H */