xref: /openbmc/u-boot/drivers/spi/sh_spi.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0 */
26639562eSYoshihiro Shimoda /*
36639562eSYoshihiro Shimoda  * SH SPI driver
46639562eSYoshihiro Shimoda  *
56639562eSYoshihiro Shimoda  * Copyright (C) 2011 Renesas Solutions Corp.
66639562eSYoshihiro Shimoda  */
76639562eSYoshihiro Shimoda 
86639562eSYoshihiro Shimoda #ifndef __SH_SPI_H__
96639562eSYoshihiro Shimoda #define __SH_SPI_H__
106639562eSYoshihiro Shimoda 
116639562eSYoshihiro Shimoda #include <spi.h>
126639562eSYoshihiro Shimoda 
136639562eSYoshihiro Shimoda struct sh_spi_regs {
146639562eSYoshihiro Shimoda 	unsigned long tbr_rbr;
156639562eSYoshihiro Shimoda 	unsigned long resv1;
166639562eSYoshihiro Shimoda 	unsigned long cr1;
176639562eSYoshihiro Shimoda 	unsigned long resv2;
186639562eSYoshihiro Shimoda 	unsigned long cr2;
196639562eSYoshihiro Shimoda 	unsigned long resv3;
206639562eSYoshihiro Shimoda 	unsigned long cr3;
216639562eSYoshihiro Shimoda 	unsigned long resv4;
226639562eSYoshihiro Shimoda 	unsigned long cr4;
236639562eSYoshihiro Shimoda };
246639562eSYoshihiro Shimoda 
256639562eSYoshihiro Shimoda /* CR1 */
266639562eSYoshihiro Shimoda #define SH_SPI_TBE	0x80
276639562eSYoshihiro Shimoda #define SH_SPI_TBF	0x40
286639562eSYoshihiro Shimoda #define SH_SPI_RBE	0x20
296639562eSYoshihiro Shimoda #define SH_SPI_RBF	0x10
306639562eSYoshihiro Shimoda #define SH_SPI_PFONRD	0x08
316639562eSYoshihiro Shimoda #define SH_SPI_SSDB	0x04
326639562eSYoshihiro Shimoda #define SH_SPI_SSD	0x02
336639562eSYoshihiro Shimoda #define SH_SPI_SSA	0x01
346639562eSYoshihiro Shimoda 
356639562eSYoshihiro Shimoda /* CR2 */
366639562eSYoshihiro Shimoda #define SH_SPI_RSTF	0x80
376639562eSYoshihiro Shimoda #define SH_SPI_LOOPBK	0x40
386639562eSYoshihiro Shimoda #define SH_SPI_CPOL	0x20
396639562eSYoshihiro Shimoda #define SH_SPI_CPHA	0x10
406639562eSYoshihiro Shimoda #define SH_SPI_L1M0	0x08
416639562eSYoshihiro Shimoda 
426639562eSYoshihiro Shimoda /* CR3 */
436639562eSYoshihiro Shimoda #define SH_SPI_MAX_BYTE	0xFF
446639562eSYoshihiro Shimoda 
456639562eSYoshihiro Shimoda /* CR4 */
466639562eSYoshihiro Shimoda #define SH_SPI_TBEI	0x80
476639562eSYoshihiro Shimoda #define SH_SPI_TBFI	0x40
486639562eSYoshihiro Shimoda #define SH_SPI_RBEI	0x20
496639562eSYoshihiro Shimoda #define SH_SPI_RBFI	0x10
50c1d4ad94SYoshihiro Shimoda #define SH_SPI_SSS1	0x08
516639562eSYoshihiro Shimoda #define SH_SPI_WPABRT	0x04
52c1d4ad94SYoshihiro Shimoda #define SH_SPI_SSS0	0x01
536639562eSYoshihiro Shimoda 
546639562eSYoshihiro Shimoda #define SH_SPI_FIFO_SIZE	32
55c1d4ad94SYoshihiro Shimoda #define SH_SPI_NUM_CS		4
566639562eSYoshihiro Shimoda 
576639562eSYoshihiro Shimoda struct sh_spi {
586639562eSYoshihiro Shimoda 	struct spi_slave	slave;
596639562eSYoshihiro Shimoda 	struct sh_spi_regs	*regs;
606639562eSYoshihiro Shimoda };
616639562eSYoshihiro Shimoda 
to_sh_spi(struct spi_slave * slave)626639562eSYoshihiro Shimoda static inline struct sh_spi *to_sh_spi(struct spi_slave *slave)
636639562eSYoshihiro Shimoda {
646639562eSYoshihiro Shimoda 	return container_of(slave, struct sh_spi, slave);
656639562eSYoshihiro Shimoda }
666639562eSYoshihiro Shimoda 
676639562eSYoshihiro Shimoda #endif
68