aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/image/lzma-loader
diff options
context:
space:
mode:
authorAntonio Vázquez <antoniovazquezblanco@gmail.com>2023-01-21 22:34:28 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2023-04-29 22:32:27 +0200
commitc31319b66934f554f6c337b4cfa888b1fb74faa4 (patch)
treec360a304dbf66444d51c3487dcd1ae4c7ea6418b /target/linux/ramips/image/lzma-loader
parente4c7703d2a62b8914e4723adae3f67c68a57532c (diff)
downloadupstream-c31319b66934f554f6c337b4cfa888b1fb74faa4.tar.gz
upstream-c31319b66934f554f6c337b4cfa888b1fb74faa4.tar.bz2
upstream-c31319b66934f554f6c337b4cfa888b1fb74faa4.zip
ramips: lzma-loader: Refactor loader
* Delete unused lantiq makefile * Delete redundant makefiles and unify them into the main makefile * Refactor and unify board code into a single file * Add support and review subtarget specific board support Signed-off-by: Antonio Vázquez <antoniovazquezblanco@gmail.com>
Diffstat (limited to 'target/linux/ramips/image/lzma-loader')
-rw-r--r--target/linux/ramips/image/lzma-loader/Makefile4
-rw-r--r--target/linux/ramips/image/lzma-loader/src/Makefile25
-rw-r--r--target/linux/ramips/image/lzma-loader/src/board-mt7621.c39
-rw-r--r--target/linux/ramips/image/lzma-loader/src/board-ralink.c42
-rw-r--r--target/linux/ramips/image/lzma-loader/src/board.c48
-rw-r--r--target/linux/ramips/image/lzma-loader/src/lantiq.mk1
-rw-r--r--target/linux/ramips/image/lzma-loader/src/mt7621.mk1
-rw-r--r--target/linux/ramips/image/lzma-loader/src/ralink.mk1
8 files changed, 74 insertions, 87 deletions
diff --git a/target/linux/ramips/image/lzma-loader/Makefile b/target/linux/ramips/image/lzma-loader/Makefile
index 4cf700d8c6..7b87941e02 100644
--- a/target/linux/ramips/image/lzma-loader/Makefile
+++ b/target/linux/ramips/image/lzma-loader/Makefile
@@ -18,6 +18,8 @@ FLASH_OFFS :=
FLASH_MAX :=
BOARD :=
PLATFORM :=
+SUBTARGET :=
+CACHE_FLAGS := -DCONFIG_CACHELINE_SIZE=32
ifeq ($(TARGET_DIR),)
TARGET_DIR := $(KDIR)
@@ -46,6 +48,8 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
FLASH_MAX=$(FLASH_MAX) \
BOARD="$(BOARD)" \
PLATFORM="$(PLATFORM)" \
+ SUBTARGET="$(SUBTARGET)" \
+ CACHE_FLAGS="$(CACHE_FLAGS)" \
clean all
loader.gz: $(PKG_BUILD_DIR)/loader.bin
diff --git a/target/linux/ramips/image/lzma-loader/src/Makefile b/target/linux/ramips/image/lzma-loader/src/Makefile
index 97fd6dad47..478cf17f29 100644
--- a/target/linux/ramips/image/lzma-loader/src/Makefile
+++ b/target/linux/ramips/image/lzma-loader/src/Makefile
@@ -23,6 +23,7 @@ FLASH_START :=
FLASH_OFFS :=
FLASH_MAX :=
PLATFORM :=
+SUBTARGET :=
CACHE_FLAGS :=
CC := $(CROSS_COMPILE)gcc
@@ -31,8 +32,6 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
-include $(PLATFORM).mk
-
BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
-R .MIPS.abiflags -S
@@ -54,7 +53,27 @@ LDFLAGS += -flto -fwhole-program -Wl,-z,max-page-size=4096
O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
-OBJECTS := head.o loader.o cache.o board-$(PLATFORM).o printf.o LzmaDecode.o
+OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o
+
+ifeq ($(strip $(SUBTARGET)),)
+$(error "Please specify a SUBTARGET!")
+endif
+
+ifeq ($(strip $(SUBTARGET)),mt7620)
+CFLAGS += -DSOC_MT7620
+endif
+
+ifeq ($(strip $(SUBTARGET)),mt7621)
+CFLAGS += -DSOC_MT7621
+endif
+
+ifeq ($(strip $(SUBTARGET)),rt305x)
+CFLAGS += -DSOC_RT305X
+endif
+
+ifeq ($(strip $(SUBTARGET)),rt3883)
+CFLAGS += -DSOC_RT3883
+endif
ifneq ($(strip $(LOADER_DATA)),)
OBJECTS += data.o
diff --git a/target/linux/ramips/image/lzma-loader/src/board-mt7621.c b/target/linux/ramips/image/lzma-loader/src/board-mt7621.c
deleted file mode 100644
index b90b2ed89f..0000000000
--- a/target/linux/ramips/image/lzma-loader/src/board-mt7621.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Arch specific code for mt7621 based boards, based on code for Ralink boards
- *
- * Copyright (C) 2018 Tobias Schramm <tobleminer@gmail.com>
- *
- * 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.
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include "config.h"
-
-#define READREG(r) *(volatile uint32_t *)(r)
-#define WRITEREG(r,v) *(volatile uint32_t *)(r) = v
-
-#define KSEG1ADDR(_x) (((_x) & 0x1fffffff) | 0xa0000000)
-
-#define UART_BASE 0xBE000C00
-
-#define UART_TBR_OFFSET 0x00
-#define UART_LSR_OFFSET 0x14
-
-#define UART_LSR_TEMT (1 << 6)
-
-#define UART_READ(r) READREG(UART_BASE + (r))
-#define UART_WRITE(r,v) WRITEREG(UART_BASE + (r), (v))
-
-void board_putc(int ch)
-{
- while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0);
- UART_WRITE(UART_TBR_OFFSET, ch);
- while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0);
-}
-
-void board_init(void)
-{
-}
diff --git a/target/linux/ramips/image/lzma-loader/src/board-ralink.c b/target/linux/ramips/image/lzma-loader/src/board-ralink.c
deleted file mode 100644
index 7c947ec6eb..0000000000
--- a/target/linux/ramips/image/lzma-loader/src/board-ralink.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Arch specific code for Ralink based boards
- *
- * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
- *
- * 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.
- */
-
-#include <stddef.h>
-#include "config.h"
-
-#define READREG(r) *(volatile unsigned int *)(r)
-#define WRITEREG(r,v) *(volatile unsigned int *)(r) = v
-
-#define KSEG1ADDR(_x) (((_x) & 0x1fffffff) | 0xa0000000)
-
-#ifdef CONFIG_SOC_RT288X
-#define UART_BASE 0xb0300c00
-#else
-#define UART_BASE 0xb0000c00
-#endif
-
-#define UART_TX 1
-#define UART_LSR 7
-
-#define UART_LSR_THRE 0x20
-
-#define UART_READ(r) READREG(UART_BASE + 4 * (r))
-#define UART_WRITE(r,v) WRITEREG(UART_BASE + 4 * (r), (v))
-
-void board_putc(int ch)
-{
- while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0);
- UART_WRITE(UART_TX, ch);
- while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0);
-}
-
-void board_init(void)
-{
-}
diff --git a/target/linux/ramips/image/lzma-loader/src/board.c b/target/linux/ramips/image/lzma-loader/src/board.c
new file mode 100644
index 0000000000..ae9da38073
--- /dev/null
+++ b/target/linux/ramips/image/lzma-loader/src/board.c
@@ -0,0 +1,48 @@
+/*
+ * Arch specific code for ramips based boards
+ *
+ * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
+ * Copyright (C) 2018 Tobias Schramm <tobleminer@gmail.com>
+ * Copyright (C) 2023 Antonio Vázquez <antoniovazquezblanco@gmail.com>
+ *
+ * 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.
+ */
+
+#include <stdint.h>
+
+#if defined(SOC_MT7620) || defined(SOC_RT3883)
+#define UART_BASE 0xb0000c00
+#define UART_THR (UART_BASE + 0x04)
+#define UART_LSR (UART_BASE + 0x1c)
+#define UART_LSR_THRE_MASK 0x40
+#elif defined(SOC_MT7621)
+#define UART_BASE 0xbe000c00
+#define UART_THR (UART_BASE + 0x00)
+#define UART_LSR (UART_BASE + 0x14)
+#define UART_LSR_THRE_MASK 0x20
+#elif defined(SOC_RT305X)
+#define UART_BASE 0x10000500
+#define UART_THR (UART_BASE + 0x04)
+#define UART_LSR (UART_BASE + 0x1c)
+#define UART_LSR_THRE_MASK 0x20
+#else
+#error "Unsupported SOC..."
+#endif
+
+// Helper functions
+#define READREG(r) (*(volatile uint32_t *)(r))
+#define WRITEREG(r,v) (*(volatile uint32_t *)(r)) = v
+
+
+void board_init(void)
+{
+}
+
+void board_putc(int ch)
+{
+ while ((READREG(UART_LSR) & UART_LSR_THRE_MASK) == 0);
+ WRITEREG(UART_THR, ch);
+ while ((READREG(UART_LSR) & UART_LSR_THRE_MASK) == 0);
+}
diff --git a/target/linux/ramips/image/lzma-loader/src/lantiq.mk b/target/linux/ramips/image/lzma-loader/src/lantiq.mk
deleted file mode 100644
index 413764593b..0000000000
--- a/target/linux/ramips/image/lzma-loader/src/lantiq.mk
+++ /dev/null
@@ -1 +0,0 @@
-CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(32 * 1024)" -DCONFIG_CACHELINE_SIZE=32
diff --git a/target/linux/ramips/image/lzma-loader/src/mt7621.mk b/target/linux/ramips/image/lzma-loader/src/mt7621.mk
deleted file mode 100644
index 3ff5fddf98..0000000000
--- a/target/linux/ramips/image/lzma-loader/src/mt7621.mk
+++ /dev/null
@@ -1 +0,0 @@
-CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(16 * 1024)" -DCONFIG_CACHELINE_SIZE=32
diff --git a/target/linux/ramips/image/lzma-loader/src/ralink.mk b/target/linux/ramips/image/lzma-loader/src/ralink.mk
deleted file mode 100644
index 3ff5fddf98..0000000000
--- a/target/linux/ramips/image/lzma-loader/src/ralink.mk
+++ /dev/null
@@ -1 +0,0 @@
-CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(16 * 1024)" -DCONFIG_CACHELINE_SIZE=32