This provides low level initialization of pll and ddr2. Resulting binary
should work from SRAM, DDR2 and SPI flash. If started from DDR2 RAM
level initialization will skipped.

Signed-off-by: Oleksij Rempel <li...@rempel-privat.de>
---
 arch/mips/Makefile                                 |  1 +
 arch/mips/boards/tplink-wdr4300/Makefile           |  1 +
 arch/mips/boards/tplink-wdr4300/board.c            | 28 ++++++++
 .../tplink-wdr4300/include/board/board_pbl_start.h | 62 +++++++++++++++++
 arch/mips/configs/tplink-wdr4300_defconfig         | 78 ++++++++++++++++++++++
 arch/mips/dts/ar9344_tl_wdr4300.dts                | 63 +++++++++++++++++
 arch/mips/mach-ath79/Kconfig                       | 10 +++
 7 files changed, 243 insertions(+)
 create mode 100644 arch/mips/boards/tplink-wdr4300/Makefile
 create mode 100644 arch/mips/boards/tplink-wdr4300/board.c
 create mode 100644 
arch/mips/boards/tplink-wdr4300/include/board/board_pbl_start.h
 create mode 100644 arch/mips/configs/tplink-wdr4300_defconfig
 create mode 100644 arch/mips/dts/ar9344_tl_wdr4300.dts

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 75761b5e7..dd5ceea20 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -80,6 +80,7 @@ board-$(CONFIG_BOARD_NETGEAR_WG102)   := netgear-wg102
 
 machine-$(CONFIG_MACH_MIPS_ATH79)      := ath79
 board-$(CONFIG_BOARD_TPLINK_MR3020)    := tplink-mr3020
+board-$(CONFIG_BOARD_TPLINK_WDR4300)   := tplink-wdr4300
 board-$(CONFIG_BOARD_BLACK_SWIFT)      := black-swift
 
 machine-$(CONFIG_MACH_MIPS_BCM47XX)    := bcm47xx
