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 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef __DFU_ENTITY_H_
24 #define __DFU_ENTITY_H_
27 #include <linux/list.h>
30 enum dfu_device_type {
44 struct mmc_internal_data {
46 unsigned int lba_start;
47 unsigned int lba_size;
48 unsigned int lba_blk_size;
55 struct nand_internal_data {
64 static inline unsigned int get_mmc_blk_size(int dev)
66 return find_mmc_device(dev)->read_bl_len;
69 #define DFU_NAME_SIZE 32
70 #define DFU_CMD_BUF_SIZE 128
71 #ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE
72 #define CONFIG_SYS_DFU_DATA_BUF_SIZE (1024*1024*8) /* 8 MiB */
74 #ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE
75 #define CONFIG_SYS_DFU_MAX_FILE_SIZE (4 << 20) /* 4 MiB */
79 char name[DFU_NAME_SIZE];
83 enum dfu_device_type dev_type;
84 enum dfu_layout layout;
87 struct mmc_internal_data mmc;
88 struct nand_internal_data nand;
91 int (*read_medium)(struct dfu_entity *dfu,
92 u64 offset, void *buf, long *len);
94 int (*write_medium)(struct dfu_entity *dfu,
95 u64 offset, void *buf, long *len);
97 int (*flush_medium)(struct dfu_entity *dfu);
99 struct list_head list;
101 /* on the fly state */
111 u32 bad_skip; /* for nand use */
113 unsigned int inited:1;
116 int dfu_config_entities(char *s, char *interface, int num);
117 void dfu_free_entities(void);
118 void dfu_show_entities(void);
119 int dfu_get_alt_number(void);
120 const char *dfu_get_dev_type(enum dfu_device_type t);
121 const char *dfu_get_layout(enum dfu_layout l);
122 struct dfu_entity *dfu_get_entity(int alt);
123 char *dfu_extract_token(char** e, int *n);
125 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
126 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
127 /* Device specific */
128 #ifdef CONFIG_DFU_MMC
129 extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s);
131 static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
133 puts("MMC support not available!\n");
138 #ifdef CONFIG_DFU_NAND
139 extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s);
141 static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s)
143 puts("NAND support not available!\n");
148 #endif /* __DFU_ENTITY_H_ */