1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __LATTICE_SYSCONFIG_H
4 #define __LATTICE_SYSCONFIG_H
6 #define SYSCONFIG_ISC_ENABLE {0xC6, 0x00, 0x00, 0x00}
7 #define SYSCONFIG_ISC_DISABLE {0x26, 0x00, 0x00, 0x00}
8 #define SYSCONFIG_ISC_ERASE {0x0E, 0x01, 0x00, 0x00}
9 #define SYSCONFIG_LSC_READ_STATUS {0x3C, 0x00, 0x00, 0x00}
10 #define SYSCONFIG_LSC_CHECK_BUSY {0xF0, 0x00, 0x00, 0x00}
11 #define SYSCONFIG_LSC_REFRESH {0x79, 0x00, 0x00, 0x00}
12 #define SYSCONFIG_LSC_INIT_ADDR {0x46, 0x00, 0x00, 0x00}
13 #define SYSCONFIG_LSC_BITSTREAM_BURST {0x7a, 0x00, 0x00, 0x00}
15 #define SYSCONFIG_STATUS_DONE BIT(8)
16 #define SYSCONFIG_STATUS_BUSY BIT(12)
17 #define SYSCONFIG_STATUS_FAIL BIT(13)
18 #define SYSCONFIG_STATUS_ERR GENMASK(25, 23)
20 #define SYSCONFIG_POLL_INTERVAL_US 30
21 #define SYSCONFIG_POLL_BUSY_TIMEOUT_US 1000000
22 #define SYSCONFIG_POLL_GPIO_TIMEOUT_US 100000
24 struct sysconfig_priv
{
25 struct gpio_desc
*program
;
26 struct gpio_desc
*init
;
27 struct gpio_desc
*done
;
29 int (*command_transfer
)(struct sysconfig_priv
*priv
, const void *tx_buf
,
30 size_t tx_len
, void *rx_buf
, size_t rx_len
);
31 int (*bitstream_burst_write_init
)(struct sysconfig_priv
*priv
);
32 int (*bitstream_burst_write
)(struct sysconfig_priv
*priv
,
33 const char *tx_buf
, size_t tx_len
);
34 int (*bitstream_burst_write_complete
)(struct sysconfig_priv
*priv
);
37 int sysconfig_probe(struct sysconfig_priv
*priv
);
39 #endif /* __LATTICE_SYSCONFIG_H */