diff --git a/arch/mips/boards/tplink-wdr4300/Makefile 
b/arch/mips/boards/tplink-wdr4300/Makefile
new file mode 100644
index 000000000..dcfc2937d
--- /dev/null
+++ b/arch/mips/boards/tplink-wdr4300/Makefile
@@ -0,0 +1 @@
+obj-y += board.o
diff --git a/arch/mips/boards/tplink-wdr4300/board.c 
b/arch/mips/boards/tplink-wdr4300/board.c
new file mode 100644
index 000000000..d6126fcb6
--- /dev/null
+++ b/arch/mips/boards/tplink-wdr4300/board.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Oleksij Rempel <o.rem...@pengutronix.de>
+ * Copyright (C) 2014 Antony Pavlov <antonynpav...@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+
+static int model_hostname_init(void)
+{
+       barebox_set_hostname("wdr4300");
+
+       return 0;
+}
+postcore_initcall(model_hostname_init);
diff --git a/arch/mips/boards/tplink-wdr4300/include/board/board_pbl_start.h 
b/arch/mips/boards/tplink-wdr4300/include/board/board_pbl_start.h
new file mode 100644
index 000000000..7d4ee4bab
--- /dev/null
+++ b/arch/mips/boards/tplink-wdr4300/include/board/board_pbl_start.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 Oleksij Rempel <o.rem...@pengutronix.de>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <mach/debug_ll_ar9344.h>
+#include <asm/pbl_macros.h>
+#include <mach/pbl_macros.h>
+#include <mach/pbl_ll_init_ar9344_1.1.h>
+#include <asm/pbl_nmon.h>
+
+       .macro  board_pbl_start
+       .set    push
+       .set    noreorder
+
+       mips_barebox_10h
+
+       debug_ll_ar9344_init
+
+       debug_ll_outc '1'
+
+       hornet_mips24k_cp0_setup
+       debug_ll_outc '2'
+
+       /* test if we are in the SRAM */
+       pbl_blt 0xbd000000 1f t8
+       debug_ll_outc '3'
+       b skip_flash_test
+       nop
+1:
+       /* test if we are in the flash */
+       pbl_blt 0xbf000000 skip_pll_ram_config t8
+       debug_ll_outc '4'
+skip_flash_test:
+
+       pbl_ar9344_v11_pll_config
+       debug_ll_outc '5'
+
+       pbl_ar9344_v11_ddr2_config
+
+skip_pll_ram_config:
+       debug_ll_outc '6'
+       debug_ll_outnl
+
+       mips_nmon
+
+       copy_to_link_location   pbl_start
+
+       .set    pop
+       .endm
diff --git a/arch/mips/configs/tplink-wdr4300_defconfig 
b/arch/mips/configs/tplink-wdr4300_defconfig
new file mode 100644
index 000000000..63189b754
--- /dev/null
+++ b/arch/mips/configs/tplink-wdr4300_defconfig
@@ -0,0 +1,78 @@
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="ar9344_tl_wdr4300"
+CONFIG_MACH_MIPS_ATH79=y
+CONFIG_BOARD_TPLINK_WDR4300=y
+CONFIG_PBL_IMAGE=y
+CONFIG_IMAGE_COMPRESSION_XZKERN=y
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0x81000000
+CONFIG_MALLOC_TLSF=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_CMD_DMESG=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_IMD=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_DEFAULTENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_SHA1SUM=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_READF=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DETECT=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_LED=y
+CONFIG_CMD_POWEROFF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_LED_TRIGGER=y
+CONFIG_CMD_BAREBOX_UPDATE=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_NET=y
+CONFIG_NET_NFS=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_NET_RESOLV=y
+CONFIG_NET_DHCP=y
+CONFIG_NET_SNTP=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_OF_BAREBOX_ENV_IN_FS=y
+CONFIG_DRIVER_SERIAL_NS16550=y
+CONFIG_DRIVER_NET_AG71XX=y
+CONFIG_AT803X_PHY=y
+CONFIG_MDIO_BITBANG=y
+CONFIG_MDIO_GPIO=y
+CONFIG_DRIVER_SPI_ATH79=y
+CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_M25P80=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_LED_TRIGGERS=y
+CONFIG_DIGEST_SHA224_GENERIC=y
+CONFIG_DIGEST_SHA256_GENERIC=y
diff --git a/arch/mips/dts/ar9344_tl_wdr4300.dts 
b/arch/mips/dts/ar9344_tl_wdr4300.dts
new file mode 100644
index 000000000..b02c1d730
--- /dev/null
+++ b/arch/mips/dts/ar9344_tl_wdr4300.dts
@@ -0,0 +1,63 @@
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar9344.dtsi"
+
+/ {
+       model = "TP-Link WDR4300";
+       compatible = "tplink,tl-wdr4300";
+
+       aliases {
+               serial0 = &uart0;
+       };
+
+       memory@0 {
+               device_type = "memory";
+               reg = <0x0 0x8000000>;
+       };
+
+       chosen {
+               stdout-path = &uart0;
+
+               environment@0 {
+                       compatible = "barebox,environment";
+                       device-path = &spiflash, "partname:barebox-environment";
+               };
+       };
+};
+
+&ref {
+       clock-frequency = <40000000>;
+};
+
+&uart0 {
+       status = "okay";
+       clock-frequency = <40000000>;
+};
+
+&spi {
+       num-chipselects = <1>;
+       status = "okay";
+
+       /* Winbond W25Q64CV SPI flash */
+       spiflash: w25q64cv@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "jedec,spi-nor", "winbond,w25q64cv";
+               spi-max-frequency = <104000000>;
+               reg = <0>;
+
+               partition@0 {
+                       label = "barebox";
+                       reg = <0 0x80000>;
+                       read-only;
+               };
+
+               partition@80000 {
+                       label = "barebox-environment";
+                       reg = <0x80000 0x10000>;
+               };
+       };
+};
diff --git a/arch/mips/mach-ath79/Kconfig b/arch/mips/mach-ath79/Kconfig
index f2eae2532..9fec00c98 100644
--- a/arch/mips/mach-ath79/Kconfig
+++ b/arch/mips/mach-ath79/Kconfig
@@ -7,6 +7,9 @@ config ARCH_TEXT_BASE
 config SOC_QCA_AR9331
        bool
 
+config SOC_QCA_AR9344
+       bool
+
 choice
        prompt "Board type"
 
@@ -17,6 +20,13 @@ config BOARD_TPLINK_MR3020
        select HAVE_IMAGE_COMPRESSION
        select HAS_NMON
 
+config BOARD_TPLINK_WDR4300
+       bool "TP-LINK WDR4300"
+       select SOC_QCA_AR9344
+       select HAVE_PBL_IMAGE
+       select HAVE_IMAGE_COMPRESSION
+       select HAS_NMON
+
 config BOARD_BLACK_SWIFT
        bool "Black Swift"
        select SOC_QCA_AR9331
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to