From patchwork Tue Nov 2 22:49:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12599737 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0EB6C433F5 for ; Tue, 2 Nov 2021 22:53: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 426D261073 for ; Tue, 2 Nov 2021 22:53:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 426D261073 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mi2eg-0004zG-Dr for qemu-devel@archiver.kernel.org; Tue, 02 Nov 2021 18:53:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3gMCBYQgKChsNL81FKJ87FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--wuhaotsh.bounces.google.com>) id 1mi2bB-0000nI-VT for qemu-devel@nongnu.org; Tue, 02 Nov 2021 18:49:46 -0400 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]:54997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3gMCBYQgKChsNL81FKJ87FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--wuhaotsh.bounces.google.com>) id 1mi2b8-0001G6-3f for qemu-devel@nongnu.org; Tue, 02 Nov 2021 18:49:45 -0400 Received: by mail-pg1-x549.google.com with SMTP id u5-20020a63d3450000b029023a5f6e6f9bso476474pgi.21 for ; Tue, 02 Nov 2021 15:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Dh6lLd3kW4ekavLFMnJxd6EMIooNZ2ySdXhGaXI8BYk=; b=Q1Kt9MU25wMrJmO0bfkFhhxg0mGMV8zMbwRbH3nqGHtJZnIwHj9S+KB0qep1RufNTU jvNcKiXAsyTVtX78rGrHB1WUAgOM70iXqOAxpS+xHbB4gscPGCjM9mqmkg+u75gb+TY3 6zLvmFx81HmV3e/STnsv8MC31HhEYdkNOTVCBfHY5MKlWXlX4jIZIN2FWuXfscSQ58Ms nOlW2CfONfLlNPJjZnapL7ayEsF+aGwxxwegsU4M3OoLohtr5TAHcrGCAUkBGMfi2XA/ nFTCV08sgsSUslgK6xXL5GfoXP0gWcNAc2FDfQLDeJIMi/Fo3SNtOhiFMYWryhdMMJC7 cAFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Dh6lLd3kW4ekavLFMnJxd6EMIooNZ2ySdXhGaXI8BYk=; b=Yc1BeXxw+vtOcbbl6wJGWwd29F3eexwopQX6JnbK2fKtm5hnRC7yXCEzPB9emb40EL KJgpKZIm2tIUoNGFDTn984RLmyvxe7lwQeWES00vUrdvOpYyhUysSodCT9UIFEQliCQi FM6RYCH69ujxxp6F6r1/Gk8568YlTtKPvY7gxvJG+f3HGzLF5kTLmkq96ouurrVMyVEH KNzzj/sWeRhxbufEB3iDpy5e4I7vcZNbtiLxjDxtzNhqg9U4cgTySZaV7kwchLyf/uyp TMkF04JcQXgZk81FUWDYXRXvnRF0kWmrk1YPPWar8fU5cBbPL4SY7FBUXsJjjYE54BlJ l2rA== X-Gm-Message-State: AOAM532fsvKdcS0mqkg0n3AAPDgsnmB1mWji2U/eFLQaDh5Sry+/WRMX P3XFtRm38VLiWV3uC2Z0MK0Vftk5tZK14A== X-Google-Smtp-Source: ABdhPJwhqdKrI/4pg5s3m2FA26sEkzntaSQ8UWmO2GZyU1gickAPsmFCOc7LB0sE6MbXdfQwox6hfusqdR0/zA== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a17:90a:5285:: with SMTP id w5mr257829pjh.1.1635893376854; Tue, 02 Nov 2021 15:49:36 -0700 (PDT) Date: Tue, 2 Nov 2021 15:49:21 -0700 In-Reply-To: <20211102224924.1244946-1-wuhaotsh@google.com> Message-Id: <20211102224924.1244946-3-wuhaotsh@google.com> Mime-Version: 1.0 References: <20211102224924.1244946-1-wuhaotsh@google.com> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH v3 2/5] hw/arm: Add Nuvoton SD module to board From: Hao Wu To: richard.henderson@linaro.org Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wuhaotsh@google.com, venture@google.com, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, hskinnemoen@google.com, f4bug@amsat.org, bin.meng@windriver.com, qemu-block@nongnu.org, maoshengtan2011@gmail.com, Shengtan Mao , Chris Rauer Received-SPF: pass client-ip=2607:f8b0:4864:20::549; envelope-from=3gMCBYQgKChsNL81FKJ87FF7C5.3FDH5DL-45M5CEFE7EL.FI7@flex--wuhaotsh.bounces.google.com; helo=mail-pg1-x549.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Shengtan Mao Signed-off-by: Shengtan Mao Reviewed-by: Hao Wu Reviewed-by: Chris Rauer Reviewed-by: Tyrone Ting Signed-off-by: Hao Wu Reviewed-by: Peter Maydell --- hw/arm/npcm7xx.c | 12 +++++++++++- include/hw/arm/npcm7xx.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index 2ab0080e0b..878c2208e0 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -63,6 +63,8 @@ #define NPCM7XX_ROM_BA (0xffff0000) #define NPCM7XX_ROM_SZ (64 * KiB) +/* SDHCI Modules */ +#define NPCM7XX_MMC_BA (0xf0842000) /* Clock configuration values to be fixed up when bypassing bootloader */ @@ -83,6 +85,7 @@ enum NPCM7xxInterrupt { NPCM7XX_UART3_IRQ, NPCM7XX_EMC1RX_IRQ = 15, NPCM7XX_EMC1TX_IRQ, + NPCM7XX_MMC_IRQ = 26, NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ NPCM7XX_TIMER1_IRQ, NPCM7XX_TIMER2_IRQ, @@ -443,6 +446,8 @@ static void npcm7xx_init(Object *obj) for (i = 0; i < ARRAY_SIZE(s->emc); i++) { object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); } + + object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); } static void npcm7xx_realize(DeviceState *dev, Error **errp) @@ -707,6 +712,12 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) &error_abort); memory_region_add_subregion(get_system_memory(), NPCM7XX_ROM_BA, &s->irom); + /* SDHCI */ + sysbus_realize(SYS_BUS_DEVICE(&s->mmc), &error_abort); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc), 0, NPCM7XX_MMC_BA); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0, + npcm7xx_irq(s, NPCM7XX_MMC_IRQ)); + create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB); create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB); create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB); @@ -736,7 +747,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) create_unimplemented_device("npcm7xx.usbd[8]", 0xf0838000, 4 * KiB); create_unimplemented_device("npcm7xx.usbd[9]", 0xf0839000, 4 * KiB); create_unimplemented_device("npcm7xx.sd", 0xf0840000, 8 * KiB); - create_unimplemented_device("npcm7xx.mmc", 0xf0842000, 8 * KiB); create_unimplemented_device("npcm7xx.pcimbx", 0xf0848000, 512 * KiB); create_unimplemented_device("npcm7xx.aes", 0xf0858000, 4 * KiB); create_unimplemented_device("npcm7xx.des", 0xf0859000, 4 * KiB); diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h index 61ecc57ab9..ce593235d9 100644 --- a/include/hw/arm/npcm7xx.h +++ b/include/hw/arm/npcm7xx.h @@ -35,6 +35,7 @@ #include "hw/usb/hcd-ehci.h" #include "hw/usb/hcd-ohci.h" #include "target/arm/cpu.h" +#include "hw/sd/npcm7xx_sdhci.h" #define NPCM7XX_MAX_NUM_CPUS (2) @@ -103,6 +104,7 @@ typedef struct NPCM7xxState { OHCISysBusState ohci; NPCM7xxFIUState fiu[2]; NPCM7xxEMCState emc[2]; + NPCM7xxSDHCIState mmc; } NPCM7xxState; #define TYPE_NPCM7XX "npcm7xx"