qemu-patch-raspberry4/hw
Peter Delevoryas 9dca455683 hw/arm/aspeed: Initialize AST2600 UART clock selection registers
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>
2021-09-20 08:50:59 +02:00
..
9pfs 9pfs: fix crash in v9fs_walk() 2021-09-02 13:26:22 +02:00
acpi hw/acpi: use existing references to pci device struct within functions 2021-09-04 17:34:05 -04:00
adc adc: Move the max111x driver to the adc directory 2021-06-17 07:10:32 -05:00
alpha hw/alpha: Provide a PCI-ISA bridge device node 2021-06-28 07:27:32 -07:00
arm arm/aspeed: Add DPS310 to Witherspoon and Rainier 2021-09-20 08:50:59 +02:00
audio hw/audio/adlib: Remove unused variable in adlib_callback 2021-07-26 07:07:07 -10:00
avr hw/avr/atmega.c: use the avr51 cpu for atmega1280 2021-05-13 19:11:42 +02:00
block pc,pci,virtio: bugfixes, improvements 2021-07-09 14:30:01 +01:00
char hw/char: cadence_uart: Log a guest error when device is unclocked or in reset 2021-09-13 16:07:21 +01:00
core Block patches: 2021-09-02 13:00:52 +01:00
cpu cpu/core: Fix "help" of CPU core device types 2021-04-09 16:05:16 -04:00
cris Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
display virtio-gpu: Add gl_flushed callback 2021-09-15 08:42:00 +02:00
dma hw/dma/xlnx-zdma Always expect 'dma' link property to be set 2021-08-26 17:01:59 +01:00
gpio hw: aspeed_gpio: Clarify GPIO controller name 2021-09-20 08:50:59 +02:00
hppa docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
hyperv vmbus: Don't make QOM property registration conditional 2021-07-06 18:04:38 -04:00
i2c i2c/smbus_eeprom: Add feature bit to SPD data 2021-07-29 10:59:49 +10:00
i386 intel_iommu: Fix typo in comments 2021-09-16 11:55:02 +02:00
ide hw/ide/Kconfig: Add missing dependency PCI -> IDE_QDEV 2021-07-20 15:30:42 +02:00
input ps2: migration support for command reply queue 2021-09-10 07:32:32 +02:00
intc hw/intc: GICv3 redistributor ITS processing 2021-09-13 21:01:08 +01:00
ipack Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
ipmi ipmi/sim: fix watchdog_expired data type error in IPMIBmcSim struct 2021-07-08 14:15:01 -05:00
isa q35: catch invalid cpu hotplug configuration 2021-09-04 09:07:45 -04:00
m68k mac_via: remove explicit viaN prefix from VIA IRQ gpios 2021-09-08 15:37:40 +02:00
mem docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
microblaze Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
mips arch_init.h: Don't include arch_init.h unnecessarily 2021-08-26 17:02:00 +01:00
misc hw/arm/aspeed: Initialize AST2600 UART clock selection registers 2021-09-20 08:50:59 +02:00
net vhost_net: do not assume nvqs is always 2 2021-09-04 17:34:05 -04:00
nios2 Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
nubus hw: Do not include hw/sysbus.h if it is not necessary 2021-05-02 17:24:50 +02:00
nvme hw/nvme: fix missing variable initializers 2021-08-09 12:52:16 +02:00
nvram fw_cfg: add etc/msr_feature_control 2021-09-13 13:56:26 +02:00
openrisc Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
pci hw/pci: Add pci_bus_range() to get PCI bus number range 2021-07-16 11:10:45 -04:00
pci-bridge hw/pcie-root-port: Fix hotplug for PCI devices requiring IO 2021-08-03 16:31:07 -04:00
pci-host hw/pci: remove all references to find_i440fx function 2021-09-04 17:34:05 -04:00
pcmcia hw/pcmcia: Do not register PCMCIA type if not required 2021-05-02 17:24:50 +02:00
ppc hw: Add compat machines for 6.2 2021-09-01 11:08:16 +01:00
rdma pvrdma: Fix the ring init error flow (CVE-2021-3608) 2021-07-04 22:47:51 +03:00
remote Remove superfluous ERRP_GUARD() 2021-08-26 17:15:28 +02:00
riscv hw/riscv/virt.c: Assemble plic_hart_config string with g_strjoinv() 2021-09-01 11:59:12 +10:00
rtc docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
rx hw/rx/rx-gdbsim: Do not accept invalid memory size 2021-05-03 10:07:41 +02:00
s390x s390x/cpumodel: Add more feature to gen16 default model 2021-09-07 13:36:43 +02:00
scsi vhost-scsi: Plug memory leak on migrate_add_blocker() failure 2021-08-26 17:15:28 +02:00
sd hw/sd/sdcard: Fix assertion accessing out-of-range addresses with CMD30 2021-08-03 19:34:51 +02:00
sensor hw/misc: Add Infineon DPS310 sensor model 2021-09-20 08:50:59 +02:00
sh4 Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
smbios hw/smbios: support for type 41 (onboard devices extended information) 2021-05-14 10:26:18 -04:00
sparc sun4m: fix setting CPU id when more than one CPU is present 2021-09-08 11:09:45 +01:00
sparc64 hw/block/fdc: Extract ISA floppy controllers to fdc-isa.c 2021-06-25 08:53:28 -04:00
ssi Trivial patches pull request 20210503 2021-05-05 13:52:00 +01:00
timer arm: Remove system_clock_scale global 2021-09-01 11:08:21 +01:00
tpm docs: fix references to docs/specs/tpm.rst 2021-06-02 06:51:09 +02:00
tricore hw/tricore: fix inclusion of tricore_testboard 2021-07-20 20:10:21 +02:00
usb hw/usb: Fix typo in comments and print 2021-09-01 06:37:13 +02:00
vfio hw/vfio: Fix typo in comments 2021-09-16 11:57:01 +02:00
virtio vhost-vdpa: correctly return err in vhost_vdpa_set_backend_cap() 2021-09-04 17:34:05 -04:00
watchdog watchdog: aspeed: Fix sequential control writes 2021-09-20 08:50:59 +02:00
xen docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
xenpv meson: convert hw/arch* 2020-08-21 06:30:33 -04:00
xtensa Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
Kconfig sensor: Move hardware sensors from misc to a sensor directory 2021-06-17 07:10:32 -05:00
meson.build sensor: Move hardware sensors from misc to a sensor directory 2021-06-17 07:10:32 -05:00