ich.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but without any warranty; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. *
  22. * This file is derived from the flashrom project.
  23. */
  24. struct ich7_spi_regs {
  25. uint16_t spis;
  26. uint16_t spic;
  27. uint32_t spia;
  28. uint64_t spid[8];
  29. uint64_t _pad;
  30. uint32_t bbar;
  31. uint16_t preop;
  32. uint16_t optype;
  33. uint8_t opmenu[8];
  34. } __packed;
  35. struct ich9_spi_regs {
  36. uint32_t bfpr; /* 0x00 */
  37. uint16_t hsfs;
  38. uint16_t hsfc;
  39. uint32_t faddr;
  40. uint32_t _reserved0;
  41. uint32_t fdata[16]; /* 0x10 */
  42. uint32_t frap; /* 0x50 */
  43. uint32_t freg[5];
  44. uint32_t _reserved1[3];
  45. uint32_t pr[5]; /* 0x74 */
  46. uint32_t _reserved2[2];
  47. uint8_t ssfs; /* 0x90 */
  48. uint8_t ssfc[3];
  49. uint16_t preop; /* 0x94 */
  50. uint16_t optype;
  51. uint8_t opmenu[8]; /* 0x98 */
  52. uint32_t bbar;
  53. uint8_t _reserved3[12];
  54. uint32_t fdoc;
  55. uint32_t fdod;
  56. uint8_t _reserved4[8];
  57. uint32_t afc;
  58. uint32_t lvscc;
  59. uint32_t uvscc;
  60. uint8_t _reserved5[4];
  61. uint32_t fpb;
  62. uint8_t _reserved6[28];
  63. uint32_t srdl;
  64. uint32_t srdc;
  65. uint32_t srd;
  66. } __packed;
  67. enum {
  68. SPIS_SCIP = 0x0001,
  69. SPIS_GRANT = 0x0002,
  70. SPIS_CDS = 0x0004,
  71. SPIS_FCERR = 0x0008,
  72. SSFS_AEL = 0x0010,
  73. SPIS_LOCK = 0x8000,
  74. SPIS_RESERVED_MASK = 0x7ff0,
  75. SSFS_RESERVED_MASK = 0x7fe2
  76. };
  77. enum {
  78. SPIC_SCGO = 0x000002,
  79. SPIC_ACS = 0x000004,
  80. SPIC_SPOP = 0x000008,
  81. SPIC_DBC = 0x003f00,
  82. SPIC_DS = 0x004000,
  83. SPIC_SME = 0x008000,
  84. SSFC_SCF_MASK = 0x070000,
  85. SSFC_RESERVED = 0xf80000,
  86. /* Mask for speed byte, biuts 23:16 of SSFC */
  87. SSFC_SCF_33MHZ = 0x01,
  88. };
  89. enum {
  90. HSFS_FDONE = 0x0001,
  91. HSFS_FCERR = 0x0002,
  92. HSFS_AEL = 0x0004,
  93. HSFS_BERASE_MASK = 0x0018,
  94. HSFS_BERASE_SHIFT = 3,
  95. HSFS_SCIP = 0x0020,
  96. HSFS_FDOPSS = 0x2000,
  97. HSFS_FDV = 0x4000,
  98. HSFS_FLOCKDN = 0x8000
  99. };
  100. enum {
  101. HSFC_FGO = 0x0001,
  102. HSFC_FCYCLE_MASK = 0x0006,
  103. HSFC_FCYCLE_SHIFT = 1,
  104. HSFC_FDBC_MASK = 0x3f00,
  105. HSFC_FDBC_SHIFT = 8,
  106. HSFC_FSMIE = 0x8000
  107. };
  108. enum {
  109. SPI_OPCODE_TYPE_READ_NO_ADDRESS = 0,
  110. SPI_OPCODE_TYPE_WRITE_NO_ADDRESS = 1,
  111. SPI_OPCODE_TYPE_READ_WITH_ADDRESS = 2,
  112. SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS = 3
  113. };
  114. enum {
  115. ICH_MAX_CMD_LEN = 5,
  116. };
  117. struct spi_trans {
  118. uint8_t cmd[ICH_MAX_CMD_LEN];
  119. int cmd_len;
  120. const uint8_t *out;
  121. uint32_t bytesout;
  122. uint8_t *in;
  123. uint32_t bytesin;
  124. uint8_t type;
  125. uint8_t opcode;
  126. uint32_t offset;
  127. };
  128. struct ich_spi_slave {
  129. struct spi_slave slave;
  130. struct spi_trans trans; /* current transaction in progress */
  131. int speed; /* SPI speed in Hz */
  132. };