From patchwork Fri Nov 29 12:19:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21873 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 224CB23FEA for ; Fri, 29 Nov 2013 12:20:09 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id jw12sf23172163veb.3 for ; Fri, 29 Nov 2013 04:20:09 -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=EOhg79o0NEQvH+M/Fyctaa4kIhk1PZ/5sP4csKz+E1E=; b=d+QuqDWYGuuQfsQwwbg/CZqrZpF3//r1m3pwT12JGHznnYR9mYs8EHzJC029o4F9WP N0UAz/5eko6OhevPWRjyapZKQm7fGnbmzfa+zRf+NK8EIAlheaxmfnMu2B/C4qeilF9v ZU5fQzhzMWRZ1sqX8Oi7iYicaIJJLqhAeHTqcVd3MhPALhaoudCcAgQdAABss3QcrkmT fwDp8AkN4ILnz0VQLuVH7+Tp4xbXZEvLjnOJmmuGnsf3zrQYg/ABCPPdgHWowcAlF2f/ 4ch8dHLW9Wh3Xs8RX2/+RAZO0Xzyw1nRBvkDd96n20Y/IUgJ77bCuURmw+q9oex1Y9GS Z+2A== X-Gm-Message-State: ALoCoQnpRBZZwG8ZJ72a+zYyZuAG8/uNu/xhZ/dIOJ6GXxqVYk0+epQRPagv5oRs9BnxzkSntqHx X-Received: by 10.236.180.2 with SMTP id i2mr21500914yhm.4.1385727608953; Fri, 29 Nov 2013 04:20:08 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.7 with SMTP id k7ls3645764qed.96.gmail; Fri, 29 Nov 2013 04:20:08 -0800 (PST) X-Received: by 10.52.98.194 with SMTP id ek2mr35164251vdb.11.1385727608886; Fri, 29 Nov 2013 04:20:08 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id xn8si82079vdc.100.2013.11.29.04.20.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:08 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id w18so6676656vbj.15 for ; Fri, 29 Nov 2013 04:20:08 -0800 (PST) X-Received: by 10.220.182.69 with SMTP id cb5mr1652456vcb.41.1385727607315; Fri, 29 Nov 2013 04:20:07 -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 u4csp87419vcz; Fri, 29 Nov 2013 04:20:06 -0800 (PST) X-Received: by 10.236.140.136 with SMTP id e8mr524337yhj.181.1385727606879; Fri, 29 Nov 2013 04:20:06 -0800 (PST) Received: from mail-yh0-f44.google.com (mail-yh0-f44.google.com [209.85.213.44]) by mx.google.com with ESMTPS id hb10si38127188qeb.8.2013.11.29.04.20.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.44 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.213.44; Received: by mail-yh0-f44.google.com with SMTP id f64so6700782yha.3 for ; Fri, 29 Nov 2013 04:20:06 -0800 (PST) X-Received: by 10.236.127.132 with SMTP id d4mr450870yhi.184.1385727606638; Fri, 29 Nov 2013 04:20:06 -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 m29sm101911689yho.14.2013.11.29.04.20.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:06 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org Cc: linus.walleij@linaro.org, linux-mtd@lists.infradead.org, angus.clark@st.com, Lee Jones Subject: [PATCH v3 16/36] mtd: st_spi_fsm: Provide the erase one sector sequence Date: Fri, 29 Nov 2013 12:19:05 +0000 Message-Id: <1385727565-25794-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1385727565-25794-1-git-send-email-lee.jones@linaro.org> References: <1385727565-25794-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.212.42 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: , 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. 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 bb642a1..47f9da0 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -44,6 +44,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; @@ -126,6 +148,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,