sh_spi.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #ifndef __SH_SPI_H__
  21. #define __SH_SPI_H__
  22. #include <spi.h>
  23. struct sh_spi_regs {
  24. unsigned long tbr_rbr;
  25. unsigned long resv1;
  26. unsigned long cr1;
  27. unsigned long resv2;
  28. unsigned long cr2;
  29. unsigned long resv3;
  30. unsigned long cr3;
  31. unsigned long resv4;
  32. unsigned long cr4;
  33. };
  34. /* CR1 */
  35. #define SH_SPI_TBE 0x80
  36. #define SH_SPI_TBF 0x40
  37. #define SH_SPI_RBE 0x20
  38. #define SH_SPI_RBF 0x10
  39. #define SH_SPI_PFONRD 0x08
  40. #define SH_SPI_SSDB 0x04
  41. #define SH_SPI_SSD 0x02
  42. #define SH_SPI_SSA 0x01
  43. /* CR2 */
  44. #define SH_SPI_RSTF 0x80
  45. #define SH_SPI_LOOPBK 0x40
  46. #define SH_SPI_CPOL 0x20
  47. #define SH_SPI_CPHA 0x10
  48. #define SH_SPI_L1M0 0x08
  49. /* CR3 */
  50. #define SH_SPI_MAX_BYTE 0xFF
  51. /* CR4 */
  52. #define SH_SPI_TBEI 0x80
  53. #define SH_SPI_TBFI 0x40
  54. #define SH_SPI_RBEI 0x20
  55. #define SH_SPI_RBFI 0x10
  56. #define SH_SPI_WPABRT 0x04
  57. #define SH_SPI_SSS 0x01
  58. #define SH_SPI_FIFO_SIZE 32
  59. struct sh_spi {
  60. struct spi_slave slave;
  61. struct sh_spi_regs *regs;
  62. };
  63. static inline struct sh_spi *to_sh_spi(struct spi_slave *slave)
  64. {
  65. return container_of(slave, struct sh_spi, slave);
  66. }
  67. #endif