From patchwork Wed Feb 12 12:36:55 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: 864460 Delivered-To: patch@linaro.org Received: by 2002:a5d:4cc5:0:b0:38f:210b:807b with SMTP id c5csp96414wrt; Wed, 12 Feb 2025 04:41:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWNaopbSE7E2VfVCJy04S50NfkCNqV7RnsbyfvB2GikIfD+O9m/foDgNLKRIdy6yPfMaSW8+A==@linaro.org X-Google-Smtp-Source: AGHT+IEctITEZx3w5G0KbS3AsdgsSaRYcf9HW3+7bdX2H0znfAzVWXFWH2ufxUV/EaQE0e1adycc X-Received: by 2002:a05:6214:240f:b0:6e4:227b:c2b0 with SMTP id 6a1803df08f44-6e46ed8ae09mr52625756d6.22.1739364113599; Wed, 12 Feb 2025 04:41:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739364113; cv=none; d=google.com; s=arc-20240605; b=F0WLI+UYsyxaSDA4UdqOTNp2kG7wkSvCl+DEUfltCoUqOTNKdeRhTF1LhcrJd0WctD uyPoj44RARh3sdqsdhbwxkZAN/RXcZDq2ekSCA/ZAe9BriAJykTW9u5eOhxlWTngsPzw aQVKMLhpfOp3BTnp7ltWmS4BTvc1VzkdxADFcsyJES3BtLZdgw/wIFPDY7BSTUBFKeN2 J+wGefyVUsREBCbvlP527zmCdzfcZIU7+1MJ9zh+NrkKOrFHdzK7j7NfYoGtsJ32UyyV Wd1K/I0mvdindPXSnz3+xfPoQbP1uEi39YiKJo8mOZpV6ZtDMlxG5rt+k+qdP1XsvI5F 4yOg== 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=IWUW6vMOmCPzMRvR9U3A14f86L3fegXfbhL6iARH54I=; fh=HlENWry5pBMj1xy+XPJJKz1+KJ8prrg3FvBcv7/VjNo=; b=eUAbN8wwIHziOJtZqdc0zIbua2/0MpSMDRRU+9XnZEmAafEGPAQYj8FnZHtIUl73CY F7Su3Uq70qkZvMxszlTjwwaPKWxJEtZGouhH/HKBdR9uKUjIuoCC0EPALf7115Ts0UZM 2kbr5uSsBfjWEyycTPbwt1qIX7zakq1WR7NoNrc3/wXQBJuZJkvm7bBSG8qoVnSH11af 5fVKG53wba9MZ2hyrwWskqMJDiXWuTgj+hvRgXqzEf6Vzz06GkdNc225YQQZA9pZ/YKY 9rgD2o1Y/r0enuC32CrrVpt7SluFftm+4+BP03n6uFvHK09JiyR6d7I9008/G/mR5sVA AhNg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gNS3ViJb; 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 6a1803df08f44-6e43ba2cd17si131976896d6.13.2025.02.12.04.41.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Feb 2025 04:41:53 -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=gNS3ViJb; 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 1tiC1e-0005iz-LU; Wed, 12 Feb 2025 07:39:34 -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 1tiBzp-0003ec-TI for qemu-devel@nongnu.org; Wed, 12 Feb 2025 07:37:46 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tiBzj-0000YR-Mn for qemu-devel@nongnu.org; Wed, 12 Feb 2025 07:37:40 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4394a0c65fcso31428715e9.1 for ; Wed, 12 Feb 2025 04:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739363851; x=1739968651; 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=IWUW6vMOmCPzMRvR9U3A14f86L3fegXfbhL6iARH54I=; b=gNS3ViJbvhPyJqtrW3bJa/BpXQLrQ+QKyoUpaUFcZ4/hfOO+a53gNGqu2x9JUKMzBW e+OlgMtkxkGyThoLV86FNRjOThpP+DcXkdSlIIM9JyULKqHsbtM1w3NnhXaoO285I+K1 0ZqJqw5fq+oCHrq1yJtXDTQbEkvFIE/OlfdeOA9AGHCtJka8b8LwR2EoKcze8HyFW+Ho kMdizkE0pRg2REWr8iKJzUIzUPT4X2819pBGt8HjEGhBHa1GoTgW0qnCIlBcUSE5JrsG phUf9+C+VOap1Jy8Gg1M9gNoszFbg5cGDeyH7Lj8Q9CSRDlXTJAjF2UiywW+TeLTgXNN nheg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739363851; x=1739968651; 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=IWUW6vMOmCPzMRvR9U3A14f86L3fegXfbhL6iARH54I=; b=Jy79kAz/QDAdkk2NGlOT32wggaxtDgMeDb1b+MUbgrqB1WYQVHxjLm0rOUko2QKwKg XX3kr1pV4pe0bHSQ0tpM3UERDuS+amXljjS2ETyj8dX1rkvOdSxwThTOYLNlNTz2FaQC zWAcbMeIVyMfNj9cmK3p7fbv5hyqNLZSyeifw+xNpndaDD2i7dsaO+tp4s3V/jc5/HS4 iFp+Y3ThEjZjiDt2ruUI/SY0PxwbkDFJEiX8NKChWHranwlrikcgNSNpj7TsqWi9K9g8 HU0m4r5wOIpbXROFAOg/ZX9M5VX4EV1blfQ/UpA72uutNZTnEb/2kT5PrFfFr7SNu8BX GVMA== X-Gm-Message-State: AOJu0YyjzyOylHdc0G+Y/MLiKZEDINIkE0rroydZleK6GwV/a0oY0jnk YCnUBTRra0tnkcP5Au/vpODtFLGf8uJnL+44kzG50CbDcKLoRAh+YQj02od5w1583z+Wn/4y2Ac 08mY= X-Gm-Gg: ASbGncuRf1LjVHeqBjIwPHULJ0Mez7e+F5130b3eRCXWRnJZy98LfDzRUZcCiiK+2rL lZjeZprBV8hgFRJcZj69ZrOLvowpMlitzbJxk2XlvAwy03bGhkIRGyGTSIyB/xHURbgmPNjjkrN BzgXR7qcjT6c3p6Hr3rZpmJiRhLbBW7HwyThWsEqX042UnrOKcVzsZD5BDGr5CUMuDk4spcrNd/ zsIeyHmLppB2r89t4I8AVGxNfjHVKlH6QorC5UisRUBYORp0R1cktiF3byZ9drdZjXnrEACaaPg FYO6fEWP35AbZLpDowiEdsFWaUKbqia1kPGuozSzVdBS3uLIpoV+GIVIa2M1b9ttJA== X-Received: by 2002:a5d:6d0b:0:b0:38d:cab2:91db with SMTP id ffacd0b85a97d-38dea251ff6mr2485464f8f.6.1739363850914; Wed, 12 Feb 2025 04:37:30 -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-38f21ea3246sm444419f8f.81.2025.02.12.04.37.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 04:37:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, Thomas Huth , qemu-arm@nongnu.org, Richard Henderson , qemu-ppc@nongnu.org, Sai Pavan Boddu , Markus Armbruster , "Edgar E. Iglesias" , Alistair Francis , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v7 06/10] hw/ssi/xilinx_spi: Make device endianness configurable Date: Wed, 12 Feb 2025 13:36:55 +0100 Message-ID: <20250212123659.52764-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250212123659.52764-1-philmd@linaro.org> References: <20250212123659.52764-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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: , 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. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/microblaze/petalogix_ml605_mmu.c | 1 + hw/ssi/xilinx_spi.c | 32 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index 490640e9428..b34edf13796 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_enum(dev, "endianness", ENDIAN_MODE_LITTLE); 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..be5baa6b350 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -25,6 +25,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "migration/vmstate.h" #include "qemu/module.h" @@ -32,6 +33,7 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/ssi/ssi.h" #include "qom/object.h" @@ -83,6 +85,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(XilinxSPI, XILINX_SPI) struct XilinxSPI { SysBusDevice parent_obj; + EndianMode model_endianness; MemoryRegion mmio; qemu_irq irq; @@ -313,14 +316,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_LITTLE_ENDIAN, + [1].endianness = DEVICE_BIG_ENDIAN, }; static void xilinx_spi_realize(DeviceState *dev, Error **errp) @@ -329,6 +335,12 @@ static void xilinx_spi_realize(DeviceState *dev, Error **errp) XilinxSPI *s = XILINX_SPI(dev); int i; + if (s->model_endianness == ENDIAN_MODE_UNSPECIFIED) { + error_setg(errp, TYPE_XILINX_SPI " property 'endianness'" + " must be set to 'big' or 'little'"); + return; + } + DB_PRINT("\n"); s->spi = ssi_create_bus(dev, "spi"); @@ -339,7 +351,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->model_endianness == ENDIAN_MODE_BIG], s, "xilinx-spi", R_MAX * 4); sysbus_init_mmio(sbd, &s->mmio); @@ -362,6 +375,7 @@ static const VMStateDescription vmstate_xilinx_spi = { }; static const Property xilinx_spi_properties[] = { + DEFINE_PROP_ENDIAN_NODEFAULT("endianness", XilinxSPI, model_endianness), DEFINE_PROP_UINT8("num-ss-bits", XilinxSPI, num_cs, 1), };