Lines Matching full:rs

48 static void mt7621_spi_reset(struct mt7621_spi *rs, int duplex)  in mt7621_spi_reset()  argument
50 setbits_le32(rs->base + MT7621_SPI_MASTER, in mt7621_spi_reset()
54 static void mt7621_spi_set_cs(struct mt7621_spi *rs, int cs, int enable) in mt7621_spi_set_cs() argument
61 iowrite32(val, rs->base + MT7621_SPI_POLAR); in mt7621_spi_set_cs()
66 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_set_mode() local
70 reg = ioread32(rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_mode()
90 iowrite32(reg, rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_mode()
97 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_set_speed() local
102 rate = DIV_ROUND_UP(rs->sys_freq, speed); in mt7621_spi_set_speed()
111 reg = ioread32(rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_speed()
114 iowrite32(reg, rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_speed()
119 static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) in mt7621_spi_wait_till_ready() argument
123 ret = wait_for_bit_le32(rs->base + MT7621_SPI_TRANS, in mt7621_spi_wait_till_ready()
135 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_xfer() local
165 mt7621_spi_wait_till_ready(rs); in mt7621_spi_xfer()
172 mt7621_spi_set_cs(rs, spi_chip_select(dev), 1); in mt7621_spi_xfer()
183 if (rs->tx_len > 4) in mt7621_spi_xfer()
184 chunk_size -= rs->tx_len; in mt7621_spi_xfer()
190 if ((chunk_size + rs->tx_len) > SPI_MSG_SIZE_OVERALL) { in mt7621_spi_xfer()
192 chunk_size + rs->tx_len); in mt7621_spi_xfer()
201 for (i = 0; i < chunk_size; i++, rs->tx_len++) { in mt7621_spi_xfer()
202 rs->data[rs->tx_len / 4] |= in mt7621_spi_xfer()
203 tx_buf[i] << (8 * (rs->tx_len & 3)); in mt7621_spi_xfer()
209 if (rs->tx_len) { in mt7621_spi_xfer()
210 rs->data[0] = swab32(rs->data[0]); in mt7621_spi_xfer()
211 if (rs->tx_len < 4) in mt7621_spi_xfer()
212 rs->data[0] >>= (4 - rs->tx_len) * 8; in mt7621_spi_xfer()
214 for (i = 0; i < rs->tx_len; i += 4) { in mt7621_spi_xfer()
215 iowrite32(rs->data[i / 4], rs->base + in mt7621_spi_xfer()
221 val = (min_t(int, rs->tx_len, 4) * 8) << 24; in mt7621_spi_xfer()
222 if (rs->tx_len > 4) in mt7621_spi_xfer()
223 val |= (rs->tx_len - 4) * 8; in mt7621_spi_xfer()
225 iowrite32(val, rs->base + MT7621_SPI_MOREBUF); in mt7621_spi_xfer()
228 setbits_le32(rs->base + MT7621_SPI_TRANS, in mt7621_spi_xfer()
232 mt7621_spi_wait_till_ready(rs); in mt7621_spi_xfer()
235 rs->tx_len = 0; in mt7621_spi_xfer()
236 memset(rs->data, 0, sizeof(rs->data)); in mt7621_spi_xfer()
240 data[i / 4] = ioread32(rs->base + MT7621_SPI_DATA0 + i); in mt7621_spi_xfer()
259 mt7621_spi_wait_till_ready(rs); in mt7621_spi_xfer()
261 mt7621_spi_set_cs(rs, spi_chip_select(dev), 0); in mt7621_spi_xfer()
268 struct mt7621_spi *rs = dev_get_priv(dev); in mt7621_spi_probe() local
270 rs->base = dev_remap_addr(dev); in mt7621_spi_probe()
271 if (!rs->base) in mt7621_spi_probe()
279 rs->sys_freq = dev_read_u32_default(dev, "clock-frequency", 0); in mt7621_spi_probe()
280 if (!rs->sys_freq) { in mt7621_spi_probe()
285 mt7621_spi_reset(rs, 0); in mt7621_spi_probe()