From patchwork Fri Aug 23 05:10:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11110611 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69B6C1709 for ; Fri, 23 Aug 2019 05:42:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F067821019 for ; Fri, 23 Aug 2019 05:42:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qr6AQSdr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F067821019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i12LV-0003um-36 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Aug 2019 01:42:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i11rR-0004J9-2g for qemu-devel@nongnu.org; Fri, 23 Aug 2019 01:11:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i11rP-0002hc-OG for qemu-devel@nongnu.org; Fri, 23 Aug 2019 01:11:40 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i11rP-0002hR-JI; Fri, 23 Aug 2019 01:11:39 -0400 Received: by mail-pl1-x641.google.com with SMTP id y8so4875553plr.12; Thu, 22 Aug 2019 22:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=atN1ZHYpk1IEAb15ukm54tI9j5l+MwwYtqox8t/Xbv0=; b=Qr6AQSdr454nSkkVcu6dh8LxCcH/vw3uf/SzIaknM7LJNRKJttnwzteGJgr+2axdiA 25TYGr853aY+H1z1HlS0CTXrb7OSF5joXO/rkx8c3R6QC5LhJdTO7dpPGCmhNWE9/FSa i0p9xWScfTGa2x2Aqb7kFqjK5I1I5IDigwvR/x07iIunNrftKKSDhh7l3yg8A1lrEIEH 46UbJcL5cqoySusPnLMpT3Xfvrj3P3c7P6FIhxowjFBbrhKYgBnaisngOLn5sXtQKArA pligtCkywFyEYoigr4tj6AGU1Wdj4ko9gBnYdw9VslhgaXP0j4Xa8QVv1EKGdyGy86mE YBLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=atN1ZHYpk1IEAb15ukm54tI9j5l+MwwYtqox8t/Xbv0=; b=fE+P+vur89Ind4QBMIL2U+K6nbJhTE1NGuOd52MD1JjOcU5atUgutN4KkMRzO+SBMw ITAVe3uVxVN9ta5J1Y/u3CAuF2sVcS6A7VfT43b/mKWZJVamG2L0BOq0ObfikzVAI0+2 sW71pNFc9WZV2ARYpjYUE/yFOxI2u63fGJSEMW04bVSPFbsgAr14o9b5/F450IuysnLX COT9O69O4lniJvOJuPHdp4gqbfB3/ovCACjGaJswPxcKp+ET6ZXh+Tp4ucoOB81dwhUv Hmazp5i1Bc0aTNoT3MbhORGZSugqJgeoPLwRnwSfRPEBfYF2NrsLkiT/sFnLHed09EO8 oRnA== X-Gm-Message-State: APjAAAWoKRHpxFpvBClzR6eQ4n4IE6Gng91BqyiKfxsETaCpbAhxI68Z ydY6Padr+CeRoVfGK36opWY= X-Google-Smtp-Source: APXvYqxUxjlJqwwDh/7Aa1QIEW+zx9WUl/BZNUIat6x1G2pr1koBiEP3UGtYBAdpjpQrBKu+fGfVFA== X-Received: by 2002:a17:902:bb95:: with SMTP id m21mr2623998pls.26.1566537098914; Thu, 22 Aug 2019 22:11:38 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id v189sm1122527pfv.176.2019.08.22.22.11.37 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Aug 2019 22:11:38 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Thu, 22 Aug 2019 22:10:59 -0700 Message-Id: <1566537069-22741-21-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566537069-22741-1-git-send-email-bmeng.cn@gmail.com> References: <1566537069-22741-1-git-send-email-bmeng.cn@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v5 20/30] riscv: sifive_u: Generate hfclk and rtcclk nodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" To keep in sync with Linux kernel device tree, generate hfclk and rtcclk nodes in the device tree, to be referenced by PRCI node. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 23 +++++++++++++++++++++++ include/hw/riscv/sifive_u.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 284f7a5..08db741 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -80,6 +80,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, char ethclk_names[] = "pclk\0hclk\0tx_clk"; uint32_t plic_phandle, ethclk_phandle, phandle = 1; uint32_t uartclk_phandle; + uint32_t hfclk_phandle, rtcclk_phandle; fdt = s->fdt = create_device_tree(&s->fdt_size); if (!fdt) { @@ -98,6 +99,28 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2); qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2); + hfclk_phandle = phandle++; + nodename = g_strdup_printf("/hfclk"); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", hfclk_phandle); + qemu_fdt_setprop_string(fdt, nodename, "clock-output-names", "hfclk"); + qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", + SIFIVE_U_HFCLK_FREQ); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "fixed-clock"); + qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0); + g_free(nodename); + + rtcclk_phandle = phandle++; + nodename = g_strdup_printf("/rtcclk"); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", rtcclk_phandle); + qemu_fdt_setprop_string(fdt, nodename, "clock-output-names", "rtcclk"); + qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", + SIFIVE_U_RTCCLK_FREQ); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "fixed-clock"); + qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0); + g_free(nodename); + nodename = g_strdup_printf("/memory@%lx", (long)memmap[SIFIVE_U_DRAM].base); qemu_fdt_add_subnode(fdt, nodename); diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 7a1a4f3..debbf28 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -68,6 +68,8 @@ enum { enum { SIFIVE_U_CLOCK_FREQ = 1000000000, + SIFIVE_U_HFCLK_FREQ = 33333333, + SIFIVE_U_RTCCLK_FREQ = 1000000, SIFIVE_U_GEM_CLOCK_FREQ = 125000000 };