Lines Matching refs:nor
37 static int m25p80_read_reg(struct spi_nor *nor, u8 code, u8 *val, int len) in m25p80_read_reg() argument
39 struct m25p *flash = nor->priv; in m25p80_read_reg()
50 static void m25p_addr2cmd(struct spi_nor *nor, unsigned int addr, u8 *cmd) in m25p_addr2cmd() argument
53 cmd[1] = addr >> (nor->addr_width * 8 - 8); in m25p_addr2cmd()
54 cmd[2] = addr >> (nor->addr_width * 8 - 16); in m25p_addr2cmd()
55 cmd[3] = addr >> (nor->addr_width * 8 - 24); in m25p_addr2cmd()
56 cmd[4] = addr >> (nor->addr_width * 8 - 32); in m25p_addr2cmd()
59 static int m25p_cmdsz(struct spi_nor *nor) in m25p_cmdsz() argument
61 return 1 + nor->addr_width; in m25p_cmdsz()
64 static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) in m25p80_write_reg() argument
66 struct m25p *flash = nor->priv; in m25p80_write_reg()
76 static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len, in m25p80_write() argument
79 struct m25p *flash = nor->priv; in m25p80_write()
83 int cmd_sz = m25p_cmdsz(nor); in m25p80_write()
87 if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) in m25p80_write()
90 flash->command[0] = nor->program_opcode; in m25p80_write()
91 m25p_addr2cmd(nor, to, flash->command); in m25p80_write()
106 static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor) in m25p80_rx_nbits() argument
108 switch (nor->flash_read) { in m25p80_rx_nbits()
122 static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len, in m25p80_read() argument
125 struct m25p *flash = nor->priv; in m25p80_read()
129 unsigned int dummy = nor->read_dummy; in m25p80_read()
137 flash->command[0] = nor->read_opcode; in m25p80_read()
138 m25p_addr2cmd(nor, from, flash->command); in m25p80_read()
141 t[0].len = m25p_cmdsz(nor) + dummy; in m25p80_read()
145 t[1].rx_nbits = m25p80_rx_nbits(nor); in m25p80_read()
151 *retlen = m.actual_length - m25p_cmdsz(nor) - dummy; in m25p80_read()
155 static int m25p80_erase(struct spi_nor *nor, loff_t offset) in m25p80_erase() argument
157 struct m25p *flash = nor->priv; in m25p80_erase()
159 dev_dbg(nor->dev, "%dKiB at 0x%08x\n", in m25p80_erase()
163 flash->command[0] = nor->erase_opcode; in m25p80_erase()
164 m25p_addr2cmd(nor, offset, flash->command); in m25p80_erase()
166 spi_write(flash->spi, flash->command, m25p_cmdsz(nor)); in m25p80_erase()
181 struct spi_nor *nor; in m25p_probe() local
192 nor = &flash->spi_nor; in m25p_probe()
195 nor->read = m25p80_read; in m25p_probe()
196 nor->write = m25p80_write; in m25p_probe()
197 nor->erase = m25p80_erase; in m25p_probe()
198 nor->write_reg = m25p80_write_reg; in m25p_probe()
199 nor->read_reg = m25p80_read_reg; in m25p_probe()
201 nor->dev = &spi->dev; in m25p_probe()
202 nor->flash_node = spi->dev.of_node; in m25p_probe()
203 nor->priv = flash; in m25p_probe()
214 nor->mtd.name = data->name; in m25p_probe()
226 ret = spi_nor_scan(nor, flash_name, mode); in m25p_probe()
232 return mtd_device_parse_register(&nor->mtd, NULL, &ppdata, in m25p_probe()