From patchwork Sat Apr 16 19:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 12816142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E948EC433EF for ; Sun, 17 Apr 2022 21:16:06 +0000 (UTC) Received: from localhost ([::1]:47568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngCFZ-0004V3-L5 for qemu-devel@archiver.kernel.org; Sun, 17 Apr 2022 17:16:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCD6-0001sL-UX; Sun, 17 Apr 2022 17:13:32 -0400 Received: from test-v6.fluff.org ([2a01:4f8:222:2004::3]:48562 helo=hetzy.fluff.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCD5-0001bW-Fd; Sun, 17 Apr 2022 17:13:32 -0400 Received: from localhost ([127.0.0.1] helo=luna) by hetzy.fluff.org with esmtp (Exim 4.89) (envelope-from ) id 1nfp7E-0008Rs-65; Sat, 16 Apr 2022 21:33:56 +0100 Received: from ben by luna with local (Exim 4.95) (envelope-from ) id 1nfo7v-002G1c-Vx; Sat, 16 Apr 2022 20:30:35 +0100 From: Ben Dooks To: qemu-devel@nongnu.org Subject: [PATCH 1/4] device_tree: add qemu_fdt_setprop_reg64 helper Date: Sat, 16 Apr 2022 20:30:31 +0100 Message-Id: <20220416193034.538161-2-qemu@ben.fluff.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220416193034.538161-1-qemu@ben.fluff.org> References: <20220416193034.538161-1-qemu@ben.fluff.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ben@luna.fluff.org X-SA-Exim-Scanned: No (on hetzy.fluff.org); SAEximRunCond expanded to false Received-SPF: none client-ip=2a01:4f8:222:2004::3; envelope-from=ben@luna.fluff.org; helo=hetzy.fluff.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.187, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Dooks , palmer@dabbelt.com, Alistair.Francis@wdc.com, bin.meng@windriver.com, qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a macro qemu_fdt_setprop_reg64() to set the given node's reg property directly from the memory map entry to avoid open coding of the following: qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_DEV_OTP].base, 0x0, memmap[SIFIVE_U_DEV_OTP].size); Signed-off-by: Ben Dooks --- include/sysemu/device_tree.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index ef060a9759..28352e7fcb 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -135,6 +135,21 @@ int qemu_fdt_add_path(void *fdt, const char *path); sizeof(qdt_tmp)); \ } while (0) +/** + * qemu_fdt_setprop_reg64: + * @fdt: the device tree path + * @node_path: node to set property on + * @map: the map entry to set the reg from + * + * A helper tp set the 'reg' node on the specified node from the given map + * entry. + */ +#define qemu_fdt_setprop_reg64(fdt, path, map) \ + qemu_fdt_setprop_cells(fdt, path, "reg", \ + (map)->base >> 32, (map)->base, \ + (map)->size >> 32, (map)->size) + + void qemu_fdt_dumpdtb(void *fdt, int size); /** From patchwork Sat Apr 16 19:30:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 12816145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 236A5C433F5 for ; Sun, 17 Apr 2022 21:17:48 +0000 (UTC) Received: from localhost ([::1]:53330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngCHD-0008Ob-3O for qemu-devel@archiver.kernel.org; Sun, 17 Apr 2022 17:17:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCDC-00021j-CD; Sun, 17 Apr 2022 17:13:38 -0400 Received: from test-v6.fluff.org ([2a01:4f8:222:2004::3]:48562 helo=hetzy.fluff.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCDA-0001bW-Je; Sun, 17 Apr 2022 17:13:38 -0400 Received: from localhost ([127.0.0.1] helo=luna) by hetzy.fluff.org with esmtp (Exim 4.89) (envelope-from ) id 1nfp7F-0008S0-DH; Sat, 16 Apr 2022 21:33:57 +0100 Received: from ben by luna with local (Exim 4.95) (envelope-from ) id 1nfo7w-002G1f-0o; Sat, 16 Apr 2022 20:30:36 +0100 From: Ben Dooks To: qemu-devel@nongnu.org Subject: [PATCH 2/4] hw/riscv: use qemu_fdt_setprop_reg64() in sifive_u.c Date: Sat, 16 Apr 2022 20:30:32 +0100 Message-Id: <20220416193034.538161-3-qemu@ben.fluff.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220416193034.538161-1-qemu@ben.fluff.org> References: <20220416193034.538161-1-qemu@ben.fluff.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ben@luna.fluff.org X-SA-Exim-Scanned: No (on hetzy.fluff.org); SAEximRunCond expanded to false Received-SPF: none client-ip=2a01:4f8:222:2004::3; envelope-from=ben@luna.fluff.org; helo=hetzy.fluff.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.187, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Dooks , palmer@dabbelt.com, Alistair.Francis@wdc.com, bin.meng@windriver.com, qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the qemu_fdt_setprop_reg64() to replace the code that sets the property manually. Signed-off-by: Ben Dooks --- hw/riscv/sifive_u.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 7fbc7dea42..1fe364cbb0 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -223,9 +223,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_string_array(fdt, nodename, "compatible", (char **)&clint_compat, ARRAY_SIZE(clint_compat)); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_CLINT].base, - 0x0, memmap[SIFIVE_U_DEV_CLINT].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_CLINT]); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", cells, ms->smp.cpus * sizeof(uint32_t) * 4); g_free(cells); @@ -235,9 +233,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, (long)memmap[SIFIVE_U_DEV_OTP].base); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_cell(fdt, nodename, "fuse-count", SIFIVE_U_OTP_REG_SIZE); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_OTP].base, - 0x0, memmap[SIFIVE_U_DEV_OTP].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_OTP]); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,fu540-c000-otp"); g_free(nodename); @@ -250,9 +246,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, 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_DEV_PRCI].base, - 0x0, memmap[SIFIVE_U_DEV_PRCI].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_PRCI]); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,fu540-c000-prci"); g_free(nodename); @@ -284,9 +278,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", cells, (ms->smp.cpus * 4 - 2) * sizeof(uint32_t)); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_PLIC].base, - 0x0, memmap[SIFIVE_U_DEV_PLIC].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_PLIC]); 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); @@ -304,9 +296,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0); qemu_fdt_setprop_cell(fdt, nodename, "#gpio-cells", 2); qemu_fdt_setprop(fdt, nodename, "gpio-controller", NULL, 0); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_GPIO].base, - 0x0, memmap[SIFIVE_U_DEV_GPIO].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_GPIO]); qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_GPIO_IRQ0, SIFIVE_U_GPIO_IRQ1, SIFIVE_U_GPIO_IRQ2, SIFIVE_U_GPIO_IRQ3, SIFIVE_U_GPIO_IRQ4, SIFIVE_U_GPIO_IRQ5, SIFIVE_U_GPIO_IRQ6, @@ -342,9 +332,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, nodename = g_strdup_printf("/soc/cache-controller@%lx", (long)memmap[SIFIVE_U_DEV_L2CC].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_L2CC].base, - 0x0, memmap[SIFIVE_U_DEV_L2CC].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_L2CC]); qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_L2CC_IRQ0, SIFIVE_U_L2CC_IRQ1, SIFIVE_U_L2CC_IRQ2); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); @@ -366,9 +354,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, prci_phandle, PRCI_CLK_TLCLK); qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_QSPI2_IRQ); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_QSPI2].base, - 0x0, memmap[SIFIVE_U_DEV_QSPI2].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_QSPI2]); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,spi0"); g_free(nodename); @@ -391,9 +377,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, prci_phandle, PRCI_CLK_TLCLK); qemu_fdt_setprop_cell(fdt, nodename, "interrupts", SIFIVE_U_QSPI0_IRQ); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_QSPI0].base, - 0x0, memmap[SIFIVE_U_DEV_QSPI0].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_QSPI0]); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,spi0"); g_free(nodename); @@ -449,9 +433,8 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, (long)memmap[SIFIVE_U_DEV_PWM0].base); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,pwm0"); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_PWM0].base, - 0x0, memmap[SIFIVE_U_DEV_PWM0].size); +qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_PWM0]); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); qemu_fdt_setprop_cells(fdt, nodename, "interrupts", SIFIVE_U_PWM0_IRQ0, SIFIVE_U_PWM0_IRQ1, @@ -496,9 +479,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, (long)memmap[SIFIVE_U_DEV_UART0].base); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_string(fdt, nodename, "compatible", "sifive,uart0"); - qemu_fdt_setprop_cells(fdt, nodename, "reg", - 0x0, memmap[SIFIVE_U_DEV_UART0].base, - 0x0, memmap[SIFIVE_U_DEV_UART0].size); + qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_UART0]); qemu_fdt_setprop_cells(fdt, nodename, "clocks", prci_phandle, PRCI_CLK_TLCLK); qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); From patchwork Sat Apr 16 19:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 12816144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4B3DEC433EF for ; Sun, 17 Apr 2022 21:16:11 +0000 (UTC) Received: from localhost ([::1]:48050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngCFe-0004sh-CZ for qemu-devel@archiver.kernel.org; Sun, 17 Apr 2022 17:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCDF-00024C-17; Sun, 17 Apr 2022 17:13:41 -0400 Received: from test-v6.fluff.org ([2a01:4f8:222:2004::3]:48562 helo=hetzy.fluff.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCDD-0001bW-Co; Sun, 17 Apr 2022 17:13:40 -0400 Received: from localhost ([127.0.0.1] helo=luna) by hetzy.fluff.org with esmtp (Exim 4.89) (envelope-from ) id 1nfp7G-0008S9-8V; Sat, 16 Apr 2022 21:33:58 +0100 Received: from ben by luna with local (Exim 4.95) (envelope-from ) id 1nfo7w-002G1i-25; Sat, 16 Apr 2022 20:30:36 +0100 From: Ben Dooks To: qemu-devel@nongnu.org Subject: [PATCH 3/4] device_tree: add qemu_fdt_setprop_strings() helper Date: Sat, 16 Apr 2022 20:30:33 +0100 Message-Id: <20220416193034.538161-4-qemu@ben.fluff.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220416193034.538161-1-qemu@ben.fluff.org> References: <20220416193034.538161-1-qemu@ben.fluff.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ben@luna.fluff.org X-SA-Exim-Scanned: No (on hetzy.fluff.org); SAEximRunCond expanded to false Received-SPF: none client-ip=2a01:4f8:222:2004::3; envelope-from=ben@luna.fluff.org; helo=hetzy.fluff.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.187, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Dooks , palmer@dabbelt.com, Alistair.Francis@wdc.com, bin.meng@windriver.com, qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a helper to set a property from a set of strings to reduce the following code: static const char * const clint_compat[2] = { "sifive,clint0", "riscv,clint0" }; qemu_fdt_setprop_string_array(fdt, nodename, "compatible", (char **)&clint_compat, ARRAY_SIZE(clint_compat)); Signed-off-by: Ben Dooks --- include/sysemu/device_tree.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index 28352e7fcb..6ad09564d7 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -87,6 +87,21 @@ int qemu_fdt_setprop_string(void *fdt, const char *node_path, int qemu_fdt_setprop_string_array(void *fdt, const char *node_path, const char *prop, char **array, int len); +/** + * qemu_fdt_setprop_strings: set a property from a set of strings + * + * @fdt: pointer to the dt blob + * @name: node name + * @prop: property array + */ +#define qemu_fdt_setprop_strings(fdt, path, prop, ...) \ + do { \ + static const char * const __strs[] = { __VA_ARGS__ }; \ + qemu_fdt_setprop_string_array(fdt, path, prop, \ + (char **)&__strs, ARRAY_SIZE(__strs)); \ + } while(0) + + int qemu_fdt_setprop_phandle(void *fdt, const char *node_path, const char *property, const char *target_node_path); From patchwork Sat Apr 16 19:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 12816143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 68F3BC433F5 for ; Sun, 17 Apr 2022 21:16:10 +0000 (UTC) Received: from localhost ([::1]:47924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngCFd-0004ne-GG for qemu-devel@archiver.kernel.org; Sun, 17 Apr 2022 17:16:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCD9-0001wf-Im; Sun, 17 Apr 2022 17:13:36 -0400 Received: from test-v6.fluff.org ([2a01:4f8:222:2004::3]:48562 helo=hetzy.fluff.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ngCD7-0001bW-VD; Sun, 17 Apr 2022 17:13:35 -0400 Received: from localhost ([127.0.0.1] helo=luna) by hetzy.fluff.org with esmtp (Exim 4.89) (envelope-from ) id 1nfp7D-0008Ro-Aj; Sat, 16 Apr 2022 21:33:55 +0100 Received: from ben by luna with local (Exim 4.95) (envelope-from ) id 1nfo7w-002G1l-3F; Sat, 16 Apr 2022 20:30:36 +0100 From: Ben Dooks To: qemu-devel@nongnu.org Subject: [PATCH 4/4] hw/riscv: use qemu_fdt_setprop_strings() in sifive_u.c Date: Sat, 16 Apr 2022 20:30:34 +0100 Message-Id: <20220416193034.538161-5-qemu@ben.fluff.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220416193034.538161-1-qemu@ben.fluff.org> References: <20220416193034.538161-1-qemu@ben.fluff.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ben@luna.fluff.org X-SA-Exim-Scanned: No (on hetzy.fluff.org); SAEximRunCond expanded to false Received-SPF: none client-ip=2a01:4f8:222:2004::3; envelope-from=ben@luna.fluff.org; helo=hetzy.fluff.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.187, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Dooks , palmer@dabbelt.com, Alistair.Francis@wdc.com, bin.meng@windriver.com, qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the qemu_fdt_setprop_strings() in sifve_u.c to simplify the code. Signed-off-by; Ben Dooks --- hw/riscv/sifive_u.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 1fe364cbb0..b00086d86e 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -103,13 +103,6 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, char *nodename; uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1; uint32_t hfclk_phandle, rtcclk_phandle, phy_phandle; - static const char * const ethclk_names[2] = { "pclk", "hclk" }; - static const char * const clint_compat[2] = { - "sifive,clint0", "riscv,clint0" - }; - static const char * const plic_compat[2] = { - "sifive,plic-1.0.0", "riscv,plic0" - }; if (ms->dtb) { fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size); @@ -221,8 +214,8 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, nodename = g_strdup_printf("/soc/clint@%lx", (long)memmap[SIFIVE_U_DEV_CLINT].base); qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string_array(fdt, nodename, "compatible", - (char **)&clint_compat, ARRAY_SIZE(clint_compat)); + qemu_fdt_setprop_strings(fdt, nodename, "compatible", + "sifive,clint0", "riscv,clint0"); qemu_fdt_setprop_reg64(fdt, nodename, &memmap[SIFIVE_U_DEV_CLINT]); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", cells, ms->smp.cpus * sizeof(uint32_t) * 4); @@ -273,8 +266,10 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, (long)memmap[SIFIVE_U_DEV_PLIC].base); qemu_fdt_add_subnode(fdt, nodename); qemu_fdt_setprop_cell(fdt, nodename, "#interrupt-cells", 1); - qemu_fdt_setprop_string_array(fdt, nodename, "compatible", - (char **)&plic_compat, ARRAY_SIZE(plic_compat)); + //qemu_fdt_setprop_string_array(fdt, nodename, "compatible", + // (char **)&plic_compat, ARRAY_SIZE(plic_compat)); + qemu_fdt_setprop_strings(fdt, nodename, "compatbile", + "sifive,plic-1.0.0", "riscv,plic0"); qemu_fdt_setprop(fdt, nodename, "interrupt-controller", NULL, 0); qemu_fdt_setprop(fdt, nodename, "interrupts-extended", cells, (ms->smp.cpus * 4 - 2) * sizeof(uint32_t)); @@ -410,8 +405,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, 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_string_array(fdt, nodename, "clock-names", - (char **)ðclk_names, ARRAY_SIZE(ethclk_names)); + qemu_fdt_setprop_strings(fdt, nodename, "clock-names", "pclk", "hclk"); 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);