aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm63xx/image
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2020-05-20 09:14:02 +0200
committerÁlvaro Fernández Rojas <noltari@gmail.com>2020-05-20 11:15:29 +0200
commitc93cdf536a086deab0fa696989263a97b4d6c417 (patch)
tree962a57d8e1150af8504eaf3b57e5d51a768f64d2 /target/linux/bcm63xx/image
parent8e8920c92f1346ff1898b8674bc79d9a1a3ea59e (diff)
downloadupstream-c93cdf536a086deab0fa696989263a97b4d6c417.tar.gz
upstream-c93cdf536a086deab0fa696989263a97b4d6c417.tar.bz2
upstream-c93cdf536a086deab0fa696989263a97b4d6c417.zip
bcm63xx: lzma-loader: rely on CHIP_ID for UART address
lzma-loader uart output wasn't working on BCM3380/BCM6362 because these SoCs have the same processor ID. Let's use CHIP_ID for establishing the UART base address. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/bcm63xx/image')
-rw-r--r--target/linux/bcm63xx/image/Makefile3
-rw-r--r--target/linux/bcm63xx/image/lzma-loader/Makefile22
-rw-r--r--target/linux/bcm63xx/image/lzma-loader/src/Makefile6
-rw-r--r--target/linux/bcm63xx/image/lzma-loader/src/board.c79
-rw-r--r--target/linux/bcm63xx/image/lzma-loader/src/loader.c5
5 files changed, 32 insertions, 83 deletions
diff --git a/target/linux/bcm63xx/image/Makefile b/target/linux/bcm63xx/image/Makefile
index ff9ec01c45..7c3091fb66 100644
--- a/target/linux/bcm63xx/image/Makefile
+++ b/target/linux/bcm63xx/image/Makefile
@@ -17,7 +17,8 @@ LOADER_MAKEOPTS= \
KDIR=$(KDIR) \
LOADADDR=$(KERNEL_LOADADDR) \
RAMSIZE=$(RAMSIZE) \
- LZMA_TEXT_START=$(LZMA_TEXT_START)
+ LZMA_TEXT_START=$(LZMA_TEXT_START) \
+ CHIP_ID=$(CHIP_ID)
RELOCATE_MAKEOPTS= \
CACHELINE_SIZE=16 \
diff --git a/target/linux/bcm63xx/image/lzma-loader/Makefile b/target/linux/bcm63xx/image/lzma-loader/Makefile
index 6100a8c2ea..2be41c875a 100644
--- a/target/linux/bcm63xx/image/lzma-loader/Makefile
+++ b/target/linux/bcm63xx/image/lzma-loader/Makefile
@@ -1,4 +1,6 @@
#
+# Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
+# Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>
# Copyright (C) 2011 OpenWrt.org
# Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
#
@@ -14,6 +16,25 @@ LOADER_NAME := $(basename $(notdir $(LOADER)))
LOADER_DATA :=
TARGET_DIR :=
+UART_BASE_3329 := 0xb0000100
+UART_BASE_3368 := 0xfff8c100
+UART_BASE_3380 := 0xb4e00200
+UART_BASE_3383 := 0xb4e00500
+UART_BASE_3384 := 0xb4e00500
+UART_BASE_6318 := 0xb0000100
+UART_BASE_6328 := 0xb0000100
+UART_BASE_6338 := 0xfffe0300
+UART_BASE_6345 := 0xfffe0300
+UART_BASE_6348 := 0xfffe0300
+UART_BASE_6358 := 0xfffe0100
+UART_BASE_6362 := 0xb0000100
+UART_BASE_6368 := 0xb0000100
+UART_BASE_63268 := 0xb0000180
+UART_BASE_6816 := 0xb0000100
+UART_BASE_6818 := 0xb0000100
+UART_BASE_6828 := 0xb0000180
+UART_BASE := $(if $(UART_BASE_$(CHIP_ID)),$(UART_BASE_$(CHIP_ID)),0)
+
ifeq ($(TARGET_DIR),)
TARGET_DIR := $(KDIR)
endif
@@ -35,6 +56,7 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
$(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE="$(TARGET_CROSS)" \
LZMA_TEXT_START=$(LZMA_TEXT_START) \
LOADER_DATA=$(LOADER_DATA) \
+ UART_BASE=$(UART_BASE) \
clean all
loader.elf: $(PKG_BUILD_DIR)/loader.elf
diff --git a/target/linux/bcm63xx/image/lzma-loader/src/Makefile b/target/linux/bcm63xx/image/lzma-loader/src/Makefile
index 167bf6455a..9115f75af3 100644
--- a/target/linux/bcm63xx/image/lzma-loader/src/Makefile
+++ b/target/linux/bcm63xx/image/lzma-loader/src/Makefile
@@ -2,6 +2,8 @@
# Makefile for the LZMA compressed kernel loader for
# Atheros AR7XXX/AR9XXX based boards
#
+# Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
+# Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>
# Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
#
# Some parts of this file was based on the OpenWrt specific lzma-loader
@@ -34,6 +36,7 @@ CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
-mabi=32 -march=mips32 \
-Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap
CFLAGS += -D_LZMA_PROB32
+CFLAGS += -DUART_BASE=$(UART_BASE)
ASFLAGS = $(CFLAGS) -D__ASSEMBLY__
@@ -82,6 +85,3 @@ mrproper: clean
clean:
rm -f loader *.elf *.bin *.o
-
-
-
diff --git a/target/linux/bcm63xx/image/lzma-loader/src/board.c b/target/linux/bcm63xx/image/lzma-loader/src/board.c
index 6a1b132254..843710baee 100644
--- a/target/linux/bcm63xx/image/lzma-loader/src/board.c
+++ b/target/linux/bcm63xx/image/lzma-loader/src/board.c
@@ -1,6 +1,7 @@
/*
* BCM63XX specific implementation parts
*
+ * Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
@@ -10,7 +11,6 @@
#include <stddef.h>
#include "config.h"
-#include "cp0regdef.h"
#define READREG(r) *(volatile unsigned int *)(r)
#define WRITEREG(r,v) *(volatile unsigned int *)(r) = v
@@ -18,14 +18,12 @@
#define UART_IR_REG 0x10
#define UART_FIFO_REG 0x14
-unsigned long uart_base;
-
static void wait_xfered(void)
{
unsigned int val;
do {
- val = READREG(uart_base + UART_IR_REG);
+ val = READREG(UART_BASE + UART_IR_REG);
if (val & (1 << 5))
break;
} while (1);
@@ -33,79 +31,10 @@ static void wait_xfered(void)
void board_putc(int ch)
{
- if (!uart_base)
+ if (!UART_BASE)
return;
wait_xfered();
- WRITEREG(uart_base + UART_FIFO_REG, ch);
+ WRITEREG(UART_BASE + UART_FIFO_REG, ch);
wait_xfered();
}
-
-#define PRID_IMP_BMIPS32_REV4 0x4000
-#define PRID_IMP_BMIPS32_REV8 0x8000
-#define PRID_IMP_BMIPS3300 0x9000
-#define PRID_IMP_BMIPS3300_ALT 0x9100
-#define PRID_IMP_BMIPS3300_BUG 0x0000
-#define PRID_IMP_BMIPS43XX 0xa000
-
-void board_init(void)
-{
- unsigned long prid, chipid, chipid_reg;
-
- prid = read_32bit_c0_register($15, 0);
-
- switch (prid & 0xff00) {
- case PRID_IMP_BMIPS32_REV4:
- case PRID_IMP_BMIPS32_REV8:
- case PRID_IMP_BMIPS3300_ALT:
- case PRID_IMP_BMIPS3300_BUG:
- chipid_reg = 0xfffe0000;
- break;
- case PRID_IMP_BMIPS3300:
- if ((prid & 0xff) >= 0x33)
- chipid_reg = 0xb0000000;
- else
- chipid_reg = 0xfffe0000;
- break;
- case PRID_IMP_BMIPS43XX:
- if ((prid & 0xff) == 0x04)
- chipid_reg = 0xfff8c000;
- else if ((prid & 0xff) == 0x70)
- return; /* FIXME: 0002a070 can be 6362 and 3380 */
- else if ((prid & 0xff) >= 0x30)
- chipid_reg = 0xb0000000;
- else
- chipid_reg = 0xfffe0000;
- break;
- default:
- return;
- }
-
- chipid = READREG(chipid_reg);
-
- switch (chipid >> 16) {
- case 0x3368:
- case 0x6318:
- case 0x6328:
- case 0x6358:
- case 0x6362:
- case 0x6368:
- case 0x6369:
- uart_base = chipid_reg + 0x100;
- break;
- case 0x6316:
- case 0x6326:
- uart_base = chipid_reg + 0x180;
- break;
- case 0x3380:
- uart_base = chipid_reg + 0x200;
- break;
- case 0x6338:
- case 0x6345:
- case 0x6348:
- uart_base = chipid_reg + 0x300;
- break;
- default:
- return;
- }
-}
diff --git a/target/linux/bcm63xx/image/lzma-loader/src/loader.c b/target/linux/bcm63xx/image/lzma-loader/src/loader.c
index 0848ce601f..37f42e5cef 100644
--- a/target/linux/bcm63xx/image/lzma-loader/src/loader.c
+++ b/target/linux/bcm63xx/image/lzma-loader/src/loader.c
@@ -44,8 +44,6 @@
extern unsigned char workspace[];
-extern void board_init(void);
-
static CLzmaDecoderState lzma_state;
static unsigned char *lzma_data;
static unsigned long lzma_datasize;
@@ -135,11 +133,10 @@ void loader_main(unsigned long reg_a0, unsigned long reg_a1,
unsigned long);
int res;
- board_init();
-
printf("\n\nOpenWrt kernel loader for BCM63XX\n");
printf("Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>\n");
printf("Copyright (C) 2014 Jonas Gorski <jogo@openwrt.org>\n");
+ printf("Copyright (C) 2020 Alvaro Fernandez Rojas <noltari@gmail.com>\n");
lzma_init_data();