Blame view
include/dfu.h
6.6 KB
f22b11c10 dfu: DFU backend ... |
1 2 3 4 5 6 7 |
/* * dfu.h - DFU flashable area description * * Copyright (C) 2012 Samsung Electronics * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com> * Lukasz Majewski <l.majewski@samsung.com> * |
1a4596601 Add GPL-2.0+ SPDX... |
8 |
* SPDX-License-Identifier: GPL-2.0+ |
f22b11c10 dfu: DFU backend ... |
9 10 11 12 13 14 15 16 |
*/ #ifndef __DFU_ENTITY_H_ #define __DFU_ENTITY_H_ #include <common.h> #include <linux/list.h> #include <mmc.h> |
6f12ebf6e dfu: add SF backend |
17 |
#include <spi_flash.h> |
a6921adcf usb:g_dnl:dfu: Do... |
18 |
#include <linux/usb/composite.h> |
f22b11c10 dfu: DFU backend ... |
19 20 21 22 23 |
enum dfu_device_type { DFU_DEV_MMC = 1, DFU_DEV_ONENAND, DFU_DEV_NAND, |
a9479f043 dfu: ram support |
24 |
DFU_DEV_RAM, |
6f12ebf6e dfu: add SF backend |
25 |
DFU_DEV_SF, |
f22b11c10 dfu: DFU backend ... |
26 27 28 29 30 31 32 33 |
}; enum dfu_layout { DFU_RAW_ADDR = 1, DFU_FS_FAT, DFU_FS_EXT2, DFU_FS_EXT3, DFU_FS_EXT4, |
a9479f043 dfu: ram support |
34 |
DFU_RAM_ADDR, |
f22b11c10 dfu: DFU backend ... |
35 |
}; |
5a127c843 dfu: unify mmc/na... |
36 37 38 |
enum dfu_op { DFU_OP_READ = 1, DFU_OP_WRITE, |
0e285b503 dfu: fix some iss... |
39 |
DFU_OP_SIZE, |
5a127c843 dfu: unify mmc/na... |
40 |
}; |
f22b11c10 dfu: DFU backend ... |
41 |
struct mmc_internal_data { |
dd64827eb dfu: defer parsin... |
42 |
int dev_num; |
f22b11c10 dfu: DFU backend ... |
43 44 45 46 |
/* RAW programming */ unsigned int lba_start; unsigned int lba_size; unsigned int lba_blk_size; |
c8151b4a5 dfu: mmc: Provide... |
47 48 |
/* eMMC HW partition access */ int hw_partition; |
f22b11c10 dfu: DFU backend ... |
49 50 51 52 |
/* FAT/EXT */ unsigned int dev; unsigned int part; }; |
c6631764c dfu: NAND specifi... |
53 54 55 56 57 58 59 |
struct nand_internal_data { /* RAW programming */ u64 start; u64 size; unsigned int dev; unsigned int part; |
815c30b2b dfu, nand, ubi: a... |
60 61 |
/* for nand/ubi use */ unsigned int ubi; |
c6631764c dfu: NAND specifi... |
62 |
}; |
a9479f043 dfu: ram support |
63 64 65 66 |
struct ram_internal_data { void *start; unsigned int size; }; |
6f12ebf6e dfu: add SF backend |
67 68 69 70 71 72 73 |
struct sf_internal_data { struct spi_flash *dev; /* RAW programming */ u64 start; u64 size; }; |
a24c3155d dfu: Change inden... |
74 75 |
#define DFU_NAME_SIZE 32 #define DFU_CMD_BUF_SIZE 128 |
e7e75c70c dfu: make data bu... |
76 77 78 |
#ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE #define CONFIG_SYS_DFU_DATA_BUF_SIZE (1024*1024*8) /* 8 MiB */ #endif |
ea2453d56 dfu: Support larg... |
79 |
#ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE |
7a813d5b7 dfu: Make maximum... |
80 |
#define CONFIG_SYS_DFU_MAX_FILE_SIZE CONFIG_SYS_DFU_DATA_BUF_SIZE |
ea2453d56 dfu: Support larg... |
81 |
#endif |
33fac4a6a usb: dfu: f_dfu: ... |
82 83 84 |
#ifndef DFU_DEFAULT_POLL_TIMEOUT #define DFU_DEFAULT_POLL_TIMEOUT 0 #endif |
001a83198 usb: dfu: introdu... |
85 86 87 |
#ifndef DFU_MANIFEST_POLL_TIMEOUT #define DFU_MANIFEST_POLL_TIMEOUT DFU_DEFAULT_POLL_TIMEOUT #endif |
f22b11c10 dfu: DFU backend ... |
88 89 90 91 92 |
struct dfu_entity { char name[DFU_NAME_SIZE]; int alt; void *dev_private; |
f22b11c10 dfu: DFU backend ... |
93 94 |
enum dfu_device_type dev_type; enum dfu_layout layout; |
7ac1b410a dfu: allow backen... |
95 |
unsigned long max_buf_size; |
f22b11c10 dfu: DFU backend ... |
96 97 98 |
union { struct mmc_internal_data mmc; |
c6631764c dfu: NAND specifi... |
99 |
struct nand_internal_data nand; |
a9479f043 dfu: ram support |
100 |
struct ram_internal_data ram; |
6f12ebf6e dfu: add SF backend |
101 |
struct sf_internal_data sf; |
f22b11c10 dfu: DFU backend ... |
102 |
} data; |
15970d871 dfu: remove limit... |
103 |
int (*get_medium_size)(struct dfu_entity *dfu, u64 *size); |
0e285b503 dfu: fix some iss... |
104 |
|
ea2453d56 dfu: Support larg... |
105 106 107 108 109 110 111 |
int (*read_medium)(struct dfu_entity *dfu, u64 offset, void *buf, long *len); int (*write_medium)(struct dfu_entity *dfu, u64 offset, void *buf, long *len); int (*flush_medium)(struct dfu_entity *dfu); |
fc25fa27e dfu, nand: add me... |
112 |
unsigned int (*poll_timeout)(struct dfu_entity *dfu); |
f22b11c10 dfu: DFU backend ... |
113 |
|
cb7bd2e07 dfu: add free_ent... |
114 |
void (*free_entity)(struct dfu_entity *dfu); |
f22b11c10 dfu: DFU backend ... |
115 |
struct list_head list; |
ea2453d56 dfu: Support larg... |
116 117 118 119 120 121 122 123 |
/* on the fly state */ u32 crc; u64 offset; int i_blk_seq_num; u8 *i_buf; u8 *i_buf_start; u8 *i_buf_end; |
15970d871 dfu: remove limit... |
124 |
u64 r_left; |
ea2453d56 dfu: Support larg... |
125 |
long b_left; |
c6631764c dfu: NAND specifi... |
126 |
u32 bad_skip; /* for nand use */ |
ea2453d56 dfu: Support larg... |
127 |
unsigned int inited:1; |
f22b11c10 dfu: DFU backend ... |
128 |
}; |
899a52821 dfu: samsung: mov... |
129 130 131 |
#ifdef CONFIG_SET_DFU_ALT_INFO void set_dfu_alt_info(char *interface, char *devstr); #endif |
dd64827eb dfu: defer parsin... |
132 |
int dfu_config_entities(char *s, char *interface, char *devstr); |
f22b11c10 dfu: DFU backend ... |
133 134 135 136 137 138 139 |
void dfu_free_entities(void); void dfu_show_entities(void); int dfu_get_alt_number(void); const char *dfu_get_dev_type(enum dfu_device_type t); const char *dfu_get_layout(enum dfu_layout l); struct dfu_entity *dfu_get_entity(int alt); char *dfu_extract_token(char** e, int *n); |
6bed7ce56 dfu: Implementati... |
140 |
void dfu_trigger_reset(void); |
fed936ed8 dfu:core: Find DF... |
141 |
int dfu_get_alt(char *name); |
dd64827eb dfu: defer parsin... |
142 |
int dfu_init_env_entities(char *interface, char *devstr); |
7ac1b410a dfu: allow backen... |
143 |
unsigned char *dfu_get_buf(struct dfu_entity *dfu); |
d42782631 dfu:core: Export ... |
144 |
unsigned char *dfu_free_buf(void); |
4fb127898 dfu: Export alloc... |
145 |
unsigned long dfu_get_buf_size(void); |
1cc03c5c5 dfu: Provide mean... |
146 |
bool dfu_usb_get_reset(void); |
f22b11c10 dfu: DFU backend ... |
147 148 149 |
int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num); int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |
a2199afea usb, dfu: extract... |
150 |
int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |
2092e4610 dfu: tftp: update... |
151 |
|
fc18f8d17 dfu: usb: f_dfu: ... |
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
/* * dfu_defer_flush - pointer to store dfu_entity for deferred flashing. * It should be NULL when not used. */ extern struct dfu_entity *dfu_defer_flush; /** * dfu_get_defer_flush - get current value of dfu_defer_flush pointer * * @return - value of the dfu_defer_flush pointer */ static inline struct dfu_entity *dfu_get_defer_flush(void) { return dfu_defer_flush; } /** * dfu_set_defer_flush - set the dfu_defer_flush pointer * * @param dfu - pointer to the dfu_entity, which should be written */ static inline void dfu_set_defer_flush(struct dfu_entity *dfu) { dfu_defer_flush = dfu; } |
2092e4610 dfu: tftp: update... |
176 177 178 179 180 181 182 183 184 185 186 187 188 |
/** * dfu_write_from_mem_addr - write data from memory to DFU managed medium * * This function adds support for writing data starting from fixed memory * address (like $loadaddr) to dfu managed medium (e.g. NAND, MMC, file system) * * @param dfu - dfu entity to which we want to store data * @param buf - fixed memory addres from where data starts * @param size - number of bytes to write * * @return - 0 on success, other value on failure */ int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size); |
f22b11c10 dfu: DFU backend ... |
189 190 |
/* Device specific */ #ifdef CONFIG_DFU_MMC |
dd64827eb dfu: defer parsin... |
191 |
extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s); |
f22b11c10 dfu: DFU backend ... |
192 |
#else |
dd64827eb dfu: defer parsin... |
193 194 |
static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s) |
f22b11c10 dfu: DFU backend ... |
195 196 197 198 199 200 |
{ puts("MMC support not available! "); return -1; } #endif |
c6631764c dfu: NAND specifi... |
201 202 |
#ifdef CONFIG_DFU_NAND |
dd64827eb dfu: defer parsin... |
203 |
extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s); |
c6631764c dfu: NAND specifi... |
204 |
#else |
dd64827eb dfu: defer parsin... |
205 206 |
static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s) |
c6631764c dfu: NAND specifi... |
207 208 209 210 211 212 |
{ puts("NAND support not available! "); return -1; } #endif |
a9479f043 dfu: ram support |
213 |
#ifdef CONFIG_DFU_RAM |
dd64827eb dfu: defer parsin... |
214 |
extern int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s); |
a9479f043 dfu: ram support |
215 |
#else |
dd64827eb dfu: defer parsin... |
216 217 |
static inline int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s) |
a9479f043 dfu: ram support |
218 219 220 221 222 223 |
{ puts("RAM support not available! "); return -1; } #endif |
6f12ebf6e dfu: add SF backend |
224 225 226 227 228 229 230 231 232 233 234 |
#ifdef CONFIG_DFU_SF extern int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s); #else static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s) { puts("SF support not available! "); return -1; } #endif |
2d50d68a4 dfu: tftp: update... |
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
/** * dfu_tftp_write - Write TFTP data to DFU medium * * This function is storing data received via TFTP on DFU supported medium. * * @param dfu_entity_name - name of DFU entity to write * @param addr - address of data buffer to write * @param len - number of bytes * @param interface - destination DFU medium (e.g. "mmc") * @param devstring - instance number of destination DFU medium (e.g. "1") * * @return 0 on success, otherwise error code */ #ifdef CONFIG_DFU_TFTP int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, char *interface, char *devstring); #else static inline int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len, char *interface, char *devstring) { puts("TFTP write support for DFU not available! "); return -ENOSYS; } #endif |
a6921adcf usb:g_dnl:dfu: Do... |
261 |
int dfu_add(struct usb_configuration *c); |
f22b11c10 dfu: DFU backend ... |
262 |
#endif /* __DFU_ENTITY_H_ */ |