Lines Matching full:fsm

3  * st_spi_fsm.c	- ST Fast Sequence Mode (FSM) Serial Flash Controller
28 * FSM SPI Controller Registers
156 * FSM SPI Instruction Opcodes
170 * FSM SPI Instructions (== opcode + operand).
200 #define STFSM_MAX_WAIT_SEQ_MS 1000 /* FSM execution time */
274 /* Parameters to configure a READ or WRITE FSM sequence */
311 static int stfsm_n25q_config(struct stfsm *fsm);
312 static int stfsm_mx25_config(struct stfsm *fsm);
313 static int stfsm_s25fl_config(struct stfsm *fsm);
314 static int stfsm_w25q_config(struct stfsm *fsm);
445 * FSM message sequence configurations:
702 static inline int stfsm_is_idle(struct stfsm *fsm) in stfsm_is_idle() argument
704 return readl(fsm->base + SPI_FAST_SEQ_STA) & 0x10; in stfsm_is_idle()
707 static inline uint32_t stfsm_fifo_available(struct stfsm *fsm) in stfsm_fifo_available() argument
709 return (readl(fsm->base + SPI_FAST_SEQ_STA) >> 5) & 0x7f; in stfsm_fifo_available()
712 static inline void stfsm_load_seq(struct stfsm *fsm, in stfsm_load_seq() argument
715 void __iomem *dst = fsm->base + SPI_FAST_SEQ_TRANSFER_SIZE; in stfsm_load_seq()
719 BUG_ON(!stfsm_is_idle(fsm)); in stfsm_load_seq()
728 static void stfsm_wait_seq(struct stfsm *fsm) in stfsm_wait_seq() argument
739 if (stfsm_is_idle(fsm)) in stfsm_wait_seq()
745 dev_err(fsm->dev, "timeout on sequence completion\n"); in stfsm_wait_seq()
748 static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, uint32_t size) in stfsm_read_fifo() argument
754 dev_dbg(fsm->dev, "Reading %d bytes from FIFO\n", size); in stfsm_read_fifo()
760 avail = stfsm_fifo_available(fsm); in stfsm_read_fifo()
768 readsl(fsm->base + SPI_FAST_SEQ_DATA_REG, buf, words); in stfsm_read_fifo()
791 * are 0, 1, 2, or 3 bytes in the FIFO. To handle all cases, a dummy FSM
799 static void stfsm_clear_fifo(struct stfsm *fsm) in stfsm_clear_fifo() argument
805 words = stfsm_fifo_available(fsm); in stfsm_clear_fifo()
808 readl(fsm->base + SPI_FAST_SEQ_DATA_REG); in stfsm_clear_fifo()
809 dev_dbg(fsm->dev, "cleared %d words from FIFO\n", words); in stfsm_clear_fifo()
818 stfsm_load_seq(fsm, seq); in stfsm_clear_fifo()
819 stfsm_wait_seq(fsm); in stfsm_clear_fifo()
820 words = stfsm_fifo_available(fsm); in stfsm_clear_fifo()
825 dev_err(fsm->dev, "failed to clear bytes from the data FIFO\n"); in stfsm_clear_fifo()
830 readl(fsm->base + SPI_FAST_SEQ_DATA_REG); in stfsm_clear_fifo()
832 dev_dbg(fsm->dev, "cleared %d byte(s) from the data FIFO\n", 4 - i); in stfsm_clear_fifo()
835 static int stfsm_write_fifo(struct stfsm *fsm, const uint32_t *buf, in stfsm_write_fifo() argument
840 dev_dbg(fsm->dev, "writing %d bytes to FIFO\n", size); in stfsm_write_fifo()
844 writesl(fsm->base + SPI_FAST_SEQ_DATA_REG, buf, words); in stfsm_write_fifo()
849 static int stfsm_enter_32bit_addr(struct stfsm *fsm, int enter) in stfsm_enter_32bit_addr() argument
851 struct stfsm_seq *seq = &fsm->stfsm_seq_en_32bit_addr; in stfsm_enter_32bit_addr()
859 stfsm_load_seq(fsm, seq); in stfsm_enter_32bit_addr()
861 stfsm_wait_seq(fsm); in stfsm_enter_32bit_addr()
866 static uint8_t stfsm_wait_busy(struct stfsm *fsm) in stfsm_wait_busy() argument
879 stfsm_load_seq(fsm, seq); in stfsm_wait_busy()
889 stfsm_wait_seq(fsm); in stfsm_wait_busy()
891 stfsm_read_fifo(fsm, &status, 4); in stfsm_wait_busy()
896 if ((fsm->configuration & CFG_S25FL_CHECK_ERROR_FLAGS) && in stfsm_wait_busy()
903 writel(seq->seq_cfg, fsm->base + SPI_FAST_SEQ_CFG); in stfsm_wait_busy()
908 dev_err(fsm->dev, "timeout on wait_busy\n"); in stfsm_wait_busy()
913 static int stfsm_read_status(struct stfsm *fsm, uint8_t cmd, in stfsm_read_status() argument
921 dev_dbg(fsm->dev, "read 'status' register [0x%02x], %d byte(s)\n", in stfsm_read_status()
929 stfsm_load_seq(fsm, seq); in stfsm_read_status()
931 stfsm_read_fifo(fsm, &tmp, 4); in stfsm_read_status()
936 stfsm_wait_seq(fsm); in stfsm_read_status()
941 static int stfsm_write_status(struct stfsm *fsm, uint8_t cmd, in stfsm_write_status() argument
946 dev_dbg(fsm->dev, in stfsm_write_status()
958 stfsm_load_seq(fsm, seq); in stfsm_write_status()
960 stfsm_wait_seq(fsm); in stfsm_write_status()
963 stfsm_wait_busy(fsm); in stfsm_write_status()
988 static bool stfsm_can_handle_soc_reset(struct stfsm *fsm) in stfsm_can_handle_soc_reset() argument
991 if (fsm->reset_signal && fsm->info->flags & FLASH_FLAG_RESET) in stfsm_can_handle_soc_reset()
995 if (fsm->reset_por) in stfsm_can_handle_soc_reset()
1003 static void stfsm_prepare_erasesec_seq(struct stfsm *fsm, in stfsm_prepare_erasesec_seq() argument
1006 int addr1_cycles = fsm->info->flags & FLASH_FLAG_32BIT_ADDR ? 16 : 8; in stfsm_prepare_erasesec_seq()
1017 stfsm_search_seq_rw_configs(struct stfsm *fsm, in stfsm_search_seq_rw_configs() argument
1021 int flags = fsm->info->flags; in stfsm_search_seq_rw_configs()
1031 static void stfsm_prepare_rw_seq(struct stfsm *fsm, in stfsm_prepare_rw_seq() argument
1053 addr1_cycles = (fsm->info->flags & FLASH_FLAG_32BIT_ADDR) ? 16 : 8; in stfsm_prepare_rw_seq()
1099 static int stfsm_search_prepare_rw_seq(struct stfsm *fsm, in stfsm_search_prepare_rw_seq() argument
1105 config = stfsm_search_seq_rw_configs(fsm, cfgs); in stfsm_search_prepare_rw_seq()
1107 dev_err(fsm->dev, "failed to find suitable config\n"); in stfsm_search_prepare_rw_seq()
1111 stfsm_prepare_rw_seq(fsm, seq, config); in stfsm_search_prepare_rw_seq()
1117 static int stfsm_prepare_rwe_seqs_default(struct stfsm *fsm) in stfsm_prepare_rwe_seqs_default() argument
1119 uint32_t flags = fsm->info->flags; in stfsm_prepare_rwe_seqs_default()
1123 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_read, in stfsm_prepare_rwe_seqs_default()
1126 dev_err(fsm->dev, in stfsm_prepare_rwe_seqs_default()
1133 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_write, in stfsm_prepare_rwe_seqs_default()
1136 dev_err(fsm->dev, in stfsm_prepare_rwe_seqs_default()
1143 stfsm_prepare_erasesec_seq(fsm, &stfsm_seq_erase_sector); in stfsm_prepare_rwe_seqs_default()
1148 static int stfsm_mx25_config(struct stfsm *fsm) in stfsm_mx25_config() argument
1150 uint32_t flags = fsm->info->flags; in stfsm_mx25_config()
1159 ret = stfsm_prepare_rwe_seqs_default(fsm); in stfsm_mx25_config()
1167 /* Configure 'enter_32bitaddr' FSM sequence */ in stfsm_mx25_config()
1168 stfsm_mx25_en_32bit_addr_seq(&fsm->stfsm_seq_en_32bit_addr); in stfsm_mx25_config()
1170 soc_reset = stfsm_can_handle_soc_reset(fsm); in stfsm_mx25_config()
1171 if (soc_reset || !fsm->booted_from_spi) in stfsm_mx25_config()
1174 stfsm_enter_32bit_addr(fsm, 1); in stfsm_mx25_config()
1179 fsm->configuration = (CFG_READ_TOGGLE_32BIT_ADDR | in stfsm_mx25_config()
1185 stfsm_read_status(fsm, SPINOR_OP_RDSR, &sta, 1); in stfsm_mx25_config()
1186 data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1; in stfsm_mx25_config()
1192 stfsm_write_status(fsm, SPINOR_OP_WRSR, sta, 1, 1); in stfsm_mx25_config()
1199 stfsm_write_status(fsm, SPINOR_OP_WRSR, sta, 1, 1); in stfsm_mx25_config()
1206 static int stfsm_n25q_config(struct stfsm *fsm) in stfsm_n25q_config() argument
1208 uint32_t flags = fsm->info->flags; in stfsm_n25q_config()
1215 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_read, in stfsm_n25q_config()
1218 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_read, in stfsm_n25q_config()
1221 dev_err(fsm->dev, in stfsm_n25q_config()
1228 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_write, in stfsm_n25q_config()
1231 dev_err(fsm->dev, in stfsm_n25q_config()
1238 stfsm_prepare_erasesec_seq(fsm, &stfsm_seq_erase_sector); in stfsm_n25q_config()
1242 stfsm_n25q_en_32bit_addr_seq(&fsm->stfsm_seq_en_32bit_addr); in stfsm_n25q_config()
1244 soc_reset = stfsm_can_handle_soc_reset(fsm); in stfsm_n25q_config()
1245 if (soc_reset || !fsm->booted_from_spi) { in stfsm_n25q_config()
1250 stfsm_enter_32bit_addr(fsm, 1); in stfsm_n25q_config()
1256 fsm->configuration = (CFG_WRITE_TOGGLE_32BIT_ADDR | in stfsm_n25q_config()
1266 stfsm_write_status(fsm, N25Q_CMD_WRVCR, vcr, 1, 0); in stfsm_n25q_config()
1284 static void stfsm_s25fl_read_dyb(struct stfsm *fsm, uint32_t offs, uint8_t *dby) in stfsm_s25fl_read_dyb() argument
1311 stfsm_load_seq(fsm, &seq); in stfsm_s25fl_read_dyb()
1313 stfsm_read_fifo(fsm, &tmp, 4); in stfsm_s25fl_read_dyb()
1317 stfsm_wait_seq(fsm); in stfsm_s25fl_read_dyb()
1320 static void stfsm_s25fl_write_dyb(struct stfsm *fsm, uint32_t offs, uint8_t dby) in stfsm_s25fl_write_dyb() argument
1349 stfsm_load_seq(fsm, &seq); in stfsm_s25fl_write_dyb()
1350 stfsm_wait_seq(fsm); in stfsm_s25fl_write_dyb()
1352 stfsm_wait_busy(fsm); in stfsm_s25fl_write_dyb()
1355 static int stfsm_s25fl_clear_status_reg(struct stfsm *fsm) in stfsm_s25fl_clear_status_reg() argument
1379 stfsm_load_seq(fsm, &seq); in stfsm_s25fl_clear_status_reg()
1381 stfsm_wait_seq(fsm); in stfsm_s25fl_clear_status_reg()
1386 static int stfsm_s25fl_config(struct stfsm *fsm) in stfsm_s25fl_config() argument
1388 struct flash_info *info = fsm->info; in stfsm_s25fl_config()
1402 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_read, in stfsm_s25fl_config()
1407 ret = stfsm_search_prepare_rw_seq(fsm, &fsm->stfsm_seq_write, in stfsm_s25fl_config()
1416 ret = stfsm_prepare_rwe_seqs_default(fsm); in stfsm_s25fl_config()
1429 stfsm_s25fl_read_dyb(fsm, offs, &dyb); in stfsm_s25fl_config()
1431 stfsm_s25fl_write_dyb(fsm, offs, 0xff); in stfsm_s25fl_config()
1443 stfsm_read_status(fsm, SPINOR_OP_RDCR, &cr1, 1); in stfsm_s25fl_config()
1444 data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1; in stfsm_s25fl_config()
1461 stfsm_read_status(fsm, SPINOR_OP_RDSR, &sr1, 1); in stfsm_s25fl_config()
1463 stfsm_write_status(fsm, SPINOR_OP_WRSR, sta_wr, 2, 1); in stfsm_s25fl_config()
1470 fsm->configuration |= CFG_S25FL_CHECK_ERROR_FLAGS; in stfsm_s25fl_config()
1475 static int stfsm_w25q_config(struct stfsm *fsm) in stfsm_w25q_config() argument
1483 ret = stfsm_prepare_rwe_seqs_default(fsm); in stfsm_w25q_config()
1488 stfsm_read_status(fsm, SPINOR_OP_RDCR, &sr2, 1); in stfsm_w25q_config()
1489 data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1; in stfsm_w25q_config()
1505 stfsm_read_status(fsm, SPINOR_OP_RDSR, &sr1, 1); in stfsm_w25q_config()
1507 stfsm_write_status(fsm, SPINOR_OP_WRSR, sr_wr, 2, 1); in stfsm_w25q_config()
1513 static int stfsm_read(struct stfsm *fsm, uint8_t *buf, uint32_t size, in stfsm_read() argument
1516 struct stfsm_seq *seq = &fsm->stfsm_seq_read; in stfsm_read()
1526 dev_dbg(fsm->dev, "reading %d bytes from 0x%08x\n", size, offset); in stfsm_read()
1529 if (fsm->configuration & CFG_READ_TOGGLE_32BIT_ADDR) in stfsm_read()
1530 stfsm_enter_32bit_addr(fsm, 1); in stfsm_read()
1548 stfsm_load_seq(fsm, seq); in stfsm_read()
1551 stfsm_read_fifo(fsm, (uint32_t *)p, size_lb); in stfsm_read()
1554 stfsm_read_fifo(fsm, tmp, read_mask + 1); in stfsm_read()
1563 stfsm_wait_seq(fsm); in stfsm_read()
1565 stfsm_clear_fifo(fsm); in stfsm_read()
1568 if (fsm->configuration & CFG_READ_TOGGLE_32BIT_ADDR) in stfsm_read()
1569 stfsm_enter_32bit_addr(fsm, 0); in stfsm_read()
1574 static int stfsm_write(struct stfsm *fsm, const uint8_t *buf, in stfsm_write() argument
1577 struct stfsm_seq *seq = &fsm->stfsm_seq_write; in stfsm_write()
1590 dev_dbg(fsm->dev, "writing %d bytes to 0x%08x\n", size, offset); in stfsm_write()
1593 if (fsm->configuration & CFG_WRITE_TOGGLE_32BIT_ADDR) in stfsm_write()
1594 stfsm_enter_32bit_addr(fsm, 1); in stfsm_write()
1620 writel(0x00040000, fsm->base + SPI_FAST_SEQ_CFG); in stfsm_write()
1626 if (fsm->fifo_dir_delay == 0) in stfsm_write()
1627 readl(fsm->base + SPI_FAST_SEQ_CFG); in stfsm_write()
1629 udelay(fsm->fifo_dir_delay); in stfsm_write()
1634 stfsm_write_fifo(fsm, (uint32_t *)p, size_lb); in stfsm_write()
1644 stfsm_write_fifo(fsm, tmp, write_mask + 1); in stfsm_write()
1648 stfsm_load_seq(fsm, seq); in stfsm_write()
1651 stfsm_wait_seq(fsm); in stfsm_write()
1654 ret = stfsm_wait_busy(fsm); in stfsm_write()
1655 if (ret && fsm->configuration & CFG_S25FL_CHECK_ERROR_FLAGS) in stfsm_write()
1656 stfsm_s25fl_clear_status_reg(fsm); in stfsm_write()
1659 if (fsm->configuration & CFG_WRITE_TOGGLE_32BIT_ADDR) in stfsm_write()
1660 stfsm_enter_32bit_addr(fsm, 0); in stfsm_write()
1672 struct stfsm *fsm = dev_get_drvdata(mtd->dev.parent); in stfsm_mtd_read() local
1675 dev_dbg(fsm->dev, "%s from 0x%08x, len %zd\n", in stfsm_mtd_read()
1678 mutex_lock(&fsm->lock); in stfsm_mtd_read()
1683 stfsm_read(fsm, buf, bytes, from); in stfsm_mtd_read()
1692 mutex_unlock(&fsm->lock); in stfsm_mtd_read()
1697 static int stfsm_erase_sector(struct stfsm *fsm, uint32_t offset) in stfsm_erase_sector() argument
1702 dev_dbg(fsm->dev, "erasing sector at 0x%08x\n", offset); in stfsm_erase_sector()
1705 if (fsm->configuration & CFG_ERASESEC_TOGGLE_32BIT_ADDR) in stfsm_erase_sector()
1706 stfsm_enter_32bit_addr(fsm, 1); in stfsm_erase_sector()
1711 stfsm_load_seq(fsm, seq); in stfsm_erase_sector()
1713 stfsm_wait_seq(fsm); in stfsm_erase_sector()
1716 ret = stfsm_wait_busy(fsm); in stfsm_erase_sector()
1717 if (ret && fsm->configuration & CFG_S25FL_CHECK_ERROR_FLAGS) in stfsm_erase_sector()
1718 stfsm_s25fl_clear_status_reg(fsm); in stfsm_erase_sector()
1721 if (fsm->configuration & CFG_ERASESEC_TOGGLE_32BIT_ADDR) in stfsm_erase_sector()
1722 stfsm_enter_32bit_addr(fsm, 0); in stfsm_erase_sector()
1727 static int stfsm_erase_chip(struct stfsm *fsm) in stfsm_erase_chip() argument
1731 dev_dbg(fsm->dev, "erasing chip\n"); in stfsm_erase_chip()
1733 stfsm_load_seq(fsm, seq); in stfsm_erase_chip()
1735 stfsm_wait_seq(fsm); in stfsm_erase_chip()
1737 return stfsm_wait_busy(fsm); in stfsm_erase_chip()
1748 struct stfsm *fsm = dev_get_drvdata(mtd->dev.parent); in stfsm_mtd_write() local
1755 dev_dbg(fsm->dev, "%s to 0x%08x, len %zd\n", __func__, (u32)to, len); in stfsm_mtd_write()
1760 mutex_lock(&fsm->lock); in stfsm_mtd_write()
1766 ret = stfsm_write(fsm, b, bytes, to); in stfsm_mtd_write()
1782 mutex_unlock(&fsm->lock); in stfsm_mtd_write()
1793 struct stfsm *fsm = dev_get_drvdata(mtd->dev.parent); in stfsm_mtd_erase() local
1797 dev_dbg(fsm->dev, "%s at 0x%llx, len %lld\n", __func__, in stfsm_mtd_erase()
1803 mutex_lock(&fsm->lock); in stfsm_mtd_erase()
1807 ret = stfsm_erase_chip(fsm); in stfsm_mtd_erase()
1812 ret = stfsm_erase_sector(fsm, addr); in stfsm_mtd_erase()
1821 mutex_unlock(&fsm->lock); in stfsm_mtd_erase()
1826 mutex_unlock(&fsm->lock); in stfsm_mtd_erase()
1831 static void stfsm_read_jedec(struct stfsm *fsm, uint8_t *jedec) in stfsm_read_jedec() argument
1836 stfsm_load_seq(fsm, seq); in stfsm_read_jedec()
1838 stfsm_read_fifo(fsm, tmp, 8); in stfsm_read_jedec()
1842 stfsm_wait_seq(fsm); in stfsm_read_jedec()
1845 static struct flash_info *stfsm_jedec_probe(struct stfsm *fsm) in stfsm_jedec_probe() argument
1852 stfsm_read_jedec(fsm, id); in stfsm_jedec_probe()
1862 dev_dbg(fsm->dev, "JEDEC = 0x%08x [%5ph]\n", jedec, id); in stfsm_jedec_probe()
1871 dev_err(fsm->dev, "Unrecognized JEDEC id %06x\n", jedec); in stfsm_jedec_probe()
1876 static int stfsm_set_mode(struct stfsm *fsm, uint32_t mode) in stfsm_set_mode() argument
1882 ret = readl(fsm->base + SPI_STA_MODE_CHANGE); in stfsm_set_mode()
1891 writel(mode, fsm->base + SPI_MODESELECT); in stfsm_set_mode()
1896 static void stfsm_set_freq(struct stfsm *fsm, uint32_t spi_freq) in stfsm_set_freq() argument
1901 emi_freq = clk_get_rate(fsm->clk); in stfsm_set_freq()
1920 fsm->fifo_dir_delay = 0; in stfsm_set_freq()
1922 fsm->fifo_dir_delay = 1; in stfsm_set_freq()
1924 fsm->fifo_dir_delay = DIV_ROUND_UP(clk_div, 10); in stfsm_set_freq()
1926 dev_dbg(fsm->dev, "emi_clk = %uHZ, spi_freq = %uHZ, clk_div = %u\n", in stfsm_set_freq()
1929 writel(clk_div, fsm->base + SPI_CLOCKDIV); in stfsm_set_freq()
1932 static int stfsm_init(struct stfsm *fsm) in stfsm_init() argument
1936 /* Perform a soft reset of the FSM controller */ in stfsm_init()
1937 writel(SEQ_CFG_SWRESET, fsm->base + SPI_FAST_SEQ_CFG); in stfsm_init()
1939 writel(0, fsm->base + SPI_FAST_SEQ_CFG); in stfsm_init()
1942 stfsm_set_freq(fsm, STFSM_FLASH_SAFE_FREQ); in stfsm_init()
1944 /* Switch to FSM */ in stfsm_init()
1945 ret = stfsm_set_mode(fsm, SPI_MODESELECT_FSM); in stfsm_init()
1954 fsm->base + SPI_CONFIGDATA); in stfsm_init()
1955 writel(STFSM_DEFAULT_WR_TIME, fsm->base + SPI_STATUS_WR_TIME_REG); in stfsm_init()
1958 * Set the FSM 'WAIT' delay to the minimum workable value. Note, for in stfsm_init()
1962 writel(0x00000001, fsm->base + SPI_PROGRAM_ERASE_TIME); in stfsm_init()
1965 stfsm_clear_fifo(fsm); in stfsm_init()
1972 struct stfsm *fsm = platform_get_drvdata(pdev); in stfsm_fetch_platform_configs() local
1981 fsm->booted_from_spi = true; in stfsm_fetch_platform_configs()
1987 fsm->reset_signal = of_property_read_bool(np, "st,reset-signal"); in stfsm_fetch_platform_configs()
1989 fsm->reset_por = of_property_read_bool(np, "st,reset-por"); in stfsm_fetch_platform_configs()
2006 fsm->booted_from_spi = false; in stfsm_fetch_platform_configs()
2019 struct stfsm *fsm; in stfsm_probe() local
2027 fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL); in stfsm_probe()
2028 if (!fsm) in stfsm_probe()
2031 fsm->dev = &pdev->dev; in stfsm_probe()
2033 platform_set_drvdata(pdev, fsm); in stfsm_probe()
2035 fsm->base = devm_platform_ioremap_resource(pdev, 0); in stfsm_probe()
2036 if (IS_ERR(fsm->base)) in stfsm_probe()
2037 return PTR_ERR(fsm->base); in stfsm_probe()
2039 fsm->clk = devm_clk_get_enabled(&pdev->dev, NULL); in stfsm_probe()
2040 if (IS_ERR(fsm->clk)) { in stfsm_probe()
2041 dev_err(fsm->dev, "Couldn't find EMI clock.\n"); in stfsm_probe()
2042 return PTR_ERR(fsm->clk); in stfsm_probe()
2045 mutex_init(&fsm->lock); in stfsm_probe()
2047 ret = stfsm_init(fsm); in stfsm_probe()
2049 dev_err(&pdev->dev, "Failed to initialise FSM Controller\n"); in stfsm_probe()
2056 info = stfsm_jedec_probe(fsm); in stfsm_probe()
2059 fsm->info = info; in stfsm_probe()
2070 ret = info->config(fsm); in stfsm_probe()
2072 ret = stfsm_prepare_rwe_seqs_default(fsm); in stfsm_probe()
2076 fsm->mtd.name = info->name; in stfsm_probe()
2077 fsm->mtd.dev.parent = &pdev->dev; in stfsm_probe()
2078 mtd_set_of_node(&fsm->mtd, np); in stfsm_probe()
2079 fsm->mtd.type = MTD_NORFLASH; in stfsm_probe()
2080 fsm->mtd.writesize = 4; in stfsm_probe()
2081 fsm->mtd.writebufsize = fsm->mtd.writesize; in stfsm_probe()
2082 fsm->mtd.flags = MTD_CAP_NORFLASH; in stfsm_probe()
2083 fsm->mtd.size = info->sector_size * info->n_sectors; in stfsm_probe()
2084 fsm->mtd.erasesize = info->sector_size; in stfsm_probe()
2086 fsm->mtd._read = stfsm_mtd_read; in stfsm_probe()
2087 fsm->mtd._write = stfsm_mtd_write; in stfsm_probe()
2088 fsm->mtd._erase = stfsm_mtd_erase; in stfsm_probe()
2094 (long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20), in stfsm_probe()
2095 fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); in stfsm_probe()
2097 return mtd_device_register(&fsm->mtd, NULL, 0); in stfsm_probe()
2102 struct stfsm *fsm = platform_get_drvdata(pdev); in stfsm_remove() local
2104 WARN_ON(mtd_device_unregister(&fsm->mtd)); in stfsm_remove()
2110 struct stfsm *fsm = dev_get_drvdata(dev); in stfsmfsm_suspend() local
2112 clk_disable_unprepare(fsm->clk); in stfsmfsm_suspend()
2119 struct stfsm *fsm = dev_get_drvdata(dev); in stfsmfsm_resume() local
2121 return clk_prepare_enable(fsm->clk); in stfsmfsm_resume()
2128 { .compatible = "st,spi-fsm", },
2137 .name = "st-spi-fsm",
2145 MODULE_DESCRIPTION("ST SPI FSM driver");