diff options
author | Lee Jones <lee.jones@linaro.org> | 2014-03-20 05:20:42 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-03-20 07:17:16 -0400 |
commit | 089812740d42104d7b9eef803a34a3940d03bcd4 (patch) | |
tree | 1cca65d2e80b973145e2d7b4607c34c9a0e94a6a /drivers/mtd/devices | |
parent | 24fec651d1cc396e6e24631386e0d5dd5f329fbc (diff) |
mtd: st_spi_fsm: Search for preferred FSM message sequence configurations
Here we provide a means to traverse though all supplied FSM message
sequence configurations and pick one based on our chip's capabilities.
The first one we match will be the preferred one, as they are
presented in order of preference.
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/devices')
-rw-r--r-- | drivers/mtd/devices/st_spi_fsm.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 9467585fcfda..2740ae195ef5 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c | |||
@@ -222,6 +222,18 @@ struct stfsm_seq { | |||
222 | uint32_t seq_cfg; | 222 | uint32_t seq_cfg; |
223 | } __packed __aligned(4); | 223 | } __packed __aligned(4); |
224 | 224 | ||
225 | /* Parameters to configure a READ or WRITE FSM sequence */ | ||
226 | struct seq_rw_config { | ||
227 | uint32_t flags; /* flags to support config */ | ||
228 | uint8_t cmd; /* FLASH command */ | ||
229 | int write; /* Write Sequence */ | ||
230 | uint8_t addr_pads; /* No. of addr pads (MODE & DUMMY) */ | ||
231 | uint8_t data_pads; /* No. of data pads */ | ||
232 | uint8_t mode_data; /* MODE data */ | ||
233 | uint8_t mode_cycles; /* No. of MODE cycles */ | ||
234 | uint8_t dummy_cycles; /* No. of DUMMY cycles */ | ||
235 | }; | ||
236 | |||
225 | /* SPI Flash Device Table */ | 237 | /* SPI Flash Device Table */ |
226 | struct flash_info { | 238 | struct flash_info { |
227 | char *name; | 239 | char *name; |
@@ -462,6 +474,21 @@ static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, | |||
462 | } | 474 | } |
463 | } | 475 | } |
464 | 476 | ||
477 | /* Search for preferred configuration based on available flags */ | ||
478 | static struct seq_rw_config * | ||
479 | stfsm_search_seq_rw_configs(struct stfsm *fsm, | ||
480 | struct seq_rw_config cfgs[]) | ||
481 | { | ||
482 | struct seq_rw_config *config; | ||
483 | int flags = fsm->info->flags; | ||
484 | |||
485 | for (config = cfgs; config->cmd != 0; config++) | ||
486 | if ((config->flags & flags) == config->flags) | ||
487 | return config; | ||
488 | |||
489 | return NULL; | ||
490 | } | ||
491 | |||
465 | static void stfsm_read_jedec(struct stfsm *fsm, uint8_t *const jedec) | 492 | static void stfsm_read_jedec(struct stfsm *fsm, uint8_t *const jedec) |
466 | { | 493 | { |
467 | const struct stfsm_seq *seq = &stfsm_seq_read_jedec; | 494 | const struct stfsm_seq *seq = &stfsm_seq_read_jedec; |