From patchwork Tue Jan 22 22:12:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 1029569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TrCiZkYk"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43kjk04Vtkz9s3l for ; Wed, 23 Jan 2019 09:28:24 +1100 (AEDT) Received: from localhost ([127.0.0.1]:51502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4Ws-0003mu-H5 for incoming@patchwork.ozlabs.org; Tue, 22 Jan 2019 17:28:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4W5-0003Cu-Du for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:27:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm4IK-0006jk-GM for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:21 -0500 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:42114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gm4IK-0006j0-8u for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:20 -0500 Received: by mail-lj1-x244.google.com with SMTP id l15-v6so99574lja.9 for ; Tue, 22 Jan 2019 14:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fKGAMLiGYpzYbr0rT9/NDrMmuQDLMVW75r0dxP9+VxQ=; b=TrCiZkYklJ9UeQlndWaOyI6xlcPQuVaro0NACxndA5iTrKSEfiszN2e6c42gFdcXrN /Te77pM/xQlO0uEjzKllMmmZRbJ8P5Ep7cN46P7FbftMqfyw+fLaoXakY1X30iODvqvB fwtOBDQZcc8scmmQtwDC8zd8wA4LbPaKowXIziZEqAieY/29okXwzqvNyBUZKRAuh48w f1D5c8AUqkdloit2FkGHgE3xNT39jtWOzlJx6iMcLneBREtRMOlWYRapNEMVuPn5o8FF z7c7CjmYbi6POxUiXvgGGsXV26ch3NWAbDFFGhykU4Q7x2QIj7glm6bQf7vBcnbyZkMW 0MbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fKGAMLiGYpzYbr0rT9/NDrMmuQDLMVW75r0dxP9+VxQ=; b=cKgCDMh/r4sJuY3PNibzRCBGPGhrfPW0eo9fO2AW7XhF3pFc2gSHdWWiKtSfX9G9f0 T8byAU98l4jb0iVm2S+/Y+26cBXMCm4nhqgh5yzbKtNoT3k8Si6akKSRbmgyuKE8WzMI AFpsktCKAPgW/FjObxHRXeqnpnLjfeJxH77+SwxdLm0VUbLguapSN+ADnqW6FfXrF2Ub 8CCBPUpmOLNfM4NjUW0MD8fKpmqCEY8s/RdfDiO9hduAHI55HxCN5vWLNkw19PocrAsb DrtZYbmABD/tJl9B8GAPvc0rq5XQTVUdMR0sJk0cHcHcJ699BzGbRxUL6kI/qKvrYXnu f7wg== X-Gm-Message-State: AJcUukcfFQL91H9Egnswc4geiloToRWTPzabRbpKxR4qXq/xmvhuXrfw p6ZnmPoUV6zx2tKetYWP01gnNP7opqo= X-Google-Smtp-Source: ALg8bN6vWJ3+b3WtUKj5ZewlGPLRKeqLYNUPlc6Z8MDQLYSdZymn+rqebSTCXibPQSiGfVzI5xBpcg== X-Received: by 2002:a2e:b04f:: with SMTP id d15-v6mr23525710ljl.3.1548195198362; Tue, 22 Jan 2019 14:13:18 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id i13-v6sm184404ljg.82.2019.01.22.14.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 14:13:17 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 14:12:56 -0800 Message-Id: <20190122221256.20883-3-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190122221256.20883-1-jcmvbkbc@gmail.com> References: <20190122221256.20883-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::244 Subject: [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" XTFPGA board FPGA peripheral exposes hard-coded 10MHz frequency regardless of the actual used core frequency. Expose actual core frequency instead. Signed-off-by: Max Filippov --- hw/xtensa/xtfpga.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index d3afdfc247a7..7379b3fff427 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -61,6 +61,7 @@ typedef struct XtfpgaBoardDesc { typedef struct XtfpgaFpgaState { MemoryRegion iomem; + uint32_t freq; uint32_t leds; uint32_t switches; } XtfpgaFpgaState; @@ -83,7 +84,7 @@ static uint64_t xtfpga_fpga_read(void *opaque, hwaddr addr, return 0x09272011; case 0x4: /*processor clock frequency, Hz*/ - return 10000000; + return s->freq; case 0x8: /*LEDs (off = 0, on = 1)*/ return s->leds; @@ -119,13 +120,14 @@ static const MemoryRegionOps xtfpga_fpga_ops = { }; static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space, - hwaddr base) + hwaddr base, uint32_t freq) { XtfpgaFpgaState *s = g_malloc(sizeof(XtfpgaFpgaState)); memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s, - "xtfpga.fpga", 0x10000); + "xtfpga.fpga", 0x10000); memory_region_add_subregion(address_space, base, &s->iomem); + s->freq = freq; xtfpga_fpga_reset(s); qemu_register_reset(xtfpga_fpga_reset, s); return s; @@ -231,6 +233,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) const char *dtb_filename = qemu_opt_get(machine_opts, "dtb"); const char *initrd_filename = qemu_opt_get(machine_opts, "initrd"); const unsigned system_io_size = 224 * MiB; + uint32_t freq = 10000000; int n; for (n = 0; n < smp_cpus; n++) { @@ -240,6 +243,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) cenv = &cpu->env; if (!env) { env = cenv; + freq = env->config->clock_freq_khz * 1000; } cenv->sregs[PRID] = n; @@ -277,7 +281,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) system_io, 0, system_io_size); memory_region_add_subregion(system_memory, board->io[1], io); } - xtfpga_fpga_init(system_io, 0x0d020000); + xtfpga_fpga_init(system_io, 0x0d020000, freq); if (nd_table[0].used) { xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, xtensa_get_extint(env, 1), nd_table);