diff options
author | Bernhard Nortmann <bernhard.nortmann@web.de> | 2016-11-19 17:57:48 +0300 |
---|---|---|
committer | Bernhard Nortmann <bernhard.nortmann@web.de> | 2016-11-29 16:22:09 +0300 |
commit | aaa677d55248ed3deb9288dd73c3fbfec9577cd5 (patch) | |
tree | 89949f0cc1ba238ded1d876c2f297f07a55872a1 /fel_lib.h | |
parent | ea3f7fee3de90ef7990807fd4193493d5ffb072f (diff) |
fel: Factor out a new FEL library
The FEL utility had accumulated enough (mostly USB-related)
"low-level" code to justify moving that to a separate code unit.
This will allow us to keep better focus on the higher level
functionality in fel.c.
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Diffstat (limited to 'fel_lib.h')
-rw-r--r-- | fel_lib.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/fel_lib.h b/fel_lib.h new file mode 100644 index 0000000..7f0524e --- /dev/null +++ b/fel_lib.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Bernhard Nortmann <bernhard.nortmann@web.de> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef _SUNXI_TOOLS_FEL_LIB_H +#define _SUNXI_TOOLS_FEL_LIB_H + +#include <stdbool.h> +#include <stdint.h> +#include "progress.h" +#include "soc_info.h" + +/* USB identifiers for Allwinner device in FEL mode */ +#define AW_USB_VENDOR_ID 0x1F3A +#define AW_USB_PRODUCT_ID 0xEFE8 + +typedef struct _felusb_handle felusb_handle; /* opaque data type */ + +/* More general FEL "device" handle, to be extended later */ +typedef struct { + felusb_handle *usb; +} feldev_handle; + +/* FEL device management */ + +void feldev_init(void); +void feldev_done(feldev_handle *dev); + +feldev_handle *feldev_open(int busnum, int devnum, + uint16_t vendor_id, uint16_t product_id); +void feldev_close(feldev_handle *dev); + +/* FEL functions */ + +void aw_fel_get_version(feldev_handle *dev, struct aw_fel_version *buf); +void aw_fel_read(feldev_handle *dev, uint32_t offset, void *buf, size_t len); +void aw_fel_write(feldev_handle *dev, void *buf, uint32_t offset, size_t len); +void aw_fel_write_buffer(feldev_handle *dev, void *buf, uint32_t offset, + size_t len, bool progress); +void aw_fel_execute(feldev_handle *dev, uint32_t offset); + +#endif /* _SUNXI_TOOLS_FEL_LIB_H */ |