xref: /linux/drivers/spi/spi-loongson.h (revision a36e9f5cfe9eb3a1dce8769c7058251c42705357)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Header File for Loongson SPI Driver. */
3 /* Copyright (C) 2023 Loongson Technology Corporation Limited */
4 
5 #ifndef __LINUX_SPI_LOONGSON_H
6 #define __LINUX_SPI_LOONGSON_H
7 
8 #include <linux/bits.h>
9 #include <linux/pm.h>
10 #include <linux/types.h>
11 
12 #define	LOONGSON_SPI_SPCR_REG	0x00
13 #define	LOONGSON_SPI_SPSR_REG	0x01
14 #define	LOONGSON_SPI_FIFO_REG	0x02
15 #define	LOONGSON_SPI_SPER_REG	0x03
16 #define	LOONGSON_SPI_PARA_REG	0x04
17 #define	LOONGSON_SPI_SFCS_REG	0x05
18 #define	LOONGSON_SPI_TIMI_REG	0x06
19 
20 /* Bits definition for Loongson SPI register */
21 #define	LOONGSON_SPI_PARA_MEM_EN	BIT(0)
22 #define	LOONGSON_SPI_SPCR_CPHA	BIT(2)
23 #define	LOONGSON_SPI_SPCR_CPOL	BIT(3)
24 #define	LOONGSON_SPI_SPCR_SPE	BIT(6)
25 #define	LOONGSON_SPI_SPSR_RFEMPTY	BIT(0)
26 #define	LOONGSON_SPI_SPSR_WCOL	BIT(6)
27 #define	LOONGSON_SPI_SPSR_SPIF	BIT(7)
28 
29 struct device;
30 struct spi_controller;
31 
32 struct loongson_spi {
33 	struct	spi_controller	*controller;
34 	void __iomem		*base;
35 	int			cs_active;
36 	unsigned int		hz;
37 	unsigned char		spcr;
38 	unsigned char		sper;
39 	unsigned char		spsr;
40 	unsigned char		para;
41 	unsigned char		sfcs;
42 	unsigned char		timi;
43 	unsigned int		mode;
44 	u64			clk_rate;
45 };
46 
47 int loongson_spi_init_controller(struct device *dev, void __iomem *reg);
48 extern const struct dev_pm_ops loongson_spi_dev_pm_ops;
49 #endif /* __LINUX_SPI_LOONGSON_H */
50