From patchwork Tue Feb 18 14:55:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 24886 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A206202B2 for ; Tue, 18 Feb 2014 15:03:28 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g12sf69984673oah.10 for ; Tue, 18 Feb 2014 07:03:27 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=glRap9iGvFSpTkmqRFTi1VCiJSDCtoOhf8beEGLv5nU=; b=XGF3kb3otiLLb89kUtHn/kUX2qHa3UZmZMqyJUGiQ8JpXOAu9p9Fma/o1yfwYRPqV7 mc/SRtqd7mTgxr5NsnY0EG9QF22zBGietws5oN0iW0VaciiZbbnlmJuWAnxYpJy8b/Sv 2wUAeGLO7p4ROqDcbk2EqvfgfL6NLKEeB6132HUrzSWaI8IG4ogKuorAabH1GzBiQav/ fN81lF5t/rof2CyrCk3Tw6Rv6D1X/EvqsgKW+UdDZ7cLuyIS2O+14/CLyjWEV1xwPY7x IJw/nx3Am2lXX6F2WpjBPszgq1IJMDq8gTdk9NXF5kawGlc1z483oSO9oP/+22D3xVwO YtwQ== X-Gm-Message-State: ALoCoQk8Hz4heH5Mr9UP6+nqDb4zPTP8P2HwxEUBfserKVO5Ab4xn4s3UKoUdnWDLtwnyNqrCEVQ X-Received: by 10.42.53.135 with SMTP id n7mr11801735icg.11.1392735807207; Tue, 18 Feb 2014 07:03:27 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.161 with SMTP id o30ls1263481qga.94.gmail; Tue, 18 Feb 2014 07:03:27 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr21578446vco.18.1392735807095; Tue, 18 Feb 2014 07:03:27 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id fb12si5583899veb.14.2014.02.18.07.03.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 07:03:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so13811838veb.30 for ; Tue, 18 Feb 2014 07:03:27 -0800 (PST) X-Received: by 10.220.89.4 with SMTP id c4mr411298vcm.53.1392735806992; Tue, 18 Feb 2014 07:03:26 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp223048vcz; Tue, 18 Feb 2014 07:03:26 -0800 (PST) X-Received: by 10.66.139.130 with SMTP id qy2mr33357309pab.73.1392735805981; Tue, 18 Feb 2014 07:03:25 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nf8si18654236pbc.0.2014.02.18.07.03.25; Tue, 18 Feb 2014 07:03:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932256AbaBRO5U (ORCPT + 27 others); Tue, 18 Feb 2014 09:57:20 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:60074 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932173AbaBRO5Q (ORCPT ); Tue, 18 Feb 2014 09:57:16 -0500 Received: by mail-wi0-f169.google.com with SMTP id e4so3491273wiv.4 for ; Tue, 18 Feb 2014 06:57:15 -0800 (PST) X-Received: by 10.194.60.16 with SMTP id d16mr8810711wjr.46.1392735434894; Tue, 18 Feb 2014 06:57:14 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id h13sm46039687wjr.22.2014.02.18.06.57.12 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:57:14 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, DCG_UPD_stlinux_kernel@list.st.com, dwmw2@infradead.org, linux-mtd@lists.infradead.org, computersforpeace@gmail.com, Angus.Clark@st.com Subject: [PATCH 18/35] mtd: st_spi_fsm: Add a check to if the chip can handle an SoC reset Date: Tue, 18 Feb 2014 14:55:45 +0000 Message-Id: <1392735362-1245-19-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> References: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.171 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org 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. Acked-by Angus Clark 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 3f5603c..b9e7061 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -210,6 +210,8 @@ struct stfsm { uint32_t fifo_dir_delay; bool booted_from_spi; + bool reset_signal; + bool reset_por; }; struct stfsm_seq { @@ -521,6 +523,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) @@ -786,6 +822,10 @@ static void stfsm_fetch_platform_configs(struct platform_device *pdev) if (IS_ERR(regmap)) 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)