xfel/fel.h

72 lines
2.3 KiB
C
Raw Normal View History

2021-05-25 16:56:02 +08:00
#ifndef __FEL_H__
#define __FEL_H__
#ifdef __cplusplus
extern "C" {
#endif
2021-05-25 23:44:28 +08:00
#include <x.h>
2021-05-25 16:56:02 +08:00
2021-05-25 23:44:28 +08:00
struct xfel_ctx_t;
struct chip_t;
2021-05-25 16:56:02 +08:00
struct xfel_ctx_t {
libusb_device_handle * hdl;
int epout;
int epin;
2021-05-25 23:44:28 +08:00
struct {
char signature[8];
uint32_t id;
uint32_t unknown_0a;
uint16_t protocol;
uint8_t unknown_12;
uint8_t unknown_13;
uint32_t scratchpad;
uint32_t pad[2];
} version;
2021-05-25 16:56:02 +08:00
struct chip_t * chip;
};
2021-05-25 23:44:28 +08:00
struct chip_t {
char * name;
uint32_t id;
int (*reset)(struct xfel_ctx_t * ctx);
2021-05-26 10:42:14 +08:00
int (*sid)(struct xfel_ctx_t * ctx, uint32_t * sid);
2021-05-25 23:44:28 +08:00
int (*jtag)(struct xfel_ctx_t * ctx);
int (*ddr)(struct xfel_ctx_t * ctx, const char * type);
int (*spinor)(struct xfel_ctx_t * ctx);
int (*spinor_read)(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int (*spinor_write)(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int (*spinand)(struct xfel_ctx_t * ctx);
int (*spinand_read)(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int (*spinand_write)(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
2021-05-25 23:44:28 +08:00
};
2021-05-26 10:03:58 +08:00
#define R32(reg) fel_read32(ctx, reg)
2021-05-26 10:49:30 +08:00
#define W32(reg, val) fel_write32(ctx, reg, val)
2021-05-25 23:44:28 +08:00
2021-05-26 10:03:58 +08:00
int fel_init(struct xfel_ctx_t * ctx);
2021-05-25 23:44:28 +08:00
void fel_exec(struct xfel_ctx_t * ctx, uint32_t addr);
uint32_t fel_read32(struct xfel_ctx_t * ctx, uint32_t addr);
void fel_write32(struct xfel_ctx_t * ctx, uint32_t addr, uint32_t val);
2021-05-26 09:54:26 +08:00
void fel_read(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len, int progress);
void fel_write(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len, int progress);
2021-05-25 23:44:28 +08:00
int fel_chip_reset(struct xfel_ctx_t * ctx);
2021-05-26 10:42:14 +08:00
int fel_chip_sid(struct xfel_ctx_t * ctx, uint32_t * sid);
2021-05-25 23:44:28 +08:00
int fel_chip_jtag(struct xfel_ctx_t * ctx);
int fel_chip_ddr(struct xfel_ctx_t * ctx, const char * type);
2021-05-26 12:09:59 +08:00
int fel_chip_spinor(struct xfel_ctx_t * ctx);
int fel_chip_spinor_read(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int fel_chip_spinor_write(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int fel_chip_spinand(struct xfel_ctx_t * ctx);
int fel_chip_spinand_read(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
int fel_chip_spinand_write(struct xfel_ctx_t * ctx, uint32_t addr, void * buf, size_t len);
2021-05-25 16:56:02 +08:00
#ifdef __cplusplus
}
#endif
#endif /* __FEL_H__ */