Lines Matching +full:cs +full:- +full:to +full:- +full:clk

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
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:
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 if (s->cs & BCM2835_SPI_CS_INTD && s->cs & BCM2835_SPI_CS_DONE) { in bcm2835_spi_update_int()
41 if (s->cs & BCM2835_SPI_CS_INTR && s->cs & BCM2835_SPI_CS_RXR) { in bcm2835_spi_update_int()
44 qemu_set_irq(s->irq, do_interrupt); in bcm2835_spi_update_int()
50 if (!fifo8_is_empty(&s->rx_fifo)) { in bcm2835_spi_update_rx_flags()
51 s->cs |= BCM2835_SPI_CS_RXD; in bcm2835_spi_update_rx_flags()
53 s->cs &= ~BCM2835_SPI_CS_RXD; in bcm2835_spi_update_rx_flags()
57 if (fifo8_is_full(&s->rx_fifo)) { in bcm2835_spi_update_rx_flags()
58 s->cs |= BCM2835_SPI_CS_RXF; in bcm2835_spi_update_rx_flags()
60 s->cs &= ~BCM2835_SPI_CS_RXF; in bcm2835_spi_update_rx_flags()
64 if (fifo8_num_used(&s->rx_fifo) >= FIFO_SIZE_3_4) { in bcm2835_spi_update_rx_flags()
65 s->cs |= BCM2835_SPI_CS_RXR; in bcm2835_spi_update_rx_flags()
67 s->cs &= ~BCM2835_SPI_CS_RXR; in bcm2835_spi_update_rx_flags()
74 if (fifo8_is_full(&s->tx_fifo)) { in bcm2835_spi_update_tx_flags()
75 s->cs &= ~BCM2835_SPI_CS_TXD; in bcm2835_spi_update_tx_flags()
77 s->cs |= BCM2835_SPI_CS_TXD; in bcm2835_spi_update_tx_flags()
81 if (fifo8_is_empty(&s->tx_fifo) && s->cs & BCM2835_SPI_CS_TA) { in bcm2835_spi_update_tx_flags()
82 s->cs |= BCM2835_SPI_CS_DONE; in bcm2835_spi_update_tx_flags()
84 s->cs &= ~BCM2835_SPI_CS_DONE; in bcm2835_spi_update_tx_flags()
92 while (!fifo8_is_empty(&s->tx_fifo) && !fifo8_is_full(&s->rx_fifo)) { in bcm2835_spi_flush_tx_fifo()
93 tx_byte = fifo8_pop(&s->tx_fifo); in bcm2835_spi_flush_tx_fifo()
94 rx_byte = ssi_transfer(s->bus, tx_byte); in bcm2835_spi_flush_tx_fifo()
95 fifo8_push(&s->rx_fifo, rx_byte); in bcm2835_spi_flush_tx_fifo()
109 readval = s->cs & 0xffffffff; in bcm2835_spi_read()
113 if (s->cs & BCM2835_SPI_CS_RXD) { in bcm2835_spi_read()
114 readval = fifo8_pop(&s->rx_fifo); in bcm2835_spi_read()
121 readval = s->clk & 0xffff; in bcm2835_spi_read()
124 readval = s->dlen & 0xffff; in bcm2835_spi_read()
127 readval = s->ltoh & 0xf; in bcm2835_spi_read()
130 readval = s->dc & 0xffffffff; in bcm2835_spi_read()
146 s->cs = (value & ~RO_MASK) | (s->cs & RO_MASK); in bcm2835_spi_write()
147 if (!(s->cs & BCM2835_SPI_CS_TA)) { in bcm2835_spi_write()
149 s->cs &= ~(BCM2835_SPI_CS_DONE); in bcm2835_spi_write()
150 s->cs &= ~(BCM2835_SPI_CS_RXR); in bcm2835_spi_write()
154 if (s->cs & BCM2835_SPI_CLEAR_RX) { in bcm2835_spi_write()
155 fifo8_reset(&s->rx_fifo); in bcm2835_spi_write()
160 if (s->cs & BCM2835_SPI_CLEAR_TX) { in bcm2835_spi_write()
161 fifo8_reset(&s->tx_fifo); in bcm2835_spi_write()
166 if (s->cs & BCM2835_SPI_CS_TA) { in bcm2835_spi_write()
170 if (s->cs & BCM2835_SPI_CS_DMAEN) { in bcm2835_spi_write()
175 if (s->cs & BCM2835_SPI_CS_LEN) { in bcm2835_spi_write()
184 * According to documentation, writes to FIFO without TA controls in bcm2835_spi_write()
185 * CS and DLEN registers. This is supposed to be used in DMA mode in bcm2835_spi_write()
187 * use of this and directly modifies the CS and DLEN registers. in bcm2835_spi_write()
189 if (s->cs & BCM2835_SPI_CS_TA) { in bcm2835_spi_write()
190 if (s->cs & BCM2835_SPI_CS_TXD) { in bcm2835_spi_write()
191 fifo8_push(&s->tx_fifo, value & 0xff); in bcm2835_spi_write()
200 s->clk = value & 0xffff; in bcm2835_spi_write()
203 s->dlen = value & 0xffff; in bcm2835_spi_write()
206 s->ltoh = value & 0xf; in bcm2835_spi_write()
209 s->dc = value & 0xffffffff; in bcm2835_spi_write()
226 s->bus = ssi_create_bus(dev, "spi"); in bcm2835_spi_realize()
228 memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_spi_ops, s, in bcm2835_spi_realize()
230 sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); in bcm2835_spi_realize()
231 sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); in bcm2835_spi_realize()
233 fifo8_create(&s->tx_fifo, FIFO_SIZE); in bcm2835_spi_realize()
234 fifo8_create(&s->rx_fifo, FIFO_SIZE); in bcm2835_spi_realize()
240 fifo8_reset(&s->tx_fifo); in bcm2835_spi_reset()
241 fifo8_reset(&s->rx_fifo); in bcm2835_spi_reset()
243 /* Reset values according to BCM2835 Peripheral Documentation */ in bcm2835_spi_reset()
244 s->cs = BCM2835_SPI_CS_TXD | BCM2835_SPI_CS_REN; in bcm2835_spi_reset()
245 s->clk = 0; in bcm2835_spi_reset()
246 s->dlen = 0; in bcm2835_spi_reset()
247 s->ltoh = 0x1; in bcm2835_spi_reset()
248 s->dc = 0x30201020; in bcm2835_spi_reset()
258 VMSTATE_UINT32(cs, BCM2835SPIState),
259 VMSTATE_UINT32(clk, BCM2835SPIState),
272 dc->realize = bcm2835_spi_realize; in bcm2835_spi_class_init()
273 dc->vmsd = &vmstate_bcm2835_spi; in bcm2835_spi_class_init()