9dca455683
UART5 is typically used as the default debug UART on the AST2600, but UART1 is also designed to be a debug UART. All the AST2600 UART's have semi-configurable clock rates through registers in the System Control Unit (SCU), but only UART5 works out of the box with zero-initialized values. The rest of the UART's expect a few of the registers to be initialized to non-zero values, or else the clock rate calculation will yield zero or undefined (due to a divide-by-zero). For reference, the U-Boot clock rate driver here shows the calculation: https://github.com/facebook/openbmc-uboot/blob/15f7e0dc01d8/drivers/clk/aspeed/clk_ast2600.c#L357 To summarize, UART5 allows selection from 4 rates: 24 MHz, 192 MHz, 24 / 13 MHz, and 192 / 13 MHz. The other UART's allow selecting either the "low" rate (UARTCLK) or the "high" rate (HUARTCLK). UARTCLK and HUARTCLK are configurable themselves: UARTCLK = UXCLK * R / (N * 2) HUARTCLK = HUXCLK * HR / (HN * 2) UXCLK and HUXCLK are also configurable, and depend on the APLL and/or HPLL clock rates, which also derive from complicated calculations. Long story short, there's lots of multiplication and division from configurable registers, and most of these registers are zero-initialized in QEMU, which at best is unexpected and at worst causes this clock rate driver to hang from divide-by-zero's. This can also be difficult to diagnose, because it may cause U-Boot to hang before serial console initialization completes, requiring intervention from gdb. This change just initializes all of these registers with default values from the datasheet. To test this, I used Facebook's AST2600 OpenBMC image for "fuji", with the following diff applied (because fuji uses UART1 for console output, not UART5). @@ -323,8 +323,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) } /* UART - attach an 8250 to the IO space as our UART5 */ - serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2, - aspeed_soc_get_irq(s, ASPEED_DEV_UART5), + serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART1], 2, + aspeed_soc_get_irq(s, ASPEED_DEV_UART1), 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); /* I2C */ Without these clock rate registers being initialized, U-Boot hangs in the clock rate driver from a divide-by-zero, because the UART1 clock rate register reads return zero, and there's no console output. After initializing them with default values, fuji boots successfully. Signed-off-by: Peter Delevoryas <pdel@fb.com> Reviewed-by: Joel Stanley <joel@jms.id.au> [ clg: Removed _PARAM suffix ] Message-Id: <20210906134023.3711031-2-pdel@fb.com> Signed-off-by: Cédric Le Goater <clg@kaod.org> |
||
---|---|---|
.. | ||
macio | ||
a9scu.c | ||
allwinner-cpucfg.c | ||
allwinner-h3-ccu.c | ||
allwinner-h3-dramc.c | ||
allwinner-h3-sysctrl.c | ||
allwinner-sid.c | ||
applesmc.c | ||
arm11scu.c | ||
arm_integrator_debug.c | ||
arm_l2x0.c | ||
arm_sysctl.c | ||
armsse-cpu-pwrctrl.c | ||
armsse-cpuid.c | ||
armsse-mhu.c | ||
armv7m_ras.c | ||
aspeed_hace.c | ||
aspeed_lpc.c | ||
aspeed_scu.c | ||
aspeed_sdmc.c | ||
aspeed_xdma.c | ||
auxbus.c | ||
avr_power.c | ||
bcm2835_cprman.c | ||
bcm2835_mbox.c | ||
bcm2835_mphi.c | ||
bcm2835_powermgt.c | ||
bcm2835_property.c | ||
bcm2835_rng.c | ||
bcm2835_thermal.c | ||
cbus.c | ||
debugexit.c | ||
eccmemctl.c | ||
edu.c | ||
empty_slot.c | ||
exynos4210_clk.c | ||
exynos4210_pmu.c | ||
exynos4210_rng.c | ||
grlib_ahb_apb_pnp.c | ||
imx6_ccm.c | ||
imx6_src.c | ||
imx6ul_ccm.c | ||
imx7_ccm.c | ||
imx7_gpr.c | ||
imx7_snvs.c | ||
imx25_ccm.c | ||
imx31_ccm.c | ||
imx_ccm.c | ||
imx_rngc.c | ||
iotkit-secctl.c | ||
iotkit-sysctl.c | ||
iotkit-sysinfo.c | ||
ivshmem.c | ||
Kconfig | ||
led.c | ||
mac_via.c | ||
mchp_pfsoc_dmc.c | ||
mchp_pfsoc_ioscb.c | ||
mchp_pfsoc_sysreg.c | ||
meson.build | ||
mips_cmgcr.c | ||
mips_cpc.c | ||
mips_itu.c | ||
mos6522.c | ||
mps2-fpgaio.c | ||
mps2-scc.c | ||
msf2-sysreg.c | ||
mst_fpga.c | ||
npcm7xx_clk.c | ||
npcm7xx_gcr.c | ||
npcm7xx_mft.c | ||
npcm7xx_pwm.c | ||
npcm7xx_rng.c | ||
nrf51_rng.c | ||
omap_clk.c | ||
omap_gpmc.c | ||
omap_l4.c | ||
omap_sdrc.c | ||
omap_tap.c | ||
pc-testdev.c | ||
pca9552.c | ||
pci-testdev.c | ||
pvpanic-isa.c | ||
pvpanic-pci.c | ||
pvpanic.c | ||
sbsa_ec.c | ||
sga.c | ||
sifive_e_prci.c | ||
sifive_test.c | ||
sifive_u_otp.c | ||
sifive_u_prci.c | ||
slavio_misc.c | ||
stm32f2xx_syscfg.c | ||
stm32f4xx_exti.c | ||
stm32f4xx_syscfg.c | ||
trace-events | ||
trace.h | ||
tz-mpc.c | ||
tz-msc.c | ||
tz-ppc.c | ||
unimp.c | ||
virt_ctrl.c | ||
vmcoreinfo.c | ||
xlnx-versal-xramc.c | ||
zynq_slcr.c |