Lines Matching +full:cs +full:- +full:mode

6  * SPDX-License-Identifier: Apache-2.0
20 /* Compile in a data bus LUT for improved performance if at least one instance uses an 8-bit bus */
38 /* Chip-select GPIO */
39 const struct gpio_dt_spec cs; member
48 /* Data GPIO remap look-up table. Valid if mipi_dbi_bitbang_data.single_port is set */
73 if (data->single_port) { in mipi_dbi_bitbang_set_data_gpios()
74 gpio_port_set_masked(data->data_port, config->data_mask, config->data_lut[value]); in mipi_dbi_bitbang_set_data_gpios()
77 for (int i = 0; i < config->data_bus_width; i++) { in mipi_dbi_bitbang_set_data_gpios()
78 gpio_pin_set_dt(&config->data[i], (value & (1 << i)) != 0); in mipi_dbi_bitbang_set_data_gpios()
89 const struct mipi_dbi_bitbang_config *config = dev->config; in mipi_dbi_bitbang_write_helper()
90 struct mipi_dbi_bitbang_data *data = dev->data; in mipi_dbi_bitbang_write_helper()
94 ret = k_mutex_lock(&data->lock, K_FOREVER); in mipi_dbi_bitbang_write_helper()
99 switch (dbi_config->mode) { in mipi_dbi_bitbang_write_helper()
103 gpio_pin_set_dt(&config->cs, 1); in mipi_dbi_bitbang_write_helper()
105 gpio_pin_set_dt(&config->wr, 0); in mipi_dbi_bitbang_write_helper()
106 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_bitbang_write_helper()
108 gpio_pin_set_dt(&config->wr, 1); in mipi_dbi_bitbang_write_helper()
111 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_bitbang_write_helper()
114 gpio_pin_set_dt(&config->wr, 0); in mipi_dbi_bitbang_write_helper()
116 gpio_pin_set_dt(&config->wr, 1); in mipi_dbi_bitbang_write_helper()
117 len--; in mipi_dbi_bitbang_write_helper()
120 gpio_pin_set_dt(&config->cs, 0); in mipi_dbi_bitbang_write_helper()
123 /* Clocked E mode */ in mipi_dbi_bitbang_write_helper()
127 gpio_pin_set_dt(&config->cs, 1); in mipi_dbi_bitbang_write_helper()
128 gpio_pin_set_dt(&config->wr, 0); in mipi_dbi_bitbang_write_helper()
130 gpio_pin_set_dt(&config->e, 1); in mipi_dbi_bitbang_write_helper()
131 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_bitbang_write_helper()
133 gpio_pin_set_dt(&config->e, 0); in mipi_dbi_bitbang_write_helper()
136 gpio_pin_set_dt(&config->cmd_data, 1); in mipi_dbi_bitbang_write_helper()
139 gpio_pin_set_dt(&config->e, 1); in mipi_dbi_bitbang_write_helper()
141 gpio_pin_set_dt(&config->e, 0); in mipi_dbi_bitbang_write_helper()
142 len--; in mipi_dbi_bitbang_write_helper()
145 gpio_pin_set_dt(&config->cs, 0); in mipi_dbi_bitbang_write_helper()
149 LOG_ERR("MIPI DBI mode %u is not supported.", dbi_config->mode); in mipi_dbi_bitbang_write_helper()
150 ret = -ENOTSUP; in mipi_dbi_bitbang_write_helper()
153 k_mutex_unlock(&data->lock); in mipi_dbi_bitbang_write_helper()
172 return mipi_dbi_bitbang_write_helper(dev, dbi_config, false, 0x0, framebuf, desc->buf_size); in mipi_dbi_bitbang_write_display()
177 const struct mipi_dbi_bitbang_config *config = dev->config; in mipi_dbi_bitbang_reset()
182 ret = gpio_pin_set_dt(&config->reset, 1); in mipi_dbi_bitbang_reset()
187 return gpio_pin_set_dt(&config->reset, 0); in mipi_dbi_bitbang_reset()
192 const struct mipi_dbi_bitbang_config *config = dev->config; in mipi_dbi_bitbang_init()
196 struct mipi_dbi_bitbang_data *data = dev->data; in mipi_dbi_bitbang_init()
199 if (gpio_is_ready_dt(&config->cmd_data)) { in mipi_dbi_bitbang_init()
200 ret = gpio_pin_configure_dt(&config->cmd_data, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
205 gpio_pin_set_dt(&config->cmd_data, 0); in mipi_dbi_bitbang_init()
207 if (gpio_is_ready_dt(&config->rd)) { in mipi_dbi_bitbang_init()
208 gpio_pin_configure_dt(&config->rd, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
210 gpio_pin_set_dt(&config->rd, 1); in mipi_dbi_bitbang_init()
212 if (gpio_is_ready_dt(&config->wr)) { in mipi_dbi_bitbang_init()
213 ret = gpio_pin_configure_dt(&config->wr, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
218 gpio_pin_set_dt(&config->wr, 1); in mipi_dbi_bitbang_init()
220 if (gpio_is_ready_dt(&config->e)) { in mipi_dbi_bitbang_init()
221 gpio_pin_configure_dt(&config->e, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
223 gpio_pin_set_dt(&config->e, 0); in mipi_dbi_bitbang_init()
225 if (gpio_is_ready_dt(&config->cs)) { in mipi_dbi_bitbang_init()
226 ret = gpio_pin_configure_dt(&config->cs, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
228 failed_pin = "cs"; in mipi_dbi_bitbang_init()
231 gpio_pin_set_dt(&config->cs, 0); in mipi_dbi_bitbang_init()
233 if (gpio_is_ready_dt(&config->reset)) { in mipi_dbi_bitbang_init()
234 ret = gpio_pin_configure_dt(&config->reset, GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
239 gpio_pin_set_dt(&config->reset, 0); in mipi_dbi_bitbang_init()
241 for (int i = 0; i < config->data_bus_width; i++) { in mipi_dbi_bitbang_init()
242 if (gpio_is_ready_dt(&config->data[i])) { in mipi_dbi_bitbang_init()
243 ret = gpio_pin_configure_dt(&config->data[i], GPIO_OUTPUT_ACTIVE); in mipi_dbi_bitbang_init()
248 gpio_pin_set_dt(&config->data[i], 0); in mipi_dbi_bitbang_init()
256 * For 8-bit mode only because LUT size grows exponentially. in mipi_dbi_bitbang_init()
258 if (config->data_bus_width == 8) { in mipi_dbi_bitbang_init()
259 data->single_port = true; in mipi_dbi_bitbang_init()
260 data->data_port = config->data[0].port; in mipi_dbi_bitbang_init()
261 for (int i = 1; i < config->data_bus_width; i++) { in mipi_dbi_bitbang_init()
262 if (data->data_port != config->data[i].port) { in mipi_dbi_bitbang_init()
263 data->single_port = false; in mipi_dbi_bitbang_init()
267 if (data->single_port) { in mipi_dbi_bitbang_init()
268 LOG_DBG("LUT optimization enabled. data_mask=0x%x", config->data_mask); in mipi_dbi_bitbang_init()
284 /* This macro is repeatedly called by LISTIFY() at compile-time to generate the data bus LUT */
294 /* If at least one instance has an 8-bit bus, add a data look-up table to the read-only config.
335 .cs = GPIO_DT_SPEC_INST_GET_OR(n, cs_gpios, {}), \