From patchwork Tue Aug 27 14:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117123 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 5E79214D5 for ; Tue, 27 Aug 2019 15:01:52 +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 333E620828 for ; Tue, 27 Aug 2019 15:01:52 +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="tC3Ikvo+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 333E620828 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]:52368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cyl-0005St-03 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:01:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46530) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvo-00039U-WE for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvn-0003K4-Ji for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:48 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:39112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvn-0003J4-Dd; Tue, 27 Aug 2019 10:58:47 -0400 Received: by mail-pf1-x444.google.com with SMTP id y200so6603619pfb.6; Tue, 27 Aug 2019 07:58:47 -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=mpyu+9zeR5NQecSQEyPIQD+gt/2HHvJQuLsDykgSNvo=; b=tC3Ikvo+TYfryayx3R86IT1tjNyF+wZn6nEAJ8mWcLu/MhDlUKpZh59w8QDM3+y3LZ x9BSS7n5oZIn4my20ccNywVK+5M0EKodD4CpKM3KyrRVw0Ngg1MPe6nYza9ine+Zpbpv IPnR8d5fiJrKSSfadoore5+vyvxyzIrtlS1uAEopT/cDcxx2ARRTZzyHe1b7zYfvqMfL FQffT7ldhTMyMbubPoSRscvT26t4Rc3zQt1Mr314DxOQd9oCeD3m3EvY06cNtEavkPas f1UQzw/UMLYbeFd3rmljGbl6zlqOWOvuDagqElWTYbxdA+Qh1mRiKLMbk4yj+K/dNoQA S/6A== 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=mpyu+9zeR5NQecSQEyPIQD+gt/2HHvJQuLsDykgSNvo=; b=GS005xnhDkRqmmopsM+L/SqzfaDy25nQh9sm4RLzZMuGRIlnGi06AXuk4P0OzR+jdM 9Pn3WUZcOJQTh+kJeSNKAVSd+HcuSUVFybseB3zGXW/V4kTW3/uyA3ULdZbqqmxpowgK aZkxvySfyRpq3SsMX6d/HNl3A7mIFElx1pzc25z8J2b0FrAynjhvw8GTk5aZnEvu5Omh 6dXBLLrUBcfE3Ee5PaAgTLMmipEmkmYCGHw5r4hIx0Y4dJfC8wzr9HPet0J920O2sEZ+ lfxoZwNf/VQO5+Z/UIANUo08Q005nn7eb2WcGtP/skf6tWjOLrJXyW3r7daXVyXusNTS aLVw== X-Gm-Message-State: APjAAAV5tI7OmGjiQ7+O478WeGdHTghS+aZYiY15Fntpk7xThb+K8ebn 6dvwlC+0Ek7pokpSQfcpERQ= X-Google-Smtp-Source: APXvYqwiAm91cMUBHNzoR/2vxP4ubMvTkxkJnuNPigxyDdlst8TKIz5llSgQAsfMo+EOXUbUN0Asxw== X-Received: by 2002:a65:68c9:: with SMTP id k9mr20449300pgt.28.1566917926098; Tue, 27 Aug 2019 07:58:46 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:45 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:10 -0700 Message-Id: <1566917919-25381-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::444 Subject: [Qemu-devel] [PATCH v6 01/30] riscv: hw: Remove superfluous "linux, phandle" property 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" "linux,phandle" property is optional. Remove all instances in the sifive_u, virt and spike machine device trees. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: - remove 2 more "linux,phandle" instances in sifive_u.c and spike.c after rebasing on Palmer's QEMU RISC-V tree Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 4 ---- hw/riscv/spike.c | 1 - hw/riscv/virt.c | 3 --- 3 files changed, 8 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 64e233d..afe304f 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -126,7 +126,6 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "device_type", "cpu"); qemu_fdt_add_subnode(fdt, intc); qemu_fdt_setprop_cell(fdt, intc, "phandle", cpu_phandle); - qemu_fdt_setprop_cell(fdt, intc, "linux,phandle", cpu_phandle); qemu_fdt_setprop_string(fdt, intc, "compatible", "riscv,cpu-intc"); qemu_fdt_setprop(fdt, intc, "interrupt-controller", NULL, 0); qemu_fdt_setprop_cell(fdt, intc, "#interrupt-cells", 1); @@ -185,7 +184,6 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", 0x35); qemu_fdt_setprop_cells(fdt, nodename, "phandle", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "linux,phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(cells); g_free(nodename); @@ -198,7 +196,6 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", SIFIVE_U_GEM_CLOCK_FREQ); qemu_fdt_setprop_cell(fdt, nodename, "phandle", ethclk_phandle); - qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", ethclk_phandle); ethclk_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(nodename); @@ -234,7 +231,6 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x0); qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", 3686400); qemu_fdt_setprop_cell(fdt, nodename, "phandle", uartclk_phandle); - qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", uartclk_phandle); uartclk_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(nodename); diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 2991b34..14acaef 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -112,7 +112,6 @@ static void create_fdt(SpikeState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "device_type", "cpu"); qemu_fdt_add_subnode(fdt, intc); qemu_fdt_setprop_cell(fdt, intc, "phandle", 1); - qemu_fdt_setprop_cell(fdt, intc, "linux,phandle", 1); qemu_fdt_setprop_string(fdt, intc, "compatible", "riscv,cpu-intc"); qemu_fdt_setprop(fdt, intc, "interrupt-controller", NULL, 0); qemu_fdt_setprop_cell(fdt, intc, "#interrupt-cells", 1); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 25faf3b..00be05a 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -170,11 +170,9 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "reg", cpu); qemu_fdt_setprop_string(fdt, nodename, "device_type", "cpu"); qemu_fdt_setprop_cell(fdt, nodename, "phandle", cpu_phandle); - qemu_fdt_setprop_cell(fdt, nodename, "linux,phandle", cpu_phandle); intc_phandle = phandle++; qemu_fdt_add_subnode(fdt, intc); qemu_fdt_setprop_cell(fdt, intc, "phandle", intc_phandle); - qemu_fdt_setprop_cell(fdt, intc, "linux,phandle", intc_phandle); qemu_fdt_setprop_string(fdt, intc, "compatible", "riscv,cpu-intc"); qemu_fdt_setprop(fdt, intc, "interrupt-controller", NULL, 0); qemu_fdt_setprop_cell(fdt, intc, "#interrupt-cells", 1); @@ -250,7 +248,6 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", VIRTIO_NDEV); qemu_fdt_setprop_cells(fdt, nodename, "phandle", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "linux,phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(cells); g_free(nodename); From patchwork Tue Aug 27 14:58:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117137 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 13EAC14DE for ; Tue, 27 Aug 2019 15:06:09 +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 DE86B214DA for ; Tue, 27 Aug 2019 15:06:08 +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="fjoGOMtj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE86B214DA 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]:52406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d2t-0001L7-L9 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:06:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46550) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvp-00039b-W7 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvo-0003KU-GM for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:49 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:37678) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvo-0003KH-A7; Tue, 27 Aug 2019 10:58:48 -0400 Received: by mail-pg1-x542.google.com with SMTP id d1so12842195pgp.4; Tue, 27 Aug 2019 07:58:48 -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=79G/OIW3W58EivGR8bRMjsOd8VJ7kwN5WzPGmoORvJg=; b=fjoGOMtjjhIc/+MRmtJbdKuzTV+JFlcdtR8VpE3OAqpaAXY7y3KTMwMRAT6sUdJvWQ eb9x95xPRc48reNp6fGD5Vw9gQwq759ziTAHM9qoBmlh0gG5SJ3UotkpkRYu7z3R7BKj NYQ8EvvtfhXhI81Qq60BhWmmGpBiqd8L6u0fxxJgALoqMyZ4thiS8oK7bqeu4kCCpaVP vzDBn/kJVgbONr424uDdyZFlvqabt4pnjCs3z8X/Qs0Wk5wmkBhVYwWeNUkBiLZUGXQB voH7ew4RkRwlCkQeUxxvoMJxfqhIDbqm0M9JwVy0aMlkQc3Tx3V7HIU/JGNHDGEQFDyj CR0A== 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=79G/OIW3W58EivGR8bRMjsOd8VJ7kwN5WzPGmoORvJg=; b=PfU1YzuNaanB9L3n9vQp8TgsesTlwgwQzxWj/SyYpFQqAnjxT+lrDjA145LURfMUk5 sBKZW+jiy6j1Vb/njT9LF5lDCyeripINKfWggV1OdQVczHDGNRAZ9p3otxed05Ag7WUA CsMBYQ7HE12XnILvc5I9FCgRIdVoujwLRqk8qFnfOy77yP97negnH6/m4Ey3B/XscJzx U4Vg5r5kWrjgA+4T2t07dyYKe8ocZ9VBt0WSk+hI/JcEFnk1NioolUZ8sQfT/mIMN0Rl C9lD3u+igfaEmUcysgaNWelHJB0RdpbODFTYD6G2agEVFAqgUzVW2wiQuVFaRqaZv0mC 64qg== X-Gm-Message-State: APjAAAXLAL+C+omRzfH6AmwllL/5ku4mbjXwgUxeQw3QFacDNV+bV7iu v8cz7z8ABqL69g38pXHkwcc= X-Google-Smtp-Source: APXvYqzIV/syxdYxFQ0YUwGrWGP29R+A62rcseLwRtqe+6UfZrg+xb1P5O3212ITTpCyGxc7u2GGRw== X-Received: by 2002:a17:90a:c20f:: with SMTP id e15mr25491190pjt.123.1566917927429; Tue, 27 Aug 2019 07:58:47 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:46 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:11 -0700 Message-Id: <1566917919-25381-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::542 Subject: [Qemu-devel] [PATCH v6 02/30] riscv: hw: Use qemu_fdt_setprop_cell() for property with only 1 cell 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" Some of the properties only have 1 cell so we should use qemu_fdt_setprop_cell() instead of qemu_fdt_setprop_cells(). Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 18 +++++++++--------- hw/riscv/virt.c | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index afe304f..3f9284e 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -183,7 +183,7 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", 0x35); - qemu_fdt_setprop_cells(fdt, nodename, "phandle", plic_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(cells); g_free(nodename); @@ -208,20 +208,20 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, 0x0, memmap[SIFIVE_U_GEM].size); qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); 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_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop_cell(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, "clock-names", ethclk_names, sizeof(ethclk_names)); - qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", 1); - qemu_fdt_setprop_cells(fdt, nodename, "#size-cells", 0); + qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", 1); + qemu_fdt_setprop_cell(fdt, nodename, "#size-cells", 0); g_free(nodename); nodename = g_strdup_printf("/soc/ethernet@%lx/ethernet-phy@0", (long)memmap[SIFIVE_U_GEM].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0); + qemu_fdt_setprop_cell(fdt, nodename, "reg", 0x0); g_free(nodename); uartclk_phandle = phandle++; @@ -241,9 +241,9 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_UART0].base, 0x0, memmap[SIFIVE_U_UART0].size); - qemu_fdt_setprop_cells(fdt, nodename, "clocks", uartclk_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_UART0_IRQ); + qemu_fdt_setprop_cell(fdt, nodename, "clocks", uartclk_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_UART0_IRQ); qemu_fdt_add_subnode(fdt, "/chosen"); qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 00be05a..127f005 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -233,8 +233,8 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, nodename = g_strdup_printf("/soc/interrupt-controller@%lx", (long)memmap[VIRT_PLIC].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", - FDT_PLIC_ADDR_CELLS); + qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", + FDT_PLIC_ADDR_CELLS); qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", FDT_PLIC_INT_CELLS); qemu_fdt_setprop_string(fdt, nodename, "compatible", "riscv,plic0"); @@ -247,7 +247,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", VIRTIO_NDEV); - qemu_fdt_setprop_cells(fdt, nodename, "phandle", plic_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(cells); g_free(nodename); @@ -260,19 +260,19 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[VIRT_VIRTIO].base + i * memmap[VIRT_VIRTIO].size, 0x0, memmap[VIRT_VIRTIO].size); - qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "interrupts", VIRTIO_IRQ + i); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "interrupts", VIRTIO_IRQ + i); g_free(nodename); } nodename = g_strdup_printf("/soc/pci@%lx", (long) memmap[VIRT_PCIE_ECAM].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_cells(fdt, nodename, "#address-cells", - FDT_PCI_ADDR_CELLS); - qemu_fdt_setprop_cells(fdt, nodename, "#interrupt-cells", - FDT_PCI_INT_CELLS); - qemu_fdt_setprop_cells(fdt, nodename, "#size-cells", 0x2); + qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", + FDT_PCI_ADDR_CELLS); + qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", + FDT_PCI_INT_CELLS); + qemu_fdt_setprop_cell(fdt, nodename, "#size-cells", 0x2); qemu_fdt_setprop_string(fdt, nodename, "compatible", "pci-host-ecam-generic"); qemu_fdt_setprop_string(fdt, nodename, "device_type", "pci"); @@ -309,8 +309,8 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, 0x0, memmap[VIRT_UART0].base, 0x0, memmap[VIRT_UART0].size); qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", 3686400); - qemu_fdt_setprop_cells(fdt, nodename, "interrupt-parent", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "interrupts", UART0_IRQ); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "interrupts", UART0_IRQ); qemu_fdt_add_subnode(fdt, "/chosen"); qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", nodename); From patchwork Tue Aug 27 14:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117139 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 55D871800 for ; Tue, 27 Aug 2019 15:06:09 +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 2CA7720828 for ; Tue, 27 Aug 2019 15:06:09 +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="H8zieEF5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CA7720828 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]:52404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d2t-0001Jf-P5 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:06:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46554) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvq-00039f-B0 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvp-0003Ky-Ab for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:50 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvp-0003Kb-52; Tue, 27 Aug 2019 10:58:49 -0400 Received: by mail-pf1-x444.google.com with SMTP id c81so14263162pfc.11; Tue, 27 Aug 2019 07:58:49 -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=PgaBfa2461mMPO3hboVa0CTJGMUC2+BnUYEwAGDtIng=; b=H8zieEF5gQh7cOmIsMkQFPdAbVhmIegiFU+478jxaySFND/FjoumMMbcWnLCPu496O Hh95S1fo1xamGUe23tcdAV4QzGszVRUMj+fxcj1vf5qH6f4xCtK7afDjBzP13Z0dUbex W59Yp2WakUDIcaR0pIh9IWQKPle+a1dR+jnuTtOfVVroJTB+1KHBJ5cpbahgvTWKZ2Go f6S+EVco/P/UwjX1KcY4Uw/Hi1QvzFQmilmY2ayY0N7Rqa5MPI+U5M29+m9uMgOMXmR/ mMfo69gcHF2WgauYZssVXUjd21F6GbksOFLxs1CdmljneiAqcgPvcfn7GVis3Ss1Vb/w o+lw== 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=PgaBfa2461mMPO3hboVa0CTJGMUC2+BnUYEwAGDtIng=; b=kg2kdeSdLaeM2qCgxn45j6uYTWEKdUMBFPIuLliqJX09kpY/rCXl8t7Hf6V3NYzNES moFLtv++96yHm9ZMnR1xXYAOiP7UHWLDTBr0DPFu69ugC6MybQ17YslIOnkVu41uqtzO PyZ4s3EPaA0CYi/XJFxwjba7ihjxgy4JIcd/a7YdDeHU3IDaaA4PcqL7DnNt3PJUSX6V pfqTXElUon43wzlbehQv/52DOZcEUedHivC9TrPVNPZ22TohYnE8OWnqI+SYf/Pa3ZTo 1T0vC5sKpEM3+dDHh3+WJ9mz0O/YA6+RVmh6o2m0M+aAdNFXWc4Mv0pE9ZE3fO8ytoEK dk2g== X-Gm-Message-State: APjAAAVYoD7qTQlSoDVL4FTc6QGpauqAfVHzka+apdF3OIUed4Ex9/FV dU/bsZoiU8/Zes02A5M6BmQ= X-Google-Smtp-Source: APXvYqzg+Ky34vZA/V5MIqMd612EfCag4uhv71DXOMzfFOfyIRNmdVkoyRWcFZyA8tu9XV4VrZKrLQ== X-Received: by 2002:a17:90a:8990:: with SMTP id v16mr12978874pjn.97.1566917928411; Tue, 27 Aug 2019 07:58:48 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.47 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:47 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:12 -0700 Message-Id: <1566917919-25381-4-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::444 Subject: [Qemu-devel] [PATCH v6 03/30] riscv: hw: Remove not needed PLIC properties in device tree 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" This removes "reg-names" and "riscv,max-priority" properties of the PLIC node from device tree. Signed-off-by: Bin Meng Reviewed-by: Jonathan Behrens Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: - keep the PLIC compatible string unchanged as OpenSBI uses that for DT fix up hw/riscv/sifive_u.c | 2 -- hw/riscv/virt.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 3f9284e..5fe0033 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -180,8 +180,6 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_PLIC].base, 0x0, memmap[SIFIVE_U_PLIC].size); - qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); - qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", 0x35); qemu_fdt_setprop_cell(fdt, nodename, "phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 127f005..2f75195 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -244,8 +244,6 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[VIRT_PLIC].base, 0x0, memmap[VIRT_PLIC].size); - qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); - qemu_fdt_setprop_cell(fdt, nodename, "riscv,max-priority", 7); qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", VIRTIO_NDEV); qemu_fdt_setprop_cell(fdt, nodename, "phandle", plic_phandle); plic_phandle = qemu_fdt_get_phandle(fdt, nodename); From patchwork Tue Aug 27 14:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117149 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 0EED814D5 for ; Tue, 27 Aug 2019 15:09:04 +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 D9DC42070B for ; Tue, 27 Aug 2019 15:09:03 +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="V9PlO+ft" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9DC42070B 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]:52466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d5i-0004ym-GB for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:09:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46580) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvr-0003Ap-Vc for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvq-0003M1-FC for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:51 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:41378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvq-0003L5-7P; Tue, 27 Aug 2019 10:58:50 -0400 Received: by mail-pf1-x444.google.com with SMTP id 196so14283076pfz.8; Tue, 27 Aug 2019 07:58:50 -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:mime-version :content-transfer-encoding; bh=WTSIdpTim8PZZEQ7sQ3k/MMjq+tZYHOHsOC3II1eIRc=; b=V9PlO+ftyN0XUa/gma5d4RGboAjPuTlPOVhyXrywNLdRYDdrbw0x0272Hv6uAmHj6M 00cZQyVpk/X1NrkGPFS1Foq/DDw0sZSTDsDAQRvqHpPpOzfJ0ZEk17y45g5rdbjSMjU2 U8SasH+486tIXOH3kxBAMk464kqtqXA5DRFj7wzND4HzkUmbCI2WzgNmorisYkWIsIt4 WW45EpMa9eXSye+rXufwJaHxcDQyTZ5iLZsrAQIgQu4c7Hy00Y6zdre+ZawkHQRLMIYa aHpDITBo4j54x3URvMs1n7/ODJ667sFUzESII1oKSjb/5wmS7SvkashsNaI4J9TUahNx YlWA== 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:mime-version:content-transfer-encoding; bh=WTSIdpTim8PZZEQ7sQ3k/MMjq+tZYHOHsOC3II1eIRc=; b=o291n24PKRdUXLpQsubaMBMnZ5dDiSs2X7kpSyrbeOn6HTtNQhkG+JrRuIOZVoxfNA 1DfgdANMwsmyWwKdC0Iz5gsFK81EaNAafWY0KulFlfF6YCs+G2ExJ+zzpKpcnff3h4ea ZrhQx36A9qVqlnKaJehDIaEppCnS5F1jn4GP4w6JUHH7J8YtZCeNXVnbk342VEWEQTIu /Dt32HKw3mRnCPBIPhvHaWDZq/edSVQq6fT+SMQSS8cp2SfjVZweqe1ThcQmP7QC9FGC VJSFVzseRvYsacItAHEZUsrn46HovH9h/I5LQ1Kmsc7OzgXNVAEZKJaodj9X/48u/4bK J/sA== X-Gm-Message-State: APjAAAVeuyrni+uABO9DArxMpWHyBP/Zkf1vulfNs2UFaRaecCxwtGGC 0u9b5dOMNIJVYfCdxpx/33E= X-Google-Smtp-Source: APXvYqxwwGYcWTaVjoGeyV2klpdDrgNYD1rTew/RXfGZMniKDFQM3k4W5HXlsldF/f273aJ607ojzg== X-Received: by 2002:a17:90a:17c4:: with SMTP id q62mr25352673pja.135.1566917929479; Tue, 27 Aug 2019 07:58:49 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.48 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:48 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:13 -0700 Message-Id: <1566917919-25381-5-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v6 04/30] riscv: hw: Change create_fdt() to return void 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" There is no need to return fdt at the end of create_fdt() because it's already saved in s->fdt. Signed-off-by: Bin Meng Reviewed-by: Chih-Min Chao Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: - change create_fdt() to return void in sifive_u.c too, after rebasing on Palmer's QEMU RISC-V tree Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 11 ++++------- hw/riscv/virt.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 5fe0033..e22803b 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -67,7 +67,7 @@ static const struct MemmapEntry { #define GEM_REVISION 0x10070109 -static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, +static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, uint64_t mem_size, const char *cmdline) { void *fdt; @@ -253,14 +253,11 @@ static void *create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, "/aliases", "serial0", nodename); g_free(nodename); - - return fdt; } static void riscv_sifive_u_init(MachineState *machine) { const struct MemmapEntry *memmap = sifive_u_memmap; - void *fdt; SiFiveUState *s = g_new0(SiFiveUState, 1); MemoryRegion *system_memory = get_system_memory(); @@ -281,7 +278,7 @@ static void riscv_sifive_u_init(MachineState *machine) main_mem); /* create device tree */ - fdt = create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); + create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); riscv_find_and_load_firmware(machine, BIOS_FILENAME, memmap[SIFIVE_U_DRAM].base); @@ -294,9 +291,9 @@ static void riscv_sifive_u_init(MachineState *machine) hwaddr end = riscv_load_initrd(machine->initrd_filename, machine->ram_size, kernel_entry, &start); - qemu_fdt_setprop_cell(fdt, "/chosen", + qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-start", start); - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", + qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", end); } } diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 2f75195..6bfa721 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -112,7 +112,7 @@ static void create_pcie_irq_map(void *fdt, char *nodename, 0x1800, 0, 0, 0x7); } -static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, +static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, uint64_t mem_size, const char *cmdline) { void *fdt; @@ -316,8 +316,6 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline); } g_free(nodename); - - return fdt; } @@ -373,7 +371,6 @@ static void riscv_virt_board_init(MachineState *machine) size_t plic_hart_config_len; int i; unsigned int smp_cpus = machine->smp.cpus; - void *fdt; /* Initialize SOC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), @@ -392,7 +389,7 @@ static void riscv_virt_board_init(MachineState *machine) main_mem); /* create device tree */ - fdt = create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); + create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline); /* boot rom */ memory_region_init_rom(mask_rom, NULL, "riscv_virt_board.mrom", @@ -411,9 +408,9 @@ static void riscv_virt_board_init(MachineState *machine) hwaddr end = riscv_load_initrd(machine->initrd_filename, machine->ram_size, kernel_entry, &start); - qemu_fdt_setprop_cell(fdt, "/chosen", + qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-start", start); - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", + qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", end); } } From patchwork Tue Aug 27 14:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117171 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 A67D214D5 for ; Tue, 27 Aug 2019 15:12:17 +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 7B1D72070B for ; Tue, 27 Aug 2019 15:12:17 +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="DH4dydZd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B1D72070B 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]:52500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d8q-0000GA-58 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:12:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46616) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvu-0003Cl-CD for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvs-0003OQ-1z for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:54 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvr-0003Mf-RH; Tue, 27 Aug 2019 10:58:51 -0400 Received: by mail-pg1-x541.google.com with SMTP id e11so12843144pga.5; Tue, 27 Aug 2019 07:58:51 -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=sVgQU9XDhEv7Fcmdko40+vQFZ7rK+wy/NH0Vxuc5IEM=; b=DH4dydZdp9Hp/p5AMsTk+aBVUODtsfX3enwvY1eQ+2I3zhjaHrZcxQpPVqL5PnZ+21 D1GT7opClbPR1n7AFXlYORH5eBmAj8LraqeX8EBzehDac49XPcxNgIW7kS6LSSnxxzav sDl1UY8Xip5MDZbK5pQOvIXhdvDreSaO3+Pe7IuZjQdFNObb5BZg3GQUWE90oH73U+YD /niNzLlIsgoKRxlQnnElxLVroNZpX1gMadWB1co1j9HeXo12fVivd/HfDW2Fbp0OFhWX 11lAJbwD0GPvH01ACL3kAy1+j7XlaoSegdSHpWt+wZHEpN/eyxDqA158saihJvSqEMsq RWbw== 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=sVgQU9XDhEv7Fcmdko40+vQFZ7rK+wy/NH0Vxuc5IEM=; b=DMp2Fj/0W33s382dalauik4lb3sYDsqMEweV63MGidr4DV/KXhz2akcIV9v9LE/jNN mjOgTAZ+U4CgtWjqtRa3ukhlP6z7xAFi2fda5MkOVkH5ztCWYihytU0W1DkjRkLfh67H FriwUizuMUGmo7a+TLnhFICFHvCcZueSY5B9lPvLBGAd4Thdo8KvKGaDPCWlg+3gp0aV xpwjyUTyzr+Cl9v/iEJDrzSCFGikXzJ75BIIu+a6P4WsEWn+tpiG1tJQGn8Tu3LNJ9BS HEA/12F9eE9yw4WtLMPXlrIg310zaDHy2BdloF/cNcv4d5ey16a1VEa50uNTry3NTCwF Zuxw== X-Gm-Message-State: APjAAAW5QdIcAeU17dGQbGmaJkGVSgRg0B8sV1h8IS7Td73thiQ1N7Sd lySgGjvNsFsuzInYOkIWrVjgnDR9 X-Google-Smtp-Source: APXvYqxnXIYCrh7Ar5cM6FhTxLD1kwde6jsg/meCpMSV71+hAT9J6qBcQF/QfuhrOz1MUKRusb2WJA== X-Received: by 2002:a17:90a:3266:: with SMTP id k93mr26209056pjb.46.1566917930627; Tue, 27 Aug 2019 07:58:50 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.49 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:49 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:14 -0700 Message-Id: <1566917919-25381-6-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::541 Subject: [Qemu-devel] [PATCH v6 05/30] riscv: hw: Change to use qemu_log_mask(LOG_GUEST_ERROR, ...) instead 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" Replace the call to hw_error() with qemu_log_mask(LOG_GUEST_ERROR,...) in various sifive models. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: - new patch to change to use qemu_log_mask(LOG_GUEST_ERROR,...) instead in various sifive models Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_prci.c | 8 +++++--- hw/riscv/sifive_test.c | 5 +++-- hw/riscv/sifive_uart.c | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/riscv/sifive_prci.c b/hw/riscv/sifive_prci.c index f406682..1ab98d4 100644 --- a/hw/riscv/sifive_prci.c +++ b/hw/riscv/sifive_prci.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" +#include "qemu/log.h" #include "qemu/module.h" #include "target/riscv/cpu.h" #include "hw/riscv/sifive_prci.h" @@ -37,7 +38,8 @@ static uint64_t sifive_prci_read(void *opaque, hwaddr addr, unsigned int size) case SIFIVE_PRCI_PLLOUTDIV: return s->plloutdiv; } - hw_error("%s: read: addr=0x%x\n", __func__, (int)addr); + qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%x\n", + __func__, (int)addr); return 0; } @@ -65,8 +67,8 @@ static void sifive_prci_write(void *opaque, hwaddr addr, s->plloutdiv = (uint32_t) val64; break; default: - hw_error("%s: bad write: addr=0x%x v=0x%x\n", - __func__, (int)addr, (int)val64); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%x v=0x%x\n", + __func__, (int)addr, (int)val64); } } diff --git a/hw/riscv/sifive_test.c b/hw/riscv/sifive_test.c index cd86831..655a3d7 100644 --- a/hw/riscv/sifive_test.c +++ b/hw/riscv/sifive_test.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" +#include "qemu/log.h" #include "qemu/module.h" #include "sysemu/sysemu.h" #include "target/riscv/cpu.h" @@ -48,8 +49,8 @@ static void sifive_test_write(void *opaque, hwaddr addr, break; } } - hw_error("%s: write: addr=0x%x val=0x%016" PRIx64 "\n", - __func__, (int)addr, val64); + qemu_log_mask(LOG_GUEST_ERROR, "%s: write: addr=0x%x val=0x%016" PRIx64 "\n", + __func__, (int)addr, val64); } static const MemoryRegionOps sifive_test_ops = { diff --git a/hw/riscv/sifive_uart.c b/hw/riscv/sifive_uart.c index 3b3f94f..cd74043 100644 --- a/hw/riscv/sifive_uart.c +++ b/hw/riscv/sifive_uart.c @@ -18,6 +18,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/log.h" #include "hw/sysbus.h" #include "chardev/char.h" #include "chardev/char-fe.h" @@ -93,8 +94,8 @@ uart_read(void *opaque, hwaddr addr, unsigned int size) return s->div; } - hw_error("%s: bad read: addr=0x%x\n", - __func__, (int)addr); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad read: addr=0x%x\n", + __func__, (int)addr); return 0; } @@ -125,8 +126,8 @@ uart_write(void *opaque, hwaddr addr, s->div = val64; return; } - hw_error("%s: bad write: addr=0x%x v=0x%x\n", - __func__, (int)addr, (int)value); + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%x v=0x%x\n", + __func__, (int)addr, (int)value); } static const MemoryRegionOps uart_ops = { From patchwork Tue Aug 27 14:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117131 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 2048914D5 for ; Tue, 27 Aug 2019 15:02:05 +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 E8565214DA for ; Tue, 27 Aug 2019 15:02:04 +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="mMDwwOz7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8565214DA 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]:52372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cyx-0005h8-4B for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:02:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46636) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvv-0003Dk-6P for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvs-0003Oq-N9 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:54 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34731) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvs-0003OA-HH; Tue, 27 Aug 2019 10:58:52 -0400 Received: by mail-pg1-x544.google.com with SMTP id n9so12856991pgc.1; Tue, 27 Aug 2019 07:58:52 -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=9zPJ4Q9TIgxIyECVOCVkDoBRfMIAHimE+QxZVrAJ+Xo=; b=mMDwwOz7p9gowc1r3aRglqPDJZ6In/MRrdUIGzJp4OD+kvIlvi0zO70cwdgeD96Ol6 UygXm3vKL5Lk+GXiS834cTSQhVS2otMKdtZICtswVGz6q45sn7mr9Ccmo42LXsiPjLmB dPyVEkvHGqij9lfKdZqwnbQOJhG9XpV4yMLS8QAjXQDymbX75AGjnIEWywSMcc4JPCyJ v6i/XMHM4taEyJ5+7ZZiSEHyK9cvzMNYCn7ul6Essfwzl2mkQVVyn0ceZr+MDi0uL1bm QumT5DEhxsHf24wElAUqAWPAM8flpFwvmtHSQw0jZbSwoVSKh8OOL/L1RokS7t+ZgrM4 O44g== 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=9zPJ4Q9TIgxIyECVOCVkDoBRfMIAHimE+QxZVrAJ+Xo=; b=qy31XN2l70tUZwjO1KeGnloe6xx0ru75ricMpkcCi50DOQ9RwNYs2kPI3T+vy5X8kM 51yZT7JGdihI7X8YmrUgrcrSpuwyHI8veaOj43c5pshhDACIxatsxsjCdWCUrtvjCxZW 8NG8Y5Y1l6+7toYQ3qOJftpVCdmJHKsZOmOKm51qncZmfTgX1T8trb4EEHNEVPWNI7bE 63PwenttqAh3F6HAzvsN87qPTWD4jY1QR7FHJFBUbG97z9QJeecm41YhTRbTtYHX6TiK eiFaE+U0X/5pnRqtStpyCRnF1OJIJRMf96m37f7hr9yCqDkMWtoR9KEweEQCzWZ6WjRh D+sw== X-Gm-Message-State: APjAAAWESQxf12/ckC/5jF6B3ybWBhaF4AaFtc7tRfJotIUy7RPfIBzz Si1MnBd+mbk4m/FXYaUXOOo= X-Google-Smtp-Source: APXvYqwB2h13iFT/lvPIBPhltqcGQ0tCsEjc7GmSxNYH2DbIJq1Vp++Xg58RHWl5oGiZzPwNl+PgBA== X-Received: by 2002:a17:90b:907:: with SMTP id bo7mr26153582pjb.107.1566917931720; Tue, 27 Aug 2019 07:58:51 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:51 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:15 -0700 Message-Id: <1566917919-25381-7-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::544 Subject: [Qemu-devel] [PATCH v6 06/30] riscv: hw: Remove the unnecessary include of target/riscv/cpu.h 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" The inclusion of "target/riscv/cpu.h" is unnecessary in various sifive model drivers. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: - new patch to remove the unnecessary include of target/riscv/cpu.h Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_prci.c | 1 - hw/riscv/sifive_test.c | 1 - hw/riscv/sifive_uart.c | 1 - 3 files changed, 3 deletions(-) diff --git a/hw/riscv/sifive_prci.c b/hw/riscv/sifive_prci.c index 1ab98d4..1957dcd 100644 --- a/hw/riscv/sifive_prci.c +++ b/hw/riscv/sifive_prci.c @@ -22,7 +22,6 @@ #include "hw/sysbus.h" #include "qemu/log.h" #include "qemu/module.h" -#include "target/riscv/cpu.h" #include "hw/riscv/sifive_prci.h" static uint64_t sifive_prci_read(void *opaque, hwaddr addr, unsigned int size) diff --git a/hw/riscv/sifive_test.c b/hw/riscv/sifive_test.c index 655a3d7..31cad9f 100644 --- a/hw/riscv/sifive_test.c +++ b/hw/riscv/sifive_test.c @@ -23,7 +23,6 @@ #include "qemu/log.h" #include "qemu/module.h" #include "sysemu/sysemu.h" -#include "target/riscv/cpu.h" #include "hw/riscv/sifive_test.h" static uint64_t sifive_test_read(void *opaque, hwaddr addr, unsigned int size) diff --git a/hw/riscv/sifive_uart.c b/hw/riscv/sifive_uart.c index cd74043..1601bd9 100644 --- a/hw/riscv/sifive_uart.c +++ b/hw/riscv/sifive_uart.c @@ -22,7 +22,6 @@ #include "hw/sysbus.h" #include "chardev/char.h" #include "chardev/char-fe.h" -#include "target/riscv/cpu.h" #include "hw/riscv/sifive_uart.h" /* From patchwork Tue Aug 27 14:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117135 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 215C314DE for ; Tue, 27 Aug 2019 15:03:44 +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 EBA6020828 for ; Tue, 27 Aug 2019 15:03:43 +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="OaYJ9H7A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBA6020828 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]:52380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d0Y-0007ST-Ik for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46692) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cw1-0003Hk-1H for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvx-0003Vu-Cp for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:58 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36125) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvv-0003Oy-5f; Tue, 27 Aug 2019 10:58:55 -0400 Received: by mail-pf1-x441.google.com with SMTP id w2so14293672pfi.3; Tue, 27 Aug 2019 07:58:54 -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=FpCtqaldJOPS+6r8LXByFWiXnp/lwboxYZuh51b65Ho=; b=OaYJ9H7AGNb0evmcU/GDuLFj6s3FsaggyADNL4nnEao+k/LFpxWHvtZZSOpvnFTkMh eJYemiOcx+4nTg51EAqt0bLWuPRId8WtKkFnYQ825KuXdkyDNuG3OCjkAb1389CymUbj R8wxCPeb6HfZ6j4QnGz0LVH4pHAABGaCtIEQ5VaRxeAy8JK81EbUQ2HzELSJuaiVZak6 DHZ96Iepk1AQdTKJFH0AhJernFIl635fKQ+CB3V5jmZAL38vTuL+53ORodBmOdWbVaEL ppLvbn1JxkVSbQFNPa86voTRZ7su5q5Mh8T9stpHQ1lrimLuJ5mj8mFZoDNi5Z47gx6H BguQ== 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=FpCtqaldJOPS+6r8LXByFWiXnp/lwboxYZuh51b65Ho=; b=klvtt1Sz8BgYTeiIJOIGye/ZEgNL8lPGzIokoaHNwmwalUSp4oPFACam0248OLYOuy sHSa6XNo5WPjrcOk3y87oeE9DnMhfEM9PkDOiKD7Cso5vO8wXNWcAYUyIQ//BJMNsaDq LzRP5LdgUrZr0dup/w+yZmx3TaRFTsMjpnkr6AwKRCxbkNtq7MQm+Wbt12KBhSN9C4iX l3Zh46wcssQk/9jUOE+JJv0qA/0jcQ0tigt1golfxd2uGcsZ8PvAej+T2jnc71XycHgh jv0600FBdzxxkeEOe0rm8wRpmu0cOxPIsB/bf8XZVrun6uo3Zw7s4cKi6wnin01XP/n7 Kpqg== X-Gm-Message-State: APjAAAX5zHOIT6vgLu6NI7tnlJW/4MkcEdMI8TamHRzLUhEBKkD0jsWy bG4WEZ0oj0NZzKTYePt+M2s= X-Google-Smtp-Source: APXvYqwZObKOM2i1J/KP2C8vyutgP/wSQvnsO/UQDzDLSg3fM9dk10L8a+OLEHDt/ndZVbAGaZ4nXA== X-Received: by 2002:a17:90a:c386:: with SMTP id h6mr25510892pjt.122.1566917932880; Tue, 27 Aug 2019 07:58:52 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:52 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:16 -0700 Message-Id: <1566917919-25381-8-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::441 Subject: [Qemu-devel] [PATCH v6 07/30] riscv: roms: Remove executable attribute of opensbi images 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" Like other binary files, the executable attribute of opensbi images should not be set. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: - new patch to remove executable attribute of opensbi images Changes in v3: None Changes in v2: None pc-bios/opensbi-riscv32-virt-fw_jump.bin | Bin pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin | Bin pc-bios/opensbi-riscv64-virt-fw_jump.bin | Bin 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pc-bios/opensbi-riscv32-virt-fw_jump.bin mode change 100755 => 100644 pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin mode change 100755 => 100644 pc-bios/opensbi-riscv64-virt-fw_jump.bin diff --git a/pc-bios/opensbi-riscv32-virt-fw_jump.bin b/pc-bios/opensbi-riscv32-virt-fw_jump.bin old mode 100755 new mode 100644 diff --git a/pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin b/pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin old mode 100755 new mode 100644 diff --git a/pc-bios/opensbi-riscv64-virt-fw_jump.bin b/pc-bios/opensbi-riscv64-virt-fw_jump.bin old mode 100755 new mode 100644 From patchwork Tue Aug 27 14:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117179 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 1EBEB14DE for ; Tue, 27 Aug 2019 15:16:11 +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 E90E52070B for ; Tue, 27 Aug 2019 15:16:10 +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="Y2gbg9Cv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E90E52070B 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]:52538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dCa-0004Zd-QU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:16:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46662) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cvx-0003G3-UZ for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvv-0003Qp-Ca for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:58:56 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvu-0003PE-M5; Tue, 27 Aug 2019 10:58:55 -0400 Received: by mail-pl1-x643.google.com with SMTP id bj8so11919698plb.4; Tue, 27 Aug 2019 07:58:54 -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=bph9QJ0bNuPskxMhwrZk+kqRsPAn0NFXg/LQc9J4RXw=; b=Y2gbg9CvjQ5C7fyxiVU2g9D8zb3NF3nYMoLQ+IrOzN87aMJpmvtvd2ZxyrWxeIrRtO AbXUIKlkl3gWk9Lj52wBC0kN1sivQ7LNTCT95REBBTj7zkhSHfcpbsfIhhTEsqAUBzdV wJROFrqmj8H9NGTgcd0017Q2lbYppmoUvkMi2N5GqUg1B8vQp4ib9yENn+KZC3Kyx692 9S8yHH6gS6WSC93zliAWXnMP+d0CGmNjsD2evNf8mjJzd3mBKVeeU7PdzQmgsck2KcbX o3Ln9tHQPzy6emLDtvKV5WhpyL3xUJRAF3LqXJEwtTfw1lNrgkewZLJ7IsBeoWGrbw2q iGEA== 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=bph9QJ0bNuPskxMhwrZk+kqRsPAn0NFXg/LQc9J4RXw=; b=JEqxYbc0dfSYr6FxOm2eOc31n96frTt4+h+FU/z22DDYwKwMqaL47ZN0EbRSdogfKU gIdtNOhIzIvhOK+ST3AtvwRCvU5WmSsEi9S0P7O6DZ1PL2sMV1TOYb2OqPIxRsgeno6Y 1rVzmUa71ZeE1lYAFk9gm3FzkfPehLjYEPQNSdvHPTlv3Vcg4qi4TKnrPEtlPPcZ7l3S ZPT1KxUE3ALBjLS6VMt4JMUXINxsTFL/26jbXgTt+DIbIHRk6GQWgK5wx2TgslGB2ZMU RqeJiXI4bioSmx8LFg2cqjr6b3bJv3RGUWlG5kmUwbyh1X91Y3vASI39Egs6j0LUS/2j 8jFA== X-Gm-Message-State: APjAAAWTX/dQmRbz7TyY/6jFevUyMM3oASmDBXyvmpQl7mp6zyo6njRy j9pZiUsz/lgUn46nH8XwHFM= X-Google-Smtp-Source: APXvYqxvPxL7tuF5Kc1X64iOAuRYnwQlnHrCpSTBel7INXKFBn/MujouENqm0koMNyDaaCTQR0V6og== X-Received: by 2002:a17:902:8a93:: with SMTP id p19mr25202024plo.106.1566917933929; Tue, 27 Aug 2019 07:58:53 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:53 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:17 -0700 Message-Id: <1566917919-25381-9-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::643 Subject: [Qemu-devel] [PATCH v6 08/30] riscv: sifive_u: Remove the unnecessary include of prci header 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" sifive_u machine does not use PRCI as of today. Remove the prci header inclusion. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index e22803b..3f58f61 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -39,7 +39,6 @@ #include "hw/riscv/sifive_plic.h" #include "hw/riscv/sifive_clint.h" #include "hw/riscv/sifive_uart.h" -#include "hw/riscv/sifive_prci.h" #include "hw/riscv/sifive_u.h" #include "hw/riscv/boot.h" #include "chardev/char.h" From patchwork Tue Aug 27 14:58:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117153 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 7A9A414DE for ; Tue, 27 Aug 2019 15:09:10 +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 41192214DA for ; Tue, 27 Aug 2019 15:09:10 +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="vSLYf+9X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41192214DA 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]:52468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d5o-00057J-R7 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:09:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46723) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cw3-0003JH-PK for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cvz-0003Y7-3F for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:00 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:42030) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvx-0003Qy-Hn; Tue, 27 Aug 2019 10:58:57 -0400 Received: by mail-pl1-x643.google.com with SMTP id y1so11887213plp.9; Tue, 27 Aug 2019 07:58:55 -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=rd2vrojE01lW2En6xwRiGJbpwm5q0JOsZnJe5Mw3Smc=; b=vSLYf+9XrySmdRuzy01hPcDquTtOClxhCSLu32h5uPseEHYjo2Xg6ttUzoFfNSHEWr Z+I4GL9JuXDnfjT2YBdCQbedHt40j0IFjtyVydwjlhVmhNK0WH8FAsRn+dmt147xRbcB rV4h/h6FWYcltVNnGKGISKfty8LhNykc6ejo7b9QuvkusjFK8TTK9qazWfvBkSZpBiNS K9FxS1usVpJkL9a9wNuxzGaV3+rIoVMYs3jwRqNTba9jHHJFmSBHar+dHX+qdCQ2/+Wp r7yJOBWsj8M8JbWEUV9KJxuwTZ4suyJExFbWAchoozAHtctS7du2kgGr33u90bPshGmq 0vsA== 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=rd2vrojE01lW2En6xwRiGJbpwm5q0JOsZnJe5Mw3Smc=; b=rAJnRDhk86bOsDIgnidKiVVPfH2fDZdKHgdHW4Zlnyy7T8AhfofvZe2fJCAGasXleQ 9UxfWhya2Fng4DnN+tBt4F7DGRopdG4z5JOedx/sqpAIXvDTO0/6YTwaQeMHh30rrXYz cG4oWoDIl/AG+n6n6MrYQxhdRkNHPRTNEJk1WrFKX79Ax7qlKeDP2QFSNbhZXfdx9lD1 mQqw1gIsmcQqi3tqbKczKKiLaym59i9MZKXDK1sYJQ2hOPumT//1gFp3+iRoIML9vROF Ez9FPoKX6JMhwvT5BubMFZVp2zx31p1DcDDUWSpMqWZ3maGhA8o1Pt5JjsEZ3ABSZn+9 D6EA== X-Gm-Message-State: APjAAAVeabgwjhD4nci4tlns57dze5UefaHXR1aghAf40ekQf0dvqdPo yrzmZofgbWeuX+Db3Z5b6hk= X-Google-Smtp-Source: APXvYqw4s79tQtV27GChC9LUKwmsomjcvl2C/JG8iCyUoUOeYSCe5r8vQeSP1Vtl+hYdikPNL3qbIA== X-Received: by 2002:a17:902:343:: with SMTP id 61mr25751316pld.215.1566917935029; Tue, 27 Aug 2019 07:58:55 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.53 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:54 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:18 -0700 Message-Id: <1566917919-25381-10-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::643 Subject: [Qemu-devel] [PATCH v6 09/30] riscv: sifive: Rename sifive_prci.{c, h} to sifive_e_prci.{c, h} 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" Current SiFive PRCI model only works with sifive_e machine, as it only emulates registers or PRCI block in the FE310 SoC. Rename the file name to make it clear that it is for sifive_e. This also prefix "sifive_e"/"SIFIVE_E" for all macros, variables and functions. Signed-off-by: Bin Meng Reviewed-by: Chih-Min Chao Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: - prefix all macros/variables/functions with SIFIVE_E/sifive_e in the sifive_e_prci driver Changes in v3: None Changes in v2: None hw/riscv/Makefile.objs | 2 +- hw/riscv/sifive_e.c | 4 +- hw/riscv/{sifive_prci.c => sifive_e_prci.c} | 79 ++++++++++++++--------------- include/hw/riscv/sifive_e_prci.h | 69 +++++++++++++++++++++++++ include/hw/riscv/sifive_prci.h | 69 ------------------------- 5 files changed, 111 insertions(+), 112 deletions(-) rename hw/riscv/{sifive_prci.c => sifive_e_prci.c} (51%) create mode 100644 include/hw/riscv/sifive_e_prci.h delete mode 100644 include/hw/riscv/sifive_prci.h diff --git a/hw/riscv/Makefile.objs b/hw/riscv/Makefile.objs index eb9d4f9..c859697 100644 --- a/hw/riscv/Makefile.objs +++ b/hw/riscv/Makefile.objs @@ -2,9 +2,9 @@ obj-y += boot.o obj-$(CONFIG_SPIKE) += riscv_htif.o obj-$(CONFIG_HART) += riscv_hart.o obj-$(CONFIG_SIFIVE_E) += sifive_e.o +obj-$(CONFIG_SIFIVE_E) += sifive_e_prci.o obj-$(CONFIG_SIFIVE) += sifive_clint.o obj-$(CONFIG_SIFIVE) += sifive_gpio.o -obj-$(CONFIG_SIFIVE) += sifive_prci.o obj-$(CONFIG_SIFIVE) += sifive_plic.o obj-$(CONFIG_SIFIVE) += sifive_test.o obj-$(CONFIG_SIFIVE_U) += sifive_u.o diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 2a499d8..2d67670 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -41,9 +41,9 @@ #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_plic.h" #include "hw/riscv/sifive_clint.h" -#include "hw/riscv/sifive_prci.h" #include "hw/riscv/sifive_uart.h" #include "hw/riscv/sifive_e.h" +#include "hw/riscv/sifive_e_prci.h" #include "hw/riscv/boot.h" #include "chardev/char.h" #include "sysemu/arch_init.h" @@ -174,7 +174,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE); sifive_mmio_emulate(sys_mem, "riscv.sifive.e.aon", memmap[SIFIVE_E_AON].base, memmap[SIFIVE_E_AON].size); - sifive_prci_create(memmap[SIFIVE_E_PRCI].base); + sifive_e_prci_create(memmap[SIFIVE_E_PRCI].base); /* GPIO */ diff --git a/hw/riscv/sifive_prci.c b/hw/riscv/sifive_e_prci.c similarity index 51% rename from hw/riscv/sifive_prci.c rename to hw/riscv/sifive_e_prci.c index 1957dcd..c514032 100644 --- a/hw/riscv/sifive_prci.c +++ b/hw/riscv/sifive_e_prci.c @@ -1,5 +1,5 @@ /* - * QEMU SiFive PRCI (Power, Reset, Clock, Interrupt) + * QEMU SiFive E PRCI (Power, Reset, Clock, Interrupt) * * Copyright (c) 2017 SiFive, Inc. * @@ -22,19 +22,19 @@ #include "hw/sysbus.h" #include "qemu/log.h" #include "qemu/module.h" -#include "hw/riscv/sifive_prci.h" +#include "hw/riscv/sifive_e_prci.h" -static uint64_t sifive_prci_read(void *opaque, hwaddr addr, unsigned int size) +static uint64_t sifive_e_prci_read(void *opaque, hwaddr addr, unsigned int size) { - SiFivePRCIState *s = opaque; + SiFiveEPRCIState *s = opaque; switch (addr) { - case SIFIVE_PRCI_HFROSCCFG: + case SIFIVE_E_PRCI_HFROSCCFG: return s->hfrosccfg; - case SIFIVE_PRCI_HFXOSCCFG: + case SIFIVE_E_PRCI_HFXOSCCFG: return s->hfxosccfg; - case SIFIVE_PRCI_PLLCFG: + case SIFIVE_E_PRCI_PLLCFG: return s->pllcfg; - case SIFIVE_PRCI_PLLOUTDIV: + case SIFIVE_E_PRCI_PLLOUTDIV: return s->plloutdiv; } qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%x\n", @@ -42,27 +42,27 @@ static uint64_t sifive_prci_read(void *opaque, hwaddr addr, unsigned int size) return 0; } -static void sifive_prci_write(void *opaque, hwaddr addr, - uint64_t val64, unsigned int size) +static void sifive_e_prci_write(void *opaque, hwaddr addr, + uint64_t val64, unsigned int size) { - SiFivePRCIState *s = opaque; + SiFiveEPRCIState *s = opaque; switch (addr) { - case SIFIVE_PRCI_HFROSCCFG: + case SIFIVE_E_PRCI_HFROSCCFG: s->hfrosccfg = (uint32_t) val64; /* OSC stays ready */ - s->hfrosccfg |= SIFIVE_PRCI_HFROSCCFG_RDY; + s->hfrosccfg |= SIFIVE_E_PRCI_HFROSCCFG_RDY; break; - case SIFIVE_PRCI_HFXOSCCFG: + case SIFIVE_E_PRCI_HFXOSCCFG: s->hfxosccfg = (uint32_t) val64; /* OSC stays ready */ - s->hfxosccfg |= SIFIVE_PRCI_HFXOSCCFG_RDY; + s->hfxosccfg |= SIFIVE_E_PRCI_HFXOSCCFG_RDY; break; - case SIFIVE_PRCI_PLLCFG: + case SIFIVE_E_PRCI_PLLCFG: s->pllcfg = (uint32_t) val64; /* PLL stays locked */ - s->pllcfg |= SIFIVE_PRCI_PLLCFG_LOCK; + s->pllcfg |= SIFIVE_E_PRCI_PLLCFG_LOCK; break; - case SIFIVE_PRCI_PLLOUTDIV: + case SIFIVE_E_PRCI_PLLOUTDIV: s->plloutdiv = (uint32_t) val64; break; default: @@ -71,9 +71,9 @@ static void sifive_prci_write(void *opaque, hwaddr addr, } } -static const MemoryRegionOps sifive_prci_ops = { - .read = sifive_prci_read, - .write = sifive_prci_write, +static const MemoryRegionOps sifive_e_prci_ops = { + .read = sifive_e_prci_read, + .write = sifive_e_prci_write, .endianness = DEVICE_NATIVE_ENDIAN, .valid = { .min_access_size = 4, @@ -81,43 +81,42 @@ static const MemoryRegionOps sifive_prci_ops = { } }; -static void sifive_prci_init(Object *obj) +static void sifive_e_prci_init(Object *obj) { - SiFivePRCIState *s = SIFIVE_PRCI(obj); + SiFiveEPRCIState *s = SIFIVE_E_PRCI(obj); - memory_region_init_io(&s->mmio, obj, &sifive_prci_ops, s, - TYPE_SIFIVE_PRCI, 0x8000); + memory_region_init_io(&s->mmio, obj, &sifive_e_prci_ops, s, + TYPE_SIFIVE_E_PRCI, 0x8000); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); - s->hfrosccfg = (SIFIVE_PRCI_HFROSCCFG_RDY | SIFIVE_PRCI_HFROSCCFG_EN); - s->hfxosccfg = (SIFIVE_PRCI_HFROSCCFG_RDY | SIFIVE_PRCI_HFROSCCFG_EN); - s->pllcfg = (SIFIVE_PRCI_PLLCFG_REFSEL | SIFIVE_PRCI_PLLCFG_BYPASS | - SIFIVE_PRCI_PLLCFG_LOCK); - s->plloutdiv = SIFIVE_PRCI_PLLOUTDIV_DIV1; - + s->hfrosccfg = (SIFIVE_E_PRCI_HFROSCCFG_RDY | SIFIVE_E_PRCI_HFROSCCFG_EN); + s->hfxosccfg = (SIFIVE_E_PRCI_HFROSCCFG_RDY | SIFIVE_E_PRCI_HFROSCCFG_EN); + s->pllcfg = (SIFIVE_E_PRCI_PLLCFG_REFSEL | SIFIVE_E_PRCI_PLLCFG_BYPASS | + SIFIVE_E_PRCI_PLLCFG_LOCK); + s->plloutdiv = SIFIVE_E_PRCI_PLLOUTDIV_DIV1; } -static const TypeInfo sifive_prci_info = { - .name = TYPE_SIFIVE_PRCI, +static const TypeInfo sifive_e_prci_info = { + .name = TYPE_SIFIVE_E_PRCI, .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(SiFivePRCIState), - .instance_init = sifive_prci_init, + .instance_size = sizeof(SiFiveEPRCIState), + .instance_init = sifive_e_prci_init, }; -static void sifive_prci_register_types(void) +static void sifive_e_prci_register_types(void) { - type_register_static(&sifive_prci_info); + type_register_static(&sifive_e_prci_info); } -type_init(sifive_prci_register_types) +type_init(sifive_e_prci_register_types) /* * Create PRCI device. */ -DeviceState *sifive_prci_create(hwaddr addr) +DeviceState *sifive_e_prci_create(hwaddr addr) { - DeviceState *dev = qdev_create(NULL, TYPE_SIFIVE_PRCI); + DeviceState *dev = qdev_create(NULL, TYPE_SIFIVE_E_PRCI); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr); return dev; diff --git a/include/hw/riscv/sifive_e_prci.h b/include/hw/riscv/sifive_e_prci.h new file mode 100644 index 0000000..c4b76aa --- /dev/null +++ b/include/hw/riscv/sifive_e_prci.h @@ -0,0 +1,69 @@ +/* + * QEMU SiFive E PRCI (Power, Reset, Clock, Interrupt) interface + * + * Copyright (c) 2017 SiFive, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_SIFIVE_E_PRCI_H +#define HW_SIFIVE_E_PRCI_H + +enum { + SIFIVE_E_PRCI_HFROSCCFG = 0x0, + SIFIVE_E_PRCI_HFXOSCCFG = 0x4, + SIFIVE_E_PRCI_PLLCFG = 0x8, + SIFIVE_E_PRCI_PLLOUTDIV = 0xC +}; + +enum { + SIFIVE_E_PRCI_HFROSCCFG_RDY = (1 << 31), + SIFIVE_E_PRCI_HFROSCCFG_EN = (1 << 30) +}; + +enum { + SIFIVE_E_PRCI_HFXOSCCFG_RDY = (1 << 31), + SIFIVE_E_PRCI_HFXOSCCFG_EN = (1 << 30) +}; + +enum { + SIFIVE_E_PRCI_PLLCFG_PLLSEL = (1 << 16), + SIFIVE_E_PRCI_PLLCFG_REFSEL = (1 << 17), + SIFIVE_E_PRCI_PLLCFG_BYPASS = (1 << 18), + SIFIVE_E_PRCI_PLLCFG_LOCK = (1 << 31) +}; + +enum { + SIFIVE_E_PRCI_PLLOUTDIV_DIV1 = (1 << 8) +}; + +#define TYPE_SIFIVE_E_PRCI "riscv.sifive.e.prci" + +#define SIFIVE_E_PRCI(obj) \ + OBJECT_CHECK(SiFiveEPRCIState, (obj), TYPE_SIFIVE_E_PRCI) + +typedef struct SiFiveEPRCIState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion mmio; + uint32_t hfrosccfg; + uint32_t hfxosccfg; + uint32_t pllcfg; + uint32_t plloutdiv; +} SiFiveEPRCIState; + +DeviceState *sifive_e_prci_create(hwaddr addr); + +#endif diff --git a/include/hw/riscv/sifive_prci.h b/include/hw/riscv/sifive_prci.h deleted file mode 100644 index bd51c4a..0000000 --- a/include/hw/riscv/sifive_prci.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * QEMU SiFive PRCI (Power, Reset, Clock, Interrupt) interface - * - * Copyright (c) 2017 SiFive, Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2 or later, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifndef HW_SIFIVE_PRCI_H -#define HW_SIFIVE_PRCI_H - -enum { - SIFIVE_PRCI_HFROSCCFG = 0x0, - SIFIVE_PRCI_HFXOSCCFG = 0x4, - SIFIVE_PRCI_PLLCFG = 0x8, - SIFIVE_PRCI_PLLOUTDIV = 0xC -}; - -enum { - SIFIVE_PRCI_HFROSCCFG_RDY = (1 << 31), - SIFIVE_PRCI_HFROSCCFG_EN = (1 << 30) -}; - -enum { - SIFIVE_PRCI_HFXOSCCFG_RDY = (1 << 31), - SIFIVE_PRCI_HFXOSCCFG_EN = (1 << 30) -}; - -enum { - SIFIVE_PRCI_PLLCFG_PLLSEL = (1 << 16), - SIFIVE_PRCI_PLLCFG_REFSEL = (1 << 17), - SIFIVE_PRCI_PLLCFG_BYPASS = (1 << 18), - SIFIVE_PRCI_PLLCFG_LOCK = (1 << 31) -}; - -enum { - SIFIVE_PRCI_PLLOUTDIV_DIV1 = (1 << 8) -}; - -#define TYPE_SIFIVE_PRCI "riscv.sifive.prci" - -#define SIFIVE_PRCI(obj) \ - OBJECT_CHECK(SiFivePRCIState, (obj), TYPE_SIFIVE_PRCI) - -typedef struct SiFivePRCIState { - /*< private >*/ - SysBusDevice parent_obj; - - /*< public >*/ - MemoryRegion mmio; - uint32_t hfrosccfg; - uint32_t hfxosccfg; - uint32_t pllcfg; - uint32_t plloutdiv; -} SiFivePRCIState; - -DeviceState *sifive_prci_create(hwaddr addr); - -#endif From patchwork Tue Aug 27 14:58:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117141 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 8AECF14D5 for ; Tue, 27 Aug 2019 15:06:20 +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 616AA217F5 for ; Tue, 27 Aug 2019 15:06:20 +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="jcoWEO1A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 616AA217F5 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]:52408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d35-0001Yt-0K for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:06:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cw7-0003K1-NT for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cw1-0003Zn-1m for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:03 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45917) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cvz-0003Ti-2e; Tue, 27 Aug 2019 10:58:59 -0400 Received: by mail-pl1-x641.google.com with SMTP id y8so11933300plr.12; Tue, 27 Aug 2019 07:58:56 -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:mime-version :content-transfer-encoding; bh=4WJCx+KkFqxUiJ7i2t7dWrFeqJqfy5xQ4bHLONc/qpY=; b=jcoWEO1A6OxaVmdhWNZzSz982QUsm06A6E1Ua7B/JSvRwfany1dfsLYJ2BWIEfYUez pDawc8Xvi8b1QmI3EXxEgHYTJqMjJI5RlWH3QLRGBIkb+wgjUshOHy/Gqz0QT/+TgUco G8VI4EWoSfIvEIKeO1VKY8c5DTJDVWTynIg561qkaxazSjAYsW/NBkt3tR+sDvTshGjJ K9T6VNkKjAPcv/EQUd1rCF7fhVgHy7nQSJ6KFaJgbzYwGqc/uvQATWC+1Pxm5Fz9TkL8 aK09DEPnO+YMZzFmauzQ6aAXnMyewhduVmy6BXP0IrHFGQyrsYeeDJR4NF0NdJVWiFsN k5hA== 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:mime-version:content-transfer-encoding; bh=4WJCx+KkFqxUiJ7i2t7dWrFeqJqfy5xQ4bHLONc/qpY=; b=IV2IjAlFQopMp1dxjq3lKTHKXby+iS9HRTusgRqn4dFRU3GEkv/I7FZiWZv6QwU3F2 kLVtiJqGNCeptOkdZsbwXQbMEEGcIAalwGudav7mKcRrC7rEZevTpPp701XtBl+EOWHi brFkcycQlLrQSfcibTRRi6TZFzBB8fF8ouCYODWF5+FzcJ3KOxsW4gP6MsZoUdFOgZ+5 STrCQ/1qhNLVqgl+4DrfWdqb0SALruAxAt84GKwZjHDBdEWgDoJz3/juvJBvp8vti/ey SbkDSYa0Bo/6h3abLyX7mAoPe1xjrnzIAh9qeecSU35iY25sOc2Q5qM/Gu6cS8HJHfbu lZzQ== X-Gm-Message-State: APjAAAUx2e6pVn6l1nPSDajmMLY8rvY9AEtK+PK6QxxmnD2o2N5tjz34 p294B9Pv96GdCVQ1L9YOBYs= X-Google-Smtp-Source: APXvYqxqFxxBhnZKLBbo6FYA53O8YE0G27r5P+0+UXNc7jm8/DQ3ksmlKewHKCVgj4G1XvJwZcSWNg== X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr25026985plb.239.1566917936021; Tue, 27 Aug 2019 07:58:56 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.55 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:55 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:19 -0700 Message-Id: <1566917919-25381-11-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> MIME-Version: 1.0 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 v6 10/30] riscv: sifive_e: prci: Fix a typo of hfxosccfg register programming 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" For hfxosccfg register programming, SIFIVE_E_PRCI_HFXOSCCFG_RDY and SIFIVE_E_PRCI_HFXOSCCFG_EN should be used. Signed-off-by: Bin Meng Acked-by: Alistair Francis Reviewed-by: Chih-Min Chao Reviewed-by: Philippe Mathieu-Daudé --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_e_prci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/sifive_e_prci.c b/hw/riscv/sifive_e_prci.c index c514032..71de089 100644 --- a/hw/riscv/sifive_e_prci.c +++ b/hw/riscv/sifive_e_prci.c @@ -90,7 +90,7 @@ static void sifive_e_prci_init(Object *obj) sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); s->hfrosccfg = (SIFIVE_E_PRCI_HFROSCCFG_RDY | SIFIVE_E_PRCI_HFROSCCFG_EN); - s->hfxosccfg = (SIFIVE_E_PRCI_HFROSCCFG_RDY | SIFIVE_E_PRCI_HFROSCCFG_EN); + s->hfxosccfg = (SIFIVE_E_PRCI_HFXOSCCFG_RDY | SIFIVE_E_PRCI_HFXOSCCFG_EN); s->pllcfg = (SIFIVE_E_PRCI_PLLCFG_REFSEL | SIFIVE_E_PRCI_PLLCFG_BYPASS | SIFIVE_E_PRCI_PLLCFG_LOCK); s->plloutdiv = SIFIVE_E_PRCI_PLLOUTDIV_DIV1; From patchwork Tue Aug 27 14:58:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117143 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 AD4DC14DE for ; Tue, 27 Aug 2019 15:07:19 +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 80D68206E0 for ; Tue, 27 Aug 2019 15:07:19 +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="qm8P/mEU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80D68206E0 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]:52416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d42-0002kR-0Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:07:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46763) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwE-0003Kz-CC for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cw7-0003jH-Kq for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:09 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:45918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cw1-0003Vq-2W; Tue, 27 Aug 2019 10:59:02 -0400 Received: by mail-pl1-x642.google.com with SMTP id y8so11933328plr.12; Tue, 27 Aug 2019 07:58:57 -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=ErrTzEEaH5aNtZRQ7ubqrvTfgn5HEr8cg14yqsqvLuo=; b=qm8P/mEUshfOkuRiceSGWGTZqz/IX9pJTLBn3ssIAQwIoievZrh6aVrb7lteyj8aez HSM9YD9EAUrVM75wkq1ruOx+F2ZVun+WEbiFRiUs6ls0pEjZAPgy3oycA/9aV/UjFtx7 Wlj5s67zIUfaspWevWvSYTKrUojo+PVO5P0RlAZXbTq5EsCNL/ihaU4jmGpHI76QmtLl jznzRSw62qfNYYEL3Fzxj8NTHw4q2Hymu1mVeUluZWOwI8gAPtMr5xrcg3rcl15Uc/Av GbjfN/hHbxKq8ZC3CFd7Gmu6DXBQllDwAHx63pIIgF01pkJAkXhmDmpfVBG4Yg3OmnBL NrAw== 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=ErrTzEEaH5aNtZRQ7ubqrvTfgn5HEr8cg14yqsqvLuo=; b=ebOK87SO3krZUZlDZs34UNMi3jhBkaauCNRSm8C+UtEcdi9CpdYYo/OPufhJ8euAwi nzR763fWazz/7DmgMRNe5ln7/U0bMIf1bDQlNgqk/MH5nhHF7W0V8romwpDJ7RHIvIaj jOIbF2nax5Asz7FcSuHY6c3/hN21bYNUymK7hW8dEh11at+EGkHSPZgXRHDdokgfUxnu CVf2OKaEo+aUYHyrOOrYw7Ra6Mm3BkfLxS8vy7/N3N09ObyBhACL2e09Gzmskm/C6l/h Vs957Ecc5Ov8AY6Y/XHPw83t2zCdWcAKythWJuPYIbopjPAxXXz92YhBCEAd/jN7K635 BtAg== X-Gm-Message-State: APjAAAWxV4Hl0fh0dov2uds2+hzWPL+Dw8lvXR2smlGX65SQeVxDlHm4 FQ0bnj0WHrB/QZNVTOQp5KM= X-Google-Smtp-Source: APXvYqxgnAO+ds4pEnGHY6HBS7KP2AgX9fhJ4WF42+jEC1REw3fMVF5/ogUd2mXbKvOxmBCkus9I4g== X-Received: by 2002:a17:902:2be6:: with SMTP id l93mr25256352plb.0.1566917937079; Tue, 27 Aug 2019 07:58:57 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.56 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:56 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:20 -0700 Message-Id: <1566917919-25381-12-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::642 Subject: [Qemu-devel] [PATCH v6 11/30] riscv: sifive_e: prci: Update the PRCI register block size 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" Currently the PRCI register block size is set to 0x8000, but in fact 0x1000 is enough, which is also what the manual says. Signed-off-by: Bin Meng Reviewed-by: Chih-Min Chao Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_e_prci.c | 2 +- include/hw/riscv/sifive_e_prci.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_e_prci.c b/hw/riscv/sifive_e_prci.c index 71de089..ad6c624 100644 --- a/hw/riscv/sifive_e_prci.c +++ b/hw/riscv/sifive_e_prci.c @@ -86,7 +86,7 @@ static void sifive_e_prci_init(Object *obj) SiFiveEPRCIState *s = SIFIVE_E_PRCI(obj); memory_region_init_io(&s->mmio, obj, &sifive_e_prci_ops, s, - TYPE_SIFIVE_E_PRCI, 0x8000); + TYPE_SIFIVE_E_PRCI, SIFIVE_E_PRCI_REG_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); s->hfrosccfg = (SIFIVE_E_PRCI_HFROSCCFG_RDY | SIFIVE_E_PRCI_HFROSCCFG_EN); diff --git a/include/hw/riscv/sifive_e_prci.h b/include/hw/riscv/sifive_e_prci.h index c4b76aa..698b0b4 100644 --- a/include/hw/riscv/sifive_e_prci.h +++ b/include/hw/riscv/sifive_e_prci.h @@ -47,6 +47,8 @@ enum { SIFIVE_E_PRCI_PLLOUTDIV_DIV1 = (1 << 8) }; +#define SIFIVE_E_PRCI_REG_SIZE 0x1000 + #define TYPE_SIFIVE_E_PRCI "riscv.sifive.e.prci" #define SIFIVE_E_PRCI(obj) \ From patchwork Tue Aug 27 14:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117173 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 D10F314DE for ; Tue, 27 Aug 2019 15:12:32 +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 A4BAE2070B for ; Tue, 27 Aug 2019 15:12:32 +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="LlpFlNiW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4BAE2070B 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]:52502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d95-0000eO-9B for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46764) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwE-0003L0-CB for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cw7-0003jN-L9 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:09 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cw1-0003Wk-4b; Tue, 27 Aug 2019 10:59:02 -0400 Received: by mail-pg1-x544.google.com with SMTP id d1so12842449pgp.4; Tue, 27 Aug 2019 07:58:58 -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=o5G5QsojHpHLZ4b2+LQv6vJDJLY5Fa7mmuwFQaJWcVM=; b=LlpFlNiWY1rkY43jpTpQb7MD/cZqjwYD+2VXSMjc2SgP2yUCX/jrCuZaioZQdHfobH rkecDGA3fiNMd+A/q+DHv+prxjkMn/V8ENPeK3qr3XRZuQ7+DQkISfQxmYDBY6xtTp4g uP5P+Ac7TO4jnceH5piPvZ/QAYr1/1eSIdow5UTJnNB+ZeZQf8NrpzlFPnZlCc1sb4pK AtWs6TpOK85favCoiShr07RmPpBn0SjjhKaXqDiMli3gX7zhQnwi6gIb66mNANbrdv3t rhLbywihuQio49spRPh4neqr3vJq+r/3z3lKeBBBVJuninJmuQjXcgsM4I6yZqDxCei3 dtHA== 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=o5G5QsojHpHLZ4b2+LQv6vJDJLY5Fa7mmuwFQaJWcVM=; b=i81C86a35V408iHMaCE4cW6NzMc7BQ/3LphbKDgOmoIjKSLXn967oKKJJoggNihJk+ lKMkl/+EKfxKf1jJDt/eTmNZ54bVzpHKOZZq3BC5LYXPnCcreBDiKrped947gIpaeLXQ v+jRtHt8m+Hn2fi8GZeET3POmsgg3jlulp8gLYcnF3fg7UxPmY1mZNygTgmZv9mmM5Ro ByPe4fbM4HIDC/+89ASCi7UQxHP6Rbjr4wVLE328B3RedSDxsTX5+hyDNAmAZGnAUpyC lkB+DPS2U5bzYydztzHiG2g1adCou75Qw0oB/kK6zHHnqAyeZemC/vou4POO7SZ1DpS9 a0WA== X-Gm-Message-State: APjAAAUpQOtQD3/CBYGmGKd3+zxDsuWuQi0fnbyIky79uZkGX6bfPsuX 1iNNoqdahHoEKR3Kq4F98pY= X-Google-Smtp-Source: APXvYqxYFc1ev1IVwtO9KjiW1BMXoZ66pm1AVfh5A5412bmWba0v/QLJGXZjcgO+dlGcUMEiD7QrdA== X-Received: by 2002:a63:1046:: with SMTP id 6mr22169466pgq.111.1566917938209; Tue, 27 Aug 2019 07:58:58 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.57 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:57 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:21 -0700 Message-Id: <1566917919-25381-13-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::544 Subject: [Qemu-devel] [PATCH v6 12/30] riscv: sifive_e: Drop sifive_mmio_emulate() 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" Use create_unimplemented_device() instead. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: - drop patch "riscv: sifive: Move sifive_mmio_emulate() to a common place" - new patch "riscv: sifive_e: Drop sifive_mmio_emulate()" hw/riscv/sifive_e.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 2d67670..040d59f 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -37,6 +37,7 @@ #include "hw/loader.h" #include "hw/sysbus.h" #include "hw/char/serial.h" +#include "hw/misc/unimp.h" #include "target/riscv/cpu.h" #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_plic.h" @@ -74,14 +75,6 @@ static const struct MemmapEntry { [SIFIVE_E_DTIM] = { 0x80000000, 0x4000 } }; -static void sifive_mmio_emulate(MemoryRegion *parent, const char *name, - uintptr_t offset, uintptr_t length) -{ - MemoryRegion *mock_mmio = g_new(MemoryRegion, 1); - memory_region_init_ram(mock_mmio, NULL, name, length, &error_fatal); - memory_region_add_subregion(parent, offset, mock_mmio); -} - static void riscv_sifive_e_init(MachineState *machine) { const struct MemmapEntry *memmap = sifive_e_memmap; @@ -172,7 +165,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) sifive_clint_create(memmap[SIFIVE_E_CLINT].base, memmap[SIFIVE_E_CLINT].size, ms->smp.cpus, SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.aon", + create_unimplemented_device("riscv.sifive.e.aon", memmap[SIFIVE_E_AON].base, memmap[SIFIVE_E_AON].size); sifive_e_prci_create(memmap[SIFIVE_E_PRCI].base); @@ -199,19 +192,19 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) sifive_uart_create(sys_mem, memmap[SIFIVE_E_UART0].base, serial_hd(0), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_E_UART0_IRQ)); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.qspi0", + create_unimplemented_device("riscv.sifive.e.qspi0", memmap[SIFIVE_E_QSPI0].base, memmap[SIFIVE_E_QSPI0].size); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.pwm0", + create_unimplemented_device("riscv.sifive.e.pwm0", memmap[SIFIVE_E_PWM0].base, memmap[SIFIVE_E_PWM0].size); sifive_uart_create(sys_mem, memmap[SIFIVE_E_UART1].base, serial_hd(1), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_E_UART1_IRQ)); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.qspi1", + create_unimplemented_device("riscv.sifive.e.qspi1", memmap[SIFIVE_E_QSPI1].base, memmap[SIFIVE_E_QSPI1].size); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.pwm1", + create_unimplemented_device("riscv.sifive.e.pwm1", memmap[SIFIVE_E_PWM1].base, memmap[SIFIVE_E_PWM1].size); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.qspi2", + create_unimplemented_device("riscv.sifive.e.qspi2", memmap[SIFIVE_E_QSPI2].base, memmap[SIFIVE_E_QSPI2].size); - sifive_mmio_emulate(sys_mem, "riscv.sifive.e.pwm2", + create_unimplemented_device("riscv.sifive.e.pwm2", memmap[SIFIVE_E_PWM2].base, memmap[SIFIVE_E_PWM2].size); /* Flash memory */ From patchwork Tue Aug 27 14:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117181 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 0200A14DE for ; Tue, 27 Aug 2019 15:16:22 +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 CC5A32070B for ; Tue, 27 Aug 2019 15:16:21 +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="e0pd/BGf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC5A32070B 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]:52540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dCm-0004mB-EW for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:16:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46819) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwI-0003Mq-Ko for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwE-0003lE-GH for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:17 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:46903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cw9-0003Yn-O0; Tue, 27 Aug 2019 10:59:10 -0400 Received: by mail-pl1-x641.google.com with SMTP id c2so11928467plz.13; Tue, 27 Aug 2019 07:59:00 -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:mime-version :content-transfer-encoding; bh=79pvv71EJWG9K9pK1hUWRwhAT6GBi9ldC6TE+e9XAbQ=; b=e0pd/BGfQ1eB00IAwbdSEPQgxueP75F/9xn5hvQnC0p7QCHFT3nG9kF83h+jSmjDGi 7OeyUaAkLYFkHKNCTIkuLRgARwzcDHg5LIbjOFUv22Huf9L3uvuS85aOltuYvYREcuJg YlTIlNC6dJsBlBAbHRxLP08NG7iwQ0BILSqzV7OVdNnPVqAwSPos9yEYky5M1CGUwp7j RZ6e7R42tx8IwKr/rgS62GoYzRHnTPQrlcWAN9BVqhJZCB5HEmixoA4vLOoVB/Yj2dW2 yLeQfkF46XEQpSMhY7PZG2eTdPAWfjPDj6D8Un4VnFF6gl7JZh2dj9Xfkhfeln0koBSt hoTg== 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:mime-version:content-transfer-encoding; bh=79pvv71EJWG9K9pK1hUWRwhAT6GBi9ldC6TE+e9XAbQ=; b=MPKFPwXr2pLjvtk1UhhZDQkFoexUk+vRKtnfJqp6bbHw8L/YhN0U/mVHGv0lWXpae0 tmgEuGTgyV4c41h5ClS2lmsdX0VlcYr+NQAxJKHPbni6YxX/yqF8GoTiLAIZf8ZCoaCU 6X7pf2d3HgHyM9tuhP+tnc93qCd44b6hNgJ4BHVvc34CzOJVz1uvysika9mamv2aW+/H KuYfrP1+3kK7PwfaAC6l//XSEql0UIVasImiouYUEk/RdSddtLyMsqt6SwuV15ZTduBm sTgk0fac+ekFFi6H0DeIbRaWR4akNMTs4KLGLPqQziw49u49iw1tcgViomB/Cs9Nj9s+ ctgQ== X-Gm-Message-State: APjAAAUtL1znKa6GOKFs6lLnJrOLkhaObA7U0MkdDqODuYXxJ7n1JWX5 vjUVQ4BffMey+a5d582GsJI= X-Google-Smtp-Source: APXvYqwmDiol2JkJ0RB4lw5k+G7qGJISY91eA5+NmfAepTiCnVPPXXTHRKCNq51O8I1w3cxjdE0QWA== X-Received: by 2002:a17:902:bb94:: with SMTP id m20mr24429061pls.336.1566917939370; Tue, 27 Aug 2019 07:58:59 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:58 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:22 -0700 Message-Id: <1566917919-25381-14-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> MIME-Version: 1.0 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 v6 13/30] riscv: Add a sifive_cpu.h to include both E and U cpu type defines 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" Group SiFive E and U cpu type defines into one header file. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None include/hw/riscv/sifive_cpu.h | 31 +++++++++++++++++++++++++++++++ include/hw/riscv/sifive_e.h | 7 +------ include/hw/riscv/sifive_u.h | 7 +------ 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 include/hw/riscv/sifive_cpu.h diff --git a/include/hw/riscv/sifive_cpu.h b/include/hw/riscv/sifive_cpu.h new file mode 100644 index 0000000..1367996 --- /dev/null +++ b/include/hw/riscv/sifive_cpu.h @@ -0,0 +1,31 @@ +/* + * SiFive CPU types + * + * Copyright (c) 2017 SiFive, Inc. + * Copyright (c) 2019 Bin Meng + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_SIFIVE_CPU_H +#define HW_SIFIVE_CPU_H + +#if defined(TARGET_RISCV32) +#define SIFIVE_E_CPU TYPE_RISCV_CPU_SIFIVE_E31 +#define SIFIVE_U_CPU TYPE_RISCV_CPU_SIFIVE_U34 +#elif defined(TARGET_RISCV64) +#define SIFIVE_E_CPU TYPE_RISCV_CPU_SIFIVE_E51 +#define SIFIVE_U_CPU TYPE_RISCV_CPU_SIFIVE_U54 +#endif + +#endif /* HW_SIFIVE_CPU_H */ diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h index d175b24..e17cdfd 100644 --- a/include/hw/riscv/sifive_e.h +++ b/include/hw/riscv/sifive_e.h @@ -19,6 +19,7 @@ #ifndef HW_SIFIVE_E_H #define HW_SIFIVE_E_H +#include "hw/riscv/sifive_cpu.h" #include "hw/riscv/sifive_gpio.h" #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc" @@ -83,10 +84,4 @@ enum { #define SIFIVE_E_PLIC_CONTEXT_BASE 0x200000 #define SIFIVE_E_PLIC_CONTEXT_STRIDE 0x1000 -#if defined(TARGET_RISCV32) -#define SIFIVE_E_CPU TYPE_RISCV_CPU_SIFIVE_E31 -#elif defined(TARGET_RISCV64) -#define SIFIVE_E_CPU TYPE_RISCV_CPU_SIFIVE_E51 -#endif - #endif diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 892f0ee..4abc621 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -20,6 +20,7 @@ #define HW_SIFIVE_U_H #include "hw/net/cadence_gem.h" +#include "hw/riscv/sifive_cpu.h" #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc" #define RISCV_U_SOC(obj) \ @@ -77,10 +78,4 @@ enum { #define SIFIVE_U_PLIC_CONTEXT_BASE 0x200000 #define SIFIVE_U_PLIC_CONTEXT_STRIDE 0x1000 -#if defined(TARGET_RISCV32) -#define SIFIVE_U_CPU TYPE_RISCV_CPU_SIFIVE_U34 -#elif defined(TARGET_RISCV64) -#define SIFIVE_U_CPU TYPE_RISCV_CPU_SIFIVE_U54 -#endif - #endif From patchwork Tue Aug 27 14:58:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117201 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 484AB14E5 for ; Tue, 27 Aug 2019 15:21:27 +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 1EB5F2070B for ; Tue, 27 Aug 2019 15:21:27 +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="QHRmqnFE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EB5F2070B 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]:52580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dHh-0000AU-RD for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:21:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46849) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwL-0003NR-G3 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwH-0003mG-T8 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:19 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:40550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwE-0003ZU-L6; Tue, 27 Aug 2019 10:59:14 -0400 Received: by mail-pl1-x644.google.com with SMTP id h3so11910335pls.7; Tue, 27 Aug 2019 07:59:01 -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=ODEtlj8wjeSL4VvR5EsvCfx+5VyX4hqhU8FC/9/mIoM=; b=QHRmqnFEp93OhUGVLzjExczv9+Vkrau6XH+7eusj7BxwwMKIpFsOPXHZMqQfCiK97O g1y4ue9bd5CwuG8pIgv7prDogyNRQ2PWQfe+QczePmSAIXzt78oKSKZWui8BKAiZ+4tt ICuRKdsJD7s9IuGMrZdplTFFbcCWPfyRksvX85DX4bO9OG5OCOkaBqkbq18GRUFx3OLj Gj7KmkbOs49WzZld0uud2dpPoJzSLVa27sx8tqD6eliGS5F11zcxhUJ6gGkHl7hKdSVv ztWRamAhxYPRfAqSlbsxuYW5bwDN3NNDkome2TpBKTXGwX0pheafM8trmDN88z/YZx/k MI4g== 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=ODEtlj8wjeSL4VvR5EsvCfx+5VyX4hqhU8FC/9/mIoM=; b=fJIRPn7vYSWL8oKcFRM4s4lVjF/jCYRbkJDXpDtF5RxktKyhNOYSRlXWz6yfUfIg8B W/C3OwpX9ZyC50zbSgt2P9jJt7lTGaf3qnGfZrsrFGZe1OM+nphUWBo/l85KLT+Dlv4X jLBBvZ3kwkaqEFwwlco7RMGoe9IG8SBIPGAM1ohLl5Xpv8+z+KoxNpPoJ+ADLXvfyNmb 1aPJY9q3fHd7n06Yaogrr+V5EPt9hTHkXMNQLcjvgNlLRetyUcVQG/jOVSbET/HF9Xkr Tl7JsZuK7SpU7ain58DZk/oUbKUo1VWrZoXOMWpK/GEYDibHccSAokzoOUxtKmIuZSz9 fDwA== X-Gm-Message-State: APjAAAWyEwJTmj/oKR1LLvw6iKFIT3JvOe6LCBxjlYR2d8EjP3aJbdMV BdQcbzcprYA+JAWYnG3pQTc= X-Google-Smtp-Source: APXvYqxfehCXKQTeOybHIH1p2joB+EHbsoozBBj2eLZmRDDuyMazsm2eNRyIxvHkM55ptWVLl//Tfw== X-Received: by 2002:a17:902:3003:: with SMTP id u3mr12386085plb.161.1566917940715; Tue, 27 Aug 2019 07:59:00 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.58.59 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:58:59 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:23 -0700 Message-Id: <1566917919-25381-15-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 14/30] riscv: hart: Extract hart realize to a separate routine 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" Currently riscv_harts_realize() creates all harts based on the same cpu type given in the hart array property. With current implementation it can only create homogeneous harts. Exact the hart realize to a separate routine in preparation for supporting multiple hart arrays. Note the file header says the RISC-V hart array holds the state of a heterogeneous array of RISC-V harts, which is not true. Update the comment to mention homogeneous array of RISC-V harts. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/riscv_hart.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index ca69a1b..9deef869 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -3,7 +3,7 @@ * * Copyright (c) 2017 SiFive, Inc. * - * Holds the state of a heterogenous array of RISC-V harts + * Holds the state of a homogeneous array of RISC-V harts * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -37,26 +37,33 @@ static void riscv_harts_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } +static void riscv_hart_realize(RISCVHartArrayState *s, int idx, + char *cpu_type, Error **errp) +{ + Error *err = NULL; + + object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], + sizeof(RISCVCPU), cpu_type, + &error_abort, NULL); + s->harts[idx].env.mhartid = idx; + qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]); + object_property_set_bool(OBJECT(&s->harts[idx]), true, + "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } +} + static void riscv_harts_realize(DeviceState *dev, Error **errp) { RISCVHartArrayState *s = RISCV_HART_ARRAY(dev); - Error *err = NULL; int n; s->harts = g_new0(RISCVCPU, s->num_harts); for (n = 0; n < s->num_harts; n++) { - object_initialize_child(OBJECT(s), "harts[*]", &s->harts[n], - sizeof(RISCVCPU), s->cpu_type, - &error_abort, NULL); - s->harts[n].env.mhartid = n; - qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]); - object_property_set_bool(OBJECT(&s->harts[n]), true, - "realized", &err); - if (err) { - error_propagate(errp, err); - return; - } + riscv_hart_realize(s, n, s->cpu_type, errp); } } From patchwork Tue Aug 27 14:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117177 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 E5E8514D5 for ; Tue, 27 Aug 2019 15:14:09 +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 BB7B22070B for ; Tue, 27 Aug 2019 15:14:09 +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="uq+EV8N1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB7B22070B 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]:52509 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dAe-0002Nr-KE for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46941) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwS-0003On-1g for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwO-0003ow-9E for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:26 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwL-0003bU-CK; Tue, 27 Aug 2019 10:59:21 -0400 Received: by mail-pf1-x443.google.com with SMTP id o70so14292415pfg.5; Tue, 27 Aug 2019 07:59:02 -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=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=uq+EV8N1IlJV9bRL7iLPiVLeUBJGzU4ZDSAZrtKNNVt4nD6Wh5w/CZ5/KOtzVRfsnQ qwYnxLuYyxaHhCrYDOq9zOqHhqH7Slmr3K1rBxtbK/9WugxZcyMqDs0vxMRkzEDhNrZY kHaER/02xdsoMg6GMFtSa/CWHZCZwm8HcFP4hvcMv6adkiYJrkLex2BKFd3MdygB0WUu uvIVavGFTKdrn5OOYvYpbJ71TwENKDYbq0YYf2TviOLHvpAbWELvmfvxTOQhIU4A1dn/ i28HVnrczu85nstJ/iOvKyzm6jiCWmfJ6faHZqvHhS1cPmy2bXJD04AC/1TaDR9T0CVE YcNg== 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=d7us2fu3ANyV0m5Az+EJmBw0pv/vpKhnOtU+MafJ4Gw=; b=HwkJrBkrb9xGtt6AbG8xnxKv8QlFBM53ORxWUv9EoXMpN6Cy8Vydy6jfsHAqFiMmp/ KWYEBU/YDwo3rlZBWYLyWrzu9AzJeXM/f72FKsprxZNikOw6jLfh3QXi5sSF8Xcrc23H LU3Bq4szXRTTTkupAc8UB6GKATssueqfadn1WizVJ0z9rl310MbUP0HtIxXjgBL/DAkj JjNGoezxQkYSZle1PfVVFvNBqqFv4Yghdad4H2U2g3rGRd1EfalfplpsuHv8xTCNqh3X qxHSZjmf26yiw0kYhWyfG9+MbDJ0NgM8RSA+DcdppKFRQe+BaYV9HpQMQ2gaxIPfOHwJ FTmA== X-Gm-Message-State: APjAAAWFUlVKqKrwF73ntxIkdTrLKQOHn2XlsRLCBzty1wTM0oGH9EQ5 Wt/qzDtwJsaxGr7pNzDx1Oc= X-Google-Smtp-Source: APXvYqwOylZlWtK6LxsNDbmSpUoQhUeW0iJgmOuiN1XMnDQgc3DjafD11YlT9v0LikmGxM9trpmmEQ== X-Received: by 2002:a62:ee0e:: with SMTP id e14mr10365737pfi.31.1566917941905; Tue, 27 Aug 2019 07:59:01 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.00 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:01 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:24 -0700 Message-Id: <1566917919-25381-16-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::443 Subject: [Qemu-devel] [PATCH v6 15/30] riscv: hart: Add a "hartid-base" property to RISC-V hart array 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" At present each hart's hartid in a RISC-V hart array is assigned the same value of its index in the hart array. But for a system that has multiple hart arrays, this is not the case any more. Add a new "hartid-base" property so that hartid number can be assigned based on the property value. Signed-off-by: Bin Meng --- Changes in v6: - use s->hartid_base directly, instead of an extra variable Changes in v5: None Changes in v4: - new patch to add a "hartid-base" property to RISC-V hart array Changes in v3: None Changes in v2: None hw/riscv/riscv_hart.c | 7 ++++--- include/hw/riscv/riscv_hart.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index 9deef869..7cfc835 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -27,6 +27,7 @@ static Property riscv_harts_props[] = { DEFINE_PROP_UINT32("num-harts", RISCVHartArrayState, num_harts, 1), + DEFINE_PROP_UINT32("hartid-base", RISCVHartArrayState, hartid_base, 0), DEFINE_PROP_STRING("cpu-type", RISCVHartArrayState, cpu_type), DEFINE_PROP_END_OF_LIST(), }; @@ -37,7 +38,7 @@ static void riscv_harts_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } -static void riscv_hart_realize(RISCVHartArrayState *s, int idx, +static void riscv_hart_realize(RISCVHartArrayState *s, int idx, uint32_t hartid, char *cpu_type, Error **errp) { Error *err = NULL; @@ -45,7 +46,7 @@ static void riscv_hart_realize(RISCVHartArrayState *s, int idx, object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], sizeof(RISCVCPU), cpu_type, &error_abort, NULL); - s->harts[idx].env.mhartid = idx; + s->harts[idx].env.mhartid = hartid; qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]); object_property_set_bool(OBJECT(&s->harts[idx]), true, "realized", &err); @@ -63,7 +64,7 @@ static void riscv_harts_realize(DeviceState *dev, Error **errp) s->harts = g_new0(RISCVCPU, s->num_harts); for (n = 0; n < s->num_harts; n++) { - riscv_hart_realize(s, n, s->cpu_type, errp); + riscv_hart_realize(s, n, s->hartid_base + n, s->cpu_type, errp); } } diff --git a/include/hw/riscv/riscv_hart.h b/include/hw/riscv/riscv_hart.h index 0671d88..1984e30 100644 --- a/include/hw/riscv/riscv_hart.h +++ b/include/hw/riscv/riscv_hart.h @@ -32,6 +32,7 @@ typedef struct RISCVHartArrayState { /*< public >*/ uint32_t num_harts; + uint32_t hartid_base; char *cpu_type; RISCVCPU *harts; } RISCVHartArrayState; From patchwork Tue Aug 27 14:58:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117161 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 694831800 for ; Tue, 27 Aug 2019 15:09:21 +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 3F6C3214DA for ; Tue, 27 Aug 2019 15:09:21 +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="QdZpBD0q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F6C3214DA 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]:52470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d60-0005NR-BD for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:09:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46854) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwL-0003Ni-Hq for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwJ-0003nB-Sl for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:21 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:38403) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwH-0003eW-S5; Tue, 27 Aug 2019 10:59:18 -0400 Received: by mail-pl1-x643.google.com with SMTP id w11so11459917plp.5; Tue, 27 Aug 2019 07:59:03 -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=XIkLolLkHu2jtT+JdqJX9hnPTa5guiQoqfo7x+mU4Yw=; b=QdZpBD0qOg6+gXhZpguix95v7EsDQzrDKkcOdyOJP+xh2rsqZ+26TNDbf8U4P4mvQ0 TQoK19PqMED1mv066dvcbJpepJanmAzmcM4JZL5Qy2qOZuMuAsd9mjeBQR6RYVvhnpj6 Z1hKSl5c9lrRSnQiMHDuGZKldSLFwkOtprGWytqEtj2eb4lFvzkZdXbOrvc+pbqlUAXz sLF7VvyfEET+1dn+cE1uUElJpcxNCq5ZQFrMapaj7+lW9zh95HBGvvkftoATg8dihp/s TqZqweEoR3k4pltUBEXQ+zbURtGsrA4zHXCRaMCDQgeqHPFOPyHTXH8jR7eECECgOKRe ZOuw== 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=XIkLolLkHu2jtT+JdqJX9hnPTa5guiQoqfo7x+mU4Yw=; b=PQMpChmVPoOsz9Q67xhoLpjbbGqCX0ZtNoMIX5YQ5AoGkB0UYaE9uBLKC8HRf8YhHA I6MPYOJqCDajFwlth8K0qhG/pNshrPjI/m/ytcOgVthlI2Uw1zD3MwYl8+cnXE/6c+Ce DqmSIlMYAU+2t+scRi7G0tXimogP5Ojxc1XSsN3Gn2kopOIlxGYD2LwJgkrag0JcDXs7 EZwMP1UaZm/SQxTIYNw1rdOofAFBK/0uE46L0q13T0TlfO0iuh6rzIa0FxzQq6bm7NTP aLsBnr8kcU5E2ZhkGm9zRCKtIP0tbxhJ2KhHXJVmG1/KsNueMJU3djwRKIfUOjrVvxEI KYLA== X-Gm-Message-State: APjAAAWdI1LrlvDwFZl2jUQQj7ruW/s4miJtLgD/QysSl22LlztdtXy5 hzeI3jJVIqoUVEfNiEFMV10= X-Google-Smtp-Source: APXvYqxpj4NoFAbmdDXXuZXzHAU07bDFTy6Rfe39g1fr+U/tNaDEbdmqdhZ2YXwzjXDnpauzunP2ZQ== X-Received: by 2002:a17:902:720a:: with SMTP id ba10mr22858949plb.231.1566917943031; Tue, 27 Aug 2019 07:59:03 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:02 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:25 -0700 Message-Id: <1566917919-25381-17-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::643 Subject: [Qemu-devel] [PATCH v6 16/30] riscv: sifive_u: Set the minimum number of cpus to 2 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" It is not useful if we only have one management CPU. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - use management cpu count + 1 for the min_cpus Changes in v2: - update the file header to indicate at least 2 harts are created hw/riscv/sifive_u.c | 4 +++- include/hw/riscv/sifive_u.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 3f58f61..67b503a 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -10,7 +10,8 @@ * 1) CLINT (Core Level Interruptor) * 2) PLIC (Platform Level Interrupt Controller) * - * This board currently uses a hardcoded devicetree that indicates one hart. + * This board currently generates devicetree dynamically that indicates at least + * two harts. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -433,6 +434,7 @@ static void riscv_sifive_u_machine_init(MachineClass *mc) * management CPU. */ mc->max_cpus = 4; + mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1; } DEFINE_MACHINE("sifive_u", riscv_sifive_u_machine_init) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 4abc621..32d680c 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -68,6 +68,8 @@ enum { SIFIVE_U_GEM_CLOCK_FREQ = 125000000 }; +#define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 + #define SIFIVE_U_PLIC_HART_CONFIG "MS" #define SIFIVE_U_PLIC_NUM_SOURCES 54 #define SIFIVE_U_PLIC_NUM_PRIORITIES 7 From patchwork Tue Aug 27 14:58:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117211 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 8268914DB for ; Tue, 27 Aug 2019 15:26:28 +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 488A0206BF for ; Tue, 27 Aug 2019 15:26:28 +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="p8Dlcpmk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 488A0206BF 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]:52640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dMY-0005yf-R1 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:26:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47162) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwa-0003cx-Df for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003sJ-NZ for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:36 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:39995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003gD-Ix; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pf1-x443.google.com with SMTP id w16so14285290pfn.7; Tue, 27 Aug 2019 07:59:04 -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=K/QjoSrZSncRwXvKc/BnOUWqW1TGuvsrLcrTWiBRDHA=; b=p8DlcpmkAOkBt434si/YukSjvbPrKftMU8rGyFmfu89hLdfzaAv3D3STmdp2vbyeYR LB7AWoMyJR5bCdsuNPCoq4aapBYld1QXFk2j1IeVOtgJVpWTqVoXUOOtFLhjjTg8NXRC lr1E5oaqxJqAS+3JLYC74ELj/L8DXCKqcokDcQ8ydUi18YvQImkzMMr4UnkYlilR5POJ KbgMb13ZBZccpjdsEYhXnLJHSk3FEYemCnXPwWTY+t/8VKlXQywr/CSfG1fsPJF1PFHr HoLJomyNBJGVvZyWWu3D8jqxIioLdpAkjeDHd24jKjqg8bHRahVgPLYIglFjPLVr8JuG Ss3A== 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=K/QjoSrZSncRwXvKc/BnOUWqW1TGuvsrLcrTWiBRDHA=; b=UHpOZp+x857USU5YsD3Z1k5xmqx3moORt98Gf/EifM1cAgbB6uuf3E+SgAZKWf4N4h qum56Q+HeVwfJzzwomBeflg0ijVIWLYcs7TDH7lpHyjfFbkHVFng7T/P2WYgx0ls9E7K fWclhn7i6DzbnwQtkd1CrEhl/rzCUXbJhhehw7ZxdWeZW3WwAIZ7+VPwH1YnXPhmQbx6 JpLwPKJOjasl170wDmMqC17rUORiVruRKGrnY+vpc4r/K+YOWKjXS4ATUi2CoXDBKU+I CMnp1d87cn6JwDiAAyV8gnhm3sFzZOWcZksDsGAHw3FOnytstuUw+k7dBpTWv6xa7n1P W+ag== X-Gm-Message-State: APjAAAUmxCPdhx0sGytpOuySzEuH0m9CZn8mFc04s/ul5a5Yg8J8kASZ A98pk3jrtfhpOYzNdzD/Lm8PCn2K X-Google-Smtp-Source: APXvYqwc50m0L03smyGQJkz2BkYLF0ioa6W5tZ7xRDRZqBz5XN/IinJbX2NJf2qjB0/xts4rkPYcKw== X-Received: by 2002:a65:6401:: with SMTP id a1mr21622927pgv.42.1566917944048; Tue, 27 Aug 2019 07:59:04 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.03 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:03 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:26 -0700 Message-Id: <1566917919-25381-18-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::443 Subject: [Qemu-devel] [PATCH v6 17/30] riscv: sifive_u: Update hart configuration to reflect the real FU540 SoC 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" The FU540-C000 includes a 64-bit E51 RISC-V core and four 64-bit U54 RISC-V cores. Currently the sifive_u machine only populates 4 U54 cores. Update the max cpu number to 5 to reflect the real hardware, by creating 2 CPU clusters as containers for RISC-V hart arrays to populate heterogeneous harts. The cpu nodes in the generated DTS have been updated as well. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: - generate u cpus unconditionally (not test ms->smp.cpus > 1) since the minimal required number of cpu is now 2, due to this patch is reordered Changes in v5: None Changes in v4: - changed to create clusters for each cpu type Changes in v3: - changed to use macros for management and compute cpu count Changes in v2: - fixed the "interrupts-extended" property size hw/riscv/sifive_u.c | 92 +++++++++++++++++++++++++++++++++------------ include/hw/riscv/sifive_u.h | 6 ++- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 67b503a..7f51d9d 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -11,7 +11,7 @@ * 2) PLIC (Platform Level Interrupt Controller) * * This board currently generates devicetree dynamically that indicates at least - * two harts. + * two harts and up to five harts. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -35,6 +35,7 @@ #include "hw/loader.h" #include "hw/sysbus.h" #include "hw/char/serial.h" +#include "hw/cpu/cluster.h" #include "target/riscv/cpu.h" #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_plic.h" @@ -70,6 +71,7 @@ static const struct MemmapEntry { static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, uint64_t mem_size, const char *cmdline) { + MachineState *ms = MACHINE(qdev_get_machine()); void *fdt; int cpu; uint32_t *cells; @@ -110,15 +112,21 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0x0); qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1); - for (cpu = s->soc.cpus.num_harts - 1; cpu >= 0; cpu--) { + for (cpu = ms->smp.cpus - 1; cpu >= 0; cpu--) { int cpu_phandle = phandle++; nodename = g_strdup_printf("/cpus/cpu@%d", cpu); char *intc = g_strdup_printf("/cpus/cpu@%d/interrupt-controller", cpu); - char *isa = riscv_isa_string(&s->soc.cpus.harts[cpu]); + char *isa; qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_cell(fdt, nodename, "clock-frequency", SIFIVE_U_CLOCK_FREQ); - qemu_fdt_setprop_string(fdt, nodename, "mmu-type", "riscv,sv48"); + /* cpu 0 is the management hart that does not have mmu */ + if (cpu != 0) { + qemu_fdt_setprop_string(fdt, nodename, "mmu-type", "riscv,sv48"); + isa = riscv_isa_string(&s->soc.u_cpus.harts[cpu - 1]); + } else { + isa = riscv_isa_string(&s->soc.e_cpus.harts[0]); + } qemu_fdt_setprop_string(fdt, nodename, "riscv,isa", isa); qemu_fdt_setprop_string(fdt, nodename, "compatible", "riscv"); qemu_fdt_setprop_string(fdt, nodename, "status", "okay"); @@ -134,8 +142,8 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, g_free(nodename); } - cells = g_new0(uint32_t, s->soc.cpus.num_harts * 4); - for (cpu = 0; cpu < s->soc.cpus.num_harts; cpu++) { + cells = g_new0(uint32_t, ms->smp.cpus * 4); + for (cpu = 0; cpu < ms->smp.cpus; cpu++) { nodename = g_strdup_printf("/cpus/cpu@%d/interrupt-controller", cpu); uint32_t intc_phandle = qemu_fdt_get_phandle(fdt, nodename); @@ -153,20 +161,26 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, 0x0, memmap[SIFIVE_U_CLINT].base, 0x0, memmap[SIFIVE_U_CLINT].size); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", - cells, s->soc.cpus.num_harts * sizeof(uint32_t) * 4); + cells, ms->smp.cpus * sizeof(uint32_t) * 4); g_free(cells); g_free(nodename); plic_phandle = phandle++; - cells = g_new0(uint32_t, s->soc.cpus.num_harts * 4); - for (cpu = 0; cpu < s->soc.cpus.num_harts; cpu++) { + cells = g_new0(uint32_t, ms->smp.cpus * 4 - 2); + for (cpu = 0; cpu < ms->smp.cpus; cpu++) { nodename = g_strdup_printf("/cpus/cpu@%d/interrupt-controller", cpu); uint32_t intc_phandle = qemu_fdt_get_phandle(fdt, nodename); - cells[cpu * 4 + 0] = cpu_to_be32(intc_phandle); - cells[cpu * 4 + 1] = cpu_to_be32(IRQ_M_EXT); - cells[cpu * 4 + 2] = cpu_to_be32(intc_phandle); - cells[cpu * 4 + 3] = cpu_to_be32(IRQ_S_EXT); + /* cpu 0 is the management hart that does not have S-mode */ + if (cpu == 0) { + cells[0] = cpu_to_be32(intc_phandle); + cells[1] = cpu_to_be32(IRQ_M_EXT); + } else { + cells[cpu * 4 - 2] = cpu_to_be32(intc_phandle); + cells[cpu * 4 - 1] = cpu_to_be32(IRQ_M_EXT); + cells[cpu * 4 + 0] = cpu_to_be32(intc_phandle); + cells[cpu * 4 + 1] = cpu_to_be32(IRQ_S_EXT); + } g_free(nodename); } nodename = g_strdup_printf("/soc/interrupt-controller@%lx", @@ -176,7 +190,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "compatible", "riscv,plic0"); qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", - cells, s->soc.cpus.num_harts * sizeof(uint32_t) * 4); + cells, (ms->smp.cpus * 4 - 2) * sizeof(uint32_t)); qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_PLIC].base, 0x0, memmap[SIFIVE_U_PLIC].size); @@ -339,12 +353,31 @@ static void riscv_sifive_u_soc_init(Object *obj) MachineState *ms = MACHINE(qdev_get_machine()); SiFiveUSoCState *s = RISCV_U_SOC(obj); - object_initialize_child(obj, "cpus", &s->cpus, sizeof(s->cpus), - TYPE_RISCV_HART_ARRAY, &error_abort, NULL); - object_property_set_str(OBJECT(&s->cpus), SIFIVE_U_CPU, "cpu-type", - &error_abort); - object_property_set_int(OBJECT(&s->cpus), ms->smp.cpus, "num-harts", - &error_abort); + object_initialize_child(obj, "e-cluster", &s->e_cluster, + sizeof(s->e_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + qdev_prop_set_uint32(DEVICE(&s->e_cluster), "cluster-id", 0); + + object_initialize_child(OBJECT(&s->e_cluster), "e-cpus", + &s->e_cpus, sizeof(s->e_cpus), + TYPE_RISCV_HART_ARRAY, &error_abort, + NULL); + qdev_prop_set_uint32(DEVICE(&s->e_cpus), "num-harts", 1); + qdev_prop_set_uint32(DEVICE(&s->e_cpus), "hartid-base", 0); + qdev_prop_set_string(DEVICE(&s->e_cpus), "cpu-type", SIFIVE_E_CPU); + + object_initialize_child(obj, "u-cluster", &s->u_cluster, + sizeof(s->u_cluster), TYPE_CPU_CLUSTER, + &error_abort, NULL); + qdev_prop_set_uint32(DEVICE(&s->u_cluster), "cluster-id", 1); + + object_initialize_child(OBJECT(&s->u_cluster), "u-cpus", + &s->u_cpus, sizeof(s->u_cpus), + TYPE_RISCV_HART_ARRAY, &error_abort, + NULL); + qdev_prop_set_uint32(DEVICE(&s->u_cpus), "num-harts", ms->smp.cpus - 1); + qdev_prop_set_uint32(DEVICE(&s->u_cpus), "hartid-base", 1); + qdev_prop_set_string(DEVICE(&s->u_cpus), "cpu-type", SIFIVE_U_CPU); sysbus_init_child_obj(obj, "gem", &s->gem, sizeof(s->gem), TYPE_CADENCE_GEM); @@ -364,7 +397,19 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) Error *err = NULL; NICInfo *nd = &nd_table[0]; - object_property_set_bool(OBJECT(&s->cpus), true, "realized", + object_property_set_bool(OBJECT(&s->e_cpus), true, "realized", + &error_abort); + object_property_set_bool(OBJECT(&s->u_cpus), true, "realized", + &error_abort); + /* + * The cluster must be realized after the RISC-V hart array container, + * as the container's CPU object is only created on realize, and the + * CPU must exist and have been parented into the cluster before the + * cluster is realized. + */ + object_property_set_bool(OBJECT(&s->e_cluster), true, "realized", + &error_abort); + object_property_set_bool(OBJECT(&s->u_cluster), true, "realized", &error_abort); /* boot rom */ @@ -430,10 +475,7 @@ static void riscv_sifive_u_machine_init(MachineClass *mc) { mc->desc = "RISC-V Board compatible with SiFive U SDK"; mc->init = riscv_sifive_u_init; - /* The real hardware has 5 CPUs, but one of them is a small embedded power - * management CPU. - */ - mc->max_cpus = 4; + mc->max_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + SIFIVE_U_COMPUTE_CPU_COUNT; mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1; } diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 32d680c..7a1a4f3 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -31,7 +31,10 @@ typedef struct SiFiveUSoCState { SysBusDevice parent_obj; /*< public >*/ - RISCVHartArrayState cpus; + CPUClusterState e_cluster; + CPUClusterState u_cluster; + RISCVHartArrayState e_cpus; + RISCVHartArrayState u_cpus; DeviceState *plic; CadenceGEMState gem; } SiFiveUSoCState; @@ -69,6 +72,7 @@ enum { }; #define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 +#define SIFIVE_U_COMPUTE_CPU_COUNT 4 #define SIFIVE_U_PLIC_HART_CONFIG "MS" #define SIFIVE_U_PLIC_NUM_SOURCES 54 From patchwork Tue Aug 27 14:58:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117175 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 36D2E14DE for ; Tue, 27 Aug 2019 15:12:39 +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 0D5CD2070B for ; Tue, 27 Aug 2019 15:12:39 +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="U/ib/eEk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D5CD2070B 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]:52504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d9C-0000sO-0c for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwQ-0003OT-9n for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwL-0003o7-GW for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:23 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:39514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwJ-0003hl-Gb; Tue, 27 Aug 2019 10:59:21 -0400 Received: by mail-pl1-x642.google.com with SMTP id z3so11950714pln.6; Tue, 27 Aug 2019 07:59:06 -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=F6B4x3xsQ3LrE7zY0k6hhCP8/PfH3NI3sEzMOKRn1i4=; b=U/ib/eEkHr5c84XKn4ipowSS2JNM1dcTy8P/bLaXcchh3YaFML8TYu2N8trKnyMLq1 lKrfu9PD6rw7cVyOq0/qdsv2VtJIb3L1p3/2UCKkgkj7pjc9xzMBFpj8AxiUKpM7ri5I OMqkcvkmkdIgyZQ5adAhP40hFghyxpBD65WyeeRGL5Kws3m0CAw+8KfiLGISXAzmoKQX Nhh2bdBZpXx/aokfFpmx5ssrx/7OHwZQq7flA0/i2fBLTedaVl6ACi7mfJfOXlBJEtVg tWSh9Xbil2EKxRLZF2uA+3niDHvSAaVgOQUnE7NzxY1QcZxXoYOYbPSdv8wxPbSi7BJm Uq7A== 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=F6B4x3xsQ3LrE7zY0k6hhCP8/PfH3NI3sEzMOKRn1i4=; b=I0aUmVaFxw+mya9q9ZFOjx7agOXJ0WJ8pK/R3QuamO/NzhMtKTGO8LQZ8G9UDuAh4g ImKiyLqmKdA7SBymCZ+kTVllf9hD0aP40BgcaP9dFHCXbnrg5Ci52X6txHzSSKb0k3Er NfP5RHfsZCFoEdCz9guPh/6Bp8KmGVZa63Cvygu1bPzuNKG6UCqYWy8b7v54MRvU9eCn 9+0G7YSuVXc88BcUl1rXX43Yk5/OMlBkJzbhXmT7TZnacXmggtOiN29yX0+V6D1qQDu4 gZMg9i5iUh0TWeBIkW4CWffVUFmRGM0Jgj9AyGFcSoomXn8VUtcRlvMj2YpVIX1dB0+l JfHA== X-Gm-Message-State: APjAAAU5+4zZzyjp0iFGwp8VrJMGxYm2vyFY2d/ryKUv6xktV0BwBCg/ mtcpLS1TGDosZWY5v/O33rA= X-Google-Smtp-Source: APXvYqytxNl5YAOykxVuMCHQhSWQZTBAAnyjdFasAMzqfAEKwM9kQr4RfctFBAkSw0SyOkG+k+nzCA== X-Received: by 2002:a17:902:8609:: with SMTP id f9mr24460307plo.112.1566917945763; Tue, 27 Aug 2019 07:59:05 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:04 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:27 -0700 Message-Id: <1566917919-25381-19-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::642 Subject: [Qemu-devel] [PATCH v6 18/30] riscv: sifive_u: Update PLIC hart topology configuration string 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" With heterogeneous harts config, the PLIC hart topology configuration string are "M,MS,.." because of the monitor hart #0. Suggested-by: Fabien Chouteau Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 7f51d9d..24ae3d1 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -424,10 +424,11 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) plic_hart_config = g_malloc0(plic_hart_config_len); for (i = 0; i < ms->smp.cpus; i++) { if (i != 0) { - strncat(plic_hart_config, ",", plic_hart_config_len); + strncat(plic_hart_config, "," SIFIVE_U_PLIC_HART_CONFIG, + plic_hart_config_len); + } else { + strncat(plic_hart_config, "M", plic_hart_config_len); } - strncat(plic_hart_config, SIFIVE_U_PLIC_HART_CONFIG, - plic_hart_config_len); plic_hart_config_len -= (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1); } From patchwork Tue Aug 27 14:58:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117219 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 1328F1398 for ; Tue, 27 Aug 2019 15:32:29 +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 CB9C32186A for ; Tue, 27 Aug 2019 15:32:28 +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="uO/kyRMb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB9C32186A 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]:52772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dSN-00043j-Kc for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:32:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47125) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwZ-0003bO-BA for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwS-0003r6-8a for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:34 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:41543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwQ-0003j6-W9; Tue, 27 Aug 2019 10:59:27 -0400 Received: by mail-pl1-x644.google.com with SMTP id m9so11909920pls.8; Tue, 27 Aug 2019 07:59:07 -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=vywFFA5HTD3v/PWfCWvmPMIAZW9Ejl9yuZmXMqlf1pI=; b=uO/kyRMbRLwK6e3Q4oNj8TgmBEnrX7qzExjeAZdAxLyt07x7SGA+ALXjqdu2wloKup TQlhXOIa6l2BSJAdK7Fa+GGF3DohUU/XGTNqMvzor3413JT/SXFf/OQ8Nhtzks4osRYK oLUia7B5DVC1BXrUScgZSZGB8omFSd4n5u44AZ0PwOGUXVhWmqFQbiMPsbqI1/8VEF4h Yw8+lyRdAUYMh6kGaxQhjlhGM15WFDkovuFzO3S2HPG7/K+QQC6//+z6Fpy+Qz4MCxvI 4GTsc/WZ117ytC4MF/a4xf/LPA0B/0gIj/YGdoWYjYBBtpOmwlh2nM2cdOWxxphJmfks NGKg== 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=vywFFA5HTD3v/PWfCWvmPMIAZW9Ejl9yuZmXMqlf1pI=; b=EF6eeZzejtyQpIk0g2yZwoFdTMnlIhdm1Fgq1YlRVZwARZXCpTlDwLINHGDfucmkaZ hfk3bx+S3b5m+Gy4zgACIsdnXzxA7tYQg0fSn1YjmZLE2RaGnC2Un7IoRU30jc5tr5pM MvC6Gb/PWHrVxRRuXIrowpkeMgrHaiZrWasAXiqt5PRBvgbb5lc58OO8aSE8BudRZnZN 4a/9ICAiMyL50XOJwySDiyt7ReGi7hr1X41GIyIJwpEQ5M1e4LYBXnz9uVi5r62dXg+i +yYechlmevgnOLYlt8M9RrUU3R0Mb317xUntG0Bj0uCEag8Xg5Gxy8IHzv26mYQvycWH c3pA== X-Gm-Message-State: APjAAAVI5Dq1j9NCRkfbnVrcHVd7s65vRHvuEOkUCkUijjHJPnFoHrjH 3DmQyBwFC+z07Ai05EMyg54= X-Google-Smtp-Source: APXvYqzJEwSjXzsSsn4vTxf1mWl5HFRJzhdtW1At7rUvbCfHSQLCEXpO7re8k2afD+QoefADfHKAvA== X-Received: by 2002:a17:902:e48d:: with SMTP id cj13mr24538419plb.177.1566917946802; Tue, 27 Aug 2019 07:59:06 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:06 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:28 -0700 Message-Id: <1566917919-25381-20-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 19/30] riscv: sifive: Implement PRCI model for FU540 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" This adds a simple PRCI model for FU540 (sifive_u). It has different register layout from the existing PRCI model for FE310 (sifive_e). Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: - fix incorrectly indented comment lines - remove unneeded brackets around assignment Changes in v5: - change to use defines instead of enums - change to use qemu_log_mask(LOG_GUEST_ERROR,...) in sifive_u_prci - creating a 32-bit val variable and using that instead of casting everywhere in sifive_u_prci_write() - move all register initialization to sifive_u_prci_reset() function - drop sifive_u_prci_create() - s/codes that worked/code that works/g Changes in v4: - prefix all macros/variables/functions with SIFIVE_U/sifive_u in the sifive_u_prci driver Changes in v3: None Changes in v2: None hw/riscv/Makefile.objs | 1 + hw/riscv/sifive_u_prci.c | 169 +++++++++++++++++++++++++++++++++++++++ include/hw/riscv/sifive_u_prci.h | 81 +++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100644 hw/riscv/sifive_u_prci.c create mode 100644 include/hw/riscv/sifive_u_prci.h diff --git a/hw/riscv/Makefile.objs b/hw/riscv/Makefile.objs index c859697..b95bbd5 100644 --- a/hw/riscv/Makefile.objs +++ b/hw/riscv/Makefile.objs @@ -8,6 +8,7 @@ obj-$(CONFIG_SIFIVE) += sifive_gpio.o obj-$(CONFIG_SIFIVE) += sifive_plic.o obj-$(CONFIG_SIFIVE) += sifive_test.o obj-$(CONFIG_SIFIVE_U) += sifive_u.o +obj-$(CONFIG_SIFIVE_U) += sifive_u_prci.o obj-$(CONFIG_SIFIVE) += sifive_uart.o obj-$(CONFIG_SPIKE) += spike.o obj-$(CONFIG_RISCV_VIRT) += virt.o diff --git a/hw/riscv/sifive_u_prci.c b/hw/riscv/sifive_u_prci.c new file mode 100644 index 0000000..ade2a1c --- /dev/null +++ b/hw/riscv/sifive_u_prci.c @@ -0,0 +1,169 @@ +/* + * QEMU SiFive U PRCI (Power, Reset, Clock, Interrupt) + * + * Copyright (c) 2019 Bin Meng + * + * Simple model of the PRCI to emulate register reads made by the SDK BSP + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/riscv/sifive_u_prci.h" + +static uint64_t sifive_u_prci_read(void *opaque, hwaddr addr, unsigned int size) +{ + SiFiveUPRCIState *s = opaque; + + switch (addr) { + case SIFIVE_U_PRCI_HFXOSCCFG: + return s->hfxosccfg; + case SIFIVE_U_PRCI_COREPLLCFG0: + return s->corepllcfg0; + case SIFIVE_U_PRCI_DDRPLLCFG0: + return s->ddrpllcfg0; + case SIFIVE_U_PRCI_DDRPLLCFG1: + return s->ddrpllcfg1; + case SIFIVE_U_PRCI_GEMGXLPLLCFG0: + return s->gemgxlpllcfg0; + case SIFIVE_U_PRCI_GEMGXLPLLCFG1: + return s->gemgxlpllcfg1; + case SIFIVE_U_PRCI_CORECLKSEL: + return s->coreclksel; + case SIFIVE_U_PRCI_DEVICESRESET: + return s->devicesreset; + case SIFIVE_U_PRCI_CLKMUXSTATUS: + return s->clkmuxstatus; + } + + qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%x\n", + __func__, (int)addr); + + return 0; +} + +static void sifive_u_prci_write(void *opaque, hwaddr addr, + uint64_t val64, unsigned int size) +{ + SiFiveUPRCIState *s = opaque; + uint32_t val32 = (uint32_t)val64; + + switch (addr) { + case SIFIVE_U_PRCI_HFXOSCCFG: + s->hfxosccfg = val32; + /* OSC stays ready */ + s->hfxosccfg |= SIFIVE_U_PRCI_HFXOSCCFG_RDY; + break; + case SIFIVE_U_PRCI_COREPLLCFG0: + s->corepllcfg0 = val32; + /* internal feedback */ + s->corepllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_FSE; + /* PLL stays locked */ + s->corepllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_LOCK; + break; + case SIFIVE_U_PRCI_DDRPLLCFG0: + s->ddrpllcfg0 = val32; + /* internal feedback */ + s->ddrpllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_FSE; + /* PLL stays locked */ + s->ddrpllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_LOCK; + break; + case SIFIVE_U_PRCI_DDRPLLCFG1: + s->ddrpllcfg1 = val32; + break; + case SIFIVE_U_PRCI_GEMGXLPLLCFG0: + s->gemgxlpllcfg0 = val32; + /* internal feedback */ + s->gemgxlpllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_FSE; + /* PLL stays locked */ + s->gemgxlpllcfg0 |= SIFIVE_U_PRCI_PLLCFG0_LOCK; + break; + case SIFIVE_U_PRCI_GEMGXLPLLCFG1: + s->gemgxlpllcfg1 = val32; + break; + case SIFIVE_U_PRCI_CORECLKSEL: + s->coreclksel = val32; + break; + case SIFIVE_U_PRCI_DEVICESRESET: + s->devicesreset = val32; + break; + case SIFIVE_U_PRCI_CLKMUXSTATUS: + s->clkmuxstatus = val32; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%x v=0x%x\n", + __func__, (int)addr, (int)val64); + } +} + +static const MemoryRegionOps sifive_u_prci_ops = { + .read = sifive_u_prci_read, + .write = sifive_u_prci_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4 + } +}; + +static void sifive_u_prci_realize(DeviceState *dev, Error **errp) +{ + SiFiveUPRCIState *s = SIFIVE_U_PRCI(dev); + + memory_region_init_io(&s->mmio, OBJECT(dev), &sifive_u_prci_ops, s, + TYPE_SIFIVE_U_PRCI, SIFIVE_U_PRCI_REG_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); +} + +static void sifive_u_prci_reset(DeviceState *dev) +{ + SiFiveUPRCIState *s = SIFIVE_U_PRCI(dev); + + /* Initialize register to power-on-reset values */ + s->hfxosccfg = SIFIVE_U_PRCI_HFXOSCCFG_RDY | SIFIVE_U_PRCI_HFXOSCCFG_EN; + s->corepllcfg0 = SIFIVE_U_PRCI_PLLCFG0_DIVR | SIFIVE_U_PRCI_PLLCFG0_DIVF | + SIFIVE_U_PRCI_PLLCFG0_DIVQ | SIFIVE_U_PRCI_PLLCFG0_FSE | + SIFIVE_U_PRCI_PLLCFG0_LOCK; + s->ddrpllcfg0 = SIFIVE_U_PRCI_PLLCFG0_DIVR | SIFIVE_U_PRCI_PLLCFG0_DIVF | + SIFIVE_U_PRCI_PLLCFG0_DIVQ | SIFIVE_U_PRCI_PLLCFG0_FSE | + SIFIVE_U_PRCI_PLLCFG0_LOCK; + s->gemgxlpllcfg0 = SIFIVE_U_PRCI_PLLCFG0_DIVR | SIFIVE_U_PRCI_PLLCFG0_DIVF | + SIFIVE_U_PRCI_PLLCFG0_DIVQ | SIFIVE_U_PRCI_PLLCFG0_FSE | + SIFIVE_U_PRCI_PLLCFG0_LOCK; + s->coreclksel = SIFIVE_U_PRCI_CORECLKSEL_HFCLK; +} + +static void sifive_u_prci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->realize = sifive_u_prci_realize; + dc->reset = sifive_u_prci_reset; +} + +static const TypeInfo sifive_u_prci_info = { + .name = TYPE_SIFIVE_U_PRCI, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(SiFiveUPRCIState), + .class_init = sifive_u_prci_class_init, +}; + +static void sifive_u_prci_register_types(void) +{ + type_register_static(&sifive_u_prci_info); +} + +type_init(sifive_u_prci_register_types) diff --git a/include/hw/riscv/sifive_u_prci.h b/include/hw/riscv/sifive_u_prci.h new file mode 100644 index 0000000..60a2eab --- /dev/null +++ b/include/hw/riscv/sifive_u_prci.h @@ -0,0 +1,81 @@ +/* + * QEMU SiFive U PRCI (Power, Reset, Clock, Interrupt) interface + * + * Copyright (c) 2019 Bin Meng + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_SIFIVE_U_PRCI_H +#define HW_SIFIVE_U_PRCI_H + +#define SIFIVE_U_PRCI_HFXOSCCFG 0x00 +#define SIFIVE_U_PRCI_COREPLLCFG0 0x04 +#define SIFIVE_U_PRCI_DDRPLLCFG0 0x0C +#define SIFIVE_U_PRCI_DDRPLLCFG1 0x10 +#define SIFIVE_U_PRCI_GEMGXLPLLCFG0 0x1C +#define SIFIVE_U_PRCI_GEMGXLPLLCFG1 0x20 +#define SIFIVE_U_PRCI_CORECLKSEL 0x24 +#define SIFIVE_U_PRCI_DEVICESRESET 0x28 +#define SIFIVE_U_PRCI_CLKMUXSTATUS 0x2C + +/* + * Current FU540-C000 manual says ready bit is at bit 29, but + * freedom-u540-c000-bootloader codes (ux00prci.h) says it is at bit 31. + * We have to trust the actual code that works. + * + * see https://github.com/sifive/freedom-u540-c000-bootloader + */ + +#define SIFIVE_U_PRCI_HFXOSCCFG_EN (1 << 30) +#define SIFIVE_U_PRCI_HFXOSCCFG_RDY (1 << 31) + +/* xxxPLLCFG0 register bits */ +#define SIFIVE_U_PRCI_PLLCFG0_DIVR (1 << 0) +#define SIFIVE_U_PRCI_PLLCFG0_DIVF (31 << 6) +#define SIFIVE_U_PRCI_PLLCFG0_DIVQ (3 << 15) +#define SIFIVE_U_PRCI_PLLCFG0_FSE (1 << 25) +#define SIFIVE_U_PRCI_PLLCFG0_LOCK (1 << 31) + +/* xxxPLLCFG1 register bits */ +#define SIFIVE_U_PRCI_PLLCFG1_CKE (1 << 24) + +/* coreclksel register bits */ +#define SIFIVE_U_PRCI_CORECLKSEL_HFCLK (1 << 0) + + +#define SIFIVE_U_PRCI_REG_SIZE 0x1000 + +#define TYPE_SIFIVE_U_PRCI "riscv.sifive.u.prci" + +#define SIFIVE_U_PRCI(obj) \ + OBJECT_CHECK(SiFiveUPRCIState, (obj), TYPE_SIFIVE_U_PRCI) + +typedef struct SiFiveUPRCIState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion mmio; + uint32_t hfxosccfg; + uint32_t corepllcfg0; + uint32_t ddrpllcfg0; + uint32_t ddrpllcfg1; + uint32_t gemgxlpllcfg0; + uint32_t gemgxlpllcfg1; + uint32_t coreclksel; + uint32_t devicesreset; + uint32_t clkmuxstatus; +} SiFiveUPRCIState; + +#endif /* HW_SIFIVE_U_PRCI_H */ From patchwork Tue Aug 27 14:58:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117183 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 DB9731800 for ; Tue, 27 Aug 2019 15:16: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 77CBC2186A for ; Tue, 27 Aug 2019 15:16:47 +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="XPYJZIPk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77CBC2186A 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]:52542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dDA-0004vw-Ev for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:16:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46948) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwS-0003PR-6i for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwP-0003pR-Vl for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:27 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:44079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwL-0003jg-Q8; Tue, 27 Aug 2019 10:59:22 -0400 Received: by mail-pl1-x644.google.com with SMTP id t14so11904690plr.11; Tue, 27 Aug 2019 07:59:08 -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=V2DW5myB/686B3BuCfQ3PMfCTq1gYnWsm27tMr5svLY=; b=XPYJZIPkDzAzX+hv7AKMuh2Q/qvMZULI+Pw0NTXuXIaezxnf+aN/3Y2+/HVOQH+RH3 jfQJtDx3XoVPz8k0jrPd9H+h4HqpH7CMVABOVVyof2GWI9clxcAPyYOyabqFiFqYx/I8 aZGSBRT1ZXPKz++h1KlK39itEflUUhVnSsKKz1WzkQFISck2Va74c53LgN7bV+xZKFOe x47rlame1RhO5DnrWq/9cV2o6SqAIcX6wQxlyc88rlGoZ7R+uyIrvLx7RfLXUlcoWku4 7998RY5qalGKvVhOHLhLYGOmHzu65BZLppsc4pY5IV/AvvFPGNISBaipEtELxhkEkz6b 3WfA== 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=V2DW5myB/686B3BuCfQ3PMfCTq1gYnWsm27tMr5svLY=; b=czG3Mh8lXl2UPEnvonVx7yS0bsqkYeiSjgCm3aezkoPLigcBZ83r7gzsE84M6XT3L1 2FX6MnSIioaJM43rQ6UrdT3x5Nje+JeytnKbTAzRmWvBMh5VD9PCm54QhdPXJEWCRChX sSP194Pelszj2vH5i4aCA7X578SZXEWnqVnDNQDvRMJCc12Fya6veAoC6rGOGOi9C4af e1O65UlWQHLX4dWQ9TM8DqA/devHBfm/NHVdn1iphhmeph3VkFWPU04b5/eSlMWv+YTx ltQSH9GZI7J/rP6nuZexyzz6fn+TBN5/8korPq4wFGA6fQy5lRyNEN6AVt+yuJ9/Xyov h8wg== X-Gm-Message-State: APjAAAW37UDYw+OJldeavVbz+gBhUfCcuYZnRtUGskBPGE1t/KtRlTLo e4g6LzfWuvkxZ/+/z8jt2ms= X-Google-Smtp-Source: APXvYqzv5NzAfFDEWN6xAxrc8woW0dD3g9iSENyIb5/17tOgJBEnKkyJKgGv+ulLgeySH0hmecwOcw== X-Received: by 2002:a17:902:8302:: with SMTP id bd2mr24226159plb.9.1566917948229; Tue, 27 Aug 2019 07:59:08 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.06 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:07 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:29 -0700 Message-Id: <1566917919-25381-21-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 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 v6: None 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 24ae3d1..f048806 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -79,6 +79,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) { @@ -97,6 +98,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 }; From patchwork Tue Aug 27 14:58:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117199 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 E690A1395 for ; Tue, 27 Aug 2019 15:21:23 +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 B8B8D2070B for ; Tue, 27 Aug 2019 15:21:23 +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="CZSD28Te" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8B8D2070B 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]:52578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dHe-00006V-9r for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46952) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwS-0003Pk-F0 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwQ-0003pt-HY for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:27 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:32920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwN-0003k6-9X; Tue, 27 Aug 2019 10:59:24 -0400 Received: by mail-pl1-x644.google.com with SMTP id go14so11908416plb.0; Tue, 27 Aug 2019 07:59:10 -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=GMi1ltGCHwQ4dkheExnUKN+OEqrYhZPFEnRLNC1m3ek=; b=CZSD28Tea+4MGnsDvC9ZP3hEoXKN9u+jULHodq20js2wClz6BjcUgcnKDAJUIDd5K4 BFNXaFSxtCFk9A1pEvOPWpPvQA7R59FbWsSIbFTbgqbfb6T61A5rPwoJ+1Ud9hI06nC6 E1mPjen/YU8czpuS9i6Y183KNzCggf8Xh1GRRZF0txSabV09VrqqfvrZgBxjxAdOBTmM zKJt+igwcsa3lWiIvxEISutIgstsN66qnPFElOF8Clt4hzgxWFrWPZC/wmgpEMSoq6++ s45Y4Bvs37xjOXe9wbzNYpip9G4ia358nsvH2151lPsSSqbBIRESk/foDqGT03laDC0J SfUw== 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=GMi1ltGCHwQ4dkheExnUKN+OEqrYhZPFEnRLNC1m3ek=; b=Btjd6Mtxe8RLm5pFqVRUnOEj48Dwc0akAotM+GJf2X0vuynZ0h8sQxsuVQklOqo/DL VpYfWTFGm/UxwUrtN5zVIWbtv5YHlvgkj7ynr9Wnr2iuWRuvnVgjLAHBnHUHA2wyMMi8 UCm4dgTPIAADR3X8rmv2vAkmRRWtVMvsis92CZad/66teq84kcetinZIN5nznaKuP5yk aeOOGr4rBPQGG+eoDsmKG0JJ57qzTdBJksadw55nn8qRWFnSPDRXHW4R3qyulRX5JYXw BCNIxNeGa+bRVLBhSPPeSUOHhv7IZAU3YIIS2MEBV6qQe5vJVqctTgOGoUNbeA9uQrsy OMUQ== X-Gm-Message-State: APjAAAUIf5bXqBeNSzX3zLQNoBGRskIIidBFLsuE2afUpNMeT34KpVWt /UM1iR8lRaJa4MniU81Ct6M= X-Google-Smtp-Source: APXvYqyyiVl8ffCo7cTxNPqkTLcAbx1hcBDcaxYie/u/mgsdDx6IDOra3fdSWrfyflgUypEiMyOhIw== X-Received: by 2002:a17:902:9f8e:: with SMTP id g14mr25117099plq.67.1566917949378; Tue, 27 Aug 2019 07:59:09 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.08 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:08 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:30 -0700 Message-Id: <1566917919-25381-22-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 21/30] riscv: sifive_u: Add PRCI block to the SoC 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" Add PRCI mmio base address and size mappings to sifive_u machine, and generate the corresponding device tree node. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: - create sifive_u_prci block directly in the machine codes, instead of calling sifive_u_prci_create() Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 24 +++++++++++++++++++++++- include/hw/riscv/sifive_u.h | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index f048806..da8ee64 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -9,6 +9,7 @@ * 0) UART * 1) CLINT (Core Level Interruptor) * 2) PLIC (Platform Level Interrupt Controller) + * 3) PRCI (Power, Reset, Clock, Interrupt) * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -60,6 +61,7 @@ static const struct MemmapEntry { [SIFIVE_U_MROM] = { 0x1000, 0x11000 }, [SIFIVE_U_CLINT] = { 0x2000000, 0x10000 }, [SIFIVE_U_PLIC] = { 0xc000000, 0x4000000 }, + [SIFIVE_U_PRCI] = { 0x10000000, 0x1000 }, [SIFIVE_U_UART0] = { 0x10013000, 0x1000 }, [SIFIVE_U_UART1] = { 0x10023000, 0x1000 }, [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, @@ -77,7 +79,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, uint32_t *cells; char *nodename; char ethclk_names[] = "pclk\0hclk\0tx_clk"; - uint32_t plic_phandle, ethclk_phandle, phandle = 1; + uint32_t plic_phandle, prci_phandle, ethclk_phandle, phandle = 1; uint32_t uartclk_phandle; uint32_t hfclk_phandle, rtcclk_phandle; @@ -188,6 +190,21 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, g_free(cells); g_free(nodename); + prci_phandle = phandle++; + nodename = g_strdup_printf("/soc/clock-controller@%lx", + (long)memmap[SIFIVE_U_PRCI].base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", prci_phandle); + qemu_fdt_setprop_cell(fdt, nodename, "#clock-cells", 0x1); + qemu_fdt_setprop_cells(fdt, nodename, "clocks", + hfclk_phandle, rtcclk_phandle); + qemu_fdt_setprop_cells(fdt, nodename, "reg", + 0x0, memmap[SIFIVE_U_PRCI].base, + 0x0, memmap[SIFIVE_U_PRCI].size); + qemu_fdt_setprop_string(fdt, nodename, "compatible", + "sifive,fu540-c000-prci"); + g_free(nodename); + plic_phandle = phandle++; cells = g_new0(uint32_t, ms->smp.cpus * 4 - 2); for (cpu = 0; cpu < ms->smp.cpus; cpu++) { @@ -402,6 +419,8 @@ static void riscv_sifive_u_soc_init(Object *obj) qdev_prop_set_uint32(DEVICE(&s->u_cpus), "hartid-base", 1); qdev_prop_set_string(DEVICE(&s->u_cpus), "cpu-type", SIFIVE_U_CPU); + sysbus_init_child_obj(obj, "prci", &s->prci, sizeof(s->prci), + TYPE_SIFIVE_U_PRCI); sysbus_init_child_obj(obj, "gem", &s->gem, sizeof(s->gem), TYPE_CADENCE_GEM); } @@ -475,6 +494,9 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) memmap[SIFIVE_U_CLINT].size, ms->smp.cpus, SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE); + object_property_set_bool(OBJECT(&s->prci), true, "realized", &err); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->prci), 0, memmap[SIFIVE_U_PRCI].base); + for (i = 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) { plic_gpios[i] = qdev_get_gpio_in(DEVICE(s->plic), i); } diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index debbf28..2a023be 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -21,6 +21,7 @@ #include "hw/net/cadence_gem.h" #include "hw/riscv/sifive_cpu.h" +#include "hw/riscv/sifive_u_prci.h" #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc" #define RISCV_U_SOC(obj) \ @@ -36,6 +37,7 @@ typedef struct SiFiveUSoCState { RISCVHartArrayState e_cpus; RISCVHartArrayState u_cpus; DeviceState *plic; + SiFiveUPRCIState prci; CadenceGEMState gem; } SiFiveUSoCState; @@ -54,6 +56,7 @@ enum { SIFIVE_U_MROM, SIFIVE_U_CLINT, SIFIVE_U_PLIC, + SIFIVE_U_PRCI, SIFIVE_U_UART0, SIFIVE_U_UART1, SIFIVE_U_DRAM, From patchwork Tue Aug 27 14:58:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117193 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 AEB521395 for ; Tue, 27 Aug 2019 15:18:45 +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 7F95B2070B for ; Tue, 27 Aug 2019 15:18:45 +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="ngyDSJ/T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F95B2070B 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]:52546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dF6-0006CB-3z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:18:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46939) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwR-0003Ol-W4 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwP-0003p6-4x for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:26 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwL-0003kN-Iv; Tue, 27 Aug 2019 10:59:22 -0400 Received: by mail-pl1-x644.google.com with SMTP id gn20so11914118plb.2; Tue, 27 Aug 2019 07:59:11 -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=txywo/qB9NDWK7jn2LNwcr8E3yWXO0rMZ+SQkFmtAiQ=; b=ngyDSJ/T0JLO+nDIjvx6EJe2Mxo6Kv9tM8U8yQYfSFyelMejEJj7PP3NaSWV69wpL2 5iEIwk+CBM9ARqli55LkEnDhxDUQ3MKQ25DNopJ99VaKv0djjo0z4Cz82XY5xibYyZWS hijcfQ2I5lOmgZnkuit4dIZfOmPspbNLbuQxtTlCg3o1H0RvQiz0bd1azUtJ+A2tCHR+ X+F+vUwmOmQ1zKutKGgRqKilaHHSNH2SzSoxsEy4k4rpebolHjUTft4R20zJzH6Di4Bh JgwlHh0MQiPpnuEWGER0d5/IJPFgDur3vfLTQNGD2gCVo+hDEVYw68VGhvrXRQaMc0a8 mydQ== 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=txywo/qB9NDWK7jn2LNwcr8E3yWXO0rMZ+SQkFmtAiQ=; b=jqqvW+uBkaqgNfE5dDyNLSGSU0F/lPqEUxwY88l9TqABi7x9nolWRXicnH5bq2k4s7 i65G8Tw+xctM0oyCZ+3WlwkzYl4fZppGF5qQtv0E7UDb9kq1qFmCcHGRgoE8zS+Th5Yh ze3RF7J8BtneTp1O0BY7cxEf45r52Ce/CT8UwVUOr2pWXLanq72plT3LihuDDo7W99cS MW+F5aFql5FwrhI+q+/Wyw+PYBya7a5vKzTKyq8r20HRIADE/ZGnx+74fxCwzVi6E5vL 8m4szC73fZZTNS2/+bJezEhFXkqcjCHVyUabLiPqGn9UO76o5+7JduOBVzUsANhVxrzW 19Tw== X-Gm-Message-State: APjAAAXZqORSKyGXIviA1YcZFs6XHn1rIEsKwx6mw053gWWJOleWxWJw VZiQAWLn4KtTCq3q7eFABl0= X-Google-Smtp-Source: APXvYqxLG2yjfkWnnp+LCB7QeBIeWEQ7oFOoMrs6yoYCrrk6iyeKkRShpyZx+lh+f3ZtIW2SM2WF0A== X-Received: by 2002:a17:902:4303:: with SMTP id i3mr6901058pld.30.1566917950488; Tue, 27 Aug 2019 07:59:10 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.09 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:09 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:31 -0700 Message-Id: <1566917919-25381-23-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 22/30] riscv: sifive_u: Reference PRCI clocks in UART and ethernet 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" Now that we have added a PRCI node, update existing UART and ethernet nodes to reference PRCI as their clock sources, to keep in sync with the Linux kernel device tree. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 7 ++++--- include/hw/riscv/sifive_u_prci.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index da8ee64..3b1fe46 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -78,7 +78,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, int cpu; uint32_t *cells; char *nodename; - char ethclk_names[] = "pclk\0hclk\0tx_clk"; + char ethclk_names[] = "pclk\0hclk"; uint32_t plic_phandle, prci_phandle, ethclk_phandle, phandle = 1; uint32_t uartclk_phandle; uint32_t hfclk_phandle, rtcclk_phandle; @@ -263,7 +263,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ); qemu_fdt_setprop_cells(fdt, nodename, "clocks", - ethclk_phandle, ethclk_phandle, ethclk_phandle); + prci_phandle, PRCI_CLK_GEMGXLPLL, prci_phandle, PRCI_CLK_GEMGXLPLL); qemu_fdt_setprop(fdt, nodename, "clock-names", ethclk_names, sizeof(ethclk_names)); qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", 1); @@ -293,7 +293,8 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_UART0].base, 0x0, memmap[SIFIVE_U_UART0].size); - qemu_fdt_setprop_cell(fdt, nodename, "clocks", uartclk_phandle); + qemu_fdt_setprop_cells(fdt, nodename, "clocks", + prci_phandle, PRCI_CLK_TLCLK); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_UART0_IRQ); diff --git a/include/hw/riscv/sifive_u_prci.h b/include/hw/riscv/sifive_u_prci.h index 60a2eab..0a531fd 100644 --- a/include/hw/riscv/sifive_u_prci.h +++ b/include/hw/riscv/sifive_u_prci.h @@ -78,4 +78,14 @@ typedef struct SiFiveUPRCIState { uint32_t clkmuxstatus; } SiFiveUPRCIState; +/* + * Clock indexes for use by Device Tree data and the PRCI driver. + * + * These values are from sifive-fu540-prci.h in the Linux kernel. + */ +#define PRCI_CLK_COREPLL 0 +#define PRCI_CLK_DDRPLL 1 +#define PRCI_CLK_GEMGXLPLL 2 +#define PRCI_CLK_TLCLK 3 + #endif /* HW_SIFIVE_U_PRCI_H */ From patchwork Tue Aug 27 14:58:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117213 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 1226B1395 for ; Tue, 27 Aug 2019 15:28:32 +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 DC4A4204EC for ; Tue, 27 Aug 2019 15:28:31 +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="HLCBVXh6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC4A4204EC 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]:52704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dOY-0008LN-0J for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:28:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47027) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwV-0003Ws-Tl for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003s0-DM for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:31 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:36531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003kf-Em; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pl1-x641.google.com with SMTP id f19so11916818plr.3; Tue, 27 Aug 2019 07:59:12 -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=l4mnDEipFGEh17kvXqEfnXVEcHixTpadUgorARruiEM=; b=HLCBVXh6PiEHN7SFesL0IEi02juaUmJaVcPPWQzruul4Nq9/oMhFZetytnrK370MNU yu7DJte2ZNhnTBdRynP32ARyzcGvrTzqnfUyaVEOi7imendZaapBndy1QWA8zIuR78lQ 4QrJcxGNTPHmTd5VaBp+t72qKkWqjUi0gr6CSa2KUp1nAsS25XTJ4HlsFPjz26O+/OAG rfnSvkiN/3V68AxtSCuu4z1GzW2mBf/lI4xCaJTN+2UVqyHEKfKOQEWVpPXkI3Co68c7 Etkiq/wC0RBF7SAKUCn9XTBt/DSD1GfedCzwwR84+s8RnIksLI8aYnBzw070vb1fgcom 4f2A== 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=l4mnDEipFGEh17kvXqEfnXVEcHixTpadUgorARruiEM=; b=NaqqVF3uo9qEbuCzHk/eu1b241FgN0PItXiId5a93DiupwATdLQUSBINqhA7RCVCy5 Tnd5ZYTiW2Ju5FJ2qJA2yWxZios4HfuSDz6T54wTUn9uAIE2wnfBz6GHPpXHpfW8Fchb 7rvY9QjCXQ1oI9NqrMKlDxDNqxTB2DUgXxWTp9aUx6AigBa5dRm1O0SIaktJ8VfwAZD3 9RX+mQgfQwa9o4jGklIEI6JxAPHfEohjKcZiDBUg8/mhVxUK/uz88dZFNfmaI9kTQS50 eRfi+Sdv5N6ntr79xA6lya3ksAyCYUSQAfnyJdwwasKaXhRYqfoGSgNiVCkXOSR+tB8R EBEg== X-Gm-Message-State: APjAAAW5qclx2aYRo9wb9hQ8kw2oXqWY/Z/fPE0FVmLp1tYL2VC27mmd exUmlsJgNV+/9l4fFyyd+6k= X-Google-Smtp-Source: APXvYqzO0X0lNzAPzieS+53NBKuoI1KXh8KEDt8sC9R2zj6OIotLFObxulDzjmJK8FcADVQzkOLRrQ== X-Received: by 2002:a17:902:b714:: with SMTP id d20mr7527653pls.281.1566917951657; Tue, 27 Aug 2019 07:59:11 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.10 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:10 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:32 -0700 Message-Id: <1566917919-25381-24-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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 v6 23/30] riscv: sifive_u: Update UART base addresses and IRQs 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" This updates the UART base address and IRQs to match the hardware. Signed-off-by: Bin Meng Reviewed-by: Jonathan Behrens Acked-by: Alistair Francis Reviewed-by: Chih-Min Chao --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - update IRQ numbers of both UARTs to match hardware as well Changes in v2: None hw/riscv/sifive_u.c | 4 ++-- include/hw/riscv/sifive_u.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 3b1fe46..c7b9f96 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -62,8 +62,8 @@ static const struct MemmapEntry { [SIFIVE_U_CLINT] = { 0x2000000, 0x10000 }, [SIFIVE_U_PLIC] = { 0xc000000, 0x4000000 }, [SIFIVE_U_PRCI] = { 0x10000000, 0x1000 }, - [SIFIVE_U_UART0] = { 0x10013000, 0x1000 }, - [SIFIVE_U_UART1] = { 0x10023000, 0x1000 }, + [SIFIVE_U_UART0] = { 0x10010000, 0x1000 }, + [SIFIVE_U_UART1] = { 0x10011000, 0x1000 }, [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, [SIFIVE_U_GEM] = { 0x100900FC, 0x2000 }, }; diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 2a023be..b41e730 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -64,8 +64,8 @@ enum { }; enum { - SIFIVE_U_UART0_IRQ = 3, - SIFIVE_U_UART1_IRQ = 4, + SIFIVE_U_UART0_IRQ = 4, + SIFIVE_U_UART1_IRQ = 5, SIFIVE_U_GEM_IRQ = 0x35 }; From patchwork Tue Aug 27 14:58:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117169 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 04E8414D5 for ; Tue, 27 Aug 2019 15:10:16 +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 CF1B42070B for ; Tue, 27 Aug 2019 15:10:15 +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="lFwnrJBu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF1B42070B 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]:52474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2d6s-0006Wi-9x for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:10:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46847) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwL-0003NP-FH for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwH-0003mC-T6 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:19 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:38403) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwE-0003kj-KR; Tue, 27 Aug 2019 10:59:14 -0400 Received: by mail-pl1-x641.google.com with SMTP id w11so11460134plp.5; Tue, 27 Aug 2019 07:59:13 -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=4iYtTwKnL9L1t7ZggPRWTntToQMd8o1RWJMYHgQ22bs=; b=lFwnrJBus6x+S1p8pp3GS4L56iXiSkFEMKj501XEo0FJoAGvY6j1aDZsTQaQ0vYgLf RovRvgcj5UkViYGZsni2hHpaSxi2VIY8E1gpKnW1y+BjTQusimHI+Xhc3W8pw1UGZGfp +AY8/XtBonGZ7Xl2PrfZPoztdcaZ8G3rjitkamNC43Dnb7oTC9f0MLY+Hi1J4XP4sst4 4+DVgAB6/Ujv6CuvHENG4CkiEb/8X+77uwvJjSHg0zWYZU5wD3LVPwnOclTbZrap7vVb iGjjc4d8It1rCoQyVDVlUZiMMQNW+9zwowUTnunCoUq6MbXmCAgJ9VgBMRoHOd0yU1Nb qBfw== 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=4iYtTwKnL9L1t7ZggPRWTntToQMd8o1RWJMYHgQ22bs=; b=eQmsdXfYEnLjuKCPqneSXGOJ1cMbVTwUGyIvTD8Wbyf4MSkIn1sPyzNmUbwsEhgnFX BC6/0XvwMrtpsLR7XiOzwjSYr/jhj9kh5JVfJ0I3NG9Pw75MnrlTJhZiEdgBbI3yLaZl 7JpSEbk3AZf0yRyc/kAdoFHyZeLvUGrux3VpvwwQORaZ1zFsN7/j3AoL/7zo9NiE4a8s ohOtETYSwIk5E4Iz0DHbqItKWtO1z8L/ic9Lxkjov3haQUosQ1IRRQV/Sb8ianFuKVWl qm1K/Sc6xqhEaDDWhCMLNU1emKC4ps7cdB0mKuQJazegKrLd/9ljcdS8cCy3M6/iVCj5 5eLg== X-Gm-Message-State: APjAAAUQ+2YGhHfwqnXRZ5i6+jQa5n1sAXf8q9TJrRoOG9J6qyINSJd8 g5jjtzE/gc8Px3ZjONyj/Oc= X-Google-Smtp-Source: APXvYqw+sMiN/1l03sByPMRgYQc/sV8+Co3t17fAF65whGNoaMQFXuQgvfKIrqcaBFc0jPxSKB7HLw== X-Received: by 2002:a17:902:8345:: with SMTP id z5mr9710660pln.29.1566917952650; Tue, 27 Aug 2019 07:59:12 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.11 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:12 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:33 -0700 Message-Id: <1566917919-25381-25-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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 v6 24/30] riscv: sifive_u: Change UART node name in device tree 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" OpenSBI for fu540 does DT fix up (see fu540_modify_dt()) by updating chosen "stdout-path" to point to "/soc/serial@...", and U-Boot will use this information to locate the serial node and probe its driver. However currently we generate the UART node name as "/soc/uart@...", causing U-Boot fail to find the serial node in DT. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index c7b9f96..d970037 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -286,7 +286,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, uartclk_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(nodename); - nodename = g_strdup_printf("/soc/uart@%lx", + nodename = g_strdup_printf("/soc/serial@%lx", (long)memmap[SIFIVE_U_UART0].base); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,uart0"); From patchwork Tue Aug 27 14:58:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117207 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 925E914DB for ; Tue, 27 Aug 2019 15:25:11 +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 580C0206BF for ; Tue, 27 Aug 2019 15:25:11 +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="DuEQ//hp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 580C0206BF 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]:52626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dLJ-0004nA-QZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47184) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwc-0003ez-0W for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003ru-DJ for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:37 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003l8-DD; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pl1-x642.google.com with SMTP id m9so11910084pls.8; Tue, 27 Aug 2019 07:59:14 -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=HRMxeupAI7nouWkR/8LtzUsK2+uiMkegRct0MROIo3Q=; b=DuEQ//hpZkogqgsV4tD1jwuLwabhlou42yMOT28oi3/JE6loWOoJHckVod9SgJjpAu VV/Sz5jsqaRX/bxh4jz0emI0KAwowyG8Obvm9S2e4zK8x79sCyUYRh123wSYlh7eQw8x 1OZoZdw0Lv+SmlXQCMBf5ia2adBuy4/ecX87giA76lRgS+xG2UFi13ersJPmTqyc1MsP H/LYQoIfON+3e+YIiLp8hEnOUwFpKvvT1ooLiiGFkLV2JL7ux3w7c1xpPzspWNvVeRaO M6AjZDqAz4S12JJfnLLZrXrAAk3OHk8sm+vfMmhcPuR6ZM8z3LHrtEfDtPl7JewFjj1G ctbA== 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=HRMxeupAI7nouWkR/8LtzUsK2+uiMkegRct0MROIo3Q=; b=JyhbdBwjmYROolSTBigLqDCD308iouBA26ikhmpojQKqa2FD9Vs6iPuXg9MPpUIjDF Gzf+hec7E1ufZS4ite0OZ73QcfVjqlZUdaWMkrUGnDfKlx3kk7Q27HyOZmtZk2SAEVSl Jrko8dly94OxvA37S9IUjzine8Q9507ySJ1bQr60Dj1sq4pIbd4xM1EmtDFpYK+seZcO HSHtvsSExVRy1eL6Zv3iJuJdNSvEcayBC7iuPeXWgvElGhym+9vTPgbuud2BiABrID8g vGazM4LOBh/56cpnm42R1iz57S4CgxcbppEQsmLLOVT5rSltaLJmjiEypsZV46hU2OtB HNUg== X-Gm-Message-State: APjAAAUNmfCO5UKLrTGNgsl4Zz2APbLzbv8SQ3OgGiXTrjPX0GxG9vT1 rTP7HcJ7MpSw9tDwJkGjHSk= X-Google-Smtp-Source: APXvYqw8woxuW0MytwxLgARicd9LmmXdBMsKMWomHilJ4/m79B6KFJnM1CT7x2Z2uKLso/ya0c/MeQ== X-Received: by 2002:a17:902:bd4a:: with SMTP id b10mr24511695plx.219.1566917953824; Tue, 27 Aug 2019 07:59:13 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.12 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:13 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:34 -0700 Message-Id: <1566917919-25381-26-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::642 Subject: [Qemu-devel] [PATCH v6 25/30] riscv: roms: Update default bios for sifive_u machine 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" With the support of heterogeneous harts and PRCI model, it's now possible to use the OpenSBI image (PLATFORM=sifive/fu540) built for the real hardware. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin | Bin 40968 -> 45064 bytes roms/Makefile | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin b/pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin index 5d7a1ef6818994bac4a36818ad36043b592ce309..eb22aefdfb468cfe2804cb4b0bc422d8ebcae93b 100644 GIT binary patch delta 10830 zcmcI~eOOf0_WwTTaAp|5zy=s$G)G2;B$Y8xQwsqZMktj?Fen8a(7-p07sHnZ7-n!l zMBCydW6I@gkn_7&ttq)_3KlO(VPJ-_F<-9NtbxZHEj z{_M5aUTf{O*51R;dU|IYeF9VCYY-ChyTdf=_$;$t$%-!FBh)PF2YiLnP&GJ#RtlO4 zf`7%(Y&Ovh1uu^=BI*)uVqWvTi1HA8ri}M#lXXVj799nsK;XrsM6yhpfDIJrX~XyC z2!|6CowN*ZcY7WO@m?9<2q^Y_gGC}=pjE1PeV*?)24lA+F1Veyny!q&5qy)IT&z** z9rPutBL0(>5I47X9AAARDRjwiGOa}(Juz}vMdK*G692<-3vK0Nnc&)lwu}o}=nauO zcZ?TY@G#q+qP_71r*$d=x5^cU{Rm;*npek1)(iPIr(~VJW~mN-36_!SG&$4uS~~N zonLU~df7CKT(SnQcb*l>JuB8)tVcB(J|0hh;{4>3FrF7NUbBFQV#_`kT`g;OzrM@A#ALL{ zFTU_?J&qa|jALA1rVijEu5Z$42A<$HLllzdOpW)s4KC2e>p^Za^`^qUJBC{Py4!EA zutuzHbf2QIpb(0@8y_(H6QcRl+ZIXQ6a)AlE~>f3d6UUogxm| z*kzH_OU(7-Ptx?B#rQ4vb~<{#`E`#i4&aR6drkM2ziH&Nh*hXk`_T9gC`6$aZcQh) zV{dOMfP%ff7aUy+I6J_`D7soZ)`!j_sahQuzb>@g*xD?yR~LRZ00n1kc|r)?_U(B6Tyr^792v7v?!|R zf-X*H>-Ak>>vO=8IlS+h~Y>Fke_l-#wN!wf;{Zxr>5mD#b1Oqq6nuJjfiZDAe z9+1=DnQRAk$Jl_kV#a`T?ZBk~oPtk`As5?`i^q`D?Z`!d^u$S$QJ%qeWbhbriXHhJ zAf2(>lu=}m9T_x+^t2;q021N)F{Hm8=|6^awj+HkZq{s^;WNrpVn<5GkjRb{0Wuv+ zq@zerJJNFu*=I+(05TC@97DR;kuGD%yLKc6$mKY1>L^dzj-IBGR@o5jR~9$w0|D(-07zoZw)HjrO(kIKH(9^=JO?UhKu_4FYHvMB-U9Ol5;Tb}yi`Px~pI?{-$hQJQaxrTZ@pusP*TeGUMh6zDgaSIhCttB64&r3AWZUC0 zLcHG{g7y88>$M&cn2ly&X0?kY`UHRT@UV5Dc67>GK61lF&Gf-Vu1MmjFVS|?rnXMP zS~hy~8X=D-nafgcAga@-Ahnk(7C>)hYpvH!N>PxPz1im`ud8~frT;?jCF_-*Yqx*y zY;RjLl-|Fw7YY9Dhk}?!5ydp~DNUo=k7AnUQko_u<-=+kR#5S!pR-K!TIzi1Y97f zbiRV)XkFOKPU~<>8)TZo5!1XJX_~T-ra1+PJ#~~=#HZqSt7CT?4Mk|>ZZVJNR!#Ci zv_z~@uslOHNT_8Khyd34{(2ES3t4SEOns6}*`hUY{yKdr&ke3CJ1*CHy{B-^+yxVgj4h;RA zzZQn^o5RdQp^GV6jd8@HIQn=cKD1~TeWMId4}ZyFVcu__;F;mU_*A$Hy=)MF8Gesm z)`S14*h)`s#nrKMaC(F%?Rpv)L`(ex{FqhxaI3XiF1*eQ_LJ_67cU@tgFr z&+yZc-2rK^X8qAGM9>NaM|XljU<~BJfrF~O%|0o?<&McD0{Em*3VS4gI6(N~BEJVXXIY&uXEeoK zOWUTyB6tr4?;UrQR%tdE(B(3lr=;G-3DJ|L+01*((zeWKLw0wLB60JBkv=<`?ZlPQ zVljvAx@l>1HQ45>X|r*AzYSlBe(+*0$e@q>#*hVVVfZ)Tac#@Anpy#pY0ce!6q!Lf z|H0Rmwr{kVDBA7c{vkmG?=N`1+2{9kKa{L7KBG`>WXXiTek1?JU9ngub zuN)A{qbI8-v2J)E7l~GoH7X_e;PTf%XEX7`<-K%31GdIy^PvlzmBs7h-k`tv#C#>L zfTqhzaYFngkGTj18@lPWlD*J3eaQ zjKSXH*Nxp@*96+1);^NTk37_W5+B=l2BIV}2e>FMDv}*sqbZh3v0 zhwZx$^bQR;7*dG33MJTarAo#1bbJ4KT=Rs3D%vAAKe#+!Iq{s&A5ws&E%A(vd$;Gi zs!3mofQOJ@<2hjwDI_U{>QOf*f$hDYJHD`TN<3hsAJ#lc#z{Y|apT&5)Vlq_rEIc{ z+o^I){_~9LkI4vJ#2xTIu0aB_s7PV^*1P^9tvre%YcXr3 z!JX?}AK;LT8H{Alvp6HegOMX=yfb4KQ|~&AKg$SU>c1Jr_cHvL`m&$!gw4|c_ZAM{ zEQK}~r*D3bsSmh~o!-2|)E_@X%g-;b0}?Hw=p) zga~=n?c5o`s%{_O$oMr3?^UYk2M!``MCwhzzxPMHtPM}h-oZ#N&cg?@0~txi9DFHz z79a3ftGI-na$*@t(kpm%&O8ve3LnY|1#u7I_MF9Z;vk;BWjd|y#|c|rU?gn|amAKb zKzMg--4a8qhjI8@DtJ8;o8DT$NZeR_`>h-BJQ26#PMIR9%rX_KUSrXnx@s*IK@M_x znWn;y2zF?x)^Z}T6}xQpp>K3y`PM0nB*Yyr-wM*TrQ_nQbAm?B83k~fEcQaGi$M(g z0gOJ8cq35Y8#)|xx^QZ!SF2FqfmB}yQBa-fAPb*3d=>X@okJ&{#?!YwOW!z!leWb? zb>kzuE(T?gmVt?NS>KHFrb0;9CnkT0FK+XZ9R84`Q0dIhhvuSAq}nt@w9Rsm^tR2NC}O@*eSju7_Ij)Ym2P$bU7RXY@n+lh7f?v9nh zd0-yBAWFy!AH2pL36q34;q5on{zV$42gN8@idhV`QiLBR_RvyB1D`ryX71)w#{D{o z`}uxCHiK5}=%Y0eMTl8!K$^w1h*8ua=%>UJ94YfH9vO+uw>+uyyYppd-h)%nYXbWPLYZ0I+ak(QAlH;+>EZQc13jNSmr(f0^WnJ16b33jx5A2~)!ZuUDcKb32&L~r1!`PH= z+iFA$SIds+ak-jL=kKj97i#si*hxp9EVi6*{RxgvPfI@-026{an~6EWjLk>Dn_!p1 zHo97Rxzx6O3Ow@n#_6id1GSNq<;12RjYUpKc%=v|Rg7Zv;>+NDuNG5cVr|c2idc!* z=A1^D;Kc1?*p)05Stj=6QNpbcUGakluC2RYE)#nflO2Zw??zBp%cMslDQVRJt!ZpP z4DqTa2QZPl%{1Ututr+bJeB6w2;v#{^Wfk`PA9RPy+?QZ)zZK5AA`0IpD}T9+;0XWNGC-@r4${g2x;-N-t164m zZBGkJuS%Z+R*m0WWv%YH(0QpXZfLbt*V}SCp?_8Hnx6FA8$0tRm>H|za(4M^zL7tzz1*mqhpNke ztB{^Jg+7!~Bxw zVhOhmx?U|4i%U@8FKa2`4|-US9@MI*q(|0pczjjx7#tgPuMk3r}-MxLR<@6P16Lf2ChYH%QW^v zpyPqfJCX6=F3Q~VHRL0(H)ze=viW;V`!4O%Mu38~z9j>~AN3H3^ho%f zp24r`8KD8_ih#l*c#acrsY6X-63Mq=6G(>r+=Ij?vQtT}_3;#cr>BHJ3h36dDo^99 zdJ4x1=$FebmkF=vX&k4gX(7o!1rtWOtajwaUllNfTRTfQ!ERy*w=f=Y%GR>adBWTQ z*O$wx1eeQv)B2zCk_vt5*oi`-wCDA>hEf4wYkLfkx zETxHp2p{E3F)z-hAOqj@I{(KwLa!r{1kBTRyhnBQC~WdV%2)xRw<{JXl@fcai;=lY zK^1tsBgo%-0S+K+L`ylb=Sbelx*f4g>Q-*9YLg8`^)Ky>vFbYGdh#6o^)rj1e6-%U zW-9bLU!BB*+nTW4_N=O0dTV=nGE8_$E95l{l4%2a{EH`@hoZT%?j|E^7&P(}=(mdT zvdtBy;(Qq;yQJny+mRwup<-C9^F|kl^(qhlYeTJOYQtb`?WE0Bx2rps4#o7x^(I(X z_2_z9+Vb2?`eVh!jB#Lp zs35?G5ZAdt1h#`fSd*DuI1~j(0!w9L+n@U$H&$Fv!fjnAF&EL*oZ?f&WOb%Os`YV`;cK~0YEaT3 zk&;;KhEDqYk%zMzK}mx|D^c17f;kjXl}%GbOBU<#9#f&1FF=Zc-$Rq03e^Y)?z=+3 z_JYj?S|hh9woJ&(EgS^B3@+8Z{sri4@RIgJesH;^^2T>(YK3Zk;ot>MO~mmQ?ll!o z8-`T^_>y)O3*PYUQKBllrg%f7zTr+V*25oBk9j=N4(2rsErok;a$ytj&;xAUFl5r^ zM~nlPlWAvx=&m<^-y@tpebo&^e|$Bn#u#f{kFIlRZ^G?7M{dgEIpA=K|Ig<2?O9>D zHlGh$mrT4Kemk;H+@gwOoxskM`i96(;NH6BJ+F;qrZo(bH!^JtX_Wvad zYI5itJ#g0D!(Rt^Lxl`ydF$Z=UX71OblaMew!oqI(O;_tTFMvjd_zh8%a4H5Y}4c1 zyf#<$SNFD9FZ5ixtsA=1d97{L(CYp*z3JAC${s`!5uPp9yr@8$s940jn2MN}vXKSt zNj2%mox7D0k+oD?oyE(&l@^g+oz7d=zAbEf)pmME`vw6RhWNs!3Oqg2N6q?*Cn-?A zU#Rl#F4gu2?wZzcsD741j?aRUGKDt2SIV78&A$#K^RK^>GbgmyQT`06?Bjury1PVy z)^B#JSk@gbin$VMw1Oh1SrQ@QOJlhjU}dS8)zYV3%Bj=4KBH913NN#oe}Gcm?{ys;qcdb5R8q$d9B{>mIn@)1}*NXAL;J#eGwZMN@%aT%d<^VcyMk;gY&sV&^#H&){+t3gG-Va)H%X6gE zz8w=j8PUvW=&{^SHN1c`&_xh1g!V^Zc^2g+Mk3Ra^%BX9>OUilB@l>f~M@{GN>=1C{bTU zQlC4t)Mo%KIo%h(!%WJf(Vx)CA@=wke|>BhNPF={pQb4s> z{pf6tWlSL%CaBu}32^ zD9Qce+C$_%b}nCnsJ-*cgUfM$BHTceo^B(4GHI@;ZQ++DEyT=Wk&N5`t&x$vQuZlM zO4=;saQr>Y2YfrXqB7i>Bqi5xLe_T|ej?eR;JzygI#%)S_tox*{gwRsM(&kitn}~A zd0bmvn@8@WrDtp2E>y`LE`QD~ z*|7umnu=6ZBuVEv>N=zP=ahgM2K|eV6@OHCO0BnCTvp1ql60Y(IFA9V?6G`EVsq5a zYeke&1~GuEa{EXw|8pW@d>aP4YO`Z6*An+8e;op>A6e=T|LSoLM1S<5A6y~5)raQt zk;8;@lXbXWH;T>s7pB!33MnHo@M$lVp27Yj2;j<1X0yeOB4} zm)qN)?Csy}{e_9P{_pMWL3>+l@851~)yVz@1*kHzGs%A;z9~f54I8p&WaVb0lJDfR zAvtqhD)eM#C1+)4BJ^fjrYdK8W=~3Bw3}}uqh%XIV)ANF?EY%A-$ z51A#G!#}xv{;XNEpOwqG88Wj{Hf3kc$Vkq51L4p1PxP7p-pEMB;gOLeK)gdEBToRm z4rBtlZ5$bKsl*TW$Elw0Nlnjup@0jCbAD?Keh7ege7zbP?$Ge@QKXZvZ+A z^iQCVfc_3t4O9tK0kjWjH_%R?0-)_cIY8@gjHpLk+Q8&M2IM8gAR_pm p7xSNl+kXQW97vc>d@}tPa3P>uKpX8XdG|PxJ_u|-I=oZq_`f`aDVP8N delta 5317 zcmcJTeOOcH`NyAgPEJCUN-#hKK?4yHL6-G((~D9Y#f+hl|Y8&^A&{@F&5l46MCEdSCVw8wl*rl1@_O2Q!ImJg zQnY;>m~IK29sJ8sD~GZ2>m%~At{5>M z*IaqaTYkmYCe*rU7%^m(!Q@M_GCHTUL_<6XrzK0pdKRaR%Qi@c z3aTTXkr@@$^ zvxYjOYze1rPKMH<(KDTOT@k0XCt-`+h;5vg92U_~GebuBwAt9DRFaWXs}pT!Ju|2g_Hau*r?pNQ z>B*8eKTN8-#wSbN{2D|K>ll3m+e;I?Yi3GG`p)yJ&v$nF{B?UogQbbnrjGr%4U%4n zg+*Qqsd_l%wT7A+}|{8zi_LKk<(Yux2;OSi0Fbx00IIu2*n2YGipT% zWCz62{rRvz!1RK1+`g3khBKE{X3&ldi0_|F>ALgc^AG0JCG3hV)#i2l)Nij{q2v0? z?9M5@*ODae@|Ry|7vq&mmUwXeDL2e!+xC%LsX#?S(-4+ahO1*L$7^E@adP^MzO(+; z?XVp4de8>VoxPsldcB3K(<{TZF+wkFR)i^|PK6^XS=>Q&o+tq_EUL>=S^xZvL1p5{VVDBO~ zI86kT5gY7siEc7dBcaNBqtzQ z0&Q+GLL?*HGH+K~)| zU1ME+_K0MUn>;I$pCaiEabYgCqIn&st}eb-H@2?Rm|^4;U2=Q~hJ}xaQ7jZXmj2oxW6ziM@4Uc6 zjXH$X<+(!a;;#*IwymuH>iI?JwddNh!%Y;c)>fF;+j=AJQC@}olT=r>I=!qvYMZ&x zW{-TAu4>dx!$X-G1;KJ6rhVuWC()}={zlD()rd>rbmt<5;dlK7@3?m%msuD2VI*RYvf9%$>I-ABos%?>|>8*?TI<$^&N9=}kICz59J zqlX=rp?UgjI2M0imWj<|`efVMxrr3*u)x`$WYAH+2S43*dU*>R(#@BgGk}KAD$6dwl_sNo(k^KN%}deWaI8y(Ryp+8 zRdY7hw^^>hsh6V|#jYT@^Kz4KI{J(SAK*pSR(9K5gsZZ)EVk{NA4n zV=(G%c-MToQ{{}_b_Cwy>?sF?EyiC2J$*AFJ~!M~D8Go&r-KsnVm@7x=}?_(@OMUvCjGdbUJFliM~@ex6ZaW{ zE~~Jtl!Z+kF_-^JL+K3P_c_NA{4L`lVR>*CGMY0jPCq?^q>p0sTAVOUh0&UAf`H?W^YG>?cu9$ulJY62FamMsP&e(UemvayDrn9N<&Op& z+Xw!b7tN2QnbD#+yJvHPp|_pbK5eI)>INJ?WZmQi>J?LCM*6mk3+NlV-$46Llc@>S zIAc%j9v=04-@SbI2UsMBuj;0$6pDowBS70n^8FN(T zO3pKQ&!myzDS&S;gV1X->zw6w?pCh!+kw_i>0h`0kb2G0OAnljJ=iMP(=GSk=rHP4 zm=L@YzBVS9o#)BzdvJd1EZH>kT$*eS=gvg&(efHKWC^q7>KV^#GE0 zwKL7LZQ$3qijRZQ$f=y1v7hTY@j3jWF%7a-Y-JP*IrOa9!zl8KVdKgIv?0*5@;c4E z32lZiu`0D4%3naSq`boSeVCXZ;^BM~P}t{yx-e5|J$F^p{5F}_3T!`(nX#Vx0=5-S z7)cZbFMh3wlssXR44o3m5u;LC`yHOoit1T#tuUIgp8FD{MNy2ksvD*kg)!FI@59QX zaD1}I!;T^i+DLe}=$DN3<{x2k@m? zVhAjamLZSXoCAwX)6vJm@zNJ@x+b_&ItQm)1Cgr}Y3?ShUmZz%{S^+ap2d*7HPEv< zjUfs>%y@MX?bQuCUNxY51w4FpCPQ{jgGpsKWh5`fQcHcbd!HXnESCinZJ4Fju#_ct z&mA#R3790J7;CA$mB2nt#)NXeg^cnLx~vmkFAru&TLS#594A>G1fP^o_1k%*NsjM- z+x&^4D~4f@Vrwh+0jMhi>8P_1TQQa94#4_~Np#r(uv9Ff%gpe7MF4$b4+N|Up`-Rf z?3zG2QNB0Hb)tbsjM&ggHrmF@2>OjT*R(}Lu-p| zJ&lDDy05}EfA4EF)12}cKHL|?G>>kCJNq{HH&@jjET`8d8N2i2OAeOMujuezTbDJ^ zYKuO0Rbq=f)+T|}rjdTp(KDt@#$W!w4E#^hx>B`zlFhGqCOv19!*K`o0M&;2y=eLJ zKdZa^F8gp3>^?Yq);@=03~K&f!4{*fMR}l)w|q>CmKR^<qaF#G@BH^uCtf0~ECDjP{R87|k|3R4_CD?4y1}qoq z38Eb?a#zH-WtkBFi)iz6g!*wY?wKppmx*?aXt#;+je=zfUx1A*fgxLtI~?8bI2`v; z$-i+pGEj$5|A*2Zb2t{CfYU7*RT*a;j=VDt$0@YeP<%ZX>le@-LhViy2L3PED)L|I z`2X4OC_*0pixtB5w?|Y(bmBHajY5q;Y5zkFN8S@9MG@4K4u|6*>H+EwsvGqe)MuzJ zR43{J>MZKr4o8(^F*Zs@C8FX{e1rc)FJYUhD1PEUUd+Fn+>H)6XvvPe(t~qC?L%2m uze4f8=XDV4{38KN-kv_r<1Q}r4nA9GJyE>neb0;cInM_?8aj4cJ^l{rCK>_& diff --git a/roms/Makefile b/roms/Makefile index 775c963..6cf07d3 100644 --- a/roms/Makefile +++ b/roms/Makefile @@ -182,8 +182,8 @@ opensbi64-virt: opensbi64-sifive_u: $(MAKE) -C opensbi \ CROSS_COMPILE=$(riscv64_cross_prefix) \ - PLATFORM="qemu/sifive_u" - cp opensbi/build/platform/qemu/sifive_u/firmware/fw_jump.bin ../pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin + PLATFORM="sifive/fu540" + cp opensbi/build/platform/sifive/fu540/firmware/fw_jump.bin ../pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin clean: rm -rf seabios/.config seabios/out seabios/builds From patchwork Tue Aug 27 14:58:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117221 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 A00E11395 for ; Tue, 27 Aug 2019 15:33:37 +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 66FB8206BF for ; Tue, 27 Aug 2019 15:33:37 +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="AXi2X6Vr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66FB8206BF 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]:52778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dTU-0004z1-7T for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:33:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47151) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwZ-0003c5-Ms for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003sX-Qg for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:35 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003lg-Dl; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pg1-x542.google.com with SMTP id i18so12832299pgl.11; Tue, 27 Aug 2019 07:59:16 -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=yTrGOZqcn9Ur+DdirV1AaFOzOQBx22unwFJ7Yun/vxk=; b=AXi2X6VrjqqEomnw4rQZ/u5ux87CSq7E1P1o5mbLCDibgup3Var3uhfF9PM6abClvc cGvaO8wV9JlOmmwLOdD46jM9Bf2eOhCRzDQu1C+XXX4R/BCXuWV6ClDnbWSX6V0Fggxp xckbQNENW+HvqF6h3qOOTic46lKyR9mCvetJYoHXnGlz+Ft4m+FNWo2iG9g4PTAXwEpD jJ0SSr75yrP/2rsgNEZ0S7+5jwEHFU4rLcf1FB6OiHYXr80TIPlf+zyr4dAOEHDtjO6x avPiONI2ohEFlvrOhpgsUe9uCyBaRxGWgZWkGhHV+MVcPFyeDsKxHeG71DnbauumWBf8 DYFg== 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=yTrGOZqcn9Ur+DdirV1AaFOzOQBx22unwFJ7Yun/vxk=; b=Eg1mbDKjq1vIEJ7KAVYnaLjZDG977eSXgX3ywKg5vo1ZImX2JT9/wRm6qwG7OfMcqL CAISTWM/aiTU4pYPXlKHhL12hnx2rSUqq9GRhvrXB0X+WoOrSgWNogZu3pT1Lkpg4IoF +rb6t5UAtG2cgtcpQ061DxmhLnE1+NW3s7Pbcx0dmbs7JLqLYPSAbSZJmLeLOGSpj6sE 4KZbvv65jOVvGC3ABwOg0rKC4o6ZDCWPFR/nlad8T7xGCIlCX4MGFJOybn0wNWKJbPtw 1yipeZLKgy6NyV5wzGwSi7w/uastKaXRWxQAWehpdNXsPqU/r1Jk0pbKgcZL/YOiT6nb XtaA== X-Gm-Message-State: APjAAAWkuhSNDuIzuM2R8gE1Pw9Q0s9XCQ2MW2l3iZE9zzOo27IEWJ42 0PM8iylKwOuaBKsJOWVoIa4= X-Google-Smtp-Source: APXvYqx2AcqdWNL/DviMHAfJJlA4Bo4HKLsE4R63YstVKVG+rIHoKEtQRjXYupUTm9yZWQPdnGwV1g== X-Received: by 2002:a63:2364:: with SMTP id u36mr20881926pgm.449.1566917955308; Tue, 27 Aug 2019 07:59:15 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.13 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:14 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:35 -0700 Message-Id: <1566917919-25381-27-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::542 Subject: [Qemu-devel] [PATCH v6 26/30] riscv: sifive: Implement a model for SiFive FU540 OTP 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" This implements a simple model for SiFive FU540 OTP (One-Time Programmable) Memory interface, primarily for reading out the stored serial number from the first 1 KiB of the 16 KiB OTP memory reserved by SiFive for internal use. Signed-off-by: Bin Meng --- Changes in v6: None Changes in v5: - change to use defines instead of enums - change to use qemu_log_mask(LOG_GUEST_ERROR,...) in sifive_u_otp - creating a 32-bit val variable and using that instead of casting everywhere in sifive_u_otp_write() - move all register initialization to sifive_u_otp_reset() function - drop sifive_u_otp_create() Changes in v4: - prefix all macros/variables/functions with SIFIVE_U/sifive_u in the sifive_u_otp driver Changes in v3: None Changes in v2: None hw/riscv/Makefile.objs | 1 + hw/riscv/sifive_u_otp.c | 190 ++++++++++++++++++++++++++++++++++++++++ include/hw/riscv/sifive_u_otp.h | 80 +++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 hw/riscv/sifive_u_otp.c create mode 100644 include/hw/riscv/sifive_u_otp.h diff --git a/hw/riscv/Makefile.objs b/hw/riscv/Makefile.objs index b95bbd5..fc3c6dd 100644 --- a/hw/riscv/Makefile.objs +++ b/hw/riscv/Makefile.objs @@ -8,6 +8,7 @@ obj-$(CONFIG_SIFIVE) += sifive_gpio.o obj-$(CONFIG_SIFIVE) += sifive_plic.o obj-$(CONFIG_SIFIVE) += sifive_test.o obj-$(CONFIG_SIFIVE_U) += sifive_u.o +obj-$(CONFIG_SIFIVE_U) += sifive_u_otp.o obj-$(CONFIG_SIFIVE_U) += sifive_u_prci.o obj-$(CONFIG_SIFIVE) += sifive_uart.o obj-$(CONFIG_SPIKE) += spike.o diff --git a/hw/riscv/sifive_u_otp.c b/hw/riscv/sifive_u_otp.c new file mode 100644 index 0000000..7d65a85 --- /dev/null +++ b/hw/riscv/sifive_u_otp.c @@ -0,0 +1,190 @@ +/* + * QEMU SiFive U OTP (One-Time Programmable) Memory interface + * + * Copyright (c) 2019 Bin Meng + * + * Simple model of the OTP to emulate register reads made by the SDK BSP + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/riscv/sifive_u_otp.h" + +static uint64_t sifive_u_otp_read(void *opaque, hwaddr addr, unsigned int size) +{ + SiFiveUOTPState *s = opaque; + + switch (addr) { + case SIFIVE_U_OTP_PA: + return s->pa; + case SIFIVE_U_OTP_PAIO: + return s->paio; + case SIFIVE_U_OTP_PAS: + return s->pas; + case SIFIVE_U_OTP_PCE: + return s->pce; + case SIFIVE_U_OTP_PCLK: + return s->pclk; + case SIFIVE_U_OTP_PDIN: + return s->pdin; + case SIFIVE_U_OTP_PDOUT: + if ((s->pce & SIFIVE_U_OTP_PCE_EN) && + (s->pdstb & SIFIVE_U_OTP_PDSTB_EN) && + (s->ptrim & SIFIVE_U_OTP_PTRIM_EN)) { + return s->fuse[s->pa & SIFIVE_U_OTP_PA_MASK]; + } else { + return 0xff; + } + case SIFIVE_U_OTP_PDSTB: + return s->pdstb; + case SIFIVE_U_OTP_PPROG: + return s->pprog; + case SIFIVE_U_OTP_PTC: + return s->ptc; + case SIFIVE_U_OTP_PTM: + return s->ptm; + case SIFIVE_U_OTP_PTM_REP: + return s->ptm_rep; + case SIFIVE_U_OTP_PTR: + return s->ptr; + case SIFIVE_U_OTP_PTRIM: + return s->ptrim; + case SIFIVE_U_OTP_PWE: + return s->pwe; + } + + qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%x\n", + __func__, (int)addr); + return 0; +} + +static void sifive_u_otp_write(void *opaque, hwaddr addr, + uint64_t val64, unsigned int size) +{ + SiFiveUOTPState *s = opaque; + uint32_t val32 = (uint32_t)val64; + + switch (addr) { + case SIFIVE_U_OTP_PA: + s->pa = val32 & SIFIVE_U_OTP_PA_MASK; + break; + case SIFIVE_U_OTP_PAIO: + s->paio = val32; + break; + case SIFIVE_U_OTP_PAS: + s->pas = val32; + break; + case SIFIVE_U_OTP_PCE: + s->pce = val32; + break; + case SIFIVE_U_OTP_PCLK: + s->pclk = val32; + break; + case SIFIVE_U_OTP_PDIN: + s->pdin = val32; + break; + case SIFIVE_U_OTP_PDOUT: + /* read-only */ + break; + case SIFIVE_U_OTP_PDSTB: + s->pdstb = val32; + break; + case SIFIVE_U_OTP_PPROG: + s->pprog = val32; + break; + case SIFIVE_U_OTP_PTC: + s->ptc = val32; + break; + case SIFIVE_U_OTP_PTM: + s->ptm = val32; + break; + case SIFIVE_U_OTP_PTM_REP: + s->ptm_rep = val32; + break; + case SIFIVE_U_OTP_PTR: + s->ptr = val32; + break; + case SIFIVE_U_OTP_PTRIM: + s->ptrim = val32; + break; + case SIFIVE_U_OTP_PWE: + s->pwe = val32; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%x v=0x%x\n", + __func__, (int)addr, (int)val64); + } +} + +static const MemoryRegionOps sifive_u_otp_ops = { + .read = sifive_u_otp_read, + .write = sifive_u_otp_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4 + } +}; + +static Property sifive_u_otp_properties[] = { + DEFINE_PROP_UINT32("serial", SiFiveUOTPState, serial, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void sifive_u_otp_realize(DeviceState *dev, Error **errp) +{ + SiFiveUOTPState *s = SIFIVE_U_OTP(dev); + + memory_region_init_io(&s->mmio, OBJECT(dev), &sifive_u_otp_ops, s, + TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); +} + +static void sifive_u_otp_reset(DeviceState *dev) +{ + SiFiveUOTPState *s = SIFIVE_U_OTP(dev); + + /* Initialize all fuses' initial value to 0xFFs */ + memset(s->fuse, 0xff, sizeof(s->fuse)); + + /* Make a valid content of serial number */ + s->fuse[SIFIVE_U_OTP_SERIAL_ADDR] = s->serial; + s->fuse[SIFIVE_U_OTP_SERIAL_ADDR + 1] = ~(s->serial); +} + +static void sifive_u_otp_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->props = sifive_u_otp_properties; + dc->realize = sifive_u_otp_realize; + dc->reset = sifive_u_otp_reset; +} + +static const TypeInfo sifive_u_otp_info = { + .name = TYPE_SIFIVE_U_OTP, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(SiFiveUOTPState), + .class_init = sifive_u_otp_class_init, +}; + +static void sifive_u_otp_register_types(void) +{ + type_register_static(&sifive_u_otp_info); +} + +type_init(sifive_u_otp_register_types) diff --git a/include/hw/riscv/sifive_u_otp.h b/include/hw/riscv/sifive_u_otp.h new file mode 100644 index 0000000..6392975 --- /dev/null +++ b/include/hw/riscv/sifive_u_otp.h @@ -0,0 +1,80 @@ +/* + * QEMU SiFive U OTP (One-Time Programmable) Memory interface + * + * Copyright (c) 2019 Bin Meng + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_SIFIVE_U_OTP_H +#define HW_SIFIVE_U_OTP_H + +#define SIFIVE_U_OTP_PA 0x00 +#define SIFIVE_U_OTP_PAIO 0x04 +#define SIFIVE_U_OTP_PAS 0x08 +#define SIFIVE_U_OTP_PCE 0x0C +#define SIFIVE_U_OTP_PCLK 0x10 +#define SIFIVE_U_OTP_PDIN 0x14 +#define SIFIVE_U_OTP_PDOUT 0x18 +#define SIFIVE_U_OTP_PDSTB 0x1C +#define SIFIVE_U_OTP_PPROG 0x20 +#define SIFIVE_U_OTP_PTC 0x24 +#define SIFIVE_U_OTP_PTM 0x28 +#define SIFIVE_U_OTP_PTM_REP 0x2C +#define SIFIVE_U_OTP_PTR 0x30 +#define SIFIVE_U_OTP_PTRIM 0x34 +#define SIFIVE_U_OTP_PWE 0x38 + +#define SIFIVE_U_OTP_PCE_EN (1 << 0) + +#define SIFIVE_U_OTP_PDSTB_EN (1 << 0) + +#define SIFIVE_U_OTP_PTRIM_EN (1 << 0) + +#define SIFIVE_U_OTP_PA_MASK 0xfff +#define SIFIVE_U_OTP_NUM_FUSES 0x1000 +#define SIFIVE_U_OTP_SERIAL_ADDR 0xfc + +#define SIFIVE_U_OTP_REG_SIZE 0x1000 + +#define TYPE_SIFIVE_U_OTP "riscv.sifive.u.otp" + +#define SIFIVE_U_OTP(obj) \ + OBJECT_CHECK(SiFiveUOTPState, (obj), TYPE_SIFIVE_U_OTP) + +typedef struct SiFiveUOTPState { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion mmio; + uint32_t pa; + uint32_t paio; + uint32_t pas; + uint32_t pce; + uint32_t pclk; + uint32_t pdin; + uint32_t pdstb; + uint32_t pprog; + uint32_t ptc; + uint32_t ptm; + uint32_t ptm_rep; + uint32_t ptr; + uint32_t ptrim; + uint32_t pwe; + uint32_t fuse[SIFIVE_U_OTP_NUM_FUSES]; + /* config */ + uint32_t serial; +} SiFiveUOTPState; + +#endif /* HW_SIFIVE_U_OTP_H */ From patchwork Tue Aug 27 14:58:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117203 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 706C014DB for ; Tue, 27 Aug 2019 15:21:39 +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 46A1F2070B for ; Tue, 27 Aug 2019 15:21:39 +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="AJ0IIfSK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46A1F2070B 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]:52582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dHt-0000T6-Rl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:21:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47063) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwX-0003ZA-BO for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003sC-NF for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:33 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:43115) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003lm-GW; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pl1-x644.google.com with SMTP id 4so11912086pld.10; Tue, 27 Aug 2019 07:59:17 -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=pPFxUsjpP9TtT276hZcFATg5pQD1Bp1U9oTzbmlgzkQ=; b=AJ0IIfSKHrJokRGYWkE8sCkpoaplr4OHiEY4LmJ5aXdVqNoO+j1opx0rWnExdo3f/7 whPTiakUVcgl5yN8X2W+w/Gy30De1OoThqIR4GbjclLwUNYbU2P2pD7SVLXxdGJeTTi4 pSbNZX015waDAN6ENYNjhX2LW7nES4bu6GG16Qmtl0YUwwsUoZ0jXgr/f7ii+wgxmR3n abfzxTNhJZ+Bz/BP3SfqcDSbSnX94FGfJLEQm1UjFQUYT8UZiyVt7fqYGSIVwt2PyO8/ hnAJ/e6w8osHPODGXFykvJE8bKHLGw8quG7637xIHa3eL9rknZWyRiFvZZl81ZvHeXPZ s0uQ== 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=pPFxUsjpP9TtT276hZcFATg5pQD1Bp1U9oTzbmlgzkQ=; b=Q9pb8PVFatf2u515xroeud1eSnnyW3umy0Cqhe+VqCPXg7DEAOz4A9QLZhyxFsku2v tuXyNwaYTHD03pnBIOul2T0BbkGljn1tBsjymsscTtSJdnbA6wvNk5tWpQG44Hh+Lmak IEsMMnJKsyzAB+3D1073sgdT7B5awA+CIioAVpvhY7BntlSaNEuMRK0mQLxcHjwI3PUu CX2SpoyBc37sHY4ser7CYlCeFRfyfzUz12GUmaakN5+A/n8+fKOgL4D4ofuVWeAKgqQt xyu8B3dSp4GhT0SJBELv97sL+D+GytXP++4I/J9eoalLM8CkchPRprK14sb71BejxxGA YMdw== X-Gm-Message-State: APjAAAWlXxRO8/TzgHJ8ySDAHE8dc+xfrsVIk3KKU5XSxmpcm0gq4ao5 asM8m/UvzcwLd+kb/3UJewR6w1OB X-Google-Smtp-Source: APXvYqyzHhY0uPeUkjdVruhJR9gXprjmkO8ZwS3ZReZKGxHWgNbFKJg/Q60/z9kAMbGo9P3qMx+2oA== X-Received: by 2002:a17:902:bcc2:: with SMTP id o2mr24997604pls.127.1566917956447; Tue, 27 Aug 2019 07:59:16 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:15 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:36 -0700 Message-Id: <1566917919-25381-28-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::644 Subject: [Qemu-devel] [PATCH v6 27/30] riscv: sifive_u: Instantiate OTP memory with a serial number 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" This adds an OTP memory with a given serial number to the sifive_u machine. With such support, the upstream U-Boot for sifive_fu540 boots out of the box on the sifive_u machine. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: - create sifive_u_otp block directly in the machine codes, instead of calling sifive_u_otp_create() Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 9 +++++++++ include/hw/riscv/sifive_u.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index d970037..516093e 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -10,6 +10,7 @@ * 1) CLINT (Core Level Interruptor) * 2) PLIC (Platform Level Interrupt Controller) * 3) PRCI (Power, Reset, Clock, Interrupt) + * 4) OTP (One-Time Programmable) memory with stored serial number * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -64,10 +65,12 @@ static const struct MemmapEntry { [SIFIVE_U_PRCI] = { 0x10000000, 0x1000 }, [SIFIVE_U_UART0] = { 0x10010000, 0x1000 }, [SIFIVE_U_UART1] = { 0x10011000, 0x1000 }, + [SIFIVE_U_OTP] = { 0x10070000, 0x1000 }, [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, [SIFIVE_U_GEM] = { 0x100900FC, 0x2000 }, }; +#define OTP_SERIAL 1 #define GEM_REVISION 0x10070109 static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, @@ -422,6 +425,9 @@ static void riscv_sifive_u_soc_init(Object *obj) sysbus_init_child_obj(obj, "prci", &s->prci, sizeof(s->prci), TYPE_SIFIVE_U_PRCI); + sysbus_init_child_obj(obj, "otp", &s->otp, sizeof(s->otp), + TYPE_SIFIVE_U_OTP); + qdev_prop_set_uint32(DEVICE(&s->otp), "serial", OTP_SERIAL); sysbus_init_child_obj(obj, "gem", &s->gem, sizeof(s->gem), TYPE_CADENCE_GEM); } @@ -498,6 +504,9 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) object_property_set_bool(OBJECT(&s->prci), true, "realized", &err); sysbus_mmio_map(SYS_BUS_DEVICE(&s->prci), 0, memmap[SIFIVE_U_PRCI].base); + object_property_set_bool(OBJECT(&s->otp), true, "realized", &err); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->otp), 0, memmap[SIFIVE_U_OTP].base); + for (i = 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) { plic_gpios[i] = qdev_get_gpio_in(DEVICE(s->plic), i); } diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index b41e730..7d9d901 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -22,6 +22,7 @@ #include "hw/net/cadence_gem.h" #include "hw/riscv/sifive_cpu.h" #include "hw/riscv/sifive_u_prci.h" +#include "hw/riscv/sifive_u_otp.h" #define TYPE_RISCV_U_SOC "riscv.sifive.u.soc" #define RISCV_U_SOC(obj) \ @@ -38,6 +39,7 @@ typedef struct SiFiveUSoCState { RISCVHartArrayState u_cpus; DeviceState *plic; SiFiveUPRCIState prci; + SiFiveUOTPState otp; CadenceGEMState gem; } SiFiveUSoCState; @@ -59,6 +61,7 @@ enum { SIFIVE_U_PRCI, SIFIVE_U_UART0, SIFIVE_U_UART1, + SIFIVE_U_OTP, SIFIVE_U_DRAM, SIFIVE_U_GEM }; From patchwork Tue Aug 27 14:58:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117217 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 29C061395 for ; Tue, 27 Aug 2019 15:29:25 +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 0044E217F5 for ; Tue, 27 Aug 2019 15:29:24 +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="SPSwl+6F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0044E217F5 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]:52720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dPP-0001BX-Sa for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47113) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwY-0003av-PN for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwS-0003rQ-T9 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:34 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003ly-BY; Tue, 27 Aug 2019 10:59:28 -0400 Received: by mail-pl1-x641.google.com with SMTP id m9so11910160pls.8; Tue, 27 Aug 2019 07:59:18 -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=nIJLB67fMjf3JVrvsxTrjVPXmzF4BcbsoumjXEkQX4M=; b=SPSwl+6FEb8CghA9OTTqWnC1R6rKXExNMamFx34rVjQBmM3+j7zlhJYgfGyNVMMMnR EF9itirMsEQI7ITV0KTDps5LBIzBabJ5wnPkSubO5aaBDOZquuZVGiXzcs2Gpt4IotrC GuJGTZvdfacKSLcVZ+DbVr1TUPj4aRaGHsAWusS2lsGgqboaCFOUoiqKTvIMUMUkgk5i VuwKR1u/cvFeAvagFQBQWKV6gETRY1dKWM/Vg8yxjliAqonceXybp1arNms0i1IEP/tU hDgr6LvcYN7paMlWgVk0jBDF6pexdPCtlPpRbw9ReuVqOU5ZCzG55heavjKbTFq0Op+z /tsA== 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=nIJLB67fMjf3JVrvsxTrjVPXmzF4BcbsoumjXEkQX4M=; b=tKWjog1CMKfZkyr/pzwBBuXuMxgPRQ7afuYvg3THZeQolzeWJaXXg2/BrHqV/FjNxI doIIflTZ+at4YdL6npFoAzrvsqmWX0nMNKZ2UN7GVax6FDZboL6baY/v+3ycAW/LuPjL luYZEghMTtrG/B1g4pthFcnz9ehQZv9HQSQVYTc9bkxqsSXTa5YfZzgGMlsZWlGG2ssm YCwWSsz7XI3xManJNRTQ4ed94tH9qfEuFWBzPlkb1fdi5N/xn86ezKaSau0S2n7oFP9X T9yW5JU021Eoe0mOjbSo4wWZQ33VcUAcR08pEQ6558XsL0EYP8m1IyRsLJuwwBmN8BR6 tiDg== X-Gm-Message-State: APjAAAVq6nKjkkSOXfNOMySVsuL79HQOD2cmwOw6/ENsowNGJP52iaAO 4lPGh4gVKmyB8bOgC9fh4N8= X-Google-Smtp-Source: APXvYqwtTtgplIH6h5Y8YBJQBvK8ZsqoRMW4VvVa0hzk/wacMa7m9OetqmZK4pHjyw/rLB9jlRHI6w== X-Received: by 2002:a17:902:d24:: with SMTP id 33mr6090007plu.133.1566917957514; Tue, 27 Aug 2019 07:59:17 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.16 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:16 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:37 -0700 Message-Id: <1566917919-25381-29-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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 v6 28/30] riscv: sifive_u: Fix broken GEM support 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" At present the GEM support in sifive_u machine is seriously broken. The GEM block register base was set to a weird number (0x100900FC), which for no way could work with the cadence_gem model in QEMU. Not like other GEM variants, the FU540-specific GEM has a management block to control 10/100/1000Mbps link speed changes, that is mapped to 0x100a0000. We can simply map it into MMIO space without special handling using create_unimplemented_device(). Update the GEM node compatible string to use the official name used by the upstream Linux kernel, and add the management block reg base & size to the property encoding. Tested with upstream U-Boot and Linux kernel MACB drivers. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: - add the missing "local-mac-address" property in the ethernet node Changes in v4: None Changes in v3: None Changes in v2: - use create_unimplemented_device() to create the GEM management block instead of sifive_mmio_emulate() - add "phy-handle" property to the ethernet node hw/riscv/sifive_u.c | 24 ++++++++++++++++++++---- include/hw/riscv/sifive_u.h | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 516093e..a7225f9 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -3,6 +3,7 @@ * * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu * Copyright (c) 2017 SiFive, Inc. + * Copyright (c) 2019 Bin Meng * * Provides a board compatible with the SiFive Freedom U SDK: * @@ -11,6 +12,7 @@ * 2) PLIC (Platform Level Interrupt Controller) * 3) PRCI (Power, Reset, Clock, Interrupt) * 4) OTP (One-Time Programmable) memory with stored serial number + * 5) GEM (Gigabit Ethernet Controller) and management block * * This board currently generates devicetree dynamically that indicates at least * two harts and up to five harts. @@ -38,6 +40,7 @@ #include "hw/sysbus.h" #include "hw/char/serial.h" #include "hw/cpu/cluster.h" +#include "hw/misc/unimp.h" #include "target/riscv/cpu.h" #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_plic.h" @@ -46,6 +49,7 @@ #include "hw/riscv/sifive_u.h" #include "hw/riscv/boot.h" #include "chardev/char.h" +#include "net/eth.h" #include "sysemu/arch_init.h" #include "sysemu/device_tree.h" #include "exec/address-spaces.h" @@ -67,7 +71,8 @@ static const struct MemmapEntry { [SIFIVE_U_UART1] = { 0x10011000, 0x1000 }, [SIFIVE_U_OTP] = { 0x10070000, 0x1000 }, [SIFIVE_U_DRAM] = { 0x80000000, 0x0 }, - [SIFIVE_U_GEM] = { 0x100900FC, 0x2000 }, + [SIFIVE_U_GEM] = { 0x10090000, 0x2000 }, + [SIFIVE_U_GEM_MGMT] = { 0x100a0000, 0x1000 }, }; #define OTP_SERIAL 1 @@ -84,7 +89,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, char ethclk_names[] = "pclk\0hclk"; uint32_t plic_phandle, prci_phandle, ethclk_phandle, phandle = 1; uint32_t uartclk_phandle; - uint32_t hfclk_phandle, rtcclk_phandle; + uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle; fdt = s->fdt = create_device_tree(&s->fdt_size); if (!fdt) { @@ -254,21 +259,28 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, ethclk_phandle = qemu_fdt_get_phandle(fdt, nodename); g_free(nodename); + phy_phandle = phandle++; nodename = g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "compatible", "cdns,macb"); + qemu_fdt_setprop_string(fdt, nodename, "compatible", + "sifive,fu540-c000-gem"); qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_GEM].base, - 0x0, memmap[SIFIVE_U_GEM].size); + 0x0, memmap[SIFIVE_U_GEM].size, + 0x0, memmap[SIFIVE_U_GEM_MGMT].base, + 0x0, memmap[SIFIVE_U_GEM_MGMT].size); qemu_fdt_setprop_string(fdt, nodename, "reg-names", "control"); qemu_fdt_setprop_string(fdt, nodename, "phy-mode", "gmii"); + qemu_fdt_setprop_cell(fdt, nodename, "phy-handle", phy_phandle); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_GEM_IRQ); qemu_fdt_setprop_cells(fdt, nodename, "clocks", prci_phandle, PRCI_CLK_GEMGXLPLL, prci_phandle, PRCI_CLK_GEMGXLPLL); qemu_fdt_setprop(fdt, nodename, "clock-names", ethclk_names, sizeof(ethclk_names)); + qemu_fdt_setprop(fdt, nodename, "local-mac-address", + s->soc.gem.conf.macaddr.a, ETH_ALEN); qemu_fdt_setprop_cell(fdt, nodename, "#address-cells", 1); qemu_fdt_setprop_cell(fdt, nodename, "#size-cells", 0); g_free(nodename); @@ -276,6 +288,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, nodename = g_strdup_printf("/soc/ethernet@%lx/ethernet-phy@0", (long)memmap[SIFIVE_U_GEM].base); qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cell(fdt, nodename, "phandle", phy_phandle); qemu_fdt_setprop_cell(fdt, nodename, "reg", 0x0); g_free(nodename); @@ -525,6 +538,9 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem), 0, memmap[SIFIVE_U_GEM].base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem), 0, plic_gpios[SIFIVE_U_GEM_IRQ]); + + create_unimplemented_device("riscv.sifive.u.gem-mgmt", + memmap[SIFIVE_U_GEM_MGMT].base, memmap[SIFIVE_U_GEM_MGMT].size); } static void riscv_sifive_u_machine_init(MachineClass *mc) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 7d9d901..d2b9d99 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -63,7 +63,8 @@ enum { SIFIVE_U_UART1, SIFIVE_U_OTP, SIFIVE_U_DRAM, - SIFIVE_U_GEM + SIFIVE_U_GEM, + SIFIVE_U_GEM_MGMT }; enum { From patchwork Tue Aug 27 14:58:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117209 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 3BB8D1395 for ; Tue, 27 Aug 2019 15:26:13 +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 126B3206BF for ; Tue, 27 Aug 2019 15:26:13 +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="p33f5w0e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 126B3206BF 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]:52632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dMJ-0005aO-K0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47070) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwX-0003ZS-H5 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003rb-5I for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:33 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003n3-DU; Tue, 27 Aug 2019 10:59:28 -0400 Received: by mail-pf1-x442.google.com with SMTP id d85so14308283pfd.2; Tue, 27 Aug 2019 07:59:20 -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=Yi7UvJSWpjgfFbNixgh5ya3t0YpLigDwkAwMsTmzWc4=; b=p33f5w0e9w1pfr0gCSa0wyPhGHhjHVyqwmWvCSCHONxnjCratIlXqMddYDoVndNR1F ZRVMhHb+scbdD9Y01TnYGes0Gat6KD2UcJJPyDb35YlKRUvk7lBUyUmjOvxMvn9oWbgv EUAt+OTQnWsoooRS0/tubwE94U5/lL/W5D9NRmUGjBISARV3TmvpTp2XZcbAreob8vWX aS/vEeoDHlnv7Zoaj4A8Htlm7kz1S4MlHBNmq7zyXikNBZJ7IBaB1D/eRLOnV6M2rJ6a l64ypSC1F3SAiX9/7NK6Nk6BL4D8VhY3OXMgg63osac8Ndeet5Kxd28BrLMB8kFdRD/x fYqg== 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=Yi7UvJSWpjgfFbNixgh5ya3t0YpLigDwkAwMsTmzWc4=; b=lVjDJbRiBF4Q/Kmly+ztHV9tL9nIdhSOvhcUfa6KhuzGS2yfXNI5YkPoDgMRixMVHQ J4s+K5bzSVzAj4HO94x2ECeMYVcF3CeyDIM9hX/T/L8EQE4Gm6PeL2zoSNe+Q816aF2K iTLUurzK3nz2tWWaz3Y7zJGtef/+lkwAtVN4gLIEKUfAhvM4n2C9CO9VLevEEkP3nM/u 2BWPN0Ndqsty719AJ5XtQSGnRT2xxpPZWZQjMNCQaAV2qurXz8VrSf4PmPEa9TTNOIIU /1oacEuycuOU51vOfVbtNVut0EcbGGj0Q2gFGiX0jfrJMockLwffTuNf0tvnSDFo0SBB bIuQ== X-Gm-Message-State: APjAAAXQQhbjrfA9TDPW5SBz2kCb5va36ko4Fczdl66Fn93Qd2xu2MMK 49jsqUehBsWCy5EN/Svw8QI= X-Google-Smtp-Source: APXvYqzdTXl4mEiVJj60mvMKorPC/nGSgLLWR2R2XoO2gyc505AcvDbiHirbwoKGu0QGsWeH/rCAVA== X-Received: by 2002:a63:29c4:: with SMTP id p187mr21929117pgp.330.1566917958474; Tue, 27 Aug 2019 07:59:18 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.17 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:17 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:38 -0700 Message-Id: <1566917919-25381-30-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::442 Subject: [Qemu-devel] [PATCH v6 29/30] riscv: sifive_u: Remove handcrafted clock nodes for UART and ethernet 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" In the past we did not have a model for PRCI, hence two handcrafted clock nodes ("/soc/ethclk" and "/soc/uartclk") were created for the purpose of supplying hard-coded clock frequencies. But now since we have added the PRCI support in QEMU, we don't need them any more. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: - new patch to remove handcrafted clock nodes for UART and ethernet Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 24 +----------------------- include/hw/riscv/sifive_u.h | 3 +-- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index a7225f9..f14217c 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -87,8 +87,7 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, uint32_t *cells; char *nodename; char ethclk_names[] = "pclk\0hclk"; - uint32_t plic_phandle, prci_phandle, ethclk_phandle, phandle = 1; - uint32_t uartclk_phandle; + uint32_t plic_phandle, prci_phandle, phandle = 1; uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle; fdt = s->fdt = create_device_tree(&s->fdt_size); @@ -248,17 +247,6 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, g_free(cells); g_free(nodename); - ethclk_phandle = phandle++; - 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", ethclk_phandle); - ethclk_phandle = qemu_fdt_get_phandle(fdt, nodename); - g_free(nodename); - phy_phandle = phandle++; nodename = g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); @@ -292,16 +280,6 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_cell(fdt, nodename, "reg", 0x0); g_free(nodename); - uartclk_phandle = phandle++; - nodename = g_strdup_printf("/soc/uartclk"); - 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", 3686400); - qemu_fdt_setprop_cell(fdt, nodename, "phandle", uartclk_phandle); - uartclk_phandle = qemu_fdt_get_phandle(fdt, nodename); - g_free(nodename); - nodename = g_strdup_printf("/soc/serial@%lx", (long)memmap[SIFIVE_U_UART0].base); qemu_fdt_add_subnode(fdt, nodename); diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index d2b9d99..3bb87cb 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -76,8 +76,7 @@ enum { enum { SIFIVE_U_CLOCK_FREQ = 1000000000, SIFIVE_U_HFCLK_FREQ = 33333333, - SIFIVE_U_RTCCLK_FREQ = 1000000, - SIFIVE_U_GEM_CLOCK_FREQ = 125000000 + SIFIVE_U_RTCCLK_FREQ = 1000000 }; #define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 From patchwork Tue Aug 27 14:58:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 11117205 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 BC8B014DB for ; Tue, 27 Aug 2019 15:22:40 +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 92C93206BF for ; Tue, 27 Aug 2019 15:22:40 +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="Qz5x9RVY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92C93206BF 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]:52584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2dIt-0001hu-A6 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 11:22:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47057) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2cwW-0003YO-OG for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2cwT-0003rk-9l for qemu-devel@nongnu.org; Tue, 27 Aug 2019 10:59:32 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2cwS-0003n5-Ds; Tue, 27 Aug 2019 10:59:29 -0400 Received: by mail-pg1-x543.google.com with SMTP id x15so12850907pgg.8; Tue, 27 Aug 2019 07:59:20 -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=pn67UZsnC0fBABeEhbb7qsEbngTloit0lPBfCFb080c=; b=Qz5x9RVY0f6zy1sxv15jZFQgu4BTKyctPMGPG+Fhn+abLOZa3KMUSIc0vaaMHXaGtm y0l1aWpHn6VU2mBOH+Tt+PsASTQSFfDJ59u90OAs7wNTH0VAVFiASqKDOafK+BQn318B AM3eDU6E87R7jFUZlfYPUbIzsKxfAnZlxc4bxQGLxT0fR5X3Tkb4pknyyHrrNXOiC/wl 7q+U+Rdf31sWa/tVHNVIDrsAyqXSwy5EJwSdgN6I/G3wsM/CxjpUTrGdF+MqT4ZF3LO3 AKCnBdczHIR8OubncjYfyFE9NsfVQfsHH3I6g9Jz+KeuA5wklpA9mQI6aHGD79R415ut YkAg== 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=pn67UZsnC0fBABeEhbb7qsEbngTloit0lPBfCFb080c=; b=NS2nS4xSXFH2/DXbnXwylV1eJtMD96KNxg+WeN6s3vDrSmbIAAvvhFfl+HXw+duaWb sD1q13e9gjH4x9p9yZ2On91uGO/tLFd7vVIaSLtBq6yMqgYiYS0FcgaHvgSQKnBsI/37 mTWrCeUBexveAvafAhm3X2OS7UeOaY5SWyiOgq1IsHVsDnEKEnnEYsrZxctHgeWQrU4X XDBd2R1SNDOekC0CA3Nj6O7tqw6lnSEkNfDgnQPPfNNLbILVylGUK5qPKd1/x804zL2O 2rpEaNu8qXSIlVJNnYGlmZ9r78DlrcsenEL5ek2zObjo6rwLSFOmaAKvIOrQOOsW+BvQ K9cw== X-Gm-Message-State: APjAAAUEjWSqddj1I4h7nwxJECs1JQKwLHP4d09VFUUYNXYVddbAEE7V 8IkuWnfrbAVlSYO0Zn2a0X4= X-Google-Smtp-Source: APXvYqwyBZSKgsxtQBF/ZMY0B9UtRW65m9H5AhDbJqRcx34mYlvhBBgfWfRL4GC26g1L+e2+PQaClw== X-Received: by 2002:a63:eb06:: with SMTP id t6mr21544689pgh.107.1566917959504; Tue, 27 Aug 2019 07:59:19 -0700 (PDT) Received: from localhost.localdomain (unknown-224-80.windriver.com. [147.11.224.80]) by smtp.gmail.com with ESMTPSA id j15sm14839344pfr.146.2019.08.27.07.59.18 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Aug 2019 07:59:18 -0700 (PDT) From: Bin Meng To: Alistair Francis , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Date: Tue, 27 Aug 2019 07:58:39 -0700 Message-Id: <1566917919-25381-31-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1566917919-25381-1-git-send-email-bmeng.cn@gmail.com> References: <1566917919-25381-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::543 Subject: [Qemu-devel] [PATCH v6 30/30] riscv: sifive_u: Update model and compatible strings in device tree 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" This updates model and compatible strings to use the same strings as used in the Linux kernel device tree (hifive-unleashed-a00.dts). Signed-off-by: Bin Meng Reviewed-by: Alistair Francis --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None hw/riscv/sifive_u.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index f14217c..c7f7c2c 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -96,8 +96,9 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, exit(1); } - qemu_fdt_setprop_string(fdt, "/", "model", "ucbbar,spike-bare,qemu"); - qemu_fdt_setprop_string(fdt, "/", "compatible", "ucbbar,spike-bare-dev"); + qemu_fdt_setprop_string(fdt, "/", "model", "SiFive HiFive Unleashed A00"); + qemu_fdt_setprop_string(fdt, "/", "compatible", + "sifive,hifive-unleashed-a00"); qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2);