From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A9DCC3A5A4 for ; Tue, 27 Aug 2019 15:22: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 57E512070B for ; Tue, 27 Aug 2019 15:22: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="AJ0IIfSK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57E512070B 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+qemu-devel=archiver.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 1i2dIO-0000T6-Tt for qemu-devel@archiver.kernel.org; Tue, 27 Aug 2019 11:22:08 -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+qemu-devel=archiver.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 }; -- 2.7.4