| Nico Huber | 11136c2 | 2023-05-01 12:00:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashprog project. |
| 3 | * |
| 4 | * Copyright (C) 2023 Nico Huber <nico.h@gmx.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __PROBING_H__ |
| 18 | #define __PROBING_H__ 1 |
| 19 | |
| Nico Huber | af9d738 | 2023-05-01 13:33:26 +0200 | [diff] [blame] | 20 | #include <stddef.h> |
| Nico Huber | 11136c2 | 2023-05-01 12:00:09 +0200 | [diff] [blame] | 21 | #include <stdint.h> |
| 22 | |
| 23 | enum id_type { |
| 24 | ID_FIXME = 0, |
| 25 | ID_NONE, |
| 26 | |
| 27 | ID_82802AB, |
| 28 | ID_EDI, |
| 29 | ID_EN29LV640B, |
| 30 | ID_JEDEC, |
| 31 | ID_JEDEC_29GL, |
| 32 | ID_OPAQUE, |
| 33 | ID_SPI_AT25F, |
| 34 | ID_SPI_RDID, |
| Nico Huber | 11136c2 | 2023-05-01 12:00:09 +0200 | [diff] [blame] | 35 | ID_SPI_REMS, |
| 36 | ID_SPI_RES1, |
| 37 | ID_SPI_RES2, |
| 38 | ID_SPI_RES3, |
| 39 | ID_SPI_SFDP, |
| 40 | ID_SPI_ST95, |
| 41 | ID_W29EE011, |
| 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * With 32bit manufacture_id and model_id we can cover IDs up to |
| 46 | * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's |
| 47 | * Identification code. |
| 48 | */ |
| 49 | struct id_info { |
| Nico Huber | af9d738 | 2023-05-01 13:33:26 +0200 | [diff] [blame] | 50 | union { |
| 51 | uint32_t manufacture; |
| Nico Huber | f3113ac | 2026-02-21 12:50:19 +0100 | [diff] [blame^] | 52 | uint32_t hwversion; |
| Nico Huber | af9d738 | 2023-05-01 13:33:26 +0200 | [diff] [blame] | 53 | uint32_t id1; |
| 54 | }; |
| 55 | union { |
| 56 | uint32_t model; |
| 57 | uint32_t id2; |
| 58 | }; |
| Nico Huber | 11136c2 | 2023-05-01 12:00:09 +0200 | [diff] [blame] | 59 | enum id_type type; |
| 60 | }; |
| 61 | |
| Nico Huber | af9d738 | 2023-05-01 13:33:26 +0200 | [diff] [blame] | 62 | struct id_info_ext { |
| 63 | struct id_info id; |
| 64 | void *ext; |
| 65 | }; |
| 66 | |
| 67 | struct found_id { |
| 68 | struct found_id *next; |
| 69 | struct id_info_ext info; |
| 70 | }; |
| 71 | |
| 72 | struct flashprog_chip; |
| 73 | struct master_common; |
| 74 | |
| 75 | struct bus_probe { |
| Nico Huber | ac13873 | 2026-02-28 17:42:27 +0100 | [diff] [blame] | 76 | unsigned int priority; |
| Nico Huber | af9d738 | 2023-05-01 13:33:26 +0200 | [diff] [blame] | 77 | enum id_type type; |
| 78 | struct found_id *(*run)(const struct bus_probe *, const struct master_common *); |
| 79 | void *arg; |
| 80 | }; |
| 81 | |
| 82 | struct bus_probing { |
| 83 | unsigned int probe_count; |
| 84 | const struct bus_probe *probes; |
| 85 | bool (*match)(const struct flashprog_chip *, const struct id_info_ext *); |
| 86 | }; |
| 87 | |
| 88 | struct flashprog_flashctx; |
| 89 | int probe_buses(struct flashprog_flashctx *); |
| 90 | |
| Nico Huber | 11136c2 | 2023-05-01 12:00:09 +0200 | [diff] [blame] | 91 | #endif /* !__PROBING_H__ */ |