1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef	__LATTICE_SYSCONFIG_H
4 #define	__LATTICE_SYSCONFIG_H
5 
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}
14 
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)
19 
20 #define	SYSCONFIG_POLL_INTERVAL_US	30
21 #define	SYSCONFIG_POLL_BUSY_TIMEOUT_US	1000000
22 #define	SYSCONFIG_POLL_GPIO_TIMEOUT_US	100000
23 
24 struct sysconfig_priv {
25 	struct gpio_desc *program;
26 	struct gpio_desc *init;
27 	struct gpio_desc *done;
28 	struct device *dev;
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);
35 };
36 
37 int sysconfig_probe(struct sysconfig_priv *priv);
38 
39 #endif /* __LATTICE_SYSCONFIG_H */
40