From patchwork Fri Dec 21 16:02:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10740665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B53C714E2 for ; Fri, 21 Dec 2018 16:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A645027C2D for ; Fri, 21 Dec 2018 16:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A722284A3; Fri, 21 Dec 2018 16:08:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46CB52845E for ; Fri, 21 Dec 2018 16:08:14 +0000 (UTC) Received: from localhost ([::1]:46429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNLR-0005bh-Do for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Dec 2018 11:08:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNHD-0001Tz-3a for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:03:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaNH5-00046I-My for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:03:45 -0500 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]:47021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gaNH5-00045l-20 for qemu-devel@nongnu.org; Fri, 21 Dec 2018 11:03:43 -0500 Received: by mail-qt1-x841.google.com with SMTP id y20so6153913qtm.13 for ; Fri, 21 Dec 2018 08:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=ZFe5OLfgkbGyNHW683WS7kU/EYaB5fvA+Mo6gZiihOw=; b=WA1hu0ATw5P872RVR53pSPFfN0wT3/cEIm4Mc76YwTq0J3mHbSoOzHTYFXrA94NCbS ql0R97LQa06CnjHZhkLFnETPuj1uSsg0DCIFH7GWmCKdCc0QJc7kC+r5A9FYfuo/eRwq 3+hqamQ0qbrbs8wilQQcz2Emh/GnZaO7KXlDjM6NCLpwAZ5lUjLbeNBQDrAXezYOQidP LZ5cGumCuO3PPw0UFYm/2fRuhnbYsPEWAlyK2jDsPPxs2nFcIBBt9wOvPb/ob0cTtIwW lIQzk1EzAtHbHk+3F7GJ6WxJv4GzrsJ9N4LwLZK/3Er0CABiWYBtaVXXykZATE2PbCM0 KGlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=ZFe5OLfgkbGyNHW683WS7kU/EYaB5fvA+Mo6gZiihOw=; b=FzEmLArpPEorpKeBi3Sx4Dgrf9NjfQnwD63DHShn6ltnoev6YXFb7WfbkynBAI9zJx ATdM7NFwq8K+deBvTr0O4Nlqw7S/8hoj6xQBwnBNAVr9gVN9i3Wvk9hgVxcXHgjmPld6 Ix6leNR/yPjltIi7OTEdcxehsxxr1nJFXjUANUBuVi1GiV9JL9zZOSxpCyaT+BCUOSeD 6S/odeUQWbMBxeSu6+JldrPj9cTvWZIqCmRL6K1yLmvY401CeWVnUffWJSkBTKld3rAa cvo6c3EYJvr86jpYW9uI+UlG0u+WMex307PHBG0oOiEGE8+LHrHdHNBCUcD6rz+XdILh cyPw== X-Gm-Message-State: AJcUukcQuEoo4GWO3he5t1nI7GF2ifH4lRNZN0ZM+uqYKL7MeTyv38cl dwSt6JrcsMEPsZU1rYRpQDENZNvB4k0= X-Google-Smtp-Source: ALg8bN6+XskU91DsmCTzLPLmxw5+yyCwMsHUWRS8+tbCbOMZjWlms19RdhAbjm/Tofar3qAVvmRPGg== X-Received: by 2002:a0c:b407:: with SMTP id u7mr2842358qve.179.1545408222095; Fri, 21 Dec 2018 08:03:42 -0800 (PST) Received: from localhost ([2601:182:c980:96c:8dd:4488:90b1:59d1]) by smtp.gmail.com with ESMTPSA id u16sm7447467qkg.14.2018.12.21.08.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Dec 2018 08:03:41 -0800 (PST) Date: Fri, 21 Dec 2018 08:02:58 -0800 Message-Id: <20181221160307.14819-6-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181221160307.14819-1-palmer@sifive.com> References: <20181221160307.14819-1-palmer@sifive.com> From: Palmer Dabbelt To: qemu-riscv@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::841 Subject: [Qemu-devel] [PULL 05/14] sifive_u: Add clock DT node for GEM ethernet 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: Anup Patel , Anup Patel , Alistair Francis , qemu-devel@nongnu.org, Palmer Dabbelt Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel The GEM ethernet on SiFive unleashed has fixed input clock of 125MHz as-per SiFive FU540 manual. This patch updates FDT generation for QEMU sifive_u machine to provide fixed-rate clock for GEM ethernet. Signed-off-by: Anup Patel Signed-off-by: Anup Patel Signed-off-by: Alistair Francis Reviewed-by: Palmer Dabbelt Signed-off-by: Palmer Dabbelt --- hw/riscv/sifive_u.c | 18 +++++++++++++++++- include/hw/riscv/sifive_u.h | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index ef07df244241..5c41ee5017e4 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -85,7 +85,8 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, int cpu; uint32_t *cells; char *nodename; - uint32_t plic_phandle; + char ethclk_names[] = "pclk\0hclk\0tx_clk"; + uint32_t plic_phandle, ethclk_phandle; fdt = s->fdt = create_device_tree(&s->fdt_size); if (!fdt) { @@ -197,6 +198,17 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, g_free(cells); g_free(nodename); + nodename = g_strdup_printf("/soc/ethclk"); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "fixed-clock"); + qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0); + qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", + SIFIVE_U_GEM_CLOCK_FREQ); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", 3); + qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", 3); + ethclk_phandle = qemu_fdt_get_phandle(fdt, nodename); + g_free(nodename); + nodename = g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); qemu_fdt_add_subnode(fdt, nodename); @@ -208,6 +220,10 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "phy-mode", "gmii"); qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle); qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ); + qemu_fdt_setprop_cells(fdt, nodename, "clocks", + ethclk_phandle, ethclk_phandle, ethclk_phandle); + qemu_fdt_setprop(fdt, nodename, "clocks-names", ethclk_names, + sizeof(ethclk_names)); qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", 1); qemu_fdt_setprop_cells(fdt, nodename, "#size-cells", 0); g_free(nodename); diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index e8b4d9ffa3fb..be13cc1304cc 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -63,7 +63,8 @@ enum { }; enum { - SIFIVE_U_CLOCK_FREQ = 1000000000 + SIFIVE_U_CLOCK_FREQ = 1000000000, + SIFIVE_U_GEM_CLOCK_FREQ = 125000000 }; #define SIFIVE_U_PLIC_HART_CONFIG "MS"