From patchwork Wed Jan 8 13:46:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 22952 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 08A1F202E2 for ; Wed, 8 Jan 2014 13:48:50 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id gq1sf6091004obb.6 for ; Wed, 08 Jan 2014 05:48:50 -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=eA0yJotVjxljXaSQmgSiI0NSLYbzw4gUexXf9TM5k/U=; b=FIhbSuIEkeg3kvYYy+fziDBi+JdcNMioASJ/5DsL0zzmic9AnK9d8Se0MYtyMi4UwO kb7SsvSbDAbX7PGvwEGFO8BwxMNXRtSkc7jk+vplXP8SnwDv4SU768sBqGbE78I2mQCW LAljntJ5pMSobYW16WVuL630Hu/ZcVLMoSGY9gyd69ASAtjBuib4qL3V8yxCliUtHvS6 OJZl2cIHIa8ddIMBQeEkeU4hrJNKzpKgwx5dPk8Iv/PVmPNVjaIvfPI2ximm1ULFMyus bkUmXhud9UIQTtTucgbYqAistuhTvFmU+RzVfBsBAtzwm/fTBPld5jzI97N8UA8EJtgI Hziw== X-Gm-Message-State: ALoCoQl5gQDxrI4EyhrCvFi7j69GpK7epNwkdjr+FPNmJw+cAlo05e8O7AxCShSQWmddiRV39pSr X-Received: by 10.182.88.200 with SMTP id bi8mr20353449obb.43.1389188930176; Wed, 08 Jan 2014 05:48:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.35 with SMTP id c3ls526590qed.83.gmail; Wed, 08 Jan 2014 05:48:50 -0800 (PST) X-Received: by 10.58.143.73 with SMTP id sc9mr2712519veb.60.1389188930072; Wed, 08 Jan 2014 05:48:50 -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 sz9si610289vdc.45.2014.01.08.05.48.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:50 -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 pa12so1252458veb.16 for ; Wed, 08 Jan 2014 05:48:50 -0800 (PST) X-Received: by 10.58.181.71 with SMTP id du7mr8917384vec.25.1389188929969; Wed, 08 Jan 2014 05:48:49 -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.59.13.131 with SMTP id ey3csp226617ved; Wed, 8 Jan 2014 05:48:49 -0800 (PST) X-Received: by 10.194.86.200 with SMTP id r8mr12322764wjz.49.1389188928990; Wed, 08 Jan 2014 05:48:48 -0800 (PST) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx.google.com with ESMTPS id fw4si30471768wjb.97.2014.01.08.05.48.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:48 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.182; Received: by mail-we0-f182.google.com with SMTP id q59so1482867wes.27 for ; Wed, 08 Jan 2014 05:48:48 -0800 (PST) X-Received: by 10.180.187.36 with SMTP id fp4mr20661285wic.9.1389188928477; Wed, 08 Jan 2014 05:48:48 -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 j9sm48125217wjx.18.2014.01.08.05.48.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:47 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, angus.clark@st.com, Lee Jones Subject: [PATCH v4 16/37] mtd: st_spi_fsm: Provide the erase one sector sequence Date: Wed, 8 Jan 2014 13:46:59 +0000 Message-Id: <1389188840-14306-17-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> References: <1389188840-14306-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.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 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 94840b5..5ee6d08 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -425,6 +425,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; @@ -508,6 +530,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,