From patchwork Thu Mar 20 09:20:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26648 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 22C27202E0 for ; Thu, 20 Mar 2014 09:21:53 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf1549096yha.11 for ; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) 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=/TfE4aeGNMfw+lBJPyD/UMVbvriCuuD2RNJUgGWZdDE=; b=c/dz6CdAK/x+t86W04Y8vBEMVpAzP/O6q2ClI35PgItsftVzxtPjDhpLiVbjQd8tLD CpVQG4/yGGoB81gvDSWDKIwDukMAtRbsC1z24O+zBE9XaWIRn09julMegsyBuoWkA/YT 1iOyKabXG71Y6dT29LIWsujXNKEE750KQl/4VJCklbKs3HrtvXkjGwRYK4EV2Ybiu6+P 1WCrDdws3v1uG854ZfKnxWLiUV00CDwbOrfPxpGH1cIU3PgirnekDQ3RU59sl4+vsM4T mM7Upz5Pgvx2AOrujoPLl48+6aHDR7NBsSHI3Qes9t+GsU2py5sgTLOpjeEMVg0lxurF okFg== X-Gm-Message-State: ALoCoQnOsJwWirrxb6t2lLWc+Rmq8d/fxqj4KoLNGcXQwivskSVH/lDGLeMfmAhzpmNKgpV972n3 X-Received: by 10.236.86.67 with SMTP id v43mr9009598yhe.41.1395307312929; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.37 with SMTP id e34ls127359qge.4.gmail; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) X-Received: by 10.52.165.105 with SMTP id yx9mr28243128vdb.22.1395307312817; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id gs7si301671vdc.92.2014.03.20.02.21.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so613034vcb.10 for ; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) X-Received: by 10.220.95.139 with SMTP id d11mr20399287vcn.21.1395307312560; Thu, 20 Mar 2014 02:21:52 -0700 (PDT) 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.78.9 with SMTP id i9csp372526vck; Thu, 20 Mar 2014 02:21:51 -0700 (PDT) X-Received: by 10.180.23.99 with SMTP id l3mr1681695wif.47.1395307311173; Thu, 20 Mar 2014 02:21:51 -0700 (PDT) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by mx.google.com with ESMTPS id pf3si867640wjb.0.2014.03.20.02.21.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:51 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.181 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.181; Received: by mail-we0-f181.google.com with SMTP id q58so358938wes.40 for ; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) X-Received: by 10.194.78.173 with SMTP id c13mr33506970wjx.0.1395307310535; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) Received: from lee--X1.home (host109-148-116-196.range109-148.btcentralplus.com. [109.148.116.196]) by mx.google.com with ESMTPSA id di9sm4735120wid.6.2014.03.20.02.21.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:49 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, Angus.Clark@st.com, Lee Jones Subject: [PATCH v6 15/36] mtd: st_spi_fsm: Provide the erase one sector sequence Date: Thu, 20 Mar 2014 09:20:47 +0000 Message-Id: <1395307268-12721-16-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395307268-12721-1-git-send-email-lee.jones@linaro.org> References: <1395307268-12721-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.220.179 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. 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 6be2672..06e6a52 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,