2 * dfu.h - DFU flashable area description
4 * Copyright (C) 2012 Samsung Electronics
5 * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
6 * Lukasz Majewski <l.majewski@samsung.com>
8 * SPDX-License-Identifier: GPL-2.0+
11 #ifndef __DFU_ENTITY_H_
12 #define __DFU_ENTITY_H_
15 #include <linux/list.h>
18 enum dfu_device_type {
32 struct mmc_internal_data {
34 unsigned int lba_start;
35 unsigned int lba_size;
36 unsigned int lba_blk_size;
43 struct nand_internal_data {
52 static inline unsigned int get_mmc_blk_size(int dev)
54 return find_mmc_device(dev)->read_bl_len;
57 #define DFU_NAME_SIZE 32
58 #define DFU_CMD_BUF_SIZE 128
59 #ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE
60 #define CONFIG_SYS_DFU_DATA_BUF_SIZE (1024*1024*8) /* 8 MiB */
62 #ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE
63 #define CONFIG_SYS_DFU_MAX_FILE_SIZE (4 << 20) /* 4 MiB */
67 char name[DFU_NAME_SIZE];
71 enum dfu_device_type dev_type;
72 enum dfu_layout layout;
75 struct mmc_internal_data mmc;
76 struct nand_internal_data nand;
79 int (*read_medium)(struct dfu_entity *dfu,
80 u64 offset, void *buf, long *len);
82 int (*write_medium)(struct dfu_entity *dfu,
83 u64 offset, void *buf, long *len);
85 int (*flush_medium)(struct dfu_entity *dfu);
87 struct list_head list;
89 /* on the fly state */
99 u32 bad_skip; /* for nand use */
101 unsigned int inited:1;
104 int dfu_config_entities(char *s, char *interface, int num);
105 void dfu_free_entities(void);
106 void dfu_show_entities(void);
107 int dfu_get_alt_number(void);
108 const char *dfu_get_dev_type(enum dfu_device_type t);
109 const char *dfu_get_layout(enum dfu_layout l);
110 struct dfu_entity *dfu_get_entity(int alt);
111 char *dfu_extract_token(char** e, int *n);
113 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
114 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
115 /* Device specific */
116 #ifdef CONFIG_DFU_MMC
117 extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s);
119 static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
121 puts("MMC support not available!\n");
126 #ifdef CONFIG_DFU_NAND
127 extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s);
129 static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s)
131 puts("NAND support not available!\n");
136 #endif /* __DFU_ENTITY_H_ */