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

1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/mtd/spi-nor.h>
4 #include <linux/spi/spi.h>
5 #include <linux/spi/spi-mem.h>
10 #define SPI_NOR_DEBUGFS_ROOT "spi-nor"
34 case SNOR_PROTO_1_1_1: return "1S-1S-1S"; in spi_nor_protocol_name()
35 case SNOR_PROTO_1_1_2: return "1S-1S-2S"; in spi_nor_protocol_name()
36 case SNOR_PROTO_1_1_4: return "1S-1S-4S"; in spi_nor_protocol_name()
37 case SNOR_PROTO_1_1_8: return "1S-1S-8S"; in spi_nor_protocol_name()
38 case SNOR_PROTO_1_2_2: return "1S-2S-2S"; in spi_nor_protocol_name()
39 case SNOR_PROTO_1_4_4: return "1S-4S-4S"; in spi_nor_protocol_name()
40 case SNOR_PROTO_1_8_8: return "1S-8S-8S"; in spi_nor_protocol_name()
41 case SNOR_PROTO_2_2_2: return "2S-2S-2S"; in spi_nor_protocol_name()
42 case SNOR_PROTO_4_4_4: return "4S-4S-4S"; in spi_nor_protocol_name()
43 case SNOR_PROTO_8_8_8: return "8S-8S-8S"; in spi_nor_protocol_name()
44 case SNOR_PROTO_1_1_1_DTR: return "1D-1D-1D"; in spi_nor_protocol_name()
45 case SNOR_PROTO_1_2_2_DTR: return "1D-2D-2D"; in spi_nor_protocol_name()
46 case SNOR_PROTO_1_4_4_DTR: return "1D-4D-4D"; in spi_nor_protocol_name()
47 case SNOR_PROTO_1_8_8_DTR: return "1D-8D-8D"; in spi_nor_protocol_name()
48 case SNOR_PROTO_8_8_8_DTR: return "8D-8D-8D"; in spi_nor_protocol_name()
75 struct spi_nor *nor = s->private; in spi_nor_params_show() local
76 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_params_show()
77 struct spi_nor_erase_map *erase_map = &params->erase_map; in spi_nor_params_show()
79 const struct flash_info *info = nor->info; in spi_nor_params_show()
83 seq_printf(s, "name\t\t%s\n", info->name); in spi_nor_params_show()
84 seq_printf(s, "id\t\t%*ph\n", info->id_len, info->id); in spi_nor_params_show()
85 string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf)); in spi_nor_params_show()
87 seq_printf(s, "write size\t%u\n", params->writesize); in spi_nor_params_show()
88 seq_printf(s, "page size\t%u\n", params->page_size); in spi_nor_params_show()
89 seq_printf(s, "address nbytes\t%u\n", nor->addr_nbytes); in spi_nor_params_show()
92 spi_nor_print_flags(s, nor->flags, snor_f_names, sizeof(snor_f_names)); in spi_nor_params_show()
96 seq_printf(s, " read\t\t0x%02x\n", nor->read_opcode); in spi_nor_params_show()
97 seq_printf(s, " dummy cycles\t%u\n", nor->read_dummy); in spi_nor_params_show()
98 seq_printf(s, " erase\t\t0x%02x\n", nor->erase_opcode); in spi_nor_params_show()
99 seq_printf(s, " program\t0x%02x\n", nor->program_opcode); in spi_nor_params_show()
101 switch (nor->cmd_ext_type) { in spi_nor_params_show()
119 spi_nor_protocol_name(nor->read_proto)); in spi_nor_params_show()
121 spi_nor_protocol_name(nor->write_proto)); in spi_nor_params_show()
123 spi_nor_protocol_name(nor->reg_proto)); in spi_nor_params_show()
127 struct spi_nor_erase_type *et = &erase_map->erase_type[i]; in spi_nor_params_show()
129 if (et->size) { in spi_nor_params_show()
130 string_get_size(et->size, 1, STRING_UNITS_2, buf, in spi_nor_params_show()
132 seq_printf(s, " %02x (%s) [%d]\n", et->opcode, buf, i); in spi_nor_params_show()
136 if (!(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { in spi_nor_params_show()
137 string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf)); in spi_nor_params_show()
143 seq_puts(s, " ------------------+------------+----------\n"); in spi_nor_params_show()
144 for (region = erase_map->regions; in spi_nor_params_show()
147 u64 start = region->offset & ~SNOR_ERASE_FLAGS_MASK; in spi_nor_params_show()
148 u64 flags = region->offset & SNOR_ERASE_FLAGS_MASK; in spi_nor_params_show()
149 u64 end = start + region->size - 1; in spi_nor_params_show()
151 seq_printf(s, " %08llx-%08llx | [%c%c%c%c] | %s\n", in spi_nor_params_show()
167 seq_printf(s, " %s%s\n", spi_nor_protocol_name(cmd->proto), in spi_nor_print_read_cmd()
169 seq_printf(s, " opcode\t0x%02x\n", cmd->opcode); in spi_nor_print_read_cmd()
170 seq_printf(s, " mode cycles\t%u\n", cmd->num_mode_clocks); in spi_nor_print_read_cmd()
171 seq_printf(s, " dummy cycles\t%u\n", cmd->num_wait_states); in spi_nor_print_read_cmd()
177 seq_printf(s, " %s\n", spi_nor_protocol_name(cmd->proto)); in spi_nor_print_pp_cmd()
178 seq_printf(s, " opcode\t0x%02x\n", cmd->opcode); in spi_nor_print_pp_cmd()
183 struct spi_nor *nor = s->private; in spi_nor_capabilities_show() local
184 struct spi_nor_flash_parameter *params = nor->params; in spi_nor_capabilities_show()
185 u32 hwcaps = params->hwcaps.mask; in spi_nor_capabilities_show()
197 spi_nor_print_read_cmd(s, BIT(i), &params->reads[cmd]); in spi_nor_capabilities_show()
210 spi_nor_print_pp_cmd(s, &params->page_programs[cmd]); in spi_nor_capabilities_show()
223 struct spi_nor *nor = data; in spi_nor_debugfs_unregister() local
225 debugfs_remove(nor->debugfs_root); in spi_nor_debugfs_unregister()
226 nor->debugfs_root = NULL; in spi_nor_debugfs_unregister()
229 void spi_nor_debugfs_register(struct spi_nor *nor) in spi_nor_debugfs_register() argument
239 ret = devm_add_action(nor->dev, spi_nor_debugfs_unregister, nor); in spi_nor_debugfs_register()
243 d = debugfs_create_dir(dev_name(nor->dev), rootdir); in spi_nor_debugfs_register()
244 nor->debugfs_root = d; in spi_nor_debugfs_register()
246 debugfs_create_file("params", 0444, d, nor, &spi_nor_params_fops); in spi_nor_debugfs_register()
247 debugfs_create_file("capabilities", 0444, d, nor, in spi_nor_debugfs_register()