1 /* 2 * SH SPI driver 3 * 4 * Copyright (C) 2011 Renesas Solutions Corp. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; version 2 of the License. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef __SH_SPI_H__ 22 #define __SH_SPI_H__ 23 24 #include <spi.h> 25 26 struct sh_spi_regs { 27 unsigned long tbr_rbr; 28 unsigned long resv1; 29 unsigned long cr1; 30 unsigned long resv2; 31 unsigned long cr2; 32 unsigned long resv3; 33 unsigned long cr3; 34 unsigned long resv4; 35 unsigned long cr4; 36 }; 37 38 /* CR1 */ 39 #define SH_SPI_TBE 0x80 40 #define SH_SPI_TBF 0x40 41 #define SH_SPI_RBE 0x20 42 #define SH_SPI_RBF 0x10 43 #define SH_SPI_PFONRD 0x08 44 #define SH_SPI_SSDB 0x04 45 #define SH_SPI_SSD 0x02 46 #define SH_SPI_SSA 0x01 47 48 /* CR2 */ 49 #define SH_SPI_RSTF 0x80 50 #define SH_SPI_LOOPBK 0x40 51 #define SH_SPI_CPOL 0x20 52 #define SH_SPI_CPHA 0x10 53 #define SH_SPI_L1M0 0x08 54 55 /* CR3 */ 56 #define SH_SPI_MAX_BYTE 0xFF 57 58 /* CR4 */ 59 #define SH_SPI_TBEI 0x80 60 #define SH_SPI_TBFI 0x40 61 #define SH_SPI_RBEI 0x20 62 #define SH_SPI_RBFI 0x10 63 #define SH_SPI_SSS1 0x08 64 #define SH_SPI_WPABRT 0x04 65 #define SH_SPI_SSS0 0x01 66 67 #define SH_SPI_FIFO_SIZE 32 68 #define SH_SPI_NUM_CS 4 69 70 struct sh_spi { 71 struct spi_slave slave; 72 struct sh_spi_regs *regs; 73 }; 74 75 static inline struct sh_spi *to_sh_spi(struct spi_slave *slave) 76 { 77 return container_of(slave, struct sh_spi, slave); 78 } 79 80 #endif 81