Index: sys/arm/allwinner/aw_machdep.c =================================================================== --- sys/arm/allwinner/aw_machdep.c +++ sys/arm/allwinner/aw_machdep.c @@ -304,3 +304,38 @@ { return (soc_family); } + +/* + * To use early printf on 64 bits Allwinner SoC, add to kernel config + * options SOCDEV_PA=0x0 + * options SOCDEV_VA=0x40000000 + * options EARLY_PRINTF + * + * To use early printf on 32 bits Allwinner SoC, add to kernel config + * options SOCDEV_PA=0x01C00000 + * options SOCDEV_VA=0x10000000 + * options EARLY_PRINTF + * +*/ +#if defined(EARLY_PRINTF) && defined(SOCDEV_PA) && defined(SOCDEV_VA) +static void +uart_snps_early_putc(int c) +{ + volatile uint32_t *stat; + volatile uint32_t *tx; + +#if defined(__aarch64__) + stat = (uint32_t *) (SOCDEV_VA + 0x1C2807C); + tx = (uint32_t *) (SOCDEV_VA + 0x1C28000); +#endif +#if defined(__arm__) + stat = (uint32_t *) (SOCDEV_VA + 0x2807C); + tx = (uint32_t *) (SOCDEV_VA + 0x28000); +#endif + + while ((*stat & (1 << 2)) == 0) + continue; + *tx = c; +} +early_putc_t *early_putc = uart_snps_early_putc; +#endif /* EARLY_PRINTF & SOCDEV_PA & SOCDEV_VA */ Index: sys/dev/uart/uart_dev_snps.c =================================================================== --- sys/dev/uart/uart_dev_snps.c +++ sys/dev/uart/uart_dev_snps.c @@ -61,44 +61,6 @@ #endif }; -/* - * To use early printf on 64 bits Allwinner SoC, add to kernel config - * options SOCDEV_PA=0x0 - * options SOCDEV_VA=0x40000000 - * options EARLY_PRINTF - * - * To use early printf on 32 bits Allwinner SoC, add to kernel config - * options SOCDEV_PA=0x01C00000 - * options SOCDEV_VA=0x10000000 - * options EARLY_PRINTF - * - * remove the if 0 -*/ -#if 0 -#ifdef EARLY_PRINTF -static void -uart_snps_early_putc(int c) -{ - volatile uint32_t *stat; - volatile uint32_t *tx; - -#ifdef ALLWINNER_64 - stat = (uint32_t *) (SOCDEV_VA + 0x1C2807C); - tx = (uint32_t *) (SOCDEV_VA + 0x1C28000); -#endif -#ifdef ALLWINNER_32 - stat = (uint32_t *) (SOCDEV_VA + 0x2807C); - tx = (uint32_t *) (SOCDEV_VA + 0x28000); -#endif - - while ((*stat & (1 << 2)) == 0) - continue; - *tx = c; -} -early_putc_t *early_putc = uart_snps_early_putc; -#endif /* EARLY_PRINTF */ -#endif - static kobj_method_t snps_methods[] = { KOBJMETHOD(uart_probe, ns8250_bus_probe), KOBJMETHOD(uart_attach, ns8250_bus_attach),