Retire BCM53XX_CONSOLE_EARLY in favour of EARLYCONS

This commit is contained in:
skrll 2024-02-16 16:28:49 +00:00
parent 040169d509
commit 790f4cb583
5 changed files with 38 additions and 65 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bcm53xx_board.c,v 1.26 2024/02/16 15:11:17 skrll Exp $ */
/* $NetBSD: bcm53xx_board.c,v 1.27 2024/02/16 16:28:49 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.26 2024/02/16 15:11:17 skrll Exp $");
__KERNEL_RCSID(1, "$NetBSD: bcm53xx_board.c,v 1.27 2024/02/16 16:28:49 skrll Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -141,56 +141,6 @@ struct arm32_bus_dma_tag bcm53xx_bounce_dma_tag = {
};
#endif
#ifdef BCM53XX_CONSOLE_EARLY
#include <dev/ic/ns16550reg.h>
#include <dev/ic/comreg.h>
#include <dev/cons.h>
static vaddr_t com_base;
static inline uint32_t
uart_read(bus_size_t o)
{
return *(volatile uint8_t *)(com_base + o);
}
static inline void
uart_write(bus_size_t o, uint32_t v)
{
*(volatile uint8_t *)(com_base + o) = v;
}
static int
bcm53xx_cngetc(dev_t dv)
{
if ((uart_read(com_lsr) & LSR_RXRDY) == 0)
return -1;
return uart_read(com_data) & 0xff;
}
static void
bcm53xx_cnputc(dev_t dv, int c)
{
int timo = 150000;
while ((uart_read(com_lsr) & LSR_TXRDY) == 0 && --timo > 0)
;
uart_write(com_data, c);
timo = 150000;
while ((uart_read(com_lsr) & LSR_TSRE) == 0 && --timo > 0)
;
}
static struct consdev bcm53xx_earlycons = {
.cn_putc = bcm53xx_cnputc,
.cn_getc = bcm53xx_cngetc,
.cn_pollc = nullcnpollc,
};
#endif /* BCM53XX_CONSOLE_EARLY */
psize_t
bcm53xx_memprobe(void)
{
@ -517,11 +467,6 @@ bcm53xx_bootstrap(vaddr_t iobase)
struct bcm53xx_chip_state bcs;
int error;
#ifdef BCM53XX_CONSOLE_EARLY
com_base = iobase + CCA_UART0_BASE;
cn_tab = &bcm53xx_earlycons;
#endif
bcm53xx_ioreg_bsh = (bus_space_handle_t) iobase;
error = bus_space_map(bcm53xx_ioreg_bst, BCM53XX_IOREG_PBASE,
BCM53XX_IOREG_SIZE, 0, &bcm53xx_ioreg_bsh);

View File

@ -1,4 +1,4 @@
# $NetBSD: files.bcm53xx,v 1.5 2018/09/21 12:04:06 skrll Exp $
# $NetBSD: files.bcm53xx,v 1.6 2024/02/16 16:28:49 skrll Exp $
#
# Configuration info for Broadcom BCM5301X ARM Peripherals
#
@ -15,7 +15,6 @@ file arch/arm/broadcom/bcm53xx_board.c
file arch/arm/broadcom/bcmgen_space.c
defparam opt_broadcom.h MEMSIZE
defflag opt_broadcom.h BCM53XX_CONSOLE_EARLY
defflag opt_broadcom.h BCMETH_COUNTERS
defflag opt_broadcom.h BCM563XX
defflag opt_broadcom.h BCM5301X

View File

@ -1,4 +1,4 @@
/* $NetBSD: bcm53xx_machdep.c,v 1.28 2023/04/21 15:04:47 skrll Exp $ */
/* $NetBSD: bcm53xx_machdep.c,v 1.29 2024/02/16 16:28:49 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
#define IDM_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bcm53xx_machdep.c,v 1.28 2023/04/21 15:04:47 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: bcm53xx_machdep.c,v 1.29 2024/02/16 16:28:49 skrll Exp $");
#include "opt_arm_debug.h"
#include "opt_console.h"
@ -114,6 +114,12 @@ int comcnmode = CONMODE | CLOCAL;
#include <sys/kgdb.h>
#endif
#ifdef VERBOSE_INIT_ARM
#define VPRINTF(...) printf(__VA_ARGS__)
#else
#define VPRINTF(...) __nothing
#endif
static void
earlyconsputc(dev_t dev, int c)
{
@ -273,9 +279,11 @@ initarm(void *arg)
cn_tab = &earlycons;
VPRINTF("devmap\n");
extern char ARM_BOOTSTRAP_LxPT[];
pmap_devmap_bootstrap((vaddr_t)ARM_BOOTSTRAP_LxPT, devmap);
VPRINTF("bootstrap\n");
bcm53xx_bootstrap(KERNEL_IO_IOREG_VBASE);
#ifdef MULTIPROCESSOR
@ -286,7 +294,9 @@ initarm(void *arg)
#endif
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
VPRINTF("consinit ");
consinit();
VPRINTF("ok\n");
bcm53xx_cpu_softc_init(curcpu());
bcm53xx_print_clocks();
@ -421,3 +431,20 @@ bcm53xx_system_reset(void)
bus_space_write_4(bcm53xx_ioreg_bst, bcm53xx_ioreg_bsh,
MISC_WATCHDOG, 1);
}
void __noasan
bcm53xx_platform_early_putchar(char c)
{
#ifdef CONSADDR
#define CONSADDR_VA (CONSADDR - BCM53XX_IOREG_PBASE + KERNEL_IO_IOREG_VBASE)
volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
(volatile uint32_t *)CONSADDR_VA :
(volatile uint32_t *)CONSADDR;
while ((le32toh(uartaddr[com_lsr]) & LSR_TXRDY) == 0)
;
uartaddr[com_data] = htole32(c);
#endif
}

View File

@ -1,5 +1,5 @@
#
# $NetBSD: BCM5301X,v 1.39 2022/08/07 02:52:25 simonb Exp $
# $NetBSD: BCM5301X,v 1.40 2024/02/16 16:28:50 skrll Exp $
#
# BCM5301X -- Broadcom BCM5301X Eval Board Kernel
#
@ -20,7 +20,6 @@ options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
#makeoptions DEFCOPTS="-O0"
options UVMHIST
#options UVMHIST_PRINT,A9WDT_PERIOD_DEFAULT=30
options BCM53XX_CONSOLE_EARLY
options BCMETH_COUNTERS
#options MULTIPROCESSOR
options CPU_CORTEX
@ -29,6 +28,8 @@ options BCM5301X
#options PMAPCOUNTERS
options BUSDMA_COUNTERS
makeoptions KERNEL_BASE_PHYS="0x80100000"
#options VERBOSE_INIT_ARM
options EARLYCONS=bcm53xx,CONSADDR=0x18000300
# Architecture options

View File

@ -1,5 +1,5 @@
#
# $NetBSD: BCM56340,v 1.22 2022/08/07 02:52:25 simonb Exp $
# $NetBSD: BCM56340,v 1.23 2024/02/16 16:28:50 skrll Exp $
#
# BCM5301X -- Broadcom BCM5301X Eval Board Kernel
#
@ -20,7 +20,6 @@ options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
#makeoptions DEFCOPTS="-O0"
options UVMHIST
#options UVMHIST_PRINT,A9WDT_PERIOD_DEFAULT=30
options BCM53XX_CONSOLE_EARLY
options BCMETH_COUNTERS
#options MULTIPROCESSOR
options CPU_CORTEX
@ -29,6 +28,8 @@ options BCM563XX
options PMAPCOUNTERS
options BUSDMA_COUNTERS
makeoptions KERNEL_BASE_PHYS="0x60100000"
#options VERBOSE_INIT_ARM
options EARLYCONS=bcm53xx,CONSADDR=0x18000300
# Architecture options