From patchwork Tue Oct 22 16: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: 21219 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3ED5244B2 for ; Tue, 22 Oct 2013 16:36:09 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id w10sf14770779pde.0 for ; Tue, 22 Oct 2013 09:36:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=GmYyT/Qk+SWTCLtJ77BpFqloHHlBFA+Sa2FwgZqxKek=; b=PiERqJyP6MvlYaws7FJZwUE347BNE45DhV2CYhxuk7ZT+nCuD+JQMNTbe5mTqxjpq8 uE1FzCwt4jdcawt7Yma7YcEf4AM3nDhX8NBjdTaz0gp+ieAWGda1qQ9SoqC9rlaNN6/q eJaxnFZVlkrcGP5pT7SizUqTol2N8AZTMrOzIYA99wzOpEtItVIIcfCq3Li4rtLBJryD atuZshzIZwFOmviCgo++DhI213c5r6BbZnWP/1bpE+/XknwDtgWMp8tPdmUo0qEWpHkm caoalR/66wCVpsTHFYVg8/NAppkdS3m1PeMmabUA75DZWDU1825L8Ru8D99IBCyr6TQe J2vg== X-Received: by 10.66.229.6 with SMTP id sm6mr9861970pac.30.1382459769018; Tue, 22 Oct 2013 09:36:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.130.233 with SMTP id oh9ls163556qeb.62.gmail; Tue, 22 Oct 2013 09:36:08 -0700 (PDT) X-Received: by 10.58.218.161 with SMTP id ph1mr22905vec.40.1382459768862; Tue, 22 Oct 2013 09:36:08 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id hc10si5969481vdb.2.2013.10.22.09.36.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 09:36:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 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.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so1429964vcb.38 for ; Tue, 22 Oct 2013 09:36:08 -0700 (PDT) X-Gm-Message-State: ALoCoQmEQI3CsFDeVZdISeocGhRLsg6z1vPzrlY0Yu2y8nUJy0lrqB5yc1L7xHnYN6HNcJGi5LWI X-Received: by 10.58.107.204 with SMTP id he12mr977937veb.26.1382459768752; Tue, 22 Oct 2013 09:36:08 -0700 (PDT) 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 u4csp244232vcz; Tue, 22 Oct 2013 09:36:08 -0700 (PDT) X-Received: by 10.68.194.69 with SMTP id hu5mr8008618pbc.170.1382459767048; Tue, 22 Oct 2013 09:36:07 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id ws5si12719580pab.151.2013.10.22.09.36.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 09:36:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of roy.franz@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id lf10so6318639pab.20 for ; Tue, 22 Oct 2013 09:36:06 -0700 (PDT) X-Received: by 10.66.161.229 with SMTP id xv5mr24521133pab.87.1382459766492; Tue, 22 Oct 2013 09:36:06 -0700 (PDT) Received: from rfranz-i7.local (c-98-244-40-86.hsd1.ca.comcast.net. [98.244.40.86]) by mx.google.com with ESMTPSA id so2sm28682792pbc.5.2013.10.22.09.36.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Oct 2013 09:36:05 -0700 (PDT) From: Roy Franz To: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@redhat.com Cc: peter.maydell@linaro.org, patches@linaro.org, Roy Franz Subject: [PATCH 3/4 v4] block: return status for each device Date: Tue, 22 Oct 2013 09:35:55 -0700 Message-Id: <1382459756-6853-4-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1382459756-6853-1-git-send-email-roy.franz@linaro.org> References: <1382459756-6853-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.179 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 --- hw/block/pflash_cfi01.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index cda8289..aa2cbbc 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -191,9 +191,21 @@ 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 (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 (width > 2) { + /* Handle 32 bit flash cases where device width may be + * improperly set. (Existing behavior before device width + * added.) + */ ret |= pfl->status << 16; } DPRINTF("%s: status %x\n", __func__, ret);