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