Lines Matching refs:rs
68 static inline u32 mt7621_spi_read(struct mt7621_spi *rs, u32 reg) in mt7621_spi_read() argument
70 return ioread32(rs->base + reg); in mt7621_spi_read()
73 static inline void mt7621_spi_write(struct mt7621_spi *rs, u32 reg, u32 val) in mt7621_spi_write() argument
75 iowrite32(val, rs->base + reg); in mt7621_spi_write()
80 struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); in mt7621_spi_set_cs() local
90 master = mt7621_spi_read(rs, MT7621_SPI_MASTER); in mt7621_spi_set_cs()
93 mt7621_spi_write(rs, MT7621_SPI_MASTER, master); in mt7621_spi_set_cs()
95 rs->pending_write = 0; in mt7621_spi_set_cs()
99 mt7621_spi_write(rs, MT7621_SPI_POLAR, polar); in mt7621_spi_set_cs()
104 struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); in mt7621_spi_prepare() local
110 rate = DIV_ROUND_UP(rs->sys_freq, speed); in mt7621_spi_prepare()
119 reg = mt7621_spi_read(rs, MT7621_SPI_MASTER); in mt7621_spi_prepare()
122 rs->speed = speed; in mt7621_spi_prepare()
135 mt7621_spi_write(rs, MT7621_SPI_MASTER, reg); in mt7621_spi_prepare()
140 static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) in mt7621_spi_wait_till_ready() argument
147 status = mt7621_spi_read(rs, MT7621_SPI_TRANS); in mt7621_spi_wait_till_ready()
157 static void mt7621_spi_read_half_duplex(struct mt7621_spi *rs, in mt7621_spi_read_half_duplex() argument
167 tx_len = rs->pending_write; in mt7621_spi_read_half_duplex()
168 rs->pending_write = 0; in mt7621_spi_read_half_duplex()
178 mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val); in mt7621_spi_read_half_duplex()
182 val = mt7621_spi_read(rs, MT7621_SPI_TRANS); in mt7621_spi_read_half_duplex()
184 mt7621_spi_write(rs, MT7621_SPI_TRANS, val); in mt7621_spi_read_half_duplex()
186 mt7621_spi_wait_till_ready(rs); in mt7621_spi_read_half_duplex()
190 val = mt7621_spi_read(rs, MT7621_SPI_DATA0 + i); in mt7621_spi_read_half_duplex()
199 static inline void mt7621_spi_flush(struct mt7621_spi *rs) in mt7621_spi_flush() argument
201 mt7621_spi_read_half_duplex(rs, 0, NULL); in mt7621_spi_flush()
204 static void mt7621_spi_write_half_duplex(struct mt7621_spi *rs, in mt7621_spi_write_half_duplex() argument
207 int len = rs->pending_write; in mt7621_spi_write_half_duplex()
211 val = mt7621_spi_read(rs, MT7621_SPI_OPCODE + (len & ~3)); in mt7621_spi_write_half_duplex()
220 rs->pending_write = len; in mt7621_spi_write_half_duplex()
221 mt7621_spi_flush(rs); in mt7621_spi_write_half_duplex()
231 mt7621_spi_write(rs, MT7621_SPI_OPCODE + len - 4, val); in mt7621_spi_write_half_duplex()
242 mt7621_spi_write(rs, MT7621_SPI_OPCODE + (len & ~3), val); in mt7621_spi_write_half_duplex()
245 rs->pending_write = len; in mt7621_spi_write_half_duplex()
251 struct mt7621_spi *rs = spi_controller_get_devdata(master); in mt7621_spi_transfer_one_message() local
257 mt7621_spi_wait_till_ready(rs); in mt7621_spi_transfer_one_message()
284 mt7621_spi_read_half_duplex(rs, t->len, t->rx_buf); in mt7621_spi_transfer_one_message()
286 mt7621_spi_write_half_duplex(rs, t->len, t->tx_buf); in mt7621_spi_transfer_one_message()
292 mt7621_spi_flush(rs); in mt7621_spi_transfer_one_message()
304 struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); in mt7621_spi_setup() local
307 (spi->max_speed_hz > (rs->sys_freq / 2))) in mt7621_spi_setup()
308 spi->max_speed_hz = rs->sys_freq / 2; in mt7621_spi_setup()
310 if (spi->max_speed_hz < (rs->sys_freq / 4097)) { in mt7621_spi_setup()
329 struct mt7621_spi *rs; in mt7621_spi_probe() local
347 master = devm_spi_alloc_master(&pdev->dev, sizeof(*rs)); in mt7621_spi_probe()
363 rs = spi_controller_get_devdata(master); in mt7621_spi_probe()
364 rs->base = base; in mt7621_spi_probe()
365 rs->master = master; in mt7621_spi_probe()
366 rs->sys_freq = clk_get_rate(clk); in mt7621_spi_probe()
367 rs->pending_write = 0; in mt7621_spi_probe()
368 dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq); in mt7621_spi_probe()