From patchwork Wed Jan 8 13:47:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 22955 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0F11202E2 for ; Wed, 8 Jan 2014 13:48:55 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id g10sf4236375pdj.5 for ; Wed, 08 Jan 2014 05:48:55 -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=rkSn178NIqIvhCUydornZBCpUC3oz4ZR82fYs8AmgA0=; b=DUaFQhb2BmuBJ1rQrkBTLiXLXzJYCM8EdAleO3zL/S1FMOmlCAPjawtRM7bEGoER2l gY50QdRg5OFhjcu/UckdxLHXiQ8r5/uR0gMWETM6yzJGfDImC6XzwVf8NfRSwdvoHyll DeA2OtsKFqIeF1GhUH01mfuqKTawcEQGbhFC/x3i63Ygp1h2/cNelLEjTLoo23dbMIx3 3XYU7i4xo+rsUwhqv54uKPRp29cyWxzvKZryIa1RY3KtVARQdOhDCSZQknu6ipbPrw/e TimLrigkTgLNCtj9N7hyDn6TOG2AX476dL0eiyJwQeGzJlRmYZYTaebynfrCr2eE6i95 rsMA== X-Gm-Message-State: ALoCoQmD9P3PbgbXauUHG89sGmIkezAmIDwOJSj31Jtg5Tz/GTN4ucKlOXoPM38fmtQ1AqqME6wo X-Received: by 10.68.201.7 with SMTP id jw7mr50532692pbc.8.1389188935067; Wed, 08 Jan 2014 05:48:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.72 with SMTP id i8ls512190qew.59.gmail; Wed, 08 Jan 2014 05:48:54 -0800 (PST) X-Received: by 10.52.157.68 with SMTP id wk4mr13300294vdb.19.1389188934927; Wed, 08 Jan 2014 05:48:54 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id gq3si589615vdc.132.2014.01.08.05.48.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.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.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so1248717veb.20 for ; Wed, 08 Jan 2014 05:48:54 -0800 (PST) X-Received: by 10.52.116.200 with SMTP id jy8mr23584262vdb.15.1389188934819; Wed, 08 Jan 2014 05:48:54 -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.59.13.131 with SMTP id ey3csp226624ved; Wed, 8 Jan 2014 05:48:54 -0800 (PST) X-Received: by 10.180.109.201 with SMTP id hu9mr21300843wib.59.1389188933834; Wed, 08 Jan 2014 05:48:53 -0800 (PST) Received: from mail-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) by mx.google.com with ESMTPS id fa12si921267wjc.149.2014.01.08.05.48.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:53 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.171 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.171; Received: by mail-we0-f171.google.com with SMTP id q58so1472772wes.30 for ; Wed, 08 Jan 2014 05:48:53 -0800 (PST) X-Received: by 10.180.99.74 with SMTP id eo10mr1421171wib.12.1389188933361; Wed, 08 Jan 2014 05:48:53 -0800 (PST) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginm.net. [92.233.57.238]) by mx.google.com with ESMTPSA id j9sm48125217wjx.18.2014.01.08.05.48.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:52 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, angus.clark@st.com, Lee Jones Subject: [PATCH v4 19/37] mtd: st_spi_fsm: Add a check to if the chip can handle an SoC reset Date: Wed, 8 Jan 2014 13:47:02 +0000 Message-Id: <1389188840-14306-20-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> References: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.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: , Based on information we can obtain though platform specific data and/or chip capabilities we are able to determine whether or not we can handle a SoC reset or not. To find out why this is important please read the comment provided in the patch. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index fc23354..b21929b 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -246,6 +246,8 @@ struct stfsm { uint32_t fifo_dir_delay; bool booted_from_spi; + bool reset_signal; + bool reset_por; }; struct stfsm_seq { @@ -552,6 +554,40 @@ static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, } } +/* + * SoC reset on 'boot-from-spi' systems + * + * Certain modes of operation cause the Flash device to enter a particular state + * for a period of time (e.g. 'Erase Sector', 'Quad Enable', and 'Enter 32-bit + * Addr' commands). On boot-from-spi systems, it is important to consider what + * happens if a warm reset occurs during this period. The SPIBoot controller + * assumes that Flash device is in its default reset state, 24-bit address mode, + * and ready to accept commands. This can be achieved using some form of + * on-board logic/controller to force a device POR in response to a SoC-level + * reset or by making use of the device reset signal if available (limited + * number of devices only). + * + * Failure to take such precautions can cause problems following a warm reset. + * For some operations (e.g. ERASE), there is little that can be done. For + * other modes of operation (e.g. 32-bit addressing), options are often + * available that can help minimise the window in which a reset could cause a + * problem. + * + */ +static bool stfsm_can_handle_soc_reset(struct stfsm *fsm) +{ + /* Reset signal is available on the board and supported by the device */ + if (fsm->reset_signal && fsm->info->flags & FLASH_FLAG_RESET) + return true; + + /* Board-level logic forces a power-on-reset */ + if (fsm->reset_por) + return true; + + /* Reset is not properly handled and may result in failure to reboot */ + return false; +} + /* Configure 'addr_cfg' according to addressing mode */ static void stfsm_prepare_erasesec_seq(struct stfsm *fsm, struct stfsm_seq *seq) @@ -824,6 +860,10 @@ static void stfsm_fetch_platform_configs(struct platform_device *pdev) goto boot_device_fail; } + fsm->reset_signal = of_property_read_bool(np, "st,reset-signal"); + + fsm->reset_por = of_property_read_bool(np, "st,reset-por"); + /* Where in the syscon the boot device information lives */ ret = of_property_read_u32(np, "st,boot-device-reg", &boot_device_reg); if (ret)