#include <linux/delay.h>
#include <linux/fpga/fpga-mgr.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/spi/spi.h>
#define IDCODE_PUB …
#define ISC_ENABLE …
#define ISC_ERASE …
#define ISC_PROGRAMDONE …
#define LSC_INITADDRESS …
#define LSC_PROGINCRNV …
#define LSC_READ_STATUS …
#define LSC_REFRESH …
#define MACHXO2_MAX_SPEED …
#define MACHXO2_LOW_DELAY_USEC …
#define MACHXO2_HIGH_DELAY_USEC …
#define MACHXO2_REFRESH_USEC …
#define MACHXO2_MAX_BUSY_LOOP …
#define MACHXO2_MAX_REFRESH_LOOP …
#define MACHXO2_PAGE_SIZE …
#define MACHXO2_BUF_SIZE …
#define BUSY …
#define DONE …
#define DVER …
#define ENAB …
#define ERRBITS …
#define ERRMASK …
#define FAIL …
#define ENOERR …
#define EID …
#define ECMD …
#define ECRC …
#define EPREAM …
#define EABRT …
#define EOVERFL …
#define ESDMEOF …
static inline u8 get_err(unsigned long *status)
{ … }
static int get_status(struct spi_device *spi, unsigned long *status)
{ … }
#ifdef DEBUG
static const char *get_err_string(u8 err)
{
switch (err) {
case ENOERR: return "No Error";
case EID: return "ID ERR";
case ECMD: return "CMD ERR";
case ECRC: return "CRC ERR";
case EPREAM: return "Preamble ERR";
case EABRT: return "Abort ERR";
case EOVERFL: return "Overflow ERR";
case ESDMEOF: return "SDM EOF";
}
return "Default switch case";
}
#endif
static void dump_status_reg(unsigned long *status)
{ … }
static int wait_until_not_busy(struct spi_device *spi)
{ … }
static int machxo2_cleanup(struct fpga_manager *mgr)
{ … }
static enum fpga_mgr_states machxo2_spi_state(struct fpga_manager *mgr)
{ … }
static int machxo2_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
{ … }
static int machxo2_write(struct fpga_manager *mgr, const char *buf,
size_t count)
{ … }
static int machxo2_write_complete(struct fpga_manager *mgr,
struct fpga_image_info *info)
{ … }
static const struct fpga_manager_ops machxo2_ops = …;
static int machxo2_spi_probe(struct spi_device *spi)
{ … }
#ifdef CONFIG_OF
static const struct of_device_id of_match[] = …;
MODULE_DEVICE_TABLE(of, of_match);
#endif
static const struct spi_device_id lattice_ids[] = …;
MODULE_DEVICE_TABLE(spi, lattice_ids);
static struct spi_driver machxo2_spi_driver = …;
module_spi_driver(…) …
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;