xilinx_spips.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. * QEMU model of the Xilinx Zynq SPI controller
  3. *
  4. * Copyright (c) 2012 Peter A. G. Crosthwaite
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #include "sysbus.h"
  25. #include "sysemu/sysemu.h"
  26. #include "ptimer.h"
  27. #include "qemu/log.h"
  28. #include "fifo.h"
  29. #include "ssi.h"
  30. #include "qemu/bitops.h"
  31. #ifdef XILINX_SPIPS_ERR_DEBUG
  32. #define DB_PRINT(...) do { \
  33. fprintf(stderr, ": %s: ", __func__); \
  34. fprintf(stderr, ## __VA_ARGS__); \
  35. } while (0);
  36. #else
  37. #define DB_PRINT(...)
  38. #endif
  39. /* config register */
  40. #define R_CONFIG (0x00 / 4)
  41. #define IFMODE (1 << 31)
  42. #define ENDIAN (1 << 26)
  43. #define MODEFAIL_GEN_EN (1 << 17)
  44. #define MAN_START_COM (1 << 16)
  45. #define MAN_START_EN (1 << 15)
  46. #define MANUAL_CS (1 << 14)
  47. #define CS (0xF << 10)
  48. #define CS_SHIFT (10)
  49. #define PERI_SEL (1 << 9)
  50. #define REF_CLK (1 << 8)
  51. #define FIFO_WIDTH (3 << 6)
  52. #define BAUD_RATE_DIV (7 << 3)
  53. #define CLK_PH (1 << 2)
  54. #define CLK_POL (1 << 1)
  55. #define MODE_SEL (1 << 0)
  56. /* interrupt mechanism */
  57. #define R_INTR_STATUS (0x04 / 4)
  58. #define R_INTR_EN (0x08 / 4)
  59. #define R_INTR_DIS (0x0C / 4)
  60. #define R_INTR_MASK (0x10 / 4)
  61. #define IXR_TX_FIFO_UNDERFLOW (1 << 6)
  62. #define IXR_RX_FIFO_FULL (1 << 5)
  63. #define IXR_RX_FIFO_NOT_EMPTY (1 << 4)
  64. #define IXR_TX_FIFO_FULL (1 << 3)
  65. #define IXR_TX_FIFO_NOT_FULL (1 << 2)
  66. #define IXR_TX_FIFO_MODE_FAIL (1 << 1)
  67. #define IXR_RX_FIFO_OVERFLOW (1 << 0)
  68. #define IXR_ALL ((IXR_TX_FIFO_UNDERFLOW<<1)-1)
  69. #define R_EN (0x14 / 4)
  70. #define R_DELAY (0x18 / 4)
  71. #define R_TX_DATA (0x1C / 4)
  72. #define R_RX_DATA (0x20 / 4)
  73. #define R_SLAVE_IDLE_COUNT (0x24 / 4)
  74. #define R_TX_THRES (0x28 / 4)
  75. #define R_RX_THRES (0x2C / 4)
  76. #define R_TXD1 (0x80 / 4)
  77. #define R_TXD2 (0x84 / 4)
  78. #define R_TXD3 (0x88 / 4)
  79. #define R_LQSPI_CFG (0xa0 / 4)
  80. #define R_LQSPI_CFG_RESET 0x03A002EB
  81. #define LQSPI_CFG_LQ_MODE (1 << 31)
  82. #define LQSPI_CFG_TWO_MEM (1 << 30)
  83. #define LQSPI_CFG_SEP_BUS (1 << 30)
  84. #define LQSPI_CFG_U_PAGE (1 << 28)
  85. #define LQSPI_CFG_MODE_EN (1 << 25)
  86. #define LQSPI_CFG_MODE_WIDTH 8
  87. #define LQSPI_CFG_MODE_SHIFT 16
  88. #define LQSPI_CFG_DUMMY_WIDTH 3
  89. #define LQSPI_CFG_DUMMY_SHIFT 8
  90. #define LQSPI_CFG_INST_CODE 0xFF
  91. #define R_LQSPI_STS (0xA4 / 4)
  92. #define LQSPI_STS_WR_RECVD (1 << 1)
  93. #define R_MOD_ID (0xFC / 4)
  94. #define R_MAX (R_MOD_ID+1)
  95. /* size of TXRX FIFOs */
  96. #define RXFF_A 32
  97. #define TXFF_A 32
  98. /* 16MB per linear region */
  99. #define LQSPI_ADDRESS_BITS 24
  100. /* Bite off 4k chunks at a time */
  101. #define LQSPI_CACHE_SIZE 1024
  102. #define SNOOP_CHECKING 0xFF
  103. #define SNOOP_NONE 0xFE
  104. #define SNOOP_STRIPING 0
  105. typedef struct {
  106. SysBusDevice busdev;
  107. MemoryRegion iomem;
  108. MemoryRegion mmlqspi;
  109. qemu_irq irq;
  110. int irqline;
  111. uint8_t num_cs;
  112. uint8_t num_busses;
  113. uint8_t snoop_state;
  114. qemu_irq *cs_lines;
  115. SSIBus **spi;
  116. Fifo8 rx_fifo;
  117. Fifo8 tx_fifo;
  118. uint8_t num_txrx_bytes;
  119. uint32_t regs[R_MAX];
  120. uint32_t lqspi_buf[LQSPI_CACHE_SIZE];
  121. hwaddr lqspi_cached_addr;
  122. } XilinxSPIPS;
  123. static inline int num_effective_busses(XilinxSPIPS *s)
  124. {
  125. return (s->regs[R_LQSPI_STS] & LQSPI_CFG_SEP_BUS &&
  126. s->regs[R_LQSPI_STS] & LQSPI_CFG_TWO_MEM) ? s->num_busses : 1;
  127. }
  128. static void xilinx_spips_update_cs_lines(XilinxSPIPS *s)
  129. {
  130. int i, j;
  131. bool found = false;
  132. int field = s->regs[R_CONFIG] >> CS_SHIFT;
  133. for (i = 0; i < s->num_cs; i++) {
  134. for (j = 0; j < num_effective_busses(s); j++) {
  135. int upage = !!(s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE);
  136. int cs_to_set = (j * s->num_cs + i + upage) %
  137. (s->num_cs * s->num_busses);
  138. if (~field & (1 << i) && !found) {
  139. DB_PRINT("selecting slave %d\n", i);
  140. qemu_set_irq(s->cs_lines[cs_to_set], 0);
  141. } else {
  142. qemu_set_irq(s->cs_lines[cs_to_set], 1);
  143. }
  144. }
  145. if (~field & (1 << i)) {
  146. found = true;
  147. }
  148. }
  149. if (!found) {
  150. s->snoop_state = SNOOP_CHECKING;
  151. }
  152. }
  153. static void xilinx_spips_update_ixr(XilinxSPIPS *s)
  154. {
  155. /* These are set/cleared as they occur */
  156. s->regs[R_INTR_STATUS] &= (IXR_TX_FIFO_UNDERFLOW | IXR_RX_FIFO_OVERFLOW |
  157. IXR_TX_FIFO_MODE_FAIL);
  158. /* these are pure functions of fifo state, set them here */
  159. s->regs[R_INTR_STATUS] |=
  160. (fifo8_is_full(&s->rx_fifo) ? IXR_RX_FIFO_FULL : 0) |
  161. (s->rx_fifo.num >= s->regs[R_RX_THRES] ? IXR_RX_FIFO_NOT_EMPTY : 0) |
  162. (fifo8_is_full(&s->tx_fifo) ? IXR_TX_FIFO_FULL : 0) |
  163. (s->tx_fifo.num < s->regs[R_TX_THRES] ? IXR_TX_FIFO_NOT_FULL : 0);
  164. /* drive external interrupt pin */
  165. int new_irqline = !!(s->regs[R_INTR_MASK] & s->regs[R_INTR_STATUS] &
  166. IXR_ALL);
  167. if (new_irqline != s->irqline) {
  168. s->irqline = new_irqline;
  169. qemu_set_irq(s->irq, s->irqline);
  170. }
  171. }
  172. static void xilinx_spips_reset(DeviceState *d)
  173. {
  174. XilinxSPIPS *s = DO_UPCAST(XilinxSPIPS, busdev.qdev, d);
  175. int i;
  176. for (i = 0; i < R_MAX; i++) {
  177. s->regs[i] = 0;
  178. }
  179. fifo8_reset(&s->rx_fifo);
  180. fifo8_reset(&s->rx_fifo);
  181. /* non zero resets */
  182. s->regs[R_CONFIG] |= MODEFAIL_GEN_EN;
  183. s->regs[R_SLAVE_IDLE_COUNT] = 0xFF;
  184. s->regs[R_TX_THRES] = 1;
  185. s->regs[R_RX_THRES] = 1;
  186. /* FIXME: move magic number definition somewhere sensible */
  187. s->regs[R_MOD_ID] = 0x01090106;
  188. s->regs[R_LQSPI_CFG] = R_LQSPI_CFG_RESET;
  189. s->snoop_state = SNOOP_CHECKING;
  190. xilinx_spips_update_ixr(s);
  191. xilinx_spips_update_cs_lines(s);
  192. }
  193. static void xilinx_spips_flush_txfifo(XilinxSPIPS *s)
  194. {
  195. for (;;) {
  196. int i;
  197. uint8_t rx;
  198. uint8_t tx = 0;
  199. for (i = 0; i < num_effective_busses(s); ++i) {
  200. if (!i || s->snoop_state == SNOOP_STRIPING) {
  201. if (fifo8_is_empty(&s->tx_fifo)) {
  202. s->regs[R_INTR_STATUS] |= IXR_TX_FIFO_UNDERFLOW;
  203. xilinx_spips_update_ixr(s);
  204. return;
  205. } else {
  206. tx = fifo8_pop(&s->tx_fifo);
  207. }
  208. }
  209. rx = ssi_transfer(s->spi[i], (uint32_t)tx);
  210. DB_PRINT("tx = %02x rx = %02x\n", tx, rx);
  211. if (!i || s->snoop_state == SNOOP_STRIPING) {
  212. if (fifo8_is_full(&s->rx_fifo)) {
  213. s->regs[R_INTR_STATUS] |= IXR_RX_FIFO_OVERFLOW;
  214. DB_PRINT("rx FIFO overflow");
  215. } else {
  216. fifo8_push(&s->rx_fifo, (uint8_t)rx);
  217. }
  218. }
  219. }
  220. switch (s->snoop_state) {
  221. case (SNOOP_CHECKING):
  222. switch (tx) { /* new instruction code */
  223. case 0x0b: /* dual/quad output read DOR/QOR */
  224. case 0x6b:
  225. s->snoop_state = 4;
  226. break;
  227. /* FIXME: these vary between vendor - set to spansion */
  228. case 0xbb: /* high performance dual read DIOR */
  229. s->snoop_state = 4;
  230. break;
  231. case 0xeb: /* high performance quad read QIOR */
  232. s->snoop_state = 6;
  233. break;
  234. default:
  235. s->snoop_state = SNOOP_NONE;
  236. }
  237. break;
  238. case (SNOOP_STRIPING):
  239. case (SNOOP_NONE):
  240. break;
  241. default:
  242. s->snoop_state--;
  243. }
  244. }
  245. }
  246. static inline void rx_data_bytes(XilinxSPIPS *s, uint32_t *value, int max)
  247. {
  248. int i;
  249. *value = 0;
  250. for (i = 0; i < max && !fifo8_is_empty(&s->rx_fifo); ++i) {
  251. uint32_t next = fifo8_pop(&s->rx_fifo) & 0xFF;
  252. *value |= next << 8 * (s->regs[R_CONFIG] & ENDIAN ? 3-i : i);
  253. }
  254. }
  255. static uint64_t xilinx_spips_read(void *opaque, hwaddr addr,
  256. unsigned size)
  257. {
  258. XilinxSPIPS *s = opaque;
  259. uint32_t mask = ~0;
  260. uint32_t ret;
  261. addr >>= 2;
  262. switch (addr) {
  263. case R_CONFIG:
  264. mask = 0x0002FFFF;
  265. break;
  266. case R_INTR_STATUS:
  267. case R_INTR_MASK:
  268. mask = IXR_ALL;
  269. break;
  270. case R_EN:
  271. mask = 0x1;
  272. break;
  273. case R_SLAVE_IDLE_COUNT:
  274. mask = 0xFF;
  275. break;
  276. case R_MOD_ID:
  277. mask = 0x01FFFFFF;
  278. break;
  279. case R_INTR_EN:
  280. case R_INTR_DIS:
  281. case R_TX_DATA:
  282. mask = 0;
  283. break;
  284. case R_RX_DATA:
  285. rx_data_bytes(s, &ret, s->num_txrx_bytes);
  286. DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, ret);
  287. xilinx_spips_update_ixr(s);
  288. return ret;
  289. }
  290. DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr * 4, s->regs[addr] & mask);
  291. return s->regs[addr] & mask;
  292. }
  293. static inline void tx_data_bytes(XilinxSPIPS *s, uint32_t value, int num)
  294. {
  295. int i;
  296. for (i = 0; i < num && !fifo8_is_full(&s->tx_fifo); ++i) {
  297. if (s->regs[R_CONFIG] & ENDIAN) {
  298. fifo8_push(&s->tx_fifo, (uint8_t)(value >> 24));
  299. value <<= 8;
  300. } else {
  301. fifo8_push(&s->tx_fifo, (uint8_t)value);
  302. value >>= 8;
  303. }
  304. }
  305. }
  306. static void xilinx_spips_write(void *opaque, hwaddr addr,
  307. uint64_t value, unsigned size)
  308. {
  309. int mask = ~0;
  310. int man_start_com = 0;
  311. XilinxSPIPS *s = opaque;
  312. DB_PRINT("addr=" TARGET_FMT_plx " = %x\n", addr, (unsigned)value);
  313. addr >>= 2;
  314. switch (addr) {
  315. case R_CONFIG:
  316. mask = 0x0002FFFF;
  317. if (value & MAN_START_COM) {
  318. man_start_com = 1;
  319. }
  320. break;
  321. case R_INTR_STATUS:
  322. mask = IXR_ALL;
  323. s->regs[R_INTR_STATUS] &= ~(mask & value);
  324. goto no_reg_update;
  325. case R_INTR_DIS:
  326. mask = IXR_ALL;
  327. s->regs[R_INTR_MASK] &= ~(mask & value);
  328. goto no_reg_update;
  329. case R_INTR_EN:
  330. mask = IXR_ALL;
  331. s->regs[R_INTR_MASK] |= mask & value;
  332. goto no_reg_update;
  333. case R_EN:
  334. mask = 0x1;
  335. break;
  336. case R_SLAVE_IDLE_COUNT:
  337. mask = 0xFF;
  338. break;
  339. case R_RX_DATA:
  340. case R_INTR_MASK:
  341. case R_MOD_ID:
  342. mask = 0;
  343. break;
  344. case R_TX_DATA:
  345. tx_data_bytes(s, (uint32_t)value, s->num_txrx_bytes);
  346. goto no_reg_update;
  347. case R_TXD1:
  348. tx_data_bytes(s, (uint32_t)value, 1);
  349. goto no_reg_update;
  350. case R_TXD2:
  351. tx_data_bytes(s, (uint32_t)value, 2);
  352. goto no_reg_update;
  353. case R_TXD3:
  354. tx_data_bytes(s, (uint32_t)value, 3);
  355. goto no_reg_update;
  356. }
  357. s->regs[addr] = (s->regs[addr] & ~mask) | (value & mask);
  358. no_reg_update:
  359. if (man_start_com) {
  360. xilinx_spips_flush_txfifo(s);
  361. }
  362. xilinx_spips_update_ixr(s);
  363. xilinx_spips_update_cs_lines(s);
  364. }
  365. static const MemoryRegionOps spips_ops = {
  366. .read = xilinx_spips_read,
  367. .write = xilinx_spips_write,
  368. .endianness = DEVICE_LITTLE_ENDIAN,
  369. };
  370. #define LQSPI_CACHE_SIZE 1024
  371. static uint64_t
  372. lqspi_read(void *opaque, hwaddr addr, unsigned int size)
  373. {
  374. int i;
  375. XilinxSPIPS *s = opaque;
  376. if (addr >= s->lqspi_cached_addr &&
  377. addr <= s->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) {
  378. return s->lqspi_buf[(addr - s->lqspi_cached_addr) >> 2];
  379. } else {
  380. int flash_addr = (addr / num_effective_busses(s));
  381. int slave = flash_addr >> LQSPI_ADDRESS_BITS;
  382. int cache_entry = 0;
  383. DB_PRINT("config reg status: %08x\n", s->regs[R_LQSPI_CFG]);
  384. fifo8_reset(&s->tx_fifo);
  385. fifo8_reset(&s->rx_fifo);
  386. s->regs[R_CONFIG] &= ~CS;
  387. s->regs[R_CONFIG] |= (~(1 << slave) << CS_SHIFT) & CS;
  388. xilinx_spips_update_cs_lines(s);
  389. /* instruction */
  390. DB_PRINT("pushing read instruction: %02x\n",
  391. (uint8_t)(s->regs[R_LQSPI_CFG] & LQSPI_CFG_INST_CODE));
  392. fifo8_push(&s->tx_fifo, s->regs[R_LQSPI_CFG] & LQSPI_CFG_INST_CODE);
  393. /* read address */
  394. DB_PRINT("pushing read address %06x\n", flash_addr);
  395. fifo8_push(&s->tx_fifo, (uint8_t)(flash_addr >> 16));
  396. fifo8_push(&s->tx_fifo, (uint8_t)(flash_addr >> 8));
  397. fifo8_push(&s->tx_fifo, (uint8_t)flash_addr);
  398. /* mode bits */
  399. if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_MODE_EN) {
  400. fifo8_push(&s->tx_fifo, extract32(s->regs[R_LQSPI_CFG],
  401. LQSPI_CFG_MODE_SHIFT,
  402. LQSPI_CFG_MODE_WIDTH));
  403. }
  404. /* dummy bytes */
  405. for (i = 0; i < (extract32(s->regs[R_LQSPI_CFG], LQSPI_CFG_DUMMY_SHIFT,
  406. LQSPI_CFG_DUMMY_WIDTH)); ++i) {
  407. DB_PRINT("pushing dummy byte\n");
  408. fifo8_push(&s->tx_fifo, 0);
  409. }
  410. xilinx_spips_flush_txfifo(s);
  411. fifo8_reset(&s->rx_fifo);
  412. DB_PRINT("starting QSPI data read\n");
  413. for (i = 0; i < LQSPI_CACHE_SIZE / 4; ++i) {
  414. tx_data_bytes(s, 0, 4);
  415. xilinx_spips_flush_txfifo(s);
  416. rx_data_bytes(s, &s->lqspi_buf[cache_entry], 4);
  417. cache_entry++;
  418. }
  419. s->regs[R_CONFIG] |= CS;
  420. xilinx_spips_update_cs_lines(s);
  421. s->lqspi_cached_addr = addr;
  422. return lqspi_read(opaque, addr, size);
  423. }
  424. }
  425. static const MemoryRegionOps lqspi_ops = {
  426. .read = lqspi_read,
  427. .endianness = DEVICE_NATIVE_ENDIAN,
  428. .valid = {
  429. .min_access_size = 4,
  430. .max_access_size = 4
  431. }
  432. };
  433. static int xilinx_spips_init(SysBusDevice *dev)
  434. {
  435. XilinxSPIPS *s = FROM_SYSBUS(typeof(*s), dev);
  436. int i;
  437. DB_PRINT("inited device model\n");
  438. s->spi = g_new(SSIBus *, s->num_busses);
  439. for (i = 0; i < s->num_busses; ++i) {
  440. char bus_name[16];
  441. snprintf(bus_name, 16, "spi%d", i);
  442. s->spi[i] = ssi_create_bus(&dev->qdev, bus_name);
  443. }
  444. s->cs_lines = g_new(qemu_irq, s->num_cs * s->num_busses);
  445. ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[0]);
  446. ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi[1]);
  447. sysbus_init_irq(dev, &s->irq);
  448. for (i = 0; i < s->num_cs * s->num_busses; ++i) {
  449. sysbus_init_irq(dev, &s->cs_lines[i]);
  450. }
  451. memory_region_init_io(&s->iomem, &spips_ops, s, "spi", R_MAX*4);
  452. sysbus_init_mmio(dev, &s->iomem);
  453. memory_region_init_io(&s->mmlqspi, &lqspi_ops, s, "lqspi",
  454. (1 << LQSPI_ADDRESS_BITS) * 2);
  455. sysbus_init_mmio(dev, &s->mmlqspi);
  456. s->irqline = -1;
  457. s->lqspi_cached_addr = ~0ULL;
  458. fifo8_create(&s->rx_fifo, RXFF_A);
  459. fifo8_create(&s->tx_fifo, TXFF_A);
  460. return 0;
  461. }
  462. static int xilinx_spips_post_load(void *opaque, int version_id)
  463. {
  464. xilinx_spips_update_ixr((XilinxSPIPS *)opaque);
  465. xilinx_spips_update_cs_lines((XilinxSPIPS *)opaque);
  466. return 0;
  467. }
  468. static const VMStateDescription vmstate_xilinx_spips = {
  469. .name = "xilinx_spips",
  470. .version_id = 2,
  471. .minimum_version_id = 2,
  472. .minimum_version_id_old = 2,
  473. .post_load = xilinx_spips_post_load,
  474. .fields = (VMStateField[]) {
  475. VMSTATE_FIFO8(tx_fifo, XilinxSPIPS),
  476. VMSTATE_FIFO8(rx_fifo, XilinxSPIPS),
  477. VMSTATE_UINT32_ARRAY(regs, XilinxSPIPS, R_MAX),
  478. VMSTATE_UINT8(snoop_state, XilinxSPIPS),
  479. VMSTATE_END_OF_LIST()
  480. }
  481. };
  482. static Property xilinx_spips_properties[] = {
  483. DEFINE_PROP_UINT8("num-busses", XilinxSPIPS, num_busses, 1),
  484. DEFINE_PROP_UINT8("num-ss-bits", XilinxSPIPS, num_cs, 4),
  485. DEFINE_PROP_UINT8("num-txrx-bytes", XilinxSPIPS, num_txrx_bytes, 1),
  486. DEFINE_PROP_END_OF_LIST(),
  487. };
  488. static void xilinx_spips_class_init(ObjectClass *klass, void *data)
  489. {
  490. DeviceClass *dc = DEVICE_CLASS(klass);
  491. SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
  492. sdc->init = xilinx_spips_init;
  493. dc->reset = xilinx_spips_reset;
  494. dc->props = xilinx_spips_properties;
  495. dc->vmsd = &vmstate_xilinx_spips;
  496. }
  497. static const TypeInfo xilinx_spips_info = {
  498. .name = "xilinx,spips",
  499. .parent = TYPE_SYS_BUS_DEVICE,
  500. .instance_size = sizeof(XilinxSPIPS),
  501. .class_init = xilinx_spips_class_init,
  502. };
  503. static void xilinx_spips_register_types(void)
  504. {
  505. type_register_static(&xilinx_spips_info);
  506. }
  507. type_init(xilinx_spips_register_types)