From patchwork Tue Feb 18 14:55:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 24888 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A3AE202B2 for ; Tue, 18 Feb 2014 15:04:04 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id up15sf39191450pbc.11 for ; Tue, 18 Feb 2014 07:04:03 -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=4xr0hCYz72Pd7S1unrjWwIz3KD1RvatPCcUgJs4NCns=; b=Dz35K6/TAi32i690WXBVV9/qh3pVYwl7wHukMrE4J92TnA7vbD2FMo4O6+hI21nKT4 mhzWKhsNrt6ux9upHZBx+VRrFIqwyOHewFhJNmjsY1Y9SI5SKcREtJj+UCU2Y42BVTCH TTjxNsXRMq4D77q9LrUHV5aTJtgYpkCH4wDKzZfEVh4DaEv5uQZ/CF9Rg5rodQjeXF5Q p33jM9qXudKmoz8PUtFrQXNAsWSgZqH/KEUvG1t/kQiTBTOevCXAp9FP42erGmpOkoBd nNtXaYM0BjqhjXznQLALbXrqy95k3HqJarF1RWBO/QjhCrfqtJWB9PFOEwFm4MJ0J9mN ZZAA== X-Gm-Message-State: ALoCoQmq3le+FUErxspaoZW2x+O2a4gQSIq1G1AmxpUpL5iNOncVFmx06DFOhhNbc6xgYgqoLl0+ X-Received: by 10.66.246.194 with SMTP id xy2mr12873025pac.36.1392735843744; Tue, 18 Feb 2014 07:04:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.47 with SMTP id s44ls1333456qgs.70.gmail; Tue, 18 Feb 2014 07:04:03 -0800 (PST) X-Received: by 10.220.225.71 with SMTP id ir7mr810770vcb.50.1392735843616; Tue, 18 Feb 2014 07:04:03 -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 tr5si5573730vdc.13.2014.02.18.07.04.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 07:04:03 -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 c14so13424169vea.20 for ; Tue, 18 Feb 2014 07:04:03 -0800 (PST) X-Received: by 10.52.155.66 with SMTP id vu2mr2099520vdb.50.1392735843345; Tue, 18 Feb 2014 07:04:03 -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 u4csp223102vcz; Tue, 18 Feb 2014 07:04:02 -0800 (PST) X-Received: by 10.66.27.13 with SMTP id p13mr33285947pag.76.1392735841020; Tue, 18 Feb 2014 07:04:01 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kr1si5228174pbc.25.2014.02.18.07.04.00; Tue, 18 Feb 2014 07:04:00 -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 S1756457AbaBRPDy (ORCPT + 27 others); Tue, 18 Feb 2014 10:03:54 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:34567 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755640AbaBRO5I (ORCPT ); Tue, 18 Feb 2014 09:57:08 -0500 Received: by mail-wg0-f51.google.com with SMTP id n12so3411917wgh.30 for ; Tue, 18 Feb 2014 06:57:07 -0800 (PST) X-Received: by 10.180.100.70 with SMTP id ew6mr18297557wib.57.1392735427610; Tue, 18 Feb 2014 06:57:07 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id h13sm46039687wjr.22.2014.02.18.06.57.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:57:06 -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 15/35] mtd: st_spi_fsm: Provide the erase one sector sequence Date: Tue, 18 Feb 2014 14:55:42 +0000 Message-Id: <1392735362-1245-16-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.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 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: , The FSM Serial Flash Controller is driven by issuing a standard set of register writes we call a message sequence. This patch supplies a method to prepare the message sequence responsible for erasing a single sector. Acked-by Angus Clark Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index fac6748..059188c 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -389,6 +389,28 @@ static struct stfsm_seq stfsm_seq_read_jedec = { SEQ_CFG_STARTSEQ), }; +static struct stfsm_seq stfsm_seq_erase_sector = { + /* 'addr_cfg' configured during initialisation */ + .seq_opc = { + (SEQ_OPC_PADS_1 | SEQ_OPC_CYCLES(8) | + SEQ_OPC_OPCODE(FLASH_CMD_WREN) | SEQ_OPC_CSDEASSERT), + + (SEQ_OPC_PADS_1 | SEQ_OPC_CYCLES(8) | + SEQ_OPC_OPCODE(FLASH_CMD_SE)), + }, + .seq = { + STFSM_INST_CMD1, + STFSM_INST_CMD2, + STFSM_INST_ADD1, + STFSM_INST_ADD2, + STFSM_INST_STOP, + }, + .seq_cfg = (SEQ_CFG_PADS_1 | + SEQ_CFG_READNOTWRITE | + SEQ_CFG_CSDEASSERT | + SEQ_CFG_STARTSEQ), +}; + static inline int stfsm_is_idle(struct stfsm *fsm) { return readl(fsm->base + SPI_FAST_SEQ_STA) & 0x10; @@ -477,6 +499,19 @@ static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, } } +/* Configure 'addr_cfg' according to addressing mode */ +static void stfsm_prepare_erasesec_seq(struct stfsm *fsm, + struct stfsm_seq *seq) +{ + int addr1_cycles = fsm->info->flags & FLASH_FLAG_32BIT_ADDR ? 16 : 8; + + seq->addr_cfg = (ADR_CFG_CYCLES_ADD1(addr1_cycles) | + ADR_CFG_PADS_1_ADD1 | + ADR_CFG_CYCLES_ADD2(16) | + ADR_CFG_PADS_1_ADD2 | + ADR_CFG_CSDEASSERT_ADD2); +} + /* Search for preferred configuration based on available flags */ static struct seq_rw_config * stfsm_search_seq_rw_configs(struct stfsm *fsm,