From patchwork Thu Dec 5 21:35:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 22094 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C5C224002 for ; Thu, 5 Dec 2013 21:36:11 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wo20sf57445995obc.9 for ; Thu, 05 Dec 2013 13:36:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=nO6RPlegVzMCS11G0RA1HFx5ykB0/Eg+amV4PciLixE=; b=J5MEWSnGcRy5C6wDfx3Z7vm8Y1jFwZaRPBtd/QZ4bBzrcnSYmaOUfFjHnrUfEiS7pM 2yOax18+zl1EhHb2Ms/VAjf6WDMIKJj61fB5S/JAyB0PnQKGU6QCeAOSx5KZkB3WzP2G Rc6V3oC1qIbhnYhAlBz0S4DsT1Nwfta23qNTCTxNV8fX5ly/YfE7vkgDSjfaAGfz9M6g SfT1VUEkyigkurQAC9UsnzLF9lyJ66iCvgadmQrhJJbBYiDgyqzKFCmUWHf//7LyF6gH QUClbbfxmvLTLNcaKvycdq6yXdhAWlCL8uF0SN1TbVwT2C2WY/9a/+9tNLnQJcMzDYzi 0VDg== X-Gm-Message-State: ALoCoQmwxDQop7oTzStg6kw8zhvKvjygQxfxkayyJ25WACVmhPeoKe9XFYZWqPhPxw8Il4T8SY9/ X-Received: by 10.182.111.227 with SMTP id il3mr16214obb.41.1386279370598; Thu, 05 Dec 2013 13:36:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.170 with SMTP id n10ls1033729qeu.82.gmail; Thu, 05 Dec 2013 13:36:10 -0800 (PST) X-Received: by 10.58.207.76 with SMTP id lu12mr83485vec.30.1386279370396; Thu, 05 Dec 2013 13:36:10 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id sj10si3088599vcb.15.2013.12.05.13.36.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:36:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ld13so13447113vcb.6 for ; Thu, 05 Dec 2013 13:36:10 -0800 (PST) X-Received: by 10.52.72.100 with SMTP id c4mr44551vdv.86.1386279370192; Thu, 05 Dec 2013 13:36:10 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp49261vcz; Thu, 5 Dec 2013 13:36:09 -0800 (PST) X-Received: by 10.68.231.72 with SMTP id te8mr213933pbc.66.1386279369457; Thu, 05 Dec 2013 13:36:09 -0800 (PST) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id ob10si59182895pbb.127.2013.12.05.13.36.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:36:09 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.192.176; Received: by mail-pd0-f176.google.com with SMTP id w10so25321129pde.21 for ; Thu, 05 Dec 2013 13:36:09 -0800 (PST) X-Received: by 10.66.242.17 with SMTP id wm17mr174463pac.102.1386279369052; Thu, 05 Dec 2013 13:36:09 -0800 (PST) Received: from rfranz-i7.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id xv2sm146889377pbb.39.2013.12.05.13.36.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 13:36:08 -0800 (PST) From: Roy Franz To: qemu-devel@nongnu.org, peter.maydell@linaro.org, kwolf@redhat.com, stefanha@redhat.com Cc: patches@linaro.org, Roy Franz Subject: [PATCH V5 2/7] Add device-width property to pflash_cfi01 Date: Thu, 5 Dec 2013 13:35:54 -0800 Message-Id: <1386279359-32286-3-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386279359-32286-1-git-send-email-roy.franz@linaro.org> References: <1386279359-32286-1-git-send-email-roy.franz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The width of the devices that make up the flash interface is required to mask certain commands, in particular the write length for buffered writes. This length will be presented to each device on the interface by the program writing the flash, and the flash emulation code needs to be able to determine the length of the write as recieved by each flash device. The device-width defaults to the bank width which should maintain existing behavior for platforms that don't need this change. This change is required to support buffered writes on the vexpress platform that has a 32 bit flash interface with 2 16 bit devices on it. Signed-off-by: Roy Franz Reviewed-by: Peter Maydell --- hw/block/pflash_cfi01.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index a0d7a16..a458ad6 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -40,6 +40,7 @@ #include "hw/block/flash.h" #include "block/block.h" #include "qemu/timer.h" +#include "qemu/bitops.h" #include "exec/address-spaces.h" #include "qemu/host-utils.h" #include "hw/sysbus.h" @@ -72,6 +73,7 @@ struct pflash_t { uint32_t nb_blocs; uint64_t sector_len; uint8_t bank_width; + uint8_t device_width; /* If 0, device width not specified. */ uint8_t be; uint8_t wcycle; /* if 0, the flash is read normally */ int ro; @@ -379,6 +381,14 @@ static void pflash_write(pflash_t *pfl, hwaddr offset, break; case 0xe8: + /* Mask writeblock size based on device width, or bank width if + * device width not specified. + */ + if (pfl->device_width) { + value = extract32(value, 0, pfl->device_width * 8); + } else { + value = extract32(value, 0, pfl->bank_width * 8); + } DPRINTF("%s: block write of %x bytes\n", __func__, value); pfl->counter = value; pfl->wcycle++; @@ -708,6 +718,7 @@ static Property pflash_cfi01_properties[] = { DEFINE_PROP_UINT32("num-blocks", struct pflash_t, nb_blocs, 0), DEFINE_PROP_UINT64("sector-length", struct pflash_t, sector_len, 0), DEFINE_PROP_UINT8("width", struct pflash_t, bank_width, 0), + DEFINE_PROP_UINT8("device-width", struct pflash_t, device_width, 0), DEFINE_PROP_UINT8("big-endian", struct pflash_t, be, 0), DEFINE_PROP_UINT16("id0", struct pflash_t, ident0, 0), DEFINE_PROP_UINT16("id1", struct pflash_t, ident1, 0),