From patchwork Fri Nov 22 16:22:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21696 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0205D23FDC for ; Fri, 22 Nov 2013 16:24:07 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id r10sf2492248pdi.2 for ; Fri, 22 Nov 2013 08:24:07 -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=9vv8K7yKN26jWlsDUML5Gre7/XAq4IPjEajzqRd1OZw=; b=J55N0EGKkKZz1N7HE/G/2wm0eU/c4l5aepGDKRoyxDPszQgpxDFSnrytthUN/QACz9 I7CUNqeoYsRpqZ9Q0wYs1OkrvmLJe+Ruj31mw+avTqWHTJc7eQouv+BmJV85O1W4TKEL WyIVQdMnNgMgbS/cVLpcuRiCCRTVmZfZhRyKZMRLPnAF3tGS5El9aJeGShkaIdOVQzHE UE3PvLJjFP9lwT4a9LQrmm7AcJvl11aDRDpTxtcWl29TyTsq4K1HANmyEGBhQKvCRihQ QQcixR36GIYCjKRCyONKRvOWBVWKJ2Qe4X//XuM3bJ876l5VN0Un3fmE4ESYwA2rDi9J FWQg== X-Gm-Message-State: ALoCoQkvjkqNHOLWGAqfCaKgdyd+8Zqe6l8DDAYHAlM3FhiCj1xFid6YMZ8jNbRGOYOBNGoEpQgf X-Received: by 10.66.138.79 with SMTP id qo15mr4192802pab.34.1385137447297; Fri, 22 Nov 2013 08:24:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.36.136 with SMTP id q8ls143224qej.36.gmail; Fri, 22 Nov 2013 08:24:07 -0800 (PST) X-Received: by 10.220.194.133 with SMTP id dy5mr12096527vcb.3.1385137447114; Fri, 22 Nov 2013 08:24:07 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id a6si12865687vdp.39.2013.11.22.08.24.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:07 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 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.177; Received: by mail-ve0-f177.google.com with SMTP id db12so1040629veb.22 for ; Fri, 22 Nov 2013 08:24:07 -0800 (PST) X-Received: by 10.220.145.75 with SMTP id c11mr2153986vcv.30.1385137447043; Fri, 22 Nov 2013 08:24: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 u4csp51543vcz; Fri, 22 Nov 2013 08:24:06 -0800 (PST) X-Received: by 10.66.218.226 with SMTP id pj2mr13062252pac.62.1385137446260; Fri, 22 Nov 2013 08:24:06 -0800 (PST) Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) by mx.google.com with ESMTPS id sn7si20165158pab.254.2013.11.22.08.24.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.47 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.160.47; Received: by mail-pb0-f47.google.com with SMTP id um1so1490806pbc.6 for ; Fri, 22 Nov 2013 08:24:05 -0800 (PST) X-Received: by 10.68.180.195 with SMTP id dq3mr2117586pbc.185.1385137445883; Fri, 22 Nov 2013 08:24:05 -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 qz9sm52962938pbc.3.2013.11.22.08.24.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:05 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, angus.clark@st.com Cc: linus.walleij@linaro.org, Lee Jones Subject: [PATCH 16/23] mtd: st_spi_fsm: Provide the erase one sector sequence Date: Fri, 22 Nov 2013 16:22:53 +0000 Message-Id: <1385137380-28968-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1385137380-28968-1-git-send-email-lee.jones@linaro.org> References: <1385137380-28968-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.177 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 dec2f83..583a0ab 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; @@ -84,6 +106,19 @@ static void stfsm_wait_seq(struct stfsm *fsm) dev_err(fsm->dev, "timeout on sequence completion\n"); } +/* 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_32BITADDR ? 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,