From patchwork Thu Dec 5 21:35:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 22095 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56011202E0 for ; Thu, 5 Dec 2013 21:36:12 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf10750454qcx.8 for ; Thu, 05 Dec 2013 13:36:12 -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=+hHwDYvFQghWVP0LNo4QgszjhZ52XGIkxlkXxi34ZYQ=; b=Dkuoq+ILMM8lYTb+vMp7A1PYYVhjfxn6+266Of7Twy5+b6vzlxQ3I1j4e3mROFEmjE ZA0etVwVfuj3gIThyLtKVVwBba4gjTTh836h9u2NeA/p375p2qTpOyNeTwoXbVPSisNP CA7rjGgDKTtp5PE3cUbzmCZCXSxqNwid76i6D3ElGhQS7bcogYM1Angdk3iuTGosv9+y uHCCKKSYCeL7IS9K2jlRmYjRZOBXx4SZtP9t2pP+XgHkt/3J1IbgY0D1OsxJ12Tf7/Sa SzGE1gld13VfrtxidOcYz1jTpDEX5C4b2SZxBxi8PRdkULtqgMTgGoeyeHMqhCrNMuyt vECA== X-Gm-Message-State: ALoCoQlf0zrXOZtyRTml//gCIf4LGNnKBdLBTzehMf5unNjpQr8ffpQdrPf8uneK7LU3siStiz2h X-Received: by 10.236.145.34 with SMTP id o22mr56626yhj.22.1386279372039; Thu, 05 Dec 2013 13:36:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.131 with SMTP id 3ls1048686qee.70.gmail; Thu, 05 Dec 2013 13:36:11 -0800 (PST) X-Received: by 10.220.86.129 with SMTP id s1mr102369vcl.63.1386279371815; Thu, 05 Dec 2013 13:36:11 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id gs2si20851665vdc.70.2013.12.05.13.36.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 13:36:11 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so14321078veb.19 for ; Thu, 05 Dec 2013 13:36:11 -0800 (PST) X-Received: by 10.52.162.168 with SMTP id yb8mr82746vdb.8.1386279371592; Thu, 05 Dec 2013 13:36:11 -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 u4csp49263vcz; Thu, 5 Dec 2013 13:36:11 -0800 (PST) X-Received: by 10.68.204.193 with SMTP id la1mr27259096pbc.159.1386279370737; Thu, 05 Dec 2013 13:36:10 -0800 (PST) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by mx.google.com with ESMTPS id kn3si59078895pbc.304.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.192.180 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.192.180; Received: by mail-pd0-f180.google.com with SMTP id q10so25411202pdj.39 for ; Thu, 05 Dec 2013 13:36:10 -0800 (PST) X-Received: by 10.66.219.233 with SMTP id pr9mr82454pac.45.1386279370348; Thu, 05 Dec 2013 13:36:10 -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.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 13:36:09 -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 3/7] return status for each NOR flash device Date: Thu, 5 Dec 2013 13:35:55 -0800 Message-Id: <1386279359-32286-4-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.128.174 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: , Now that we know how wide each flash device that makes up the bank is, return status for each device in the bank. Leave existing code that treats 32 bit wide banks as composed of two 16 bit devices as otherwise we may break configurations that do not set the device_width propery. Signed-off-by: Roy Franz Reviewed-by: Peter Maydell --- hw/block/pflash_cfi01.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index a458ad6..82a2519 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -193,9 +193,20 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, case 0x60: /* Block /un)lock */ case 0x70: /* Status Register */ case 0xe8: /* Write block */ - /* Status register read */ + /* Status register read. Return status from each device in + * bank. + */ ret = pfl->status; - if (width > 2) { + if (pfl->device_width && width > pfl->device_width) { + int shift = pfl->device_width * 8; + while (shift + pfl->device_width * 8 <= width * 8) { + ret |= pfl->status << shift; + shift += pfl->device_width * 8; + } + } else if (!pfl->device_width && width > 2) { + /* Handle 32 bit flash cases where device width is not + * set. (Existing behavior before device width added.) + */ ret |= pfl->status << 16; } DPRINTF("%s: status %x\n", __func__, ret);