From patchwork Mon Oct 31 11:53:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025684 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 D0101FA3740 for ; Mon, 31 Oct 2022 11:56:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTMy-0004t9-60; Mon, 31 Oct 2022 07:54:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTMw-0004oh-3Y for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:18 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTMt-00055H-EZ for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:17 -0400 Received: by mail-wr1-x431.google.com with SMTP id y16so15571712wrt.12 for ; Mon, 31 Oct 2022 04:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mqt78t47J2vCxiAvHYahQR0hEHA/val3YfW49MCpoMc=; b=nbhwO2gbJ85PCopF7SzzgNLm/X3y3SCQlinM+OqgmjO2TnuxTY9GSfM1hLyWaNqnJM CkkSx75xRmy6UfllRIygX/whoizI2H2fNpfnioUMNUF81bKLpnL6S2r1TAArBHC3JoLF Ig+BytPeb95H+9Yv5Zrw0PZUFOrPPj5vvyDtEWtpvZJt55oN4cvql3xZc41ddBQrythb GL44TcbQEpND8SXYKXhn1r/DNYVSkdEuCJe1nOliAnsnGe9ua1RDZmbIn1geLb5TJG9H sAGq43/Twfrqlj7clgMjD1OsD0InpEjKeufds0A+Goeu+aJA6P4w/7rzHM88ubNeH5a/ BBKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mqt78t47J2vCxiAvHYahQR0hEHA/val3YfW49MCpoMc=; b=0LqTk9PL0KcOccBwWsociA5KfDFSsEJIs0+qSZzk6zlahzDutqw0GZQbKO5xSpsPeL AVRhWaQqNnonHNL3ZDf6VG3FVgNomMDCw176Ku3NTjtpX0W+yc1zIiK89PfcsWXxJ/VX 8PSSSuan/2hplxPCrg13lQpWDbK9ETnzshrjWvWFMnfA01r9um38cRGGNSLHPP55+Iaj ZkDVzeBSun49IjFQAjZPao8HqHK4bII8cWkriiHSWM3j6BIQXDYm+STm36YdHOzKWhKk 6if+MbMLQClbtNEt7Q7d418EovK08Ov5ra9/9r6c6hmbw+5naIEiegtgErfAyfjRP6qA 1x0Q== X-Gm-Message-State: ACrzQf04sq9mkmYJRsTzTjCsoinBYO3Fa0/zEeXVyOPdvKo2te/qZdAB zYqMpgMdxYz2qJKjFFQ19LVZNLuK+Y8ZyQ== X-Google-Smtp-Source: AMsMyM74KVeJT4fUeVlf+Odj6FInBjybYFm2Gawvb5LxsnK5TTSpupPxkzITwgq7EczMr1D/ao0tVg== X-Received: by 2002:adf:e8cb:0:b0:236:7ae2:918e with SMTP id k11-20020adfe8cb000000b002367ae2918emr7911805wrn.613.1667217250497; Mon, 31 Oct 2022 04:54:10 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id iv9-20020a05600c548900b003a84375d0d1sm7293751wmb.44.2022.10.31.04.54.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 1/6] hw/sd/sdhci: MMIO region is implemented in 32-bit accesses Date: Mon, 31 Oct 2022 12:53:57 +0100 Message-Id: <20221031115402.91912-2-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Bernhard Beschow --- hw/sd/sdhci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 0e5e988927..f9c5b58e6d 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1332,6 +1332,10 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) static const MemoryRegionOps sdhci_mmio_ops = { .read = sdhci_read, .write = sdhci_write, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, .valid = { .min_access_size = 1, .max_access_size = 4, From patchwork Mon Oct 31 11:53:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025679 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 4D883FA3742 for ; Mon, 31 Oct 2022 11:56:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTMz-0004ux-A6; Mon, 31 Oct 2022 07:54:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTMx-0004rU-F1 for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:19 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTMv-00055b-Sn for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:19 -0400 Received: by mail-wr1-x42f.google.com with SMTP id v1so15591136wrt.11 for ; Mon, 31 Oct 2022 04:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=37rpDi9RI9hPWc9AWLWhs9sb9dymPc7fADlcHGCKa94=; b=nyUvbVm5gbNI6MfmRQLdedJW6ffvOYyA4xIkbOTQx15Vz/V6jKQhpXfec+ciZbLnNe fLTCxJOBUu+ytYVOAVlf+YDHlHH/fQXWGLl/N0HkPdJsnmh41862VL1IFt55CjlqEcV9 p4fCom4Nf96T6UV/tS4aIqV25pEP1ruLL34RHGP33ULEkdB7A0LOSm6A3APPO2WIpEnt qMfh8XG+BXqyv8Sj55683jNuyFCe1U0ksCVNwbXnG9f+HzeIOOtrE6kOKFOndxHyDo7E neY5TvrJOw8aoMqndQ7r7eXV8jFdBEtGZ2gLQQu7pyzpF+yI5mu1dGjoYCZhBLEG5eAv yjdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=37rpDi9RI9hPWc9AWLWhs9sb9dymPc7fADlcHGCKa94=; b=WJZSnwIDLXC5Ru8RMm/paM0J9p2e8KR+lIRtuvtBL3IJTHsbK+wgqAXtGaBtR+Ou0B KKmZHcanqVfzCV+YaeB8PTUQFn+RcB64dTdUJCbX3IViZgT1PZoFL4ZiVPea98gQNWJz drZLbLU5AmCdCfkqSzOR+B3/FueqIMpi+1ZM7Lt9Ukb52JLxzKOZc99vIoNfc7JAXcTp EjES+LJH2XwpfMT1NBvFS3YUxDhn4nU3uT2pjFzSAU4wMjVKT1zJ1cQYUNzOd/+Ef5kT JGU2STCFo3GrBE9bR0xuGV0hv0v0DUxVpJBZEbJ6GHSDKWW4g+vWbOTqElygJIdlQp4J a0uA== X-Gm-Message-State: ACrzQf2ZqsdO+pDZN3JogEbJHiMHXBoCCENyhD55bbwgiVm7s3t0rC1n wen1Y6Ll20G2uaCh51qAJJqr/fFmimETyA== X-Google-Smtp-Source: AMsMyM5Wviqac6oCue0JwKDxxZ4Rzu0BbRzxnZIL3dmvOYrhp3/Xs4dk7R22kEOvK536pkKJzCxjDA== X-Received: by 2002:a5d:6c6b:0:b0:225:dde:ab40 with SMTP id r11-20020a5d6c6b000000b002250ddeab40mr7828685wrz.690.1667217256025; Mon, 31 Oct 2022 04:54:16 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id fc6-20020a05600c524600b003c6bbe910fdsm8260671wmb.9.2022.10.31.04.54.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH v5 2/6] hw/sd/sdhci: Map host controller interface in host endianess Date: Mon, 31 Oct 2022 12:53:58 +0100 Message-Id: <20221031115402.91912-3-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index f9c5b58e6d..40f37694d5 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1341,7 +1341,7 @@ static const MemoryRegionOps sdhci_mmio_ops = { .max_access_size = 4, .unaligned = false }, - .endianness = DEVICE_LITTLE_ENDIAN, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp) From patchwork Mon Oct 31 11:53:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025675 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 AE8E1FA3740 for ; Mon, 31 Oct 2022 11:55:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTNG-00052U-31; Mon, 31 Oct 2022 07:54:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTNE-0004zX-5T for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:36 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTN1-00056O-13 for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:35 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5so6982887wmo.1 for ; Mon, 31 Oct 2022 04:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1/4JZmuQZ1gB1VY/86Ldup/MWy51zk8s66DoSoeNl6U=; b=YSLKwjAgFqL+u/XcX4wkDnPivk1mb/mw+jiwo6SyoHJebi/qiZcUEXGpUeXDVskRKY dSJy13kuGnowdavy/tHpnQVRt9aQ0aFzRfjMEQNxNWc+0c0Ck5uvLGK0s73rr2ZKaGrl 8uT9Ozslfd7gvdafV+wEicz0i84Vdp6QyMEDBYJtCf4/YDOpqvSoBLudRNGYMDWzOnSM w8HyceXmtlmjiCHOtmixDtzWHj+BCI5vpeIKF+9KQwuf90KdLxTQeHjUsmk6POhgQuA2 wL7Z/JDCoyzRBRj3YaNf1xviJvedNbJrlMJ5EcRylDn1hxx884UzyvCo9YPNpQY5rGJH VMAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1/4JZmuQZ1gB1VY/86Ldup/MWy51zk8s66DoSoeNl6U=; b=khnUbjJOQvPl8r9o9NZRmR675HAqph6BSc/iaFxhjEhTQWq/h41xsVnslpOF3BG/As IzXe1egwAM7/oh39gEI6nCv8R75/JrCUTWoqS6eIyT39eRbAZw7/ffVxji2YlerKpntz FMXSltnMVI4QXnh11j9vJpmWMTvpCM8JM9e9NRq47r7T0EZFLZCjbZuWXpB501ayezcp vBeTTif0bNZ1jo+2e1g0ejuEf8qLR3lX0VVdLyA1h8evVYn16TNBne4rrwkZ/J4dpS50 rVHiyO37RXUcG1dFSHvxUj2hvs4sebGx3ctNeMg5v46vEVhSJv9oclUiTv21yGAHjYr5 lNOQ== X-Gm-Message-State: ACrzQf1frgXVHylDuAQD185LWmLvGGREsW9XLoLiPBOH+sblDbVZnuM2 /kINkZVbQUIVUtOg2bb20uefPmpVn08VoQ== X-Google-Smtp-Source: AMsMyM7se0dB8f7rNew34GvZL1dTWRVdRSIPZLEXFunhvDMS9DQHKmApV3KXJVtcHnoVMgR0b2Q96Q== X-Received: by 2002:a05:600c:5546:b0:3cf:5f20:3e13 with SMTP id iz6-20020a05600c554600b003cf5f203e13mr7545864wmb.155.1667217261572; Mon, 31 Oct 2022 04:54:21 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id r10-20020a05600c35ca00b003c6f1732f65sm4757795wmq.38.2022.10.31.04.54.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 3/6] hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power of two Date: Mon, 31 Oct 2022 12:53:59 +0100 Message-Id: <20221031115402.91912-4-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=ham 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow According to the JEDEC standard the device length is communicated to an OS as an exponent (power of two). Signed-off-by: Bernhard Beschow Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20221018210146.193159-3-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi01.c | 8 ++++++-- hw/block/pflash_cfi02.c | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 0cbc2fb4cb..9c235bf66e 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -690,7 +690,7 @@ static const MemoryRegionOps pflash_cfi01_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl) +static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl, Error **errp) { uint64_t blocks_per_device, sector_len_per_device, device_len; int num_devices; @@ -708,6 +708,10 @@ static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl) sector_len_per_device = pfl->sector_len / num_devices; } device_len = sector_len_per_device * blocks_per_device; + if (!is_power_of_2(device_len)) { + error_setg(errp, "Device size must be a power of two."); + return; + } /* Hardcoded CFI table */ /* Standard "QRY" string */ @@ -865,7 +869,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) */ pfl->cmd = 0x00; pfl->status = 0x80; /* WSM ready */ - pflash_cfi01_fill_cfi_table(pfl); + pflash_cfi01_fill_cfi_table(pfl, errp); } static void pflash_cfi01_system_reset(DeviceState *dev) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 2a99b286b0..ff2fe154c1 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -880,6 +880,11 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp) return; } + if (!is_power_of_2(pfl->chip_len)) { + error_setg(errp, "Device size must be a power of two."); + return; + } + memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl), &pflash_cfi02_ops, pfl, pfl->name, pfl->chip_len, errp); From patchwork Mon Oct 31 11:54:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025677 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 37864C38A02 for ; Mon, 31 Oct 2022 11:55:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTNR-0005IL-Vp; Mon, 31 Oct 2022 07:54:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTNK-00056X-PS for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:45 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTN6-000574-PI for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:42 -0400 Received: by mail-wr1-x42e.google.com with SMTP id g12so15597227wrs.10 for ; Mon, 31 Oct 2022 04:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lPGvzb6Tis+8r2QYoWc1QH4dM6oWwndybei8DLOeu1s=; b=wfWCGpvs5dTcgiYteFRIwEx1OFy5o0jyoqrZv3v7LaKwH9Mv6aeNZKuOX4go/ojyml RRTg/J7mPCWVHkmC1rmYPUGBe1HSWOnpZG85QOD3xdHLJxW/A7Zy7OaTd7GJI99tHiaN hKRIbuJVSHUH3x7hg4YEmN7zrrpMXUWLGyzscLumMKJkH3yaLBKmmv8QEuS7U83C8jAs vFsbFySpZg0P2lp//iLPBB0h/ljZWV4rWYFoe1dqt8jxFtVZEHt30FQcDPy0gLFOb0xV aN+h5iryFTXO9iwf538iw3Jbg8+MbA+8f6JrIqdGC05xU/BC2v7M5uWopQECi+stkHfq rLLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lPGvzb6Tis+8r2QYoWc1QH4dM6oWwndybei8DLOeu1s=; b=MABNDFd/15BlIH7qKvh42/GfAW55pHY2P+zU221fMzE1wi3vBM3p2GgUncg2BxoS+J qDmdjWfV9mnL5MQdMBXZrdq0LRM4wv9pKg2IFZZ/Ny36W0/y7Z1g1Ski5LLVaJ1znhjU jm9Jyd3FKBdVOTI5Q8WMoNKG53RSd9TPEjCiSA9U44pE/aKje9Vilmr/LsoFdxVVm+nr tCM03/9BI52pAhb3UTHt9/b8VuWE3BKvuCbCgNLapfNYiI0eti9w6CtvVkiUBX/Mt3UE pvOhBUM/Zbnzs5YwtAo+g0//7K7wAFGMBpi4g6SiXnWFZh1zhzByskukEae+jNPs0ISa cy6A== X-Gm-Message-State: ACrzQf3u6E1uQG0hLE0/O+xcZNH4YKIuPG2MW880hwMqnZtI4MK1C8D9 cseG0mYN0FXNsNzFJW0MwK5Eysn9szWKGA== X-Google-Smtp-Source: AMsMyM7ENxJ06kmLGO0/D994pN50pJK7GSwY6NTTbJmukQxuIvG9xAlfF3R7qMsR+MTmYPzjcRSaMw== X-Received: by 2002:a5d:5346:0:b0:235:6c05:6272 with SMTP id t6-20020a5d5346000000b002356c056272mr7999648wrv.332.1667217267258; Mon, 31 Oct 2022 04:54:27 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id bd26-20020a05600c1f1a00b003c6b70a4d69sm7024579wmb.42.2022.10.31.04.54.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , BALATON Zoltan , Bin Meng Subject: [PATCH v5 4/6] docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s) Date: Mon, 31 Oct 2022 12:54:00 +0100 Message-Id: <20221031115402.91912-5-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow The documentation suggests that there is a qemu-system-ppc32 binary while the 32 bit version is actually just named qemu-system-ppc. Settle on qemu-system-ppc64 which also works for 32 bit machines and causes less clutter in the documentation. Found-by: BALATON Zoltan Suggested-by: Bin Meng Signed-off-by: Bernhard Beschow Message-Id: <20221018210146.193159-2-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- docs/system/ppc/ppce500.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/system/ppc/ppce500.rst b/docs/system/ppc/ppce500.rst index ba6bcb7314..7b5eb3c4ee 100644 --- a/docs/system/ppc/ppce500.rst +++ b/docs/system/ppc/ppce500.rst @@ -113,7 +113,7 @@ To boot the 32-bit Linux kernel: .. code-block:: bash - $ qemu-system-ppc{64|32} -M ppce500 -cpu e500mc -smp 4 -m 2G \ + $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ -display none -serial stdio \ -kernel vmlinux \ -initrd /path/to/rootfs.cpio \ @@ -154,10 +154,10 @@ interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by: .. code-block:: bash - $ qemu-system-ppc -M ppce500 -smp 4 -m 2G \ - -display none -serial stdio \ - -bios u-boot \ - -nic tap,ifname=tap0,script=no,downscript=no,model=e1000 + $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \ + -display none -serial stdio \ + -bios u-boot \ + -nic tap,ifname=tap0,script=no,downscript=no,model=e1000 The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device if “-device eTSEC” is given to QEMU: From patchwork Mon Oct 31 11:54:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025676 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 1A07AC38A02 for ; Mon, 31 Oct 2022 11:55:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTNP-0005ED-R9; Mon, 31 Oct 2022 07:54:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTNJ-000563-Ix for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:45 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTNC-00057X-0n for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:41 -0400 Received: by mail-wr1-x42e.google.com with SMTP id bs21so15620480wrb.4 for ; Mon, 31 Oct 2022 04:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rOz1DKZXV40J6g7C+ONkZnsrdceIgT9c6MhorQOyVQk=; b=hMLVFq4fnca67iVicKyJb0/l0K6J8q6tNoXKLuLHKEvFDmc3S1Fy4YppxssYQjoAMA 66em6ckL/KBsSLzIUXpzjHMC8DYNLUbbdsrVg+3uq3auR45oLmaw5TzbC846y+jOKdHH WJcdjgbBdeH4qXddJz1I1T44DwmE9Webty0bM7zziygFVGo4/pj8IaPj62Bp0GKYpzWY cChTGH6jagYIcQ+q9TVCmkm/1wcm82so4NN/yrX8BvBvjOom6VeBvsa5UbcL/Wr0y9qm h1lye6jNt4YRVCB5hhMazNjD8sxSUijVpOwp3Tb+j8AegA4ZxWOgkWxTq+UEp3TNg35i 1YMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rOz1DKZXV40J6g7C+ONkZnsrdceIgT9c6MhorQOyVQk=; b=zSc+PMw+95Nft+etx9DGns3t5wcezH/CwaXX0jU0PAR5CWnIe3jic20CGzOtcROjtz 89CgeIBPhpP4vuA7ds3NL07i5WuM5FEX3ByPs85lY9fA0DvQCxn+6vz6NcbMmb1SzINl s8963v5KBateqabiS9DfpiDz8grJWs+sSucZJj1WWb9yCRk8wtvau8ErKATYT6FQhmrV iiK5PqGs5dKOO7YSm6F8/MrTHL72Ry1oZ99veGpUcJSufX7geLpUOKddGlP7dmC/ZZIT WJWAY6V3owFGJuXD49UrNz4Or51c8mGvEs0Go5wyCvpRGi0GCPYPGyh0VyClz/GP6NJv IRSg== X-Gm-Message-State: ACrzQf0BiVMX+XQSj4V8+1IzeOnSt8kUUnwY6WcqEtSGl5WwE26+DJD6 Ng9Gjxe4k/HKcr9FbeTtCGL8QFgUpib2qw== X-Google-Smtp-Source: AMsMyM6RdyPHd7WNd0NPX/4Wc5XMcQDzCaDeuqBEvGYi76Ii8X64HoV+cEzP8SwdjoE5yxEtKrqk8Q== X-Received: by 2002:a5d:6112:0:b0:236:740e:5938 with SMTP id v18-20020a5d6112000000b00236740e5938mr7592682wrt.155.1667217272442; Mon, 31 Oct 2022 04:54:32 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id q7-20020a1ce907000000b003c701c12a17sm6993131wmc.12.2022.10.31.04.54.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 5/6] hw/ppc/e500: Implement pflash handling Date: Mon, 31 Oct 2022 12:54:01 +0100 Message-Id: <20221031115402.91912-6-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 autolearn=ham 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow Allows e500 boards to have their root file system reside on flash using only builtin devices located in the eLBC memory region. Note that the flash memory area is only created when a -pflash argument is given, and that the size is determined by the given file. The idea is to put users into control. Signed-off-by: Bernhard Beschow Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20221018210146.193159-6-shentey@gmail.com> [PMD: Use memory_region_size()] Signed-off-by: Philippe Mathieu-Daudé --- docs/system/ppc/ppce500.rst | 16 ++++++++ hw/ppc/Kconfig | 1 + hw/ppc/e500.c | 79 +++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/docs/system/ppc/ppce500.rst b/docs/system/ppc/ppce500.rst index 7b5eb3c4ee..38f8ceb0cf 100644 --- a/docs/system/ppc/ppce500.rst +++ b/docs/system/ppc/ppce500.rst @@ -165,3 +165,19 @@ if “-device eTSEC” is given to QEMU: .. code-block:: bash -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0 + +Root file system on flash drive +------------------------------- + +Rather than using a root file system on ram disk, it is possible to have it on +CFI flash. Given an ext2 image whose size must be a power of two, it can be used +as follows: + +.. code-block:: bash + + $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ + -display none -serial stdio \ + -kernel vmlinux \ + -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \ + -append "rootwait root=/dev/mtdblock0" + diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 791fe78a50..769a1ead1c 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -126,6 +126,7 @@ config E500 select ETSEC select GPIO_MPC8XXX select OPENPIC + select PFLASH_CFI01 select PLATFORM_BUS select PPCE500_PCI select SERIAL diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 3e950ea3ba..84bcc25526 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -23,8 +23,10 @@ #include "e500-ccsr.h" #include "net/net.h" #include "qemu/config-file.h" +#include "hw/block/flash.h" #include "hw/char/serial.h" #include "hw/pci/pci.h" +#include "sysemu/block-backend-io.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" @@ -267,6 +269,31 @@ static void sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque) } } +static void create_devtree_flash(SysBusDevice *sbdev, + PlatformDevtreeData *data) +{ + g_autofree char *name = NULL; + uint64_t num_blocks = object_property_get_uint(OBJECT(sbdev), + "num-blocks", + &error_fatal); + uint64_t sector_length = object_property_get_uint(OBJECT(sbdev), + "sector-length", + &error_fatal); + uint64_t bank_width = object_property_get_uint(OBJECT(sbdev), + "width", + &error_fatal); + hwaddr flashbase = 0; + hwaddr flashsize = num_blocks * sector_length; + void *fdt = data->fdt; + + name = g_strdup_printf("%s/nor@%" PRIx64, data->node, flashbase); + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_string(fdt, name, "compatible", "cfi-flash"); + qemu_fdt_setprop_sized_cells(fdt, name, "reg", + 1, flashbase, 1, flashsize); + qemu_fdt_setprop_cell(fdt, name, "bank-width", bank_width); +} + static void platform_bus_create_devtree(PPCE500MachineState *pms, void *fdt, const char *mpic) { @@ -276,6 +303,8 @@ static void platform_bus_create_devtree(PPCE500MachineState *pms, uint64_t addr = pmc->platform_bus_base; uint64_t size = pmc->platform_bus_size; int irq_start = pmc->platform_bus_first_irq; + SysBusDevice *sbdev; + bool ambiguous; /* Create a /platform node that we can put all devices into */ @@ -302,6 +331,13 @@ static void platform_bus_create_devtree(PPCE500MachineState *pms, /* Loop through all dynamic sysbus devices and create nodes for them */ foreach_dynamic_sysbus_device(sysbus_device_create_devtree, &data); + sbdev = SYS_BUS_DEVICE(object_resolve_path_type("", TYPE_PFLASH_CFI01, + &ambiguous)); + if (sbdev) { + assert(!ambiguous); + create_devtree_flash(sbdev, &data); + } + g_free(node); } @@ -856,6 +892,7 @@ void ppce500_init(MachineState *machine) unsigned int pci_irq_nrs[PCI_NUM_PINS] = {1, 2, 3, 4}; IrqLines *irqs; DeviceState *dev, *mpicdev; + DriveInfo *dinfo; CPUPPCState *firstenv = NULL; MemoryRegion *ccsr_addr_space; SysBusDevice *s; @@ -1024,6 +1061,48 @@ void ppce500_init(MachineState *machine) pmc->platform_bus_base, &pms->pbus_dev->mmio); + dinfo = drive_get(IF_PFLASH, 0, 0); + if (dinfo) { + BlockBackend *blk = blk_by_legacy_dinfo(dinfo); + BlockDriverState *bs = blk_bs(blk); + uint64_t size = bdrv_getlength(bs); + uint32_t sector_len = 64 * KiB; + uint64_t mmio_size = memory_region_size(&pms->pbus_dev->mmio); + + if (!is_power_of_2(size)) { + error_report("Size of pflash file must be a power of two."); + exit(1); + } + + if (size > mmio_size) { + error_report("Size of pflash file must not be bigger than %" PRIu64 + " bytes.", mmio_size); + exit(1); + } + + if (!QEMU_IS_ALIGNED(size, sector_len)) { + error_report("Size of pflash file must be a multiple of %" PRIu32 + ".", sector_len); + exit(1); + } + + dev = qdev_new(TYPE_PFLASH_CFI01); + qdev_prop_set_drive(dev, "drive", blk); + qdev_prop_set_uint32(dev, "num-blocks", size / sector_len); + qdev_prop_set_uint64(dev, "sector-length", sector_len); + qdev_prop_set_uint8(dev, "width", 2); + qdev_prop_set_bit(dev, "big-endian", true); + qdev_prop_set_uint16(dev, "id0", 0x89); + qdev_prop_set_uint16(dev, "id1", 0x18); + qdev_prop_set_uint16(dev, "id2", 0x0000); + qdev_prop_set_uint16(dev, "id3", 0x0); + qdev_prop_set_string(dev, "name", "e500.flash"); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + + memory_region_add_subregion(&pms->pbus_dev->mmio, 0, + pflash_cfi01_get_memory(PFLASH_CFI01(dev))); + } + /* * Smart firmware defaults ahead! * From patchwork Mon Oct 31 11:54:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13025678 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 96E8EFA3740 for ; Mon, 31 Oct 2022 11:56:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opTNR-0005Ft-63; Mon, 31 Oct 2022 07:54:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opTNM-00056t-9G for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:45 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opTNH-0005Dh-Eo for qemu-devel@nongnu.org; Mon, 31 Oct 2022 07:54:44 -0400 Received: by mail-wr1-x435.google.com with SMTP id v1so15592456wrt.11 for ; Mon, 31 Oct 2022 04:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oYVFA4SdMsanc8gPQeu65EoQCeO4p7z8sr2O1U80+4s=; b=bk+h0ypSbH5+uV44P25t82lWkWiVMjRITgKhCADIORghg40CB+7ynvKV5CcsCFq288 FD5jCEosUaK7i+kwpmd2JB4q1jaqUPEFU5c0WeGCb2OwePRND+Xk912lWwGVtcijhNsW lXsXoxzBqllngHHiES++Oa1Uxa5VOzgQQcXil43B+Xx685v+gt0sLm1v9dpG8qoKL6A+ y+QJqcVz+AgteBwJSRJYZN1Jfi6kIhwQj/5ZgycWUJSm2W6RAm3fM5BhGZHmY1BkscsQ 134P23EUxk83snPxzJ4lvduWNqkpRpmj/3fSkdGiZU5BCpiCNn3bfRwIqv7URs3BwADK fGfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oYVFA4SdMsanc8gPQeu65EoQCeO4p7z8sr2O1U80+4s=; b=cJ6zOGpb7S/sjCZecfApJTmBugGPg1lOFQnkrg/6UXjW1O+Lslw03CZemIzmTFu1WR VRxY0N2m2ZOp+eB+Ec5kVheFncTlm/TBvy4BLhJELzgO3hxY70wIo5zSKYSCE3wHFuzO NSW3UlpqLltjAvwE2P/aP+a5f/mpMTVQbf7PF2A52lLRF7bXM4lPEi/x7iZU8dJndFaF CQkOykakgc8l4KqHU1e6bp64e5Aszshjbt7sPJAMm7ouX+SVXbs69/WDDb9uxZQO9JFE uMIYO0BulozVzpgyuw060+BDdCr93Om37rwn4dcJpVVDp0UkY9gcaJk/ysC6k7ptXHGu BiMA== X-Gm-Message-State: ACrzQf03m3Zi87bz4Bt3MGIhUfQPKa50xywbH04tY96tC95PUYAc1tvd sQy2UfkJjAkBJcR5RyY8YU//Y8nrFcnPUA== X-Google-Smtp-Source: AMsMyM79z+MWjfmotPbG2TfElaYc3Sv8dgB2vUBxXZHB29Gcvb43a9jD2ZLETVXQJSW2IdGwgDS6PA== X-Received: by 2002:a05:6000:1f8b:b0:236:7766:4b32 with SMTP id bw11-20020a0560001f8b00b0023677664b32mr7442524wrb.683.1667217277997; Mon, 31 Oct 2022 04:54:37 -0700 (PDT) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id o17-20020a05600c4fd100b003a5f3f5883dsm7429867wmq.17.2022.10.31.04.54.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Oct 2022 04:54:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Bernhard Beschow Cc: Daniel Henrique Barboza , Hanna Reitz , qemu-ppc@nongnu.org, Bin Meng , Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 6/6] hw/ppc/e500: Add Freescale eSDHC to e500plat Date: Mon, 31 Oct 2022 12:54:02 +0100 Message-Id: <20221031115402.91912-7-philmd@linaro.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031115402.91912-1-philmd@linaro.org> References: <20221031115402.91912-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Bernhard Beschow Adds missing functionality to e500plat machine which increases the chance of given "real" firmware images to access SD cards. Signed-off-by: Bernhard Beschow Message-Id: <20221018210146.193159-8-shentey@gmail.com> [PMD: Simplify using create_unimplemented_device("esdhc")] Signed-off-by: Philippe Mathieu-Daudé --- docs/system/ppc/ppce500.rst | 12 ++++++++++ hw/ppc/Kconfig | 2 ++ hw/ppc/e500.c | 48 ++++++++++++++++++++++++++++++++++++- hw/ppc/e500.h | 1 + hw/ppc/e500plat.c | 1 + 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/docs/system/ppc/ppce500.rst b/docs/system/ppc/ppce500.rst index 38f8ceb0cf..c9fe0915dc 100644 --- a/docs/system/ppc/ppce500.rst +++ b/docs/system/ppc/ppce500.rst @@ -19,6 +19,7 @@ The ``ppce500`` machine supports the following devices: * Power-off functionality via one GPIO pin * 1 Freescale MPC8xxx PCI host controller * VirtIO devices via PCI bus +* 1 Freescale Enhanced Secure Digital Host controller (eSDHC) * 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC) Hardware configuration information @@ -181,3 +182,14 @@ as follows: -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \ -append "rootwait root=/dev/mtdblock0" +Alternatively, the root file system can also reside on an emulated SD card +whose size must again be a power of two: + +.. code-block:: bash + + $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ + -display none -serial stdio \ + -kernel vmlinux \ + -device sd-card,drive=mydrive \ + -drive id=mydrive,if=none,file=/path/to/rootfs.ext2,format=raw \ + -append "rootwait root=/dev/mmcblk0" diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 769a1ead1c..c48aaaa9dc 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -129,10 +129,12 @@ config E500 select PFLASH_CFI01 select PLATFORM_BUS select PPCE500_PCI + select SDHCI select SERIAL select MPC_I2C select FDT_PPC select DS1338 + select UNIMP config E500PLAT bool diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 84bcc25526..80e4c4c4ca 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -48,6 +48,8 @@ #include "hw/net/fsl_etsec/etsec.h" #include "hw/i2c/i2c.h" #include "hw/irq.h" +#include "hw/sd/sdhci.h" +#include "hw/misc/unimp.h" #define EPAPR_MAGIC (0x45504150) #define DTC_LOAD_PAD 0x1800000 @@ -66,11 +68,14 @@ #define MPC8544_SERIAL1_REGS_OFFSET 0x4600ULL #define MPC8544_PCI_REGS_OFFSET 0x8000ULL #define MPC8544_PCI_REGS_SIZE 0x1000ULL +#define MPC85XX_ESDHC_REGS_OFFSET 0x2e000ULL +#define MPC85XX_ESDHC_REGS_SIZE 0x1000ULL #define MPC8544_UTIL_OFFSET 0xe0000ULL #define MPC8XXX_GPIO_OFFSET 0x000FF000ULL #define MPC8544_I2C_REGS_OFFSET 0x3000ULL #define MPC8XXX_GPIO_IRQ 47 #define MPC8544_I2C_IRQ 43 +#define MPC85XX_ESDHC_IRQ 72 #define RTC_REGS_OFFSET 0x68 #define PLATFORM_CLK_FREQ_HZ (400 * 1000 * 1000) @@ -203,6 +208,22 @@ static void dt_i2c_create(void *fdt, const char *soc, const char *mpic, g_free(i2c); } +static void dt_sdhc_create(void *fdt, const char *parent, const char *mpic) +{ + hwaddr mmio = MPC85XX_ESDHC_REGS_OFFSET; + hwaddr size = MPC85XX_ESDHC_REGS_SIZE; + int irq = MPC85XX_ESDHC_IRQ; + g_autofree char *name = NULL; + + name = g_strdup_printf("%s/sdhc@%" PRIx64, parent, mmio); + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop(fdt, name, "sdhci,auto-cmd12", NULL, 0); + qemu_fdt_setprop_phandle(fdt, name, "interrupt-parent", mpic); + qemu_fdt_setprop_cells(fdt, name, "bus-width", 4); + qemu_fdt_setprop_cells(fdt, name, "interrupts", irq, 0x2); + qemu_fdt_setprop_cells(fdt, name, "reg", mmio, size); + qemu_fdt_setprop_string(fdt, name, "compatible", "fsl,esdhc"); +} typedef struct PlatformDevtreeData { void *fdt; @@ -553,6 +574,10 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms, dt_rtc_create(fdt, "i2c", "rtc"); + /* sdhc */ + if (pmc->has_esdhc) { + dt_sdhc_create(fdt, soc, mpic); + } gutil = g_strdup_printf("%s/global-utilities@%llx", soc, MPC8544_UTIL_OFFSET); @@ -982,7 +1007,8 @@ void ppce500_init(MachineState *machine) 0, qdev_get_gpio_in(mpicdev, 42), 399193, serial_hd(1), DEVICE_BIG_ENDIAN); } - /* I2C */ + + /* I2C */ dev = qdev_new("mpc-i2c"); s = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(s, &error_fatal); @@ -992,6 +1018,26 @@ void ppce500_init(MachineState *machine) i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c"); i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET); + /* eSDHC */ + if (pmc->has_esdhc) { + uint64_t sdhci_regsize; + + dev = qdev_new(TYPE_SYSBUS_SDHCI); + /* + * Compatible with: + * - SD Host Controller Specification Version 2.0 Part A2 + */ + qdev_prop_set_uint8(dev, "sd-spec-version", 2); + s = SYS_BUS_DEVICE(dev); + sysbus_realize_and_unref(s, &error_fatal); + sysbus_mmio_map(s, 0, pmc->ccsrbar_base + MPC85XX_ESDHC_REGS_OFFSET); + sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC85XX_ESDHC_IRQ)); + sdhci_regsize = memory_region_size(sysbus_mmio_get_region(s, 0)); + create_unimplemented_device("esdhc", + pmc->ccsrbar_base + + MPC85XX_ESDHC_REGS_OFFSET + sdhci_regsize, + MPC85XX_ESDHC_REGS_SIZE - sdhci_regsize); + } /* General Utility device */ dev = qdev_new("mpc8544-guts"); diff --git a/hw/ppc/e500.h b/hw/ppc/e500.h index 68f754ce50..8c09ef92e4 100644 --- a/hw/ppc/e500.h +++ b/hw/ppc/e500.h @@ -27,6 +27,7 @@ struct PPCE500MachineClass { int mpic_version; bool has_mpc8xxx_gpio; + bool has_esdhc; hwaddr platform_bus_base; hwaddr platform_bus_size; int platform_bus_first_irq; diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 5bb1c603da..44bf874b0f 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -86,6 +86,7 @@ static void e500plat_machine_class_init(ObjectClass *oc, void *data) pmc->fixup_devtree = e500plat_fixup_devtree; pmc->mpic_version = OPENPIC_MODEL_FSL_MPIC_42; pmc->has_mpc8xxx_gpio = true; + pmc->has_esdhc = true; pmc->platform_bus_base = 0xf00000000ULL; pmc->platform_bus_size = 128 * MiB; pmc->platform_bus_first_irq = 5;