From patchwork Thu Feb 6 11:33:10 2025 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: 862494 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp79277wrv; Thu, 6 Feb 2025 03:36:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXpYjzId4LhIryzGEsjoUA6hcrRDQZbaQi02LDJNCsMRRu7NlTctV8Nolo4wEFGZQsGFalPpg==@linaro.org X-Google-Smtp-Source: AGHT+IF3mZfFF1xBKrVi8iMuxtAvtNR71/iB6BQZ6HGnyy0dDa//HYsqoqzoQffCX/tr53y8Imsn X-Received: by 2002:a05:620a:268d:b0:7b6:d5ed:6091 with SMTP id af79cd13be357-7c03a03701cmr1017594485a.45.1738841790514; Thu, 06 Feb 2025 03:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738841790; cv=none; d=google.com; s=arc-20240605; b=UoJzxT/82U4GwGwd2C1z+h6sKGYWIhSsrqhqzss2Yytj+QEXfhFaXKpCZjWbXIJFTH lrrUlHtgfr6KGxriZcO9P6AGxlnYZSkErdpYr9aB1vh9vq6d5n1IF+KignfN4WeCCuol cUo599dPLFysvNdijEwG3vj+DDtQfEQuzxR8D/AangQY3xrzIkfhgn8bNMXM86KlDAAw NZE2psjiu9mvFAg/12/NPxQs6ymwT1c9W0s8UQSDjh4Cia6isSQ9iSpzvJNE3tRb57go /g3YeXYuz0R1dzRVgTZXuWskHlwtafHxW9bmBGV6lZtV8F11lDXwd6tCp1NAz5MbmNvt 35wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X20R65gi2tCckItv1V/R89183LZ1ZNOLWFw83d9B9RI=; fh=KB7JHaNjI5K4DpKM/QhtRxZS6iSNZtGQL2GKAsTumMw=; b=T2Ez9PpljXUHa5btFI1PW+ybJiFcWooh4FQPEEimWuCjXmtgwGCJynhE3bscdh0g1s pF5PB4m8SnhhbAMKqy7rnju1Eta+XNRFj50sM2ngsW/DhcAsrXQ+XboU+A3q0kpgH5VC X6BPSqgPbyatjczYeCwvmoWe7tezSFZZTcOJC1G2W7bmB4H6IEWuEZh9fLhHYFJCOjvB 4PDOHj1faOvaC8dq3IKnohc1NDluQGWsz04AhWlsZj7q5PNKr1CjWzF/HvZAuCkC0PPS DyM8qPOhngcdODsgukGQiZLVywQjZrSOeF2id8nHK+D34w7tCHlGjS50b6jl4KLgazOR mQhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fTVFry/L"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c041ee5359si94647485a.606.2025.02.06.03.36.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 03:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fTVFry/L"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg08p-000779-K5; Thu, 06 Feb 2025 06:33:55 -0500 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 1tg08l-00076R-2g for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:51 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg08j-0000qv-BZ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 06:33:50 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso4309255e9.1 for ; Thu, 06 Feb 2025 03:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738841627; x=1739446427; darn=nongnu.org; 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=X20R65gi2tCckItv1V/R89183LZ1ZNOLWFw83d9B9RI=; b=fTVFry/L3Z/M1se7dWdF3V2OXQxtjAvxLOJN36qmdQ1aInhKwbeqz2poczB/Vxzaf5 dJDsjcvnnSCkAG5XPLlMw8IFEBH6w2PtUFjAVUzqXSKQ1qIIBr633hdSKbYhWgIK7cop /hj1rDjYBEw69dyHnPjG4Rltag7UZmRdw81NLsHaVT8Sovyrj6N2VQ90y+ohrYOIH1wy VY2nsQq88kEHWHlWetg0wHLaWLZgkrH98lW5o6UBprC/zPS62XsyNTaYR2F9d4wT9aeI 2lfADfWeXL4HTsTjeWOl7URd/yBL31u9uDXAiLD0RnKWiYRZYkM+czgJgf9oSxd3fKE8 kDmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738841627; x=1739446427; 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=X20R65gi2tCckItv1V/R89183LZ1ZNOLWFw83d9B9RI=; b=dKAwZLdej6h9REJB1wV5dZYUTCn+fLqMV6SE0mtxe1Vu6C+kBg7P8cCHWYglCfycGT ojt3fbCa9vVF8EJO4td5M2n0nLcoWx9y5tpTJQcBGjroE/K/zzYiKBUeIlnO5c7B+CCb F3FX48qTRMSB0mxD6oQcsjYq6LWAd5IKq4T3L/SRFjyxyryNPfdUC/0wa2LfdBgw//DL 1DAEJHyT+/FXvjZseHv+6/cCMwReSBYwrAl9oTA+hFd2E1uU0BV2INEI8qGMU5rZKEEz ZaEMN8IsYEx69IJjCtguUudPKpftG0NJsgC0P52C9sOCd0sjz1M+cY3hDtqYGYxq4k+R fQVw== X-Gm-Message-State: AOJu0YyO/v74dPzD+vhBsZL3hkdUt+IqYAa83CXay3tn//KhDNi2Vud9 HySISXazBLDu+bMmfMrnHictUNNkVz5u1/J//mjnQ5IVfSmvGo96zSlYoXxL1dQwi7djeMPL0Q/ 4vB0= X-Gm-Gg: ASbGncshLMABEN1Bae0+g9qGm+kwRVGJ2os99BFC9y5rhDpOzXEGPhq/1L2yMpDQL9N mTQalBlc/F35ANybneBpTHlrxCoPOahQTmgldg0A17OutNt1IcLuFjeDM419nNUBlpmCknGMtnF PhMbEKGPUHHGZcD+SRGVD2VtnoN7WdE7EBG7BZfKzMvHvKR/SlqeLo43x68J00LezoyLOyIne+2 7iR5AjVBgrnIHcZhVpDmyHw83CGffwAIXrOR/ALfrMQrmqY/tEN2CmV3c55wYowNyDgAu1GHsA9 n6/2yu5f86UjkwA5NLYT88TimF0l2jt9RFfLWyZscF0emc1WoDYApZH6X/hisXviUQ== X-Received: by 2002:a05:600c:a089:b0:436:1b86:f05 with SMTP id 5b1f17b1804b1-43912d3822cmr22096705e9.11.1738841627478; Thu, 06 Feb 2025 03:33:47 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38dbdd3856fsm1476849f8f.28.2025.02.06.03.33.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Feb 2025 03:33:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anton Johansson , Alistair Francis , Richard Henderson , Thomas Huth , Jason Wang , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH v4 05/16] hw/ssi/xilinx_spi: Make device endianness configurable Date: Thu, 6 Feb 2025 12:33:10 +0100 Message-ID: <20250206113321.94906-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250206113321.94906-1-philmd@linaro.org> References: <20250206113321.94906-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN. Add the "little-endian" property to select the device endianness, defaulting to little endian. Set the proper endianness on the single machine using the device. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/ssi/xilinx_spi.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index bbda70aa93b..a795c6385b4 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -175,6 +175,7 @@ petalogix_ml605_init(MachineState *machine) SSIBus *spi; dev = qdev_new("xlnx.xps-spi"); + qdev_prop_set_bit(dev, "little-endian", true); qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES); busdev = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(busdev, &error_fatal); diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c index fd1ff12eb1d..299004ff36d 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -83,6 +83,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(XilinxSPI, XILINX_SPI) struct XilinxSPI { SysBusDevice parent_obj; + bool little_endian_model; MemoryRegion mmio; qemu_irq irq; @@ -313,14 +314,17 @@ done: xlx_spi_update_irq(s); } -static const MemoryRegionOps spi_ops = { - .read = spi_read, - .write = spi_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .valid = { - .min_access_size = 4, - .max_access_size = 4 - } +static const MemoryRegionOps spi_ops[2] = { + [0 ... 1] = { + .read = spi_read, + .write = spi_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + }, + [0].endianness = DEVICE_BIG_ENDIAN, + [1].endianness = DEVICE_LITTLE_ENDIAN, }; static void xilinx_spi_realize(DeviceState *dev, Error **errp) @@ -339,7 +343,8 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->cs_lines[i]); } - memory_region_init_io(&s->mmio, OBJECT(s), &spi_ops, s, + memory_region_init_io(&s->mmio, OBJECT(s), + &spi_ops[s->little_endian_model], s, "xilinx-spi", R_MAX * 4); sysbus_init_mmio(sbd, &s->mmio); @@ -362,6 +367,7 @@ static const VMStateDescription vmstate_xilinx_spi = { }; static const Property xilinx_spi_properties[] = { + DEFINE_PROP_BOOL("little-endian", XilinxSPI, little_endian_model, true), DEFINE_PROP_UINT8("num-ss-bits", XilinxSPI, num_cs, 1), };