Lines Matching +full:dma +full:- +full:enabled
4 * SPDX-License-Identifier: Apache-2.0
18 #include <zephyr/drivers/dma.h>
68 /* DMA device */
69 const struct device *dma; member
70 /* DMA configuration structures */
73 /* DMA memory transfer synchronization token */
75 /* Granted DMA channel used for memory transfers */
104 if (atomic_test_and_set_bit(data->pm_policy_state_flag, 0) == 0) { in lcdc_smartbond_pm_policy_state_lock_get()
117 if (atomic_test_and_clear_bit(data->pm_policy_state_flag, 0) == 1) { in lcdc_smartbond_pm_policy_state_lock_put()
143 const struct display_smartbond_config *config = dev->config; in display_smartbond_configure()
144 struct display_smartbond_data *data = dev->data; in display_smartbond_configure()
154 return -EINVAL; in display_smartbond_configure()
157 da1469x_lcdc_parallel_interface_configure((lcdc_smartbond_mode_cfg *)&config->mode); in display_smartbond_configure()
158 da1469x_lcdc_bgcolor_configure((lcdc_smartbond_bgcolor_cfg *)&config->bgcolor_cfg); in display_smartbond_configure()
164 ret = da1469x_lcdc_timings_configure(config->x_res, config->y_res, in display_smartbond_configure()
165 (lcdc_smartbond_timing_cfg *)&config->timing_cfg); in display_smartbond_configure()
174 * It's OK to update stride here as continuous mode should not be enabled yet. in display_smartbond_configure()
176 data->layer.color_format = in display_smartbond_configure()
177 lcdc_smartbond_pixel_to_lcm(config->pixel_format); in display_smartbond_configure()
178 data->layer.stride = in display_smartbond_configure()
179 da1469x_lcdc_stride_calculation(data->layer.color_format, config->x_res); in display_smartbond_configure()
181 ret = da1469x_lcdc_layer_configure(&data->layer); in display_smartbond_configure()
188 LCDC->LCDC_LAYER0_OFFSETX_REG, DISPLAY_SMARTBOND_IS_DMA_PREFETCH_ENABLED); in display_smartbond_configure()
190 LCDC->LCDC_MODE_REG |= LCDC_LCDC_MODE_REG_LCDC_MODE_EN_Msk; in display_smartbond_configure()
197 struct display_smartbond_data *data = ((const struct device *)arg)->data; in smartbond_display_isr()
199 data->underflow_flag = LCDC_STATUS_REG_GET_FIELD(LCDC_STICKY_UNDERFLOW); in smartbond_display_isr()
205 LCDC->LCDC_INTERRUPT_REG &= ~LCDC_LCDC_INTERRUPT_REG_LCDC_VSYNC_IRQ_EN_Msk; in smartbond_display_isr()
208 k_sem_give(&data->sync_sem); in smartbond_display_isr()
211 static void display_smartbond_dma_cb(const struct device *dma, void *arg, in display_smartbond_dma_cb() argument
217 LOG_WRN("DMA transfer did not complete"); in display_smartbond_dma_cb()
220 k_sem_give(&data->dma_sync_sem); in display_smartbond_dma_cb()
225 struct display_smartbond_data *data = dev->data; in display_smartbond_dma_config()
227 data->dma = DEVICE_DT_GET(DT_NODELABEL(dma)); in display_smartbond_dma_config()
228 if (!device_is_ready(data->dma)) { in display_smartbond_dma_config()
229 LOG_ERR("DMA device is not ready"); in display_smartbond_dma_config()
230 return -ENODEV; in display_smartbond_dma_config()
233 data->dma_cfg.channel_direction = MEMORY_TO_MEMORY; in display_smartbond_dma_config()
234 data->dma_cfg.user_data = data; in display_smartbond_dma_config()
235 data->dma_cfg.dma_callback = display_smartbond_dma_cb; in display_smartbond_dma_config()
236 data->dma_cfg.block_count = 1; in display_smartbond_dma_config()
237 data->dma_cfg.head_block = &data->dma_block_cfg; in display_smartbond_dma_config()
238 data->dma_cfg.error_callback_dis = 1; in display_smartbond_dma_config()
240 /* Request an arbitrary DMA channel */ in display_smartbond_dma_config()
241 data->dma_channel = dma_request_channel(data->dma, NULL); in display_smartbond_dma_config()
242 if (data->dma_channel < 0) { in display_smartbond_dma_config()
243 LOG_ERR("Could not acquire a DMA channel"); in display_smartbond_dma_config()
244 return -EIO; in display_smartbond_dma_config()
252 const struct display_smartbond_config *config = dev->config; in display_smartbond_resume()
256 ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in display_smartbond_resume()
259 return -EIO; in display_smartbond_resume()
267 return -ENODEV; in display_smartbond_resume()
273 return -EIO; in display_smartbond_resume()
288 struct display_smartbond_data *data = dev->data; in display_smartbond_dma_deconfig()
290 __ASSERT(data->dma, "DMA should be already initialized"); in display_smartbond_dma_deconfig()
292 dma_release_channel(data->dma, data->dma_channel); in display_smartbond_dma_deconfig()
297 const struct display_smartbond_config *config = dev->config; in display_smartbond_suspend()
301 ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); in display_smartbond_suspend()
317 const struct display_smartbond_config *config = dev->config; in display_smartbond_init()
318 struct display_smartbond_data *data = dev->data; in display_smartbond_init()
322 k_sem_init(&data->device_sem, 1, 1); in display_smartbond_init()
324 k_sem_init(&data->sync_sem, 0, 1); in display_smartbond_init()
325 /* Event should be signaled by DMA ISR */ in display_smartbond_init()
326 k_sem_init(&data->dma_sync_sem, 0, 1); in display_smartbond_init()
328 /* As per docs, display port should be enabled by default. */ in display_smartbond_init()
329 if (gpio_is_ready_dt(&config->disp)) { in display_smartbond_init()
330 ret = gpio_pin_configure_dt(&config->disp, GPIO_OUTPUT_ACTIVE); in display_smartbond_init()
333 return -EIO; in display_smartbond_init()
358 /* Display port should be enabled at this moment and so sleep is not allowed. */ in display_smartbond_init()
367 const struct display_smartbond_config *config = dev->config; in display_smartbond_blanking_on()
368 struct display_smartbond_data *data = dev->data; in display_smartbond_blanking_on()
371 k_sem_take(&data->device_sem, K_FOREVER); in display_smartbond_blanking_on()
378 LCDC->LCDC_MODE_REG |= LCDC_LCDC_MODE_REG_LCDC_FORCE_BLANK_Msk; in display_smartbond_blanking_on()
380 /* If enabled, disable display port. */ in display_smartbond_blanking_on()
381 if (gpio_is_ready_dt(&config->disp)) { in display_smartbond_blanking_on()
382 ret = gpio_pin_configure_dt(&config->disp, GPIO_OUTPUT_INACTIVE); in display_smartbond_blanking_on()
384 LOG_WRN("Display port could not be de-activated"); in display_smartbond_blanking_on()
394 k_sem_give(&data->device_sem); in display_smartbond_blanking_on()
401 const struct display_smartbond_config *config = dev->config; in display_smartbond_blanking_off()
402 struct display_smartbond_data *data = dev->data; in display_smartbond_blanking_off()
405 k_sem_take(&data->device_sem, K_FOREVER); in display_smartbond_blanking_off()
408 if (gpio_is_ready_dt(&config->disp)) { in display_smartbond_blanking_off()
409 ret = gpio_pin_configure_dt(&config->disp, GPIO_OUTPUT_ACTIVE); in display_smartbond_blanking_off()
420 LCDC->LCDC_MODE_REG &= ~LCDC_LCDC_MODE_REG_LCDC_FORCE_BLANK_Msk; in display_smartbond_blanking_off()
428 k_sem_give(&data->device_sem); in display_smartbond_blanking_off()
435 struct display_smartbond_data *data = dev->data; in display_smartbond_get_framebuffer()
437 return ((void *)data->buffer); in display_smartbond_get_framebuffer()
451 * format is defined based on the pixel-format property dictated by lcd-controller in display_smartbond_get_capabilities()
454 capabilities->supported_pixel_formats = DT_INST_PROP(0, pixel_format); in display_smartbond_get_capabilities()
455 capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL; in display_smartbond_get_capabilities()
456 capabilities->current_pixel_format = DT_INST_PROP(0, pixel_format); in display_smartbond_get_capabilities()
457 capabilities->x_resolution = DT_INST_PROP(0, width); in display_smartbond_get_capabilities()
458 capabilities->y_resolution = DT_INST_PROP(0, height); in display_smartbond_get_capabilities()
466 struct display_smartbond_data *data = dev->data; in display_smartbond_read()
467 const struct display_smartbond_config *config = dev->config; in display_smartbond_read()
469 const uint8_t *src = data->buffer; in display_smartbond_read()
471 k_sem_take(&data->device_sem, K_FOREVER); in display_smartbond_read()
474 src += (x * config->pixel_size); in display_smartbond_read()
475 src += (y * data->layer.stride); in display_smartbond_read()
477 data->dma_block_cfg.block_size = desc->width * config->pixel_size; in display_smartbond_read()
483 data->dma_cfg.source_data_size = data->dma_cfg.dest_data_size = in display_smartbond_read()
484 !(config->pixel_size & 3) ? 4 : in display_smartbond_read()
485 !(config->pixel_size & 1) ? 2 : 1; in display_smartbond_read()
487 data->dma_cfg.dest_burst_length = data->dma_cfg.source_burst_length = in display_smartbond_read()
488 !((data->dma_block_cfg.block_size / data->dma_cfg.source_data_size) & 7) ? 8 : in display_smartbond_read()
489 !((data->dma_block_cfg.block_size / data->dma_cfg.source_data_size) & 3) ? 4 : 1; in display_smartbond_read()
491 for (int row = 0; row < desc->height; row++) { in display_smartbond_read()
493 data->dma_block_cfg.dest_address = (uint32_t)dst; in display_smartbond_read()
494 data->dma_block_cfg.source_address = (uint32_t)src; in display_smartbond_read()
496 if (dma_config(data->dma, data->dma_channel, &data->dma_cfg)) { in display_smartbond_read()
497 LOG_ERR("Could not configure DMA"); in display_smartbond_read()
498 k_sem_give(&data->device_sem); in display_smartbond_read()
499 return -EIO; in display_smartbond_read()
502 if (dma_start(data->dma, data->dma_channel)) { in display_smartbond_read()
503 LOG_ERR("Could not start DMA"); in display_smartbond_read()
504 k_sem_give(&data->device_sem); in display_smartbond_read()
505 return -EIO; in display_smartbond_read()
508 k_sem_take(&data->dma_sync_sem, K_FOREVER); in display_smartbond_read()
510 src += data->layer.stride; in display_smartbond_read()
511 dst += (desc->pitch * config->pixel_size); in display_smartbond_read()
514 if (dma_stop(data->dma, data->dma_channel)) { in display_smartbond_read()
515 LOG_WRN("Could not stop DMA"); in display_smartbond_read()
518 k_sem_give(&data->device_sem); in display_smartbond_read()
528 struct display_smartbond_data *data = dev->data; in display_smartbond_write()
529 const struct display_smartbond_config *config = dev->config; in display_smartbond_write()
530 uint8_t *dst = data->buffer; in display_smartbond_write()
533 k_sem_take(&data->device_sem, K_FOREVER); in display_smartbond_write()
536 dst += (x * config->pixel_size); in display_smartbond_write()
537 dst += (y * data->layer.stride); in display_smartbond_write()
543 LCDC->LCDC_INTERRUPT_REG |= LCDC_LCDC_INTERRUPT_REG_LCDC_VSYNC_IRQ_EN_Msk; in display_smartbond_write()
544 k_sem_take(&data->sync_sem, K_FOREVER); in display_smartbond_write()
546 data->dma_block_cfg.block_size = desc->width * config->pixel_size; in display_smartbond_write()
552 data->dma_cfg.source_data_size = data->dma_cfg.dest_data_size = in display_smartbond_write()
553 !(config->pixel_size & 3) ? 4 : in display_smartbond_write()
554 !(config->pixel_size & 1) ? 2 : 1; in display_smartbond_write()
556 data->dma_cfg.dest_burst_length = data->dma_cfg.source_burst_length = in display_smartbond_write()
557 !((data->dma_block_cfg.block_size / data->dma_cfg.source_data_size) & 7) ? 8 : in display_smartbond_write()
558 !((data->dma_block_cfg.block_size / data->dma_cfg.source_data_size) & 3) ? 4 : 1; in display_smartbond_write()
560 for (int row = 0; row < desc->height; row++) { in display_smartbond_write()
562 data->dma_block_cfg.dest_address = (uint32_t)dst; in display_smartbond_write()
563 data->dma_block_cfg.source_address = (uint32_t)src; in display_smartbond_write()
565 if (dma_config(data->dma, data->dma_channel, &data->dma_cfg)) { in display_smartbond_write()
566 LOG_ERR("Could not configure DMA"); in display_smartbond_write()
567 k_sem_give(&data->device_sem); in display_smartbond_write()
568 return -EIO; in display_smartbond_write()
571 if (dma_start(data->dma, data->dma_channel)) { in display_smartbond_write()
572 LOG_ERR("Could not start DMA"); in display_smartbond_write()
573 k_sem_give(&data->device_sem); in display_smartbond_write()
574 return -EIO; in display_smartbond_write()
577 k_sem_take(&data->dma_sync_sem, K_FOREVER); in display_smartbond_write()
579 dst += data->layer.stride; in display_smartbond_write()
580 src += (desc->pitch * config->pixel_size); in display_smartbond_write()
583 if (dma_stop(data->dma, data->dma_channel)) { in display_smartbond_write()
584 LOG_WRN("Could not stop DMA"); in display_smartbond_write()
587 k_sem_give(&data->device_sem); in display_smartbond_write()
599 /* A non-zero value should not affect sleep */ in display_smartbond_pm_action()
610 ret = -ENOTSUP; in display_smartbond_pm_action()