Lines Matching +full:xfr +full:- +full:min +full:- +full:bits
5 * SPDX-License-Identifier: Apache-2.0
25 /* Minimum transfer bits */
35 /* Expands to 1 if the node does not have the `write-only` property */
38 /* This macro will evaluate to 1 if any of the nodes with zephyr,mipi-dbi-spi
39 * lack a `write-only` property. The intention here is to allow the entire
45 /* Expands to 1 if the node does reflect the enum in `xfr-min-bits` property */
49 /* This macros will evaluate to 1 if any of the nodes with zephyr,mipi-dbi-spi
50 * have the `xfr-min-bits` property to corresponding enum value. The intention
52 * minimum transfer bits will be needed.
71 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_write_helper_3wire()
72 struct mipi_dbi_spi_data *data = dev->data; in mipi_dbi_spi_write_helper_3wire()
85 if ((dbi_config->config.operation & SPI_WORD_SIZE_MASK) in mipi_dbi_spi_write_helper_3wire()
87 return -ENOTSUP; in mipi_dbi_spi_write_helper_3wire()
89 buffer.buf = &data->spi_byte; in mipi_dbi_spi_write_helper_3wire()
94 data->spi_byte = cmd; in mipi_dbi_spi_write_helper_3wire()
95 ret = spi_write(config->spi_dev, &dbi_config->config, &buf_set); in mipi_dbi_spi_write_helper_3wire()
102 data->spi_byte = MIPI_DBI_DC_BIT | data_buf[i]; in mipi_dbi_spi_write_helper_3wire()
103 ret = spi_write(config->spi_dev, &dbi_config->config, &buf_set); in mipi_dbi_spi_write_helper_3wire()
120 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_write_helper_4wire_8bit()
139 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_spi_write_helper_4wire_8bit()
140 ret = spi_write(config->spi_dev, &dbi_config->config, &buf_set); in mipi_dbi_spi_write_helper_4wire_8bit()
151 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_spi_write_helper_4wire_8bit()
152 ret = spi_write(config->spi_dev, &dbi_config->config, &buf_set); in mipi_dbi_spi_write_helper_4wire_8bit()
171 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_write_helper_4wire_16bit()
183 * but send 16-bit blocks (with bit stuffing). in mipi_dbi_spi_write_helper_4wire_16bit()
192 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_spi_write_helper_4wire_16bit()
193 ret = spi_write(config->spi_dev, &dbi_config->config, in mipi_dbi_spi_write_helper_4wire_16bit()
201 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_spi_write_helper_4wire_16bit()
208 ret = spi_write(config->spi_dev, &dbi_config->config, in mipi_dbi_spi_write_helper_4wire_16bit()
219 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_spi_write_helper_4wire_16bit()
223 if (len - stuffing > 0) { in mipi_dbi_spi_write_helper_4wire_16bit()
225 buffer.len = len - stuffing; in mipi_dbi_spi_write_helper_4wire_16bit()
227 ret = spi_write(config->spi_dev, &dbi_config->config, in mipi_dbi_spi_write_helper_4wire_16bit()
235 for (int i = len - stuffing; i < len; i++) { in mipi_dbi_spi_write_helper_4wire_16bit()
240 ret = spi_write(config->spi_dev, &dbi_config->config, in mipi_dbi_spi_write_helper_4wire_16bit()
258 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_write_helper()
259 struct mipi_dbi_spi_data *data = dev->data; in mipi_dbi_spi_write_helper()
262 ret = k_mutex_lock(&data->lock, K_FOREVER); in mipi_dbi_spi_write_helper()
267 if (dbi_config->mode == MIPI_DBI_MODE_SPI_3WIRE && in mipi_dbi_spi_write_helper()
275 if (dbi_config->mode == MIPI_DBI_MODE_SPI_4WIRE) { in mipi_dbi_spi_write_helper()
278 if (config->xfr_min_bits == MIPI_DBI_SPI_XFR_8BIT) { in mipi_dbi_spi_write_helper()
288 if (config->xfr_min_bits == MIPI_DBI_SPI_XFR_16BIT) { in mipi_dbi_spi_write_helper()
300 ret = -ENOTSUP; in mipi_dbi_spi_write_helper()
303 k_mutex_unlock(&data->lock); in mipi_dbi_spi_write_helper()
325 framebuf, desc->buf_size); in mipi_dbi_spi_write_display()
336 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_read_helper_3wire()
337 struct mipi_dbi_spi_data *data = dev->data; in mipi_dbi_spi_read_helper_3wire()
352 if ((dbi_config->config.operation & SPI_WORD_SIZE_MASK) in mipi_dbi_spi_read_helper_3wire()
354 return -ENOTSUP; in mipi_dbi_spi_read_helper_3wire()
357 memcpy(&tmp_config, &dbi_config->config, sizeof(tmp_config)); in mipi_dbi_spi_read_helper_3wire()
361 buffer.buf = &data->spi_byte; in mipi_dbi_spi_read_helper_3wire()
366 data->spi_byte = cmds[i]; in mipi_dbi_spi_read_helper_3wire()
367 ret = spi_write(config->spi_dev, &tmp_config, &buf_set); in mipi_dbi_spi_read_helper_3wire()
376 ret = spi_read(config->spi_dev, &dbi_config->config, &buf_set); in mipi_dbi_spi_read_helper_3wire()
379 spi_release(config->spi_dev, &tmp_config); /* Really necessary here? */ in mipi_dbi_spi_read_helper_3wire()
389 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_read_helper_4wire()
406 memcpy(&tmp_config, &dbi_config->config, sizeof(tmp_config)); in mipi_dbi_spi_read_helper_4wire()
414 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_spi_read_helper_4wire()
416 ret = spi_write(config->spi_dev, &tmp_config, &buf_set); in mipi_dbi_spi_read_helper_4wire()
427 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_spi_read_helper_4wire()
429 ret = spi_read(config->spi_dev, &tmp_config, &buf_set); in mipi_dbi_spi_read_helper_4wire()
436 spi_release(config->spi_dev, &tmp_config); in mipi_dbi_spi_read_helper_4wire()
445 struct mipi_dbi_spi_data *data = dev->data; in mipi_dbi_spi_command_read()
448 ret = k_mutex_lock(&data->lock, K_FOREVER); in mipi_dbi_spi_command_read()
452 if (dbi_config->mode == MIPI_DBI_MODE_SPI_3WIRE && in mipi_dbi_spi_command_read()
460 } else if (dbi_config->mode == MIPI_DBI_MODE_SPI_4WIRE) { in mipi_dbi_spi_command_read()
469 ret = -ENOTSUP; in mipi_dbi_spi_command_read()
472 k_mutex_unlock(&data->lock); in mipi_dbi_spi_command_read()
480 return spec->port != NULL; in mipi_dbi_has_pin()
485 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_reset()
488 if (!mipi_dbi_has_pin(&config->reset)) { in mipi_dbi_spi_reset()
489 return -ENOTSUP; in mipi_dbi_spi_reset()
492 ret = gpio_pin_set_dt(&config->reset, 1); in mipi_dbi_spi_reset()
497 return gpio_pin_set_dt(&config->reset, 0); in mipi_dbi_spi_reset()
503 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_release()
505 return spi_release(config->spi_dev, &dbi_config->config); in mipi_dbi_spi_release()
510 const struct mipi_dbi_spi_config *config = dev->config; in mipi_dbi_spi_init()
511 struct mipi_dbi_spi_data *data = dev->data; in mipi_dbi_spi_init()
514 if (!device_is_ready(config->spi_dev)) { in mipi_dbi_spi_init()
516 return -ENODEV; in mipi_dbi_spi_init()
519 if (mipi_dbi_has_pin(&config->cmd_data)) { in mipi_dbi_spi_init()
520 if (!gpio_is_ready_dt(&config->cmd_data)) { in mipi_dbi_spi_init()
521 return -ENODEV; in mipi_dbi_spi_init()
523 ret = gpio_pin_configure_dt(&config->cmd_data, GPIO_OUTPUT); in mipi_dbi_spi_init()
530 if (mipi_dbi_has_pin(&config->reset)) { in mipi_dbi_spi_init()
531 if (!gpio_is_ready_dt(&config->reset)) { in mipi_dbi_spi_init()
532 return -ENODEV; in mipi_dbi_spi_init()
534 ret = gpio_pin_configure_dt(&config->reset, GPIO_OUTPUT_INACTIVE); in mipi_dbi_spi_init()
541 k_mutex_init(&data->lock); in mipi_dbi_spi_init()