From nobody Tue Nov 18 14:13:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1611061613; cv=none; d=zohomail.com; s=zohoarc; b=UpEVgAfcSQH/HRGFhLfrjLXcdQ6KQA0wNg5Vog5MZ7Gujz8HRqw5lAvKFI/kfkUNRNpE7velWxl7P1YSBlALeASDFw4PGKqBOM+rwslUR3WskvVzqb1gGpVVlugs3bNY4mJ/WrInUh+ovTaZxZF+XEDtGlf0BcWqt99AKIL3Wyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611061613; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nBfQdnHsV8Wq5vizPIPoPSOpWjRk29x+48yhgI+v53U=; b=nA+iw8J7TOuR3R6x4OOfTIx3CYavdsZksboRlAU2tlL1NaGsZqs5K1vMHqSDZhmWU94UBHg3VABNB+vhEC32ak0knGqMQHWJ2h51yIHyxg/0PcEdfg36D1bQfh+We+ga4eyz/aal0/Tt1hfVjvE1gwk+mQefBv35DTBVOjDTmhM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611061613808556.2925273824145; Tue, 19 Jan 2021 05:06:53 -0800 (PST) Received: from localhost ([::1]:52602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1qii-0001YH-Qd for importer@patchew.org; Tue, 19 Jan 2021 08:06:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1qe9-0006S7-3k for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:09 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:46530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l1qe4-0005vP-0L for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:08 -0500 Received: by mail-lj1-x22e.google.com with SMTP id u11so21757197ljo.13 for ; Tue, 19 Jan 2021 05:01:59 -0800 (PST) Received: from localhost.localdomain (31-208-27-151.cust.bredband2.com. [31.208.27.151]) by smtp.gmail.com with ESMTPSA id e25sm2356745lfc.40.2021.01.19.05.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 05:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nBfQdnHsV8Wq5vizPIPoPSOpWjRk29x+48yhgI+v53U=; b=Smtge64XARU4FTT8xy+y8pOgxiXZS+tRx4NFa7AIcTNFRBTmerY5lxD0ffrwyYRq0z mdJgyGBhAG73Au8zm4u63mEaJY0/pFe4h91+E2tUkGEgXUHDYNYotxN96fqeoafw3yM9 0ARA5c/fiXWkBXug53PGDcslu49Y495dQNoeyVAahRxqRUWVBpnTfBopbn5LLxnLlmxD GThQPvN3LJMg1R93NicjYFkHghv6n8Ud3rRdxvarTPEwz5sg63f6u6s7dGrEv6u2bvsN 0yrdmP134miK+h4zuQYfwbwE9C22bpsbA5TBMwxFwbF658fJ5lwdhRG74AY9ad6zJ6wd PiCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nBfQdnHsV8Wq5vizPIPoPSOpWjRk29x+48yhgI+v53U=; b=HK9YyA9IWaxrYpIozGVzDOCO3C6PDrr07E1FwBS9omDNJiANlk0Ez7i+LNfoAU1KG1 dTU8JpInM2hHh1yyIEdbwjN1WwbYNT5XQ620NFqUmRCo6WkjLCyVtIbX9L45LT89BIXf LJBKtWEpaQB1nfTJ9YhMYX2AzVySz37cZLX2/JwSYi6i8hVRcuUDrBB9wvuyMW9XJU2G jXFKF75gOCvn4lM6J/7qf6y38437ceIeMddrgA6ovmGmdXe1ehOfZNLO7grXJxPvXQ56 owLqfPxY3JQlS0X7Y7H8hBtx56uG0+GpGHemewuDakXNsYR4v/vnl797A7YNVwforJoJ XHOQ== X-Gm-Message-State: AOAM533VyQ0/A68qQ3LnMLn7X1tjBFGDB9z3ckuM8VgU9UKyTo3pM9kE tFO75ThEWjJLB/vXqoFQfvBOdFJXyMXLeg== X-Google-Smtp-Source: ABdhPJycHhG3ZEMo421Jaj7Vewsc7/+Iiamyn+MuthQWfi8J38cZVFm1Z+i5v0B4pHNNCT9/49gJsA== X-Received: by 2002:a2e:740d:: with SMTP id p13mr1950333ljc.288.1611061317926; Tue, 19 Jan 2021 05:01:57 -0800 (PST) From: Francisco Iglesias To: qemu-devel@nongnu.org, frasse.iglesias@gmail.com Subject: [RFC PATCH v1 1/3] hw: ssi: Introduce ssi_txfifo_transfer Date: Tue, 19 Jan 2021 14:01:53 +0100 Message-Id: <20210119130155.30194-2-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210119130155.30194-1-frasse.iglesias@gmail.com> References: <20210119130155.30194-1-frasse.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=frasse.iglesias@gmail.com; helo=mail-lj1-x22e.google.com X-Spam_score_int: -1020 X-Spam_score: -102.1 X-Spam_bar: --------------------------------------------------- X-Spam_report: (-102.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_WELCOMELIST=-0.01, USER_IN_WHITELIST=-100 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, alistair@alistair23.me, bin.meng@windriver.com, mreitz@redhat.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch introduces ssi_txfifo_transfer aimed to be used by SPI controllers transfering through a txfifo. When interacting with a SPI flash (m25p80), ssi_txfifo_transfer will toggle the accuracy from dummy clock cycles to dummy bytes and by doing this above mentioned SPI controllers will obtain support for the commands requiring those. Signed-off-by: Francisco Iglesias --- hw/ssi/ssi.c | 22 ++++++++++++++++++++++ include/hw/ssi/ssi.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c index e5d7ce9523..b87628ea0c 100644 --- a/hw/ssi/ssi.c +++ b/hw/ssi/ssi.c @@ -127,6 +127,28 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) return r; } =20 +uint32_t ssi_txfifo_transfer(SSIBus *bus, uint32_t val) +{ + BusState *b =3D BUS(bus); + BusChild *kid; + SSIPeripheralClass *ssc; + uint32_t r =3D 0; + + QTAILQ_FOREACH(kid, &b->children, sibling) { + SSIPeripheral *peripheral =3D SSI_PERIPHERAL(kid->child); + ssc =3D SSI_PERIPHERAL_GET_CLASS(peripheral); + if (ssc->set_dummy_byte_accuracy) { + ssc->set_dummy_byte_accuracy(peripheral, true); + } + r |=3D ssc->transfer_raw(peripheral, val); + if (ssc->set_dummy_byte_accuracy) { + ssc->set_dummy_byte_accuracy(peripheral, false); + } + } + + return r; +} + const VMStateDescription vmstate_ssi_peripheral =3D { .name =3D "SSISlave", .version_id =3D 1, diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h index f411858ab0..39bf00ec96 100644 --- a/include/hw/ssi/ssi.h +++ b/include/hw/ssi/ssi.h @@ -54,6 +54,8 @@ struct SSIPeripheralClass { * always be called for the device for every txrx access to the parent= bus */ uint32_t (*transfer_raw)(SSIPeripheral *dev, uint32_t val); + + void (*set_dummy_byte_accuracy)(SSIPeripheral *dev, bool val); }; =20 struct SSIPeripheral { @@ -105,5 +107,6 @@ bool ssi_realize_and_unref(DeviceState *dev, SSIBus *bu= s, Error **errp); SSIBus *ssi_create_bus(DeviceState *parent, const char *name); =20 uint32_t ssi_transfer(SSIBus *bus, uint32_t val); +uint32_t ssi_txfifo_transfer(SSIBus *bus, uint32_t val); =20 #endif --=20 2.20.1 From nobody Tue Nov 18 14:13:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1611061447; cv=none; d=zohomail.com; s=zohoarc; b=WEl+pDM8XNHmOlSL6sYTa0WUPv5j9nJdCD8f1h4B+fjIA7H3kriyzupSN4TWInUuzOxJRCPU+6pqSjayVp/o50WIdS/SPL4JQaTCiXbBBeEdiTrX707S2HGI+IgQw3vv82CWR0MLa7v9C5WaQSY5rgkG6Zdtq6gxbeB9GRwfmvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611061447; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eF3PdkZp88Dtx8+Gjn51Fph38Ji7ew7FQX7/6hEKv5w=; b=JgZLpUGUIyeb6jBwCYXAeZKM1A5pmyQsKjU1FMKzT28aeHO0SI+JgBYmXFCcaETTqbjFf2MFJibcJpdRSYhSe05aXDoSwj5XfMB++fsTefZX8amey8vzyjcOo7Bo5CJ7CBJ7vH0E6zWGM8V28XzDfP60kwKjh9JlSKaRsf+Zb6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611061447527306.8235281953905; Tue, 19 Jan 2021 05:04:07 -0800 (PST) Received: from localhost ([::1]:47928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1qg2-0007zX-9S for importer@patchew.org; Tue, 19 Jan 2021 08:04:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1qeA-0006Tz-Rx for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:10 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:44249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l1qe4-0005vV-0K for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:10 -0500 Received: by mail-lf1-x136.google.com with SMTP id m25so28888905lfc.11 for ; Tue, 19 Jan 2021 05:02:01 -0800 (PST) Received: from localhost.localdomain (31-208-27-151.cust.bredband2.com. [31.208.27.151]) by smtp.gmail.com with ESMTPSA id e25sm2356745lfc.40.2021.01.19.05.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 05:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eF3PdkZp88Dtx8+Gjn51Fph38Ji7ew7FQX7/6hEKv5w=; b=hgogRVOcMOo2v1ThHrdeeUdouzs/HmoVUCToY+6k4NxxJfdVIvi8UyZX7vYUDjoF90 DaTwycskKkrV7oknCI7vH/7SO7cC6JENZc/KIHkjTdV4QfzsVZoYf1kPfxKOByfaO9NT 1glOQ7QVwAu+j+0VkDfAx6ti1WTSL0U27lhVwuVlQa8v4QA550vVzJ2bc4uqYNmMKMvZ DKgoMJM77E8We4o0m8+6HKM/J0RrEI4ILDin8WM2KYdp9gnMjWKnrgQUgAyr1HYEVUgX 59XUdjaYDzIR1yT2fXIoFkIHsAF1shlhjUBzvMBsFgw8A5ecf1uFccDv5MQ1XRAizKK/ 6TMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eF3PdkZp88Dtx8+Gjn51Fph38Ji7ew7FQX7/6hEKv5w=; b=gCAIqXXpenGBRVZ9JBXiRnIvgjWobL5f6iy01ntUY7SpYsZWSglgpBB0al3o+Ccdnr ywj+RLdGxW+1HRvmWRR9ZCeWoWDuzZmAwomGJ6mZeWRyR77YarwaWFwlgNgsv6HUDkkb Z3V7zFu0A+WiYV89Ga/TVbuD90fQBzwJc4WY/tuBh95+968/NIOIIq9ppkZbZx4xHdRw sSTZEaCZFaj0PW9I1UzQLor/WBYaEtuGhM9C5bIj58gXnja/+tUvzKWIM59egYnvbSJ9 vveX7w4zv87aZtVJe2c1INzExZ/CwHrhTWgjqcFYLuyOLzJvisaE/4GB0x6y1oI/rbaE tnOw== X-Gm-Message-State: AOAM533VKLzWL9sqxH4UJ1Vd7LnByQHxvN0fmwVPoz3VeDxEoATpyp35 j6Lv5b6Gyw+/GEtzkvnLoukbe4Q1RLyvmA== X-Google-Smtp-Source: ABdhPJyWp1XqxgL91u7wVZE4Fbm0Ntzy4nSGIKpyiVrJeUvoV2p4NSXoJz2lHlNnGL0iqNHhomEQKw== X-Received: by 2002:a05:6512:338e:: with SMTP id h14mr1856046lfg.324.1611061319068; Tue, 19 Jan 2021 05:01:59 -0800 (PST) From: Francisco Iglesias To: qemu-devel@nongnu.org, frasse.iglesias@gmail.com Subject: [RFC PATCH v1 2/3] hw: block: m25p80: Support dummy byte accuracy Date: Tue, 19 Jan 2021 14:01:54 +0100 Message-Id: <20210119130155.30194-3-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210119130155.30194-1-frasse.iglesias@gmail.com> References: <20210119130155.30194-1-frasse.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=frasse.iglesias@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -1020 X-Spam_score: -102.1 X-Spam_bar: --------------------------------------------------- X-Spam_report: (-102.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_WELCOMELIST=-0.01, USER_IN_WHITELIST=-100 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, alistair@alistair23.me, bin.meng@windriver.com, mreitz@redhat.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch adds support to toggle the accuracy in m25p80 between dummy clock cycle to dummy byte. By being able to do this the SPI controllers transfering through a txfifo will be able to support commands with dummy clock cycles. Signed-off-by: Francisco Iglesias --- hw/block/m25p80.c | 112 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 20 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 1b3f2405a1..c9342e1842 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -462,6 +462,7 @@ struct Flash { =20 const FlashPartInfo *pi; =20 + bool dummy_byte_accuracy; }; =20 struct M25P80Class { @@ -862,26 +863,59 @@ static uint8_t numonyx_extract_cfg_num_dummies(Flash = *s) return num_dummies; } =20 +static uint8_t to_dummy_bytes(Flash *s, uint8_t dummy_clk_cycles) +{ + uint8_t lines =3D 1; + + switch (s->cmd_in_progress) { + case DOR: + case DOR4: + case DIOR: + case DIOR4: + lines =3D 2; + break; + case QOR: + case QOR4: + case QIOR: + case QIOR4: + lines =3D 4; + break; + default: + break; + } + + if ((dummy_clk_cycles * lines) % 8) { + qemu_log_mask(LOG_UNIMP, "M25P80: Non multiple of 8 number of dumm= y" + " clock cycles while operating with dummy byte" + " accuracy\n"); + } + + return (dummy_clk_cycles * lines) / 8; +} + static void decode_fast_read_cmd(Flash *s) { + uint8_t dummy_clk_cycles =3D 0; + uint8_t extra_bytes; + s->needed_bytes =3D get_addr_length(s); switch (get_man(s)) { /* Dummy cycles - modeled with bytes writes instead of bits */ case MAN_WINBOND: - s->needed_bytes +=3D 8; + dummy_clk_cycles =3D 8; break; case MAN_NUMONYX: - s->needed_bytes +=3D numonyx_extract_cfg_num_dummies(s); + dummy_clk_cycles =3D numonyx_extract_cfg_num_dummies(s); break; case MAN_MACRONIX: if (extract32(s->volatile_cfg, 6, 2) =3D=3D 1) { - s->needed_bytes +=3D 6; + dummy_clk_cycles =3D 6; } else { - s->needed_bytes +=3D 8; + dummy_clk_cycles =3D 8; } break; case MAN_SPANSION: - s->needed_bytes +=3D extract32(s->spansion_cr2v, + dummy_clk_cycles =3D extract32(s->spansion_cr2v, SPANSION_DUMMY_CLK_POS, SPANSION_DUMMY_CLK_LEN ); @@ -889,6 +923,14 @@ static void decode_fast_read_cmd(Flash *s) default: break; } + + if (s->dummy_byte_accuracy) { + extra_bytes =3D to_dummy_bytes(s, dummy_clk_cycles); + } else { + extra_bytes =3D dummy_clk_cycles; + } + + s->needed_bytes +=3D extra_bytes; s->pos =3D 0; s->len =3D 0; s->state =3D STATE_COLLECTING_DATA; @@ -896,38 +938,49 @@ static void decode_fast_read_cmd(Flash *s) =20 static void decode_dio_read_cmd(Flash *s) { + uint8_t dummy_clk_cycles =3D 0; + uint8_t extra_bytes; + s->needed_bytes =3D get_addr_length(s); /* Dummy cycles modeled with bytes writes instead of bits */ switch (get_man(s)) { case MAN_WINBOND: - s->needed_bytes +=3D WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; + dummy_clk_cycles =3D WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; break; case MAN_SPANSION: - s->needed_bytes +=3D SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; - s->needed_bytes +=3D extract32(s->spansion_cr2v, + dummy_clk_cycles =3D SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; + dummy_clk_cycles =3D extract32(s->spansion_cr2v, SPANSION_DUMMY_CLK_POS, SPANSION_DUMMY_CLK_LEN ); break; case MAN_NUMONYX: - s->needed_bytes +=3D numonyx_extract_cfg_num_dummies(s); + dummy_clk_cycles =3D numonyx_extract_cfg_num_dummies(s); break; case MAN_MACRONIX: switch (extract32(s->volatile_cfg, 6, 2)) { case 1: - s->needed_bytes +=3D 6; + dummy_clk_cycles =3D 6; break; case 2: - s->needed_bytes +=3D 8; + dummy_clk_cycles =3D 8; break; default: - s->needed_bytes +=3D 4; + dummy_clk_cycles =3D 4; break; } break; default: break; } + + if (s->dummy_byte_accuracy) { + extra_bytes =3D to_dummy_bytes(s, dummy_clk_cycles); + } else { + extra_bytes =3D dummy_clk_cycles; + } + + s->needed_bytes +=3D extra_bytes; s->pos =3D 0; s->len =3D 0; s->state =3D STATE_COLLECTING_DATA; @@ -935,39 +988,50 @@ static void decode_dio_read_cmd(Flash *s) =20 static void decode_qio_read_cmd(Flash *s) { + uint8_t dummy_clk_cycles =3D 0; + uint8_t extra_bytes; + s->needed_bytes =3D get_addr_length(s); /* Dummy cycles modeled with bytes writes instead of bits */ switch (get_man(s)) { case MAN_WINBOND: - s->needed_bytes +=3D WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; - s->needed_bytes +=3D 4; + dummy_clk_cycles =3D WINBOND_CONTINUOUS_READ_MODE_CMD_LEN; + dummy_clk_cycles +=3D 4; break; case MAN_SPANSION: - s->needed_bytes +=3D SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; - s->needed_bytes +=3D extract32(s->spansion_cr2v, + dummy_clk_cycles =3D SPANSION_CONTINUOUS_READ_MODE_CMD_LEN; + dummy_clk_cycles +=3D extract32(s->spansion_cr2v, SPANSION_DUMMY_CLK_POS, SPANSION_DUMMY_CLK_LEN ); break; case MAN_NUMONYX: - s->needed_bytes +=3D numonyx_extract_cfg_num_dummies(s); + dummy_clk_cycles =3D numonyx_extract_cfg_num_dummies(s); break; case MAN_MACRONIX: switch (extract32(s->volatile_cfg, 6, 2)) { case 1: - s->needed_bytes +=3D 4; + dummy_clk_cycles =3D 4; break; case 2: - s->needed_bytes +=3D 8; + dummy_clk_cycles =3D 8; break; default: - s->needed_bytes +=3D 6; + dummy_clk_cycles =3D 6; break; } break; default: break; } + + if (s->dummy_byte_accuracy) { + extra_bytes =3D to_dummy_bytes(s, dummy_clk_cycles); + } else { + extra_bytes =3D dummy_clk_cycles; + } + + s->needed_bytes +=3D extra_bytes; s->pos =3D 0; s->len =3D 0; s->state =3D STATE_COLLECTING_DATA; @@ -1291,6 +1355,13 @@ static int m25p80_cs(SSIPeripheral *ss, bool select) return 0; } =20 +static void m25p80_dummy_byte_accuracy(SSIPeripheral *ss, bool val) +{ + Flash *s =3D M25P80(ss); + + s->dummy_byte_accuracy =3D val; +} + static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx) { Flash *s =3D M25P80(ss); @@ -1494,6 +1565,7 @@ static void m25p80_class_init(ObjectClass *klass, voi= d *data) k->transfer =3D m25p80_transfer8; k->set_cs =3D m25p80_cs; k->cs_polarity =3D SSI_CS_LOW; + k->set_dummy_byte_accuracy =3D m25p80_dummy_byte_accuracy; dc->vmsd =3D &vmstate_m25p80; device_class_set_props(dc, m25p80_properties); dc->reset =3D m25p80_reset; --=20 2.20.1 From nobody Tue Nov 18 14:13:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1611061775; cv=none; d=zohomail.com; s=zohoarc; b=NMpX7pH3yWI8azsjZzokzHwkeXxbaIUi6NMKYXNfi3IoAQWlrWe9s27AmqhVtSywL1MaTObbpzAECmbUXWtYxHe6QNvKVKuTge+oYr4mt1Z5GCy3yovolCByMqbdMumKbo+QtLvaVjKmNnBxU10sTBD+m/DERaJ4zG72AHIuQ1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611061775; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xFkGVZT5LAaP1cSLjH/YT+DBh9Jxe/ABwDeVi+JdLe0=; b=HC1RJHi3qtUgKHu/eA5XQNZzH6aso3Jq4IPkguux0LVt263pM4P7+6IDYYd9gw7P3YgKgSFGmc2lrygGapvLUYz3GLIzDnuJovtKsTZ0/CPusyBAJRATT8HuGNEKRzpwx4kN8FVowrWBIFy8HM1mIzYwtcJfINuxiy0/tfA77Ds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611061775110825.0476301243341; Tue, 19 Jan 2021 05:09:35 -0800 (PST) Received: from localhost ([::1]:55258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1qlJ-0002iM-Mv for importer@patchew.org; Tue, 19 Jan 2021 08:09:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1qeD-0006Uz-1r for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:14 -0500 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]:42378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l1qe4-0005vc-0I for qemu-devel@nongnu.org; Tue, 19 Jan 2021 08:02:12 -0500 Received: by mail-lj1-x233.google.com with SMTP id j3so2082102ljb.9 for ; Tue, 19 Jan 2021 05:02:01 -0800 (PST) Received: from localhost.localdomain (31-208-27-151.cust.bredband2.com. [31.208.27.151]) by smtp.gmail.com with ESMTPSA id e25sm2356745lfc.40.2021.01.19.05.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 05:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xFkGVZT5LAaP1cSLjH/YT+DBh9Jxe/ABwDeVi+JdLe0=; b=gL5K9Zmt7ROthD+wyW1/UdrmagfT/iffRZXPpCvVJVOUugNdEzaoez1jUpy5XCKiMc nWWM0etmATYocwHh/BzWgDuvx0hRHy3961589LQ/qR/AUXy6x+uyHTRNGm1m7BmjkWV8 lsBrF90bcySX+hgJlyt58MhSvZZ3upMsUR9Ibzhc7ypJ6tWPNDF+BKnNXk0uEEfd4ysu tqnc8ALtQ0Y4i0n+khXaOHGoRk+IgEA/qOmvqWSJuKWsvQuhJqIs9SrBT1nmleqa9SU9 pZp/svZ+ALxsKwDVMJliBnnPNlc4SZGiJVTn8SHbhE0HX22ULs0Udm1ljlFnctJSLkg4 qAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xFkGVZT5LAaP1cSLjH/YT+DBh9Jxe/ABwDeVi+JdLe0=; b=Ck2u1N5eQowURnRAkFki+s76C1XFfM2xryaT3EYyuxlrJLpx/Dd2WxLOSsxSsPpD9Z Uqixam3NkEtAz6uFcmhLWB34BVRDtKTFbHPvlbRVM6xUhQnlvXpcZEq7cUba+JPR+j/9 cnEPRIi6cgJyiKbXUQsetBIqgBUup6MjYCkVdmNUTIQFdep0HknLmBAVMB6SmohxodY3 g7U5/SdY2KwGEkS9RN51Oh3BhNWpGjOH2VKSRNOI/9yQiox9imiNJsVWzAV21OaF6jeR V+oWqKIGnarIYsOY5gd8gEJIvuMT9SIgOS3PcWjs4DDtKuABQ2P+mQrRIvXN11udchs4 3jrQ== X-Gm-Message-State: AOAM530Nh+VPkU4exq/NSWNo7E6errsyxt7vMkMMyTSup1E+uE9WA/P9 2/Xc7JAo4Wxti+UZm1b1A+9jaH+OLcPq0g== X-Google-Smtp-Source: ABdhPJxJpcU/+DY3qaI5Y3J0MckNDUExZO9j3RX/dE6Lil+8oDrZZU5dICGzpOe5JrFWonAaQAvaAg== X-Received: by 2002:a2e:9410:: with SMTP id i16mr1798130ljh.183.1611061320229; Tue, 19 Jan 2021 05:02:00 -0800 (PST) From: Francisco Iglesias To: qemu-devel@nongnu.org, frasse.iglesias@gmail.com Subject: [RFC PATCH v1 3/3] hw: ssi: xilinx_spi: Change to use ssi_txfifo_transfer Date: Tue, 19 Jan 2021 14:01:55 +0100 Message-Id: <20210119130155.30194-4-frasse.iglesias@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210119130155.30194-1-frasse.iglesias@gmail.com> References: <20210119130155.30194-1-frasse.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=frasse.iglesias@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -1020 X-Spam_score: -102.1 X-Spam_bar: --------------------------------------------------- X-Spam_report: (-102.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_WELCOMELIST=-0.01, USER_IN_WHITELIST=-100 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, alistair@alistair23.me, bin.meng@windriver.com, mreitz@redhat.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch changes the SPI controller to use the ssi_txfifo_transfer for being able to support SPI flash commands requiring dummy clock cycles. Signed-off-by: Francisco Iglesias --- hw/ssi/xilinx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c index 49ff275593..ae34cdc436 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -179,7 +179,7 @@ static void spi_flush_txfifo(XilinxSPI *s) while (!fifo8_is_empty(&s->tx_fifo)) { tx =3D (uint32_t)fifo8_pop(&s->tx_fifo); DB_PRINT("data tx:%x\n", tx); - rx =3D ssi_transfer(s->spi, tx); + rx =3D ssi_txfifo_transfer(s->spi, tx); DB_PRINT("data rx:%x\n", rx); if (fifo8_is_full(&s->rx_fifo)) { s->regs[R_IPISR] |=3D IRQ_DRR_OVERRUN; --=20 2.20.1