Lines Matching +full:spi +full:- +full:nor

1 // SPDX-License-Identifier: GPL-2.0
4 #include <linux/mtd/spi-nor.h>
5 #include <linux/spi/spi.h>
6 #include <linux/spi/spi-mem.h>
10 #define SPI_NOR_DEBUGFS_ROOT "spi-nor"
37 case SNOR_PROTO_1_1_1: return "1S-1S-1S"; in spi_nor_protocol_name()
38 case SNOR_PROTO_1_1_2: return "1S-1S-2S"; in spi_nor_protocol_name()
39 case SNOR_PROTO_1_1_4: return "1S-1S-4S"; in spi_nor_protocol_name()
40 case SNOR_PROTO_1_1_8: return "1S-1S-8S"; in spi_nor_protocol_name()
41 case SNOR_PROTO_1_2_2: return "1S-2S-2S"; in spi_nor_protocol_name()
42 case SNOR_PROTO_1_4_4: return "1S-4S-4S"; in spi_nor_protocol_name()
43 case SNOR_PROTO_1_8_8: return "1S-8S-8S"; in spi_nor_protocol_name()
44 case SNOR_PROTO_2_2_2: return "2S-2S-2S"; in spi_nor_protocol_name()
45 case SNOR_PROTO_4_4_4: return "4S-4S-4S"; in spi_nor_protocol_name()
46 case SNOR_PROTO_8_8_8: return "8S-8S-8S"; in spi_nor_protocol_name()
47 case SNOR_PROTO_1_1_1_DTR: return "1D-1D-1D"; in spi_nor_protocol_name()
48 case SNOR_PROTO_1_2_2_DTR: return "1D-2D-2D"; in spi_nor_protocol_name()
49 case SNOR_PROTO_1_4_4_DTR: return "1D-4D-4D"; in spi_nor_protocol_name()
50 case SNOR_PROTO_1_8_8_DTR: return "1D-8D-8D"; in spi_nor_protocol_name()
51 case SNOR_PROTO_8_8_8_DTR: return "8D-8D-8D"; in spi_nor_protocol_name()
78 struct spi_nor *nor = s->private; in spi_nor_params_show() local
79 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_params_show()
80 struct spi_nor_erase_map *erase_map = &params->erase_map; in spi_nor_params_show()
81 struct spi_nor_erase_region *region = erase_map->regions; in spi_nor_params_show()
82 const struct flash_info *info = nor->info; in spi_nor_params_show()
86 seq_printf(s, "name\t\t%s\n", info->name); in spi_nor_params_show()
87 seq_printf(s, "id\t\t%*ph\n", SPI_NOR_MAX_ID_LEN, nor->id); in spi_nor_params_show()
88 string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf)); in spi_nor_params_show()
90 seq_printf(s, "write size\t%u\n", params->writesize); in spi_nor_params_show()
91 seq_printf(s, "page size\t%u\n", params->page_size); in spi_nor_params_show()
92 seq_printf(s, "address nbytes\t%u\n", nor->addr_nbytes); in spi_nor_params_show()
95 spi_nor_print_flags(s, nor->flags, snor_f_names, sizeof(snor_f_names)); in spi_nor_params_show()
99 seq_printf(s, " read\t\t0x%02x\n", nor->read_opcode); in spi_nor_params_show()
100 seq_printf(s, " dummy cycles\t%u\n", nor->read_dummy); in spi_nor_params_show()
101 seq_printf(s, " erase\t\t0x%02x\n", nor->erase_opcode); in spi_nor_params_show()
102 seq_printf(s, " program\t0x%02x\n", nor->program_opcode); in spi_nor_params_show()
104 switch (nor->cmd_ext_type) { in spi_nor_params_show()
122 spi_nor_protocol_name(nor->read_proto)); in spi_nor_params_show()
124 spi_nor_protocol_name(nor->write_proto)); in spi_nor_params_show()
126 spi_nor_protocol_name(nor->reg_proto)); in spi_nor_params_show()
130 struct spi_nor_erase_type *et = &erase_map->erase_type[i]; in spi_nor_params_show()
132 if (et->size) { in spi_nor_params_show()
133 string_get_size(et->size, 1, STRING_UNITS_2, buf, in spi_nor_params_show()
135 seq_printf(s, " %02x (%s) [%d]\n", et->opcode, buf, i); in spi_nor_params_show()
139 if (!(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { in spi_nor_params_show()
140 string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf)); in spi_nor_params_show()
141 seq_printf(s, " %02x (%s)\n", nor->params->die_erase_opcode, buf); in spi_nor_params_show()
146 seq_puts(s, " ------------------+------------+----------\n"); in spi_nor_params_show()
147 for (i = 0; i < erase_map->n_regions; i++) { in spi_nor_params_show()
149 u64 end = start + region[i].size - 1; in spi_nor_params_show()
152 seq_printf(s, " %08llx-%08llx | [%c%c%c%c] | %s\n", in spi_nor_params_show()
168 seq_printf(s, " %s%s\n", spi_nor_protocol_name(cmd->proto), in spi_nor_print_read_cmd()
170 seq_printf(s, " opcode\t0x%02x\n", cmd->opcode); in spi_nor_print_read_cmd()
171 seq_printf(s, " mode cycles\t%u\n", cmd->num_mode_clocks); in spi_nor_print_read_cmd()
172 seq_printf(s, " dummy cycles\t%u\n", cmd->num_wait_states); in spi_nor_print_read_cmd()
178 seq_printf(s, " %s\n", spi_nor_protocol_name(cmd->proto)); in spi_nor_print_pp_cmd()
179 seq_printf(s, " opcode\t0x%02x\n", cmd->opcode); in spi_nor_print_pp_cmd()
184 struct spi_nor *nor = s->private; in spi_nor_capabilities_show() local
185 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_capabilities_show()
186 u32 hwcaps = params->hwcaps.mask; in spi_nor_capabilities_show()
198 spi_nor_print_read_cmd(s, BIT(i), &params->reads[cmd]); in spi_nor_capabilities_show()
211 spi_nor_print_pp_cmd(s, &params->page_programs[cmd]); in spi_nor_capabilities_show()
224 struct spi_nor *nor = data; in spi_nor_debugfs_unregister() local
226 debugfs_remove(nor->debugfs_root); in spi_nor_debugfs_unregister()
227 nor->debugfs_root = NULL; in spi_nor_debugfs_unregister()
232 void spi_nor_debugfs_register(struct spi_nor *nor) in spi_nor_debugfs_register() argument
240 ret = devm_add_action(nor->dev, spi_nor_debugfs_unregister, nor); in spi_nor_debugfs_register()
244 d = debugfs_create_dir(dev_name(nor->dev), rootdir); in spi_nor_debugfs_register()
245 nor->debugfs_root = d; in spi_nor_debugfs_register()
247 debugfs_create_file("params", 0444, d, nor, &spi_nor_params_fops); in spi_nor_debugfs_register()
248 debugfs_create_file("capabilities", 0444, d, nor, in spi_nor_debugfs_register()