From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Havard Skinnemoen <hskinnemoen@google.com>, peter.maydell@linaro.org
Cc: kfting@nuvoton.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Avi.Fishman@nuvoton.com
Subject: Re: [PATCH v8 12/14] hw/arm/npcm7xx: add board setup stub for CPU and UART clocks
Date: Fri, 4 Sep 2020 11:34:27 +0200 [thread overview]
Message-ID: <65832bc3-6f22-bc11-d559-02b0810d73ee@amsat.org> (raw)
In-Reply-To: <20200825001711.1340443-13-hskinnemoen@google.com>
On 8/25/20 2:17 AM, Havard Skinnemoen via wrote:
> When booting directly into a kernel, bypassing the boot loader, the CPU and
> UART clocks are not set up correctly. This makes the system appear very
> slow, and causes the initrd boot test to fail when optimization is off.
>
> The UART clock must run at 24 MHz. The default 25 MHz reference clock
> cannot achieve this, so switch to PLL2/2 @ 480 MHz, which works
> perfectly with the default /20 divider.
>
> The CPU clock should run at 800 MHz, so switch it to PLL1/2. PLL1 runs
> at 800 MHz by default, so we need to double the feedback divider as well
> to make it run at 1600 MHz (so PLL1/2 runs at 800 MHz).
>
> We don't bother checking for PLL lock because we know our emulated PLLs
> lock instantly.
>
> Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
> ---
> include/hw/arm/npcm7xx.h | 1 +
> hw/arm/npcm7xx.c | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
> index 78d0d78c52..13106af215 100644
> --- a/include/hw/arm/npcm7xx.h
> +++ b/include/hw/arm/npcm7xx.h
> @@ -37,6 +37,7 @@
> #define NPCM7XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */
> #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */
> #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */
> +#define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */
>
> typedef struct NPCM7xxMachine {
> MachineState parent;
> diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
> index 7884b2b03d..037f3a26f2 100644
> --- a/hw/arm/npcm7xx.c
> +++ b/hw/arm/npcm7xx.c
> @@ -55,6 +55,13 @@
> #define NPCM7XX_ROM_BA (0xffff0000)
> #define NPCM7XX_ROM_SZ (64 * KiB)
>
> +/* Clock configuration values to be fixed up when bypassing bootloader */
> +
> +/* Run PLL1 at 1600 MHz */
> +#define NPCM7XX_PLLCON1_FIXUP_VAL (0x00402101)
> +/* Run the CPU from PLL1 and UART from PLL2 */
> +#define NPCM7XX_CLKSEL_FIXUP_VAL (0x004aaba9)
> +
> /*
> * Interrupt lines going into the GIC. This does not include internal Cortex-A9
> * interrupts.
> @@ -132,6 +139,29 @@ static const struct {
> },
> };
>
> +static void npcm7xx_write_board_setup(ARMCPU *cpu,
> + const struct arm_boot_info *info)
> +{
> + uint32_t board_setup[] = {
> + 0xe59f0010, /* ldr r0, clk_base_addr */
> + 0xe59f1010, /* ldr r1, pllcon1_value */
> + 0xe5801010, /* str r1, [r0, #16] */
> + 0xe59f100c, /* ldr r1, clksel_value */
> + 0xe5801004, /* str r1, [r0, #4] */
> + 0xe12fff1e, /* bx lr */
> + NPCM7XX_CLK_BA,
> + NPCM7XX_PLLCON1_FIXUP_VAL,
> + NPCM7XX_CLKSEL_FIXUP_VAL,
> + };
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(board_setup); i++) {
> + board_setup[i] = tswap32(board_setup[i]);
> + }
> + rom_add_blob_fixed("board-setup", board_setup, sizeof(board_setup),
> + info->board_setup_addr);
> +}
> +
> static void npcm7xx_write_secondary_boot(ARMCPU *cpu,
> const struct arm_boot_info *info)
> {
> @@ -170,6 +200,8 @@ static struct arm_boot_info npcm7xx_binfo = {
> .gic_cpu_if_addr = NPCM7XX_GIC_CPU_IF_ADDR,
> .write_secondary_boot = npcm7xx_write_secondary_boot,
> .board_id = -1,
> + .board_setup_addr = NPCM7XX_BOARD_SETUP_ADDR,
> + .write_board_setup = npcm7xx_write_board_setup,
> };
>
> void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc)
>
Very very clean :) :)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
next prev parent reply other threads:[~2020-09-04 9:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 0:16 [PATCH v8 00/14] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines Havard Skinnemoen via
2020-08-25 0:16 ` [PATCH v8 01/14] hw/misc: Add NPCM7xx System Global Control Registers device model Havard Skinnemoen via
2020-08-25 0:16 ` [PATCH v8 02/14] hw/misc: Add NPCM7xx Clock Controller " Havard Skinnemoen via
2020-09-04 9:32 ` Philippe Mathieu-Daudé
2020-09-04 22:02 ` Havard Skinnemoen
2020-09-04 22:38 ` Havard Skinnemoen
2020-09-07 13:40 ` Philippe Mathieu-Daudé
2020-09-07 17:58 ` Havard Skinnemoen
2020-08-25 0:17 ` [PATCH v8 03/14] hw/timer: Add NPCM7xx Timer " Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 04/14] hw/arm: Add NPCM730 and NPCM750 SoC models Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 05/14] hw/arm: Add two NPCM7xx-based machines Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 06/14] roms: Add virtual Boot ROM for NPCM7xx SoCs Havard Skinnemoen via
2020-09-04 9:24 ` Philippe Mathieu-Daudé
2020-08-25 0:17 ` [PATCH v8 07/14] hw/arm: Load -bios image as a boot ROM for npcm7xx Havard Skinnemoen via
2020-09-03 18:59 ` Philippe Mathieu-Daudé
2020-09-10 23:52 ` Havard Skinnemoen
2020-08-25 0:17 ` [PATCH v8 08/14] hw/nvram: NPCM7xx OTP device model Havard Skinnemoen via
2020-09-07 19:47 ` Alexander Bulekov
2020-09-07 19:57 ` Alexander Bulekov
2020-09-07 21:52 ` Havard Skinnemoen
2020-08-25 0:17 ` [PATCH v8 09/14] hw/mem: Stubbed out NPCM7xx Memory Controller model Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 10/14] hw/ssi: NPCM7xx Flash Interface Unit device model Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 11/14] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj Havard Skinnemoen via
2020-08-25 0:17 ` [PATCH v8 12/14] hw/arm/npcm7xx: add board setup stub for CPU and UART clocks Havard Skinnemoen via
2020-09-04 9:34 ` Philippe Mathieu-Daudé [this message]
2020-08-25 0:17 ` [PATCH v8 13/14] docs/system: Add Nuvoton machine documentation Havard Skinnemoen via
2020-09-03 19:11 ` Philippe Mathieu-Daudé
2020-08-25 0:17 ` [PATCH v8 14/14] tests/acceptance: console boot tests for quanta-gsj Havard Skinnemoen via
2020-09-03 18:20 ` [PATCH v8 00/14] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines Philippe Mathieu-Daudé
2020-09-08 15:02 ` Alexander Bulekov
2020-09-08 15:52 ` Philippe Mathieu-Daudé
2020-09-08 16:58 ` Philippe Mathieu-Daudé
2020-09-08 19:52 ` Havard Skinnemoen
2020-09-09 1:32 ` Havard Skinnemoen
2020-09-11 0:03 ` Havard Skinnemoen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65832bc3-6f22-bc11-d559-02b0810d73ee@amsat.org \
--to=f4bug@amsat.org \
--cc=Avi.Fishman@nuvoton.com \
--cc=hskinnemoen@google.com \
--cc=kfting@nuvoton.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).