From patchwork Mon Feb 10 20:41:38 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: 863826 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1791324wrt; Mon, 10 Feb 2025 12:43:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUicl04VdrKhmWKxLQokCYGK/io+IxuOxsoagHEfJlOvF7c+SNVsHNrh+IEiVPd3Qo8Xidi2A==@linaro.org X-Google-Smtp-Source: AGHT+IGQJD8agtjmHBwA+B7xgcT7SakckwGPyAliCLdLNqV/NWGx8bqcs+/VeK+M7oL5EggjX4Ey X-Received: by 2002:a05:6214:2486:b0:6d8:8b9d:1502 with SMTP id 6a1803df08f44-6e4456c56cdmr190416876d6.30.1739220212350; Mon, 10 Feb 2025 12:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739220212; cv=none; d=google.com; s=arc-20240605; b=ePxM6tI0CT9MxXl05tBuiIYteZJxrNz+MzwsmzaDPdWj4hFD4dDBD8zBrGD+JgFuNY bf972PASVlqUagSbrxq1SWx9e2Fenrl6Pm4/OA+yOBCdnpa/9iOxeV9Pq6bJObsUBx7d SmOqsCq7EOaGB9Jx+sPFdYXiiiA6ynpidifgVMoVnOlJFajLJkf7U+yKR/3IjvPTZzgc cJV1lP7yejtSpKP+8USCrYUSPqA+/FtEzgbwFHMUtNti9v1vc+df6Djt02jVbsfe6mnd TV1tZNwBf9MdGZHl/UfziFnhiFnLCf7lh2w8F8/AY882GGjoibamEZwEaunH77zQVcMX gCLg== 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=BYj1i0C2Bzb8mJTlz6kNhAyO1j8/RdFzATqWG3urJNQ=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=N+WtGaqkpz2YBPyGMp34mqLZcK97ehGIug1dgYw2vavNLw/EHZjGW1Qwpu/cKCWe1/ fC62pp4JWnutWc5w5yPMzvJUlPms1XTZflNabsyC9c5Y2oKJY7WtGWFjImoC2blnZiw8 marXZK6lc2jM4whYR3bdSOGMMRBo4eTjIIoJIfox+9drRq+D/pYCs4x4g0VM1wiSQDuU Kk35VwjiMwuXkZg12UhgqwZrWxbeZPTIAyLeepcVYA0RziNDjhL7nUZwf1kiLcpdMqYF +FBK0uDbE9PofToFtwUveP75hmpmEEdTuCUH33Yt9sIxuBNCL0GlXPXoWJ0B74xiIuer Ynsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S30yiYi5; 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-6e450f37082si62220856d6.363.2025.02.10.12.43.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 12:43:32 -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=S30yiYi5; 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 1thacB-0006Lr-89; Mon, 10 Feb 2025 15:42:47 -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 1thac6-0006Gh-Jg for qemu-devel@nongnu.org; Mon, 10 Feb 2025 15:42:44 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thac3-0003cJ-CD for qemu-devel@nongnu.org; Mon, 10 Feb 2025 15:42:40 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4362f61757fso48058275e9.2 for ; Mon, 10 Feb 2025 12:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739220157; x=1739824957; 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=BYj1i0C2Bzb8mJTlz6kNhAyO1j8/RdFzATqWG3urJNQ=; b=S30yiYi5/13bzm0QteEdEcOMAadosYfGQDRGdsdvDHi3znzNPOG9T17Mz89+7mVVth v9Ri9DxLIg7SL1tGYSKMbU4pLsXUcaCsv8TWpYddnNKMTnGjyhVh5cG8YdNs9w8QyQWx 57eCRHPiD1bkLQEgQjja2mNiQCDpaNAtTcFEqM3sgaFW4MAujeRJlzLblO+0oLOOCLq4 NLZs5qr6CGwRaF4BlI4x/BPZ2a8PrqIuNqp8/pgzpSlPCIbrjXhb5vy/u4LIreQuLRHI 4ii1dYbFv7aFGqwUZ3gNe3A50F0uZJkuA+LCefkZ1yCpLhtRcWG5GdqjNByhgN99sshy k91Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739220157; x=1739824957; 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=BYj1i0C2Bzb8mJTlz6kNhAyO1j8/RdFzATqWG3urJNQ=; b=EwXDOlsAtYZ7gQ8qgW1JHXzMKp5GZPMypIXmDdjgFIN3IhbpSsK/oojZMt8v7cvWUQ /AXHD4PBNEw3OZdya8ixh0PjFBUSdfzaiB4lhlXF65EH+9bGMPV5/DCjbKZFhW2XUHL/ 86fN2cc09cs8IE7Eob9ywufc/l4QdEYT7SCuTSgk22ZvWw4X/rM9nPBXrpw+vdlXV0OP Hb/BBdclyiBsRHI5aCp3YQAox9Wbh8p4qF4IxMsrizlYRFdlQjeEh6NnsED9df04zY5z gN5f0Hl4BNreje/s55S8H5jQQw62V830UUXjlWZqCF0IITCS6IS1QdqM26t3TvmfDlPv JYuQ== X-Gm-Message-State: AOJu0Yxpj+221QsZVC2e5lIs270vlnyrVDuh9/n4cG1xLEg4IXqQ95zb yAYUj8qqdul4q/EVYjL048rY6jpgD3M5wlQDplxepy8AZhLwNffChSxwSCfDOW+cKmLiW5mJlHO WmuY= X-Gm-Gg: ASbGncvRZLOu2+lLjonxiVt5n4p1Ve4mN2829+smsOSLke5sEghoL6ftWI6WS/yz4hR VtuM6tp4eWqV+LotZ2eAt6MRWPcjzhCVNRMAYuiE2yYcU3RIBOmGLSnEIn2sVBhjdv4YmSd3cvd FwNcJWpjIFPJ9EXAMwuE4n9HdgFCcGG/Pu51gBO/cuKBGyYpXPkLDdqVKBSNiiI+aB3G3VZRC6b zEapE2cEi/Kgdaf5PFAGQJdJnz9bR/LypuIIQ9vcyp3WysTVD8BLKR3lR3Q5Qx4CPR0w5M3Gjl3 uQIdmRoZnNNbF0tpmdgGzZ8iNa7qoqb9hEIa/FvMZ1aQJ1/WCJmSay/zl2iCRxPYAQ== X-Received: by 2002:a5d:6705:0:b0:386:3e3c:efd with SMTP id ffacd0b85a97d-38dc9359019mr11007358f8f.44.1739220156654; Mon, 10 Feb 2025 12:42:36 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4390daf4438sm195336895e9.25.2025.02.10.12.42.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Feb 2025 12:42:36 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 06/32] hw/ssi/xilinx_spi: Make device endianness configurable Date: Mon, 10 Feb 2025 21:41:38 +0100 Message-ID: <20250210204204.54407-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250210204204.54407-1-philmd@linaro.org> References: <20250210204204.54407-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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é Message-Id: <20250206131052.30207-7-philmd@linaro.org> --- 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), };