Lines Matching refs:rs
59 static void mt7621_spi_set_cs(struct mt7621_spi *rs, int cs, int enable) in mt7621_spi_set_cs() argument
64 setbits_le32(rs->base + MT7621_SPI_MASTER, in mt7621_spi_set_cs()
66 iowrite32(BIT(cs), rs->base + MT7621_SPI_POLAR); in mt7621_spi_set_cs()
68 iowrite32(0, rs->base + MT7621_SPI_POLAR); in mt7621_spi_set_cs()
71 rs->base + MT7621_SPI_TRANS); in mt7621_spi_set_cs()
72 clrbits_le32(rs->base + MT7621_SPI_MASTER, in mt7621_spi_set_cs()
79 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_set_mode() local
83 reg = ioread32(rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_mode()
103 iowrite32(reg, rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_mode()
110 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_set_speed() local
115 rate = DIV_ROUND_UP(rs->sys_freq, speed); in mt7621_spi_set_speed()
124 reg = ioread32(rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_speed()
127 iowrite32(reg, rs->base + MT7621_SPI_MASTER); in mt7621_spi_set_speed()
132 static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs) in mt7621_spi_wait_till_ready() argument
136 ret = wait_for_bit_le32(rs->base + MT7621_SPI_TRANS, in mt7621_spi_wait_till_ready()
144 static int mt7621_spi_read(struct mt7621_spi *rs, u8 *buf, size_t len) in mt7621_spi_read() argument
154 rs->base + MT7621_SPI_MOREBUF); in mt7621_spi_read()
155 iowrite32(MT7621_SPI_TRANS_START, rs->base + MT7621_SPI_TRANS); in mt7621_spi_read()
157 ret = mt7621_spi_wait_till_ready(rs); in mt7621_spi_read()
163 val = ioread32(rs->base + MT7621_SPI_DATA0 + i); in mt7621_spi_read()
174 static int mt7621_spi_write(struct mt7621_spi *rs, const u8 *buf, size_t len) in mt7621_spi_write() argument
192 iowrite32(val, rs->base + MT7621_SPI_OPCODE); in mt7621_spi_write()
199 iowrite32(val, rs->base + MT7621_SPI_DATA0 + in mt7621_spi_write()
207 rs->base + MT7621_SPI_MOREBUF); in mt7621_spi_write()
208 iowrite32(MT7621_SPI_TRANS_START, rs->base + MT7621_SPI_TRANS); in mt7621_spi_write()
210 ret = mt7621_spi_wait_till_ready(rs); in mt7621_spi_write()
224 struct mt7621_spi *rs = dev_get_priv(bus); in mt7621_spi_xfer() local
240 mt7621_spi_wait_till_ready(rs); in mt7621_spi_xfer()
247 mt7621_spi_set_cs(rs, spi_chip_select(dev), 1); in mt7621_spi_xfer()
250 ret = mt7621_spi_read(rs, din, total_size); in mt7621_spi_xfer()
252 ret = mt7621_spi_write(rs, dout, total_size); in mt7621_spi_xfer()
255 mt7621_spi_set_cs(rs, spi_chip_select(dev), 0); in mt7621_spi_xfer()
262 struct mt7621_spi *rs = dev_get_priv(dev); in mt7621_spi_probe() local
266 rs->base = dev_remap_addr(dev); in mt7621_spi_probe()
267 if (!rs->base) in mt7621_spi_probe()
278 rs->sys_freq = clk_get_rate(&clk); in mt7621_spi_probe()
279 if (!rs->sys_freq) { in mt7621_spi_probe()