Changeset 415 for trunk/softs/tsar_boot/src/spi.c
- Timestamp:
- Jun 18, 2013, 10:25:15 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/tsar_boot/src/spi.c
r398 r415 92 92 93 93 _spi_wait_if_busy(spi); 94 94 95 /* switch to 128 bits words */ 95 96 spi_ctrl0 = ioread32(&spi->ctrl); … … 99 100 /* read data */ 100 101 for (i = 0; i + 3 < count / 4; i += 4) { 101 iowrite32(&spi->rx_tx[0], 0xffffffff); 102 iowrite32(&spi->rx_tx[1], 0xffffffff); 103 iowrite32(&spi->rx_tx[2], 0xffffffff); 104 iowrite32(&spi->rx_tx[3], 0xffffffff); 105 iowrite32(&spi->ctrl, spi_ctrl | SPI_CTRL_GO_BSY); 102 iowrite32(&spi->rx_tx[0], 0xffffffff); 103 iowrite32(&spi->rx_tx[1], 0xffffffff); 104 iowrite32(&spi->rx_tx[2], 0xffffffff); 105 iowrite32(&spi->rx_tx[3], 0xffffffff); 106 iowrite32(&spi->ctrl, spi_ctrl | SPI_CTRL_GO_BSY); 107 106 108 _spi_wait_if_busy(spi); 107 *data = bswap32(ioread32(&spi->rx_tx[3])); 108 data++; 109 *data = bswap32(ioread32(&spi->rx_tx[2])); 110 data++; 111 *data = bswap32(ioread32(&spi->rx_tx[1])); 112 data++; 113 *data = bswap32(ioread32(&spi->rx_tx[0])); 114 data++; 109 110 *data = bswap32(ioread32(&spi->rx_tx[3])); 111 data++; 112 *data = bswap32(ioread32(&spi->rx_tx[2])); 113 data++; 114 *data = bswap32(ioread32(&spi->rx_tx[1])); 115 data++; 116 *data = bswap32(ioread32(&spi->rx_tx[0])); 117 data++; 115 118 } 119 116 120 /* switch back to original word size */ 117 121 iowrite32(&spi->ctrl, spi_ctrl0); 122 118 123 /* read missing bits */ 119 124 data8 = (void *)data; 120 125 i = i * 4; 121 for (; i < count; i++) { 122 iowrite32(&spi->rx_tx[0], 0xffffffff); 123 iowrite32(&spi->ctrl, spi_ctrl0 | SPI_CTRL_GO_BSY); 124 _spi_wait_if_busy(spi); 125 *data8 = spi_get_rx(spi, 0); 126 data8++; 126 for (; i < count; i++) 127 { 128 iowrite32(&spi->rx_tx[0], 0xffffffff); 129 iowrite32(&spi->ctrl, spi_ctrl0 | SPI_CTRL_GO_BSY); 130 131 _spi_wait_if_busy(spi); 132 133 *data8 = spi_get_rx(spi, 0); 134 data8++; 127 135 } 128 136 return; … … 145 153 void spi_dev_config ( 146 154 struct spi_dev * spi, 147 int spi_freq 155 int spi_freq , 148 156 int sys_freq , 149 int char_len 150 int tx_edge 151 int rx_edge 157 int char_len , 158 int tx_edge , 159 int rx_edge ) 152 160 { 153 161 unsigned int spi_ctrl = ioread32(&spi->ctrl);
Note: See TracChangeset
for help on using the changeset viewer.