Lines Matching refs:ops
22 #define TOG_SCLK(ops) ops->tog_sclk(ops->data) argument
23 #define SET_SCLK(ops, val) ops->set_sclk(ops->data, val) argument
24 #define SET_MOSI(ops, val) ops->set_mosi(ops->data, val) argument
25 #define SET_MISO(ops, val) ops->set_miso(ops->data, val) argument
26 #define GET_SCLK(ops) ops->get_sclk(ops->data) argument
27 #define GET_MOSI(ops) ops->get_mosi(ops->data) argument
28 #define GET_MISO(ops) ops->get_miso(ops->data) argument
29 #define DIR_MOSI(ops, val) ops->dir_mosi(ops->data, val) argument
30 #define DIR_MISO(ops, val) ops->dir_miso(ops->data, val) argument
32 rt_inline void spi_delay(struct rt_spi_bit_ops *ops) in spi_delay() argument
34 ops->udelay((ops->delay_us + 1) >> 1); in spi_delay()
37 rt_inline void spi_delay2(struct rt_spi_bit_ops *ops) in spi_delay2() argument
39 ops->udelay(ops->delay_us); in spi_delay2()
42 #define SCLK_H(ops) SET_SCLK(ops, 1) argument
43 #define SCLK_L(ops) SET_SCLK(ops, 0) argument
44 #define MOSI_H(ops) SET_MOSI(ops, 1) argument
45 #define MOSI_L(ops) SET_MOSI(ops, 0) argument
46 #define MOSI_IN(ops) DIR_MOSI(ops, 1) argument
47 #define MOSI_OUT(ops) DIR_MOSI(ops, 0) argument
48 #define MISO_IN(ops) DIR_MISO(ops, 1) argument
49 #define MISO_OUT(ops) DIR_MISO(ops, 0) argument
51 rt_inline rt_ssize_t spi_xfer_4line_data8(struct rt_spi_bit_ops *ops, in spi_xfer_4line_data8() argument
59 RT_ASSERT(ops != RT_NULL); in spi_xfer_4line_data8()
83 if (bit) MOSI_H(ops); in spi_xfer_4line_data8()
84 else MOSI_L(ops); in spi_xfer_4line_data8()
86 spi_delay2(ops); in spi_xfer_4line_data8()
88 TOG_SCLK(ops); in spi_xfer_4line_data8()
99 if (GET_MISO(ops)) in spi_xfer_4line_data8()
108 spi_delay2(ops); in spi_xfer_4line_data8()
112 TOG_SCLK(ops); in spi_xfer_4line_data8()
126 rt_inline rt_ssize_t spi_xfer_4line_data16(struct rt_spi_bit_ops *ops, in spi_xfer_4line_data16() argument
134 RT_ASSERT(ops != RT_NULL); in spi_xfer_4line_data16()
158 if (bit) MOSI_H(ops); in spi_xfer_4line_data16()
159 else MOSI_L(ops); in spi_xfer_4line_data16()
161 spi_delay2(ops); in spi_xfer_4line_data16()
163 TOG_SCLK(ops); in spi_xfer_4line_data16()
174 if (GET_MISO(ops)) in spi_xfer_4line_data16()
183 spi_delay2(ops); in spi_xfer_4line_data16()
187 TOG_SCLK(ops); in spi_xfer_4line_data16()
201 rt_inline rt_ssize_t spi_xfer_3line_data8(struct rt_spi_bit_ops *ops, in spi_xfer_3line_data8() argument
209 RT_ASSERT(ops != RT_NULL); in spi_xfer_3line_data8()
220 MOSI_OUT(ops); in spi_xfer_3line_data8()
225 MOSI_IN(ops); in spi_xfer_3line_data8()
246 if (bit) MOSI_H(ops); in spi_xfer_3line_data8()
247 else MOSI_L(ops); in spi_xfer_3line_data8()
249 spi_delay2(ops); in spi_xfer_3line_data8()
251 TOG_SCLK(ops); in spi_xfer_3line_data8()
253 spi_delay2(ops); in spi_xfer_3line_data8()
257 TOG_SCLK(ops); in spi_xfer_3line_data8()
267 spi_delay2(ops); in spi_xfer_3line_data8()
269 TOG_SCLK(ops); in spi_xfer_3line_data8()
280 if (GET_MOSI(ops)) in spi_xfer_3line_data8()
289 spi_delay2(ops); in spi_xfer_3line_data8()
293 TOG_SCLK(ops); in spi_xfer_3line_data8()
307 MOSI_OUT(ops); in spi_xfer_3line_data8()
314 rt_inline rt_ssize_t spi_xfer_3line_data16(struct rt_spi_bit_ops *ops, in spi_xfer_3line_data16() argument
322 RT_ASSERT(ops != RT_NULL); in spi_xfer_3line_data16()
333 MOSI_OUT(ops); in spi_xfer_3line_data16()
338 MOSI_IN(ops); in spi_xfer_3line_data16()
359 if (bit) MOSI_H(ops); in spi_xfer_3line_data16()
360 else MOSI_L(ops); in spi_xfer_3line_data16()
362 spi_delay2(ops); in spi_xfer_3line_data16()
364 TOG_SCLK(ops); in spi_xfer_3line_data16()
366 spi_delay2(ops); in spi_xfer_3line_data16()
370 TOG_SCLK(ops); in spi_xfer_3line_data16()
380 spi_delay2(ops); in spi_xfer_3line_data16()
382 TOG_SCLK(ops); in spi_xfer_3line_data16()
393 if (GET_MOSI(ops)) in spi_xfer_3line_data16()
402 spi_delay2(ops); in spi_xfer_3line_data16()
406 TOG_SCLK(ops); in spi_xfer_3line_data16()
420 MOSI_OUT(ops); in spi_xfer_3line_data16()
430 struct rt_spi_bit_ops *ops = obj->ops; in spi_bit_configure() local
435 if(ops->pin_init != RT_NULL) in spi_bit_configure()
437 ops->pin_init(); in spi_bit_configure()
447 SCLK_H(ops); in spi_bit_configure()
451 SCLK_L(ops); in spi_bit_configure()
456 ops->delay_us = 1; in spi_bit_configure()
460 ops->delay_us = 0; in spi_bit_configure()
471 struct rt_spi_bit_ops *ops = obj->ops; in spi_bit_xfer() local
480 if (!ops->tog_sclk || !ops->set_sclk || !ops->get_sclk) in spi_bit_xfer()
484 if (!ops->set_mosi || !ops->get_mosi) in spi_bit_xfer()
488 if (!ops->set_miso || !ops->get_miso) in spi_bit_xfer()
506 spi_delay(ops); in spi_bit_xfer()
512 spi_delay(ops); in spi_bit_xfer()
513 TOG_SCLK(ops); in spi_bit_xfer()
519 … length = spi_xfer_3line_data8(ops, config, message->send_buf, message->recv_buf, message->length); in spi_bit_xfer()
523 …length = spi_xfer_3line_data16(ops, config, message->send_buf, message->recv_buf, message->length); in spi_bit_xfer()
530 … length = spi_xfer_4line_data8(ops, config, message->send_buf, message->recv_buf, message->length); in spi_bit_xfer()
534 …length = spi_xfer_4line_data16(ops, config, message->send_buf, message->recv_buf, message->length); in spi_bit_xfer()
541 if ((config->mode & RT_SPI_CPOL) && !GET_SCLK(ops)) in spi_bit_xfer()
543 spi_delay(ops); in spi_bit_xfer()
544 TOG_SCLK(ops); in spi_bit_xfer()
546 spi_delay(ops); in spi_bit_xfer()
570 struct rt_spi_bit_ops *ops) in rt_spi_bit_add_bus() argument
572 obj->ops = ops; in rt_spi_bit_add_bus()