aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2014-03-20 05:20:47 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-03-20 07:17:17 -0400
commitfa5ba3af200db0b9c2922dc463ecdf122a93012b (patch)
tree52c5e1eb116c33640f8d8c5393503713bb23128f /drivers/mtd
parenta63984c18a6186a323987817f01095d07503bda1 (diff)
mtd: st_spi_fsm: Provide the erase one sector sequence
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 <angus.clark@st.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/st_spi_fsm.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 6be267277756..06e6a5282044 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 = {
389 SEQ_CFG_STARTSEQ), 389 SEQ_CFG_STARTSEQ),
390}; 390};
391 391
392static struct stfsm_seq stfsm_seq_erase_sector = {
393 /* 'addr_cfg' configured during initialisation */
394 .seq_opc = {
395 (SEQ_OPC_PADS_1 | SEQ_OPC_CYCLES(8) |
396 SEQ_OPC_OPCODE(FLASH_CMD_WREN) | SEQ_OPC_CSDEASSERT),
397
398 (SEQ_OPC_PADS_1 | SEQ_OPC_CYCLES(8) |
399 SEQ_OPC_OPCODE(FLASH_CMD_SE)),
400 },
401 .seq = {
402 STFSM_INST_CMD1,
403 STFSM_INST_CMD2,
404 STFSM_INST_ADD1,
405 STFSM_INST_ADD2,
406 STFSM_INST_STOP,
407 },
408 .seq_cfg = (SEQ_CFG_PADS_1 |
409 SEQ_CFG_READNOTWRITE |
410 SEQ_CFG_CSDEASSERT |
411 SEQ_CFG_STARTSEQ),
412};
413
392static inline int stfsm_is_idle(struct stfsm *fsm) 414static inline int stfsm_is_idle(struct stfsm *fsm)
393{ 415{
394 return readl(fsm->base + SPI_FAST_SEQ_STA) & 0x10; 416 return readl(fsm->base + SPI_FAST_SEQ_STA) & 0x10;
@@ -477,6 +499,19 @@ static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf,
477 } 499 }
478} 500}
479 501
502/* Configure 'addr_cfg' according to addressing mode */
503static void stfsm_prepare_erasesec_seq(struct stfsm *fsm,
504 struct stfsm_seq *seq)
505{
506 int addr1_cycles = fsm->info->flags & FLASH_FLAG_32BIT_ADDR ? 16 : 8;
507
508 seq->addr_cfg = (ADR_CFG_CYCLES_ADD1(addr1_cycles) |
509 ADR_CFG_PADS_1_ADD1 |
510 ADR_CFG_CYCLES_ADD2(16) |
511 ADR_CFG_PADS_1_ADD2 |
512 ADR_CFG_CSDEASSERT_ADD2);
513}
514
480/* Search for preferred configuration based on available flags */ 515/* Search for preferred configuration based on available flags */
481static struct seq_rw_config * 516static struct seq_rw_config *
482stfsm_search_seq_rw_configs(struct stfsm *fsm, 517stfsm_search_seq_rw_configs(struct stfsm *fsm,