Lines Matching +full:dclk +full:- +full:frq

1 // SPDX-License-Identifier: GPL-2.0-only
167 return regmap_bulk_write(ssd130x->regmap, SSD130X_DATA, values, count); in ssd130x_write_data()
189 ret = regmap_write(ssd130x->regmap, SSD130X_COMMAND, value); in ssd130x_write_cmd()
192 } while (--count); in ssd130x_write_cmd()
204 u8 col_end = col_start + cols - 1; in ssd130x_set_col_range()
207 if (col_start == ssd130x->col_start && col_end == ssd130x->col_end) in ssd130x_set_col_range()
214 ssd130x->col_start = col_start; in ssd130x_set_col_range()
215 ssd130x->col_end = col_end; in ssd130x_set_col_range()
222 u8 page_end = page_start + pages - 1; in ssd130x_set_page_range()
225 if (page_start == ssd130x->page_start && page_end == ssd130x->page_end) in ssd130x_set_page_range()
232 ssd130x->page_start = page_start; in ssd130x_set_page_range()
233 ssd130x->page_end = page_end; in ssd130x_set_page_range()
259 struct device *dev = ssd130x->dev; in ssd130x_pwm_enable()
262 ssd130x->pwm = pwm_get(dev, NULL); in ssd130x_pwm_enable()
263 if (IS_ERR(ssd130x->pwm)) { in ssd130x_pwm_enable()
265 return PTR_ERR(ssd130x->pwm); in ssd130x_pwm_enable()
268 pwm_init_state(ssd130x->pwm, &pwmstate); in ssd130x_pwm_enable()
270 pwm_apply_might_sleep(ssd130x->pwm, &pwmstate); in ssd130x_pwm_enable()
273 pwm_enable(ssd130x->pwm); in ssd130x_pwm_enable()
276 ssd130x->pwm->pwm, pwm_get_period(ssd130x->pwm)); in ssd130x_pwm_enable()
283 if (!ssd130x->reset) in ssd130x_reset()
287 gpiod_set_value_cansleep(ssd130x->reset, 1); in ssd130x_reset()
289 gpiod_set_value_cansleep(ssd130x->reset, 0); in ssd130x_reset()
295 struct device *dev = ssd130x->dev; in ssd130x_power_on()
300 ret = regulator_enable(ssd130x->vcc_reg); in ssd130x_power_on()
306 if (ssd130x->device_info->need_pwm) { in ssd130x_power_on()
310 regulator_disable(ssd130x->vcc_reg); in ssd130x_power_on()
320 pwm_disable(ssd130x->pwm); in ssd130x_power_off()
321 pwm_put(ssd130x->pwm); in ssd130x_power_off()
323 regulator_disable(ssd130x->vcc_reg); in ssd130x_power_off()
328 u32 precharge, dclk, com_invdir, compins, chargepump, seg_remap; in ssd130x_init() local
333 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_CONTRAST, ssd130x->contrast); in ssd130x_init()
337 /* Set segment re-map */ in ssd130x_init()
339 SSD130X_SET_SEG_REMAP_SET(ssd130x->seg_remap)); in ssd130x_init()
346 SSD130X_SET_COM_SCAN_DIR_SET(ssd130x->com_invdir)); in ssd130x_init()
352 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_MULTIPLEX_RATIO, ssd130x->height - 1); in ssd130x_init()
357 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_DISPLAY_OFFSET, ssd130x->com_offset); in ssd130x_init()
362 dclk = (SSD130X_SET_CLOCK_DIV_SET(ssd130x->dclk_div - 1) | in ssd130x_init()
363 SSD130X_SET_CLOCK_FREQ_SET(ssd130x->dclk_frq)); in ssd130x_init()
364 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_CLOCK_FREQ, dclk); in ssd130x_init()
369 if (ssd130x->area_color_enable || ssd130x->low_power) { in ssd130x_init()
372 if (ssd130x->area_color_enable) in ssd130x_init()
375 if (ssd130x->low_power) in ssd130x_init()
384 precharge = (SSD130X_SET_PRECHARGE_PERIOD1_SET(ssd130x->prechargep1) | in ssd130x_init()
385 SSD130X_SET_PRECHARGE_PERIOD2_SET(ssd130x->prechargep2)); in ssd130x_init()
394 * property "solomon,com-seq". The value 0b means scan from COM0 to in ssd130x_init()
395 * COM[N - 1] while 1b means scan from COM[N - 1] to COM0. in ssd130x_init()
397 scan_mode = !ssd130x->com_seq; in ssd130x_init()
399 SSD130X_SET_COM_PINS_CONFIG2_SET(ssd130x->com_lrremap)); in ssd130x_init()
405 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_VCOMH, ssd130x->vcomh); in ssd130x_init()
409 /* Turn on the DC-DC Charge Pump */ in ssd130x_init()
412 if (ssd130x->device_info->need_chargepump) in ssd130x_init()
420 if (ssd130x->lookup_table_set) { in ssd130x_init()
427 for (i = 0; i < ARRAY_SIZE(ssd130x->lookup_table); i++) { in ssd130x_init()
428 u8 val = ssd130x->lookup_table[i]; in ssd130x_init()
431 dev_warn(ssd130x->dev, in ssd130x_init()
441 if (ssd130x->page_address_mode) in ssd130x_init()
454 unsigned int x = rect->x1; in ssd130x_update_rect()
455 unsigned int y = rect->y1; in ssd130x_update_rect()
456 u8 *buf = ssd130x_state->buffer; in ssd130x_update_rect()
457 u8 *data_array = ssd130x_state->data_array; in ssd130x_update_rect()
461 unsigned int page_height = ssd130x->device_info->page_height; in ssd130x_update_rect()
463 struct drm_device *drm = &ssd130x->drm; in ssd130x_update_rect()
478 * wide. Each letter-number combination is a bit that controls in ssd130x_update_rect()
498 if (!ssd130x->page_address_mode) { in ssd130x_update_rect()
500 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width); in ssd130x_update_rect()
504 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages); in ssd130x_update_rect()
513 if (8 * (y / 8 + i + 1) > ssd130x->height) in ssd130x_update_rect()
514 m = ssd130x->height % 8; in ssd130x_update_rect()
531 if (ssd130x->page_address_mode) { in ssd130x_update_rect()
533 ssd130x->page_offset + i, in ssd130x_update_rect()
534 ssd130x->col_offset + x); in ssd130x_update_rect()
547 if (!ssd130x->page_address_mode) in ssd130x_update_rect()
556 unsigned int page_height = ssd130x->device_info->page_height; in ssd130x_clear_screen()
557 unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); in ssd130x_clear_screen()
558 u8 *data_array = ssd130x_state->data_array; in ssd130x_clear_screen()
559 unsigned int width = ssd130x->width; in ssd130x_clear_screen()
562 if (!ssd130x->page_address_mode) { in ssd130x_clear_screen()
566 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset, width); in ssd130x_clear_screen()
570 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset, pages); in ssd130x_clear_screen()
585 ssd130x->page_offset + i, in ssd130x_clear_screen()
586 ssd130x->col_offset); in ssd130x_clear_screen()
601 struct drm_framebuffer *fb = state->fb; in ssd130x_fb_blit_rect()
602 struct ssd130x_device *ssd130x = drm_to_ssd130x(fb->dev); in ssd130x_fb_blit_rect()
603 unsigned int page_height = ssd130x->device_info->page_height; in ssd130x_fb_blit_rect()
605 u8 *buf = ssd130x_state->buffer; in ssd130x_fb_blit_rect()
611 rect->y1 = round_down(rect->y1, page_height); in ssd130x_fb_blit_rect()
612 rect->y2 = min_t(unsigned int, round_up(rect->y2, page_height), ssd130x->height); in ssd130x_fb_blit_rect()
633 struct drm_device *drm = plane->dev; in ssd130x_primary_plane_helper_atomic_check()
637 unsigned int page_height = ssd130x->device_info->page_height; in ssd130x_primary_plane_helper_atomic_check()
638 unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); in ssd130x_primary_plane_helper_atomic_check()
649 return -EINVAL; in ssd130x_primary_plane_helper_atomic_check()
651 pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width); in ssd130x_primary_plane_helper_atomic_check()
653 ssd130x_state->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL); in ssd130x_primary_plane_helper_atomic_check()
654 if (!ssd130x_state->buffer) in ssd130x_primary_plane_helper_atomic_check()
655 return -ENOMEM; in ssd130x_primary_plane_helper_atomic_check()
657 ssd130x_state->data_array = kcalloc(ssd130x->width, pages, GFP_KERNEL); in ssd130x_primary_plane_helper_atomic_check()
658 if (!ssd130x_state->data_array) { in ssd130x_primary_plane_helper_atomic_check()
659 kfree(ssd130x_state->buffer); in ssd130x_primary_plane_helper_atomic_check()
661 ssd130x_state->buffer = NULL; in ssd130x_primary_plane_helper_atomic_check()
662 return -ENOMEM; in ssd130x_primary_plane_helper_atomic_check()
675 struct drm_device *drm = plane->dev; in ssd130x_primary_plane_helper_atomic_update()
685 dst_clip = plane_state->dst; in ssd130x_primary_plane_helper_atomic_update()
690 ssd130x_fb_blit_rect(plane_state, &shadow_plane_state->data[0], &dst_clip); in ssd130x_primary_plane_helper_atomic_update()
699 struct drm_device *drm = plane->dev; in ssd130x_primary_plane_helper_atomic_disable()
701 struct ssd130x_plane_state *ssd130x_state = to_ssd130x_plane_state(plane->state); in ssd130x_primary_plane_helper_atomic_disable()
717 WARN_ON(plane->state); in ssd130x_primary_plane_reset()
723 __drm_gem_reset_shadow_plane(plane, &ssd130x_state->base); in ssd130x_primary_plane_reset()
732 if (WARN_ON(!plane->state)) in ssd130x_primary_plane_duplicate_state()
735 old_ssd130x_state = to_ssd130x_plane_state(plane->state); in ssd130x_primary_plane_duplicate_state()
741 ssd130x_state->buffer = NULL; in ssd130x_primary_plane_duplicate_state()
742 ssd130x_state->data_array = NULL; in ssd130x_primary_plane_duplicate_state()
744 new_shadow_plane_state = &ssd130x_state->base; in ssd130x_primary_plane_duplicate_state()
748 return &new_shadow_plane_state->base; in ssd130x_primary_plane_duplicate_state()
756 kfree(ssd130x_state->data_array); in ssd130x_primary_plane_destroy_state()
757 kfree(ssd130x_state->buffer); in ssd130x_primary_plane_destroy_state()
759 __drm_gem_destroy_shadow_plane_state(&ssd130x_state->base); in ssd130x_primary_plane_destroy_state()
783 struct ssd130x_device *ssd130x = drm_to_ssd130x(crtc->dev); in ssd130x_crtc_helper_mode_valid()
785 if (mode->hdisplay != ssd130x->mode.hdisplay && in ssd130x_crtc_helper_mode_valid()
786 mode->vdisplay != ssd130x->mode.vdisplay) in ssd130x_crtc_helper_mode_valid()
788 else if (mode->hdisplay != ssd130x->mode.hdisplay) in ssd130x_crtc_helper_mode_valid()
790 else if (mode->vdisplay != ssd130x->mode.vdisplay) in ssd130x_crtc_helper_mode_valid()
818 struct drm_device *drm = encoder->dev; in ssd130x_encoder_helper_atomic_enable()
832 backlight_enable(ssd130x->bl_dev); in ssd130x_encoder_helper_atomic_enable()
844 struct drm_device *drm = encoder->dev; in ssd130x_encoder_helper_atomic_disable()
847 backlight_disable(ssd130x->bl_dev); in ssd130x_encoder_helper_atomic_disable()
865 struct ssd130x_device *ssd130x = drm_to_ssd130x(connector->dev); in ssd130x_connector_helper_get_modes()
867 struct device *dev = ssd130x->dev; in ssd130x_connector_helper_get_modes()
869 mode = drm_mode_duplicate(connector->dev, &ssd130x->mode); in ssd130x_connector_helper_get_modes()
876 drm_set_preferred_mode(connector, mode->hdisplay, mode->vdisplay); in ssd130x_connector_helper_get_modes()
923 ssd130x->contrast = brightness; in ssd130x_update_bl()
929 ret = ssd130x_write_cmd(ssd130x, 1, ssd130x->contrast); in ssd130x_update_bl()
942 struct device *dev = ssd130x->dev; in ssd130x_parse_properties()
944 if (device_property_read_u32(dev, "solomon,width", &ssd130x->width)) in ssd130x_parse_properties()
945 ssd130x->width = ssd130x->device_info->default_width; in ssd130x_parse_properties()
947 if (device_property_read_u32(dev, "solomon,height", &ssd130x->height)) in ssd130x_parse_properties()
948 ssd130x->height = ssd130x->device_info->default_height; in ssd130x_parse_properties()
950 if (device_property_read_u32(dev, "solomon,page-offset", &ssd130x->page_offset)) in ssd130x_parse_properties()
951 ssd130x->page_offset = 1; in ssd130x_parse_properties()
953 if (device_property_read_u32(dev, "solomon,col-offset", &ssd130x->col_offset)) in ssd130x_parse_properties()
954 ssd130x->col_offset = 0; in ssd130x_parse_properties()
956 if (device_property_read_u32(dev, "solomon,com-offset", &ssd130x->com_offset)) in ssd130x_parse_properties()
957 ssd130x->com_offset = 0; in ssd130x_parse_properties()
959 if (device_property_read_u32(dev, "solomon,prechargep1", &ssd130x->prechargep1)) in ssd130x_parse_properties()
960 ssd130x->prechargep1 = 2; in ssd130x_parse_properties()
962 if (device_property_read_u32(dev, "solomon,prechargep2", &ssd130x->prechargep2)) in ssd130x_parse_properties()
963 ssd130x->prechargep2 = 2; in ssd130x_parse_properties()
965 if (!device_property_read_u8_array(dev, "solomon,lookup-table", in ssd130x_parse_properties()
966 ssd130x->lookup_table, in ssd130x_parse_properties()
967 ARRAY_SIZE(ssd130x->lookup_table))) in ssd130x_parse_properties()
968 ssd130x->lookup_table_set = 1; in ssd130x_parse_properties()
970 ssd130x->seg_remap = !device_property_read_bool(dev, "solomon,segment-no-remap"); in ssd130x_parse_properties()
971 ssd130x->com_seq = device_property_read_bool(dev, "solomon,com-seq"); in ssd130x_parse_properties()
972 ssd130x->com_lrremap = device_property_read_bool(dev, "solomon,com-lrremap"); in ssd130x_parse_properties()
973 ssd130x->com_invdir = device_property_read_bool(dev, "solomon,com-invdir"); in ssd130x_parse_properties()
974 ssd130x->area_color_enable = in ssd130x_parse_properties()
975 device_property_read_bool(dev, "solomon,area-color-enable"); in ssd130x_parse_properties()
976 ssd130x->low_power = device_property_read_bool(dev, "solomon,low-power"); in ssd130x_parse_properties()
978 ssd130x->contrast = 127; in ssd130x_parse_properties()
979 ssd130x->vcomh = ssd130x->device_info->default_vcomh; in ssd130x_parse_properties()
982 if (device_property_read_u32(dev, "solomon,dclk-div", &ssd130x->dclk_div)) in ssd130x_parse_properties()
983 ssd130x->dclk_div = ssd130x->device_info->default_dclk_div; in ssd130x_parse_properties()
984 if (device_property_read_u32(dev, "solomon,dclk-frq", &ssd130x->dclk_frq)) in ssd130x_parse_properties()
985 ssd130x->dclk_frq = ssd130x->device_info->default_dclk_frq; in ssd130x_parse_properties()
990 struct drm_display_mode *mode = &ssd130x->mode; in ssd130x_init_modeset()
991 struct device *dev = ssd130x->dev; in ssd130x_init_modeset()
992 struct drm_device *drm = &ssd130x->drm; in ssd130x_init_modeset()
1010 mode->type = DRM_MODE_TYPE_DRIVER; in ssd130x_init_modeset()
1011 mode->clock = 1; in ssd130x_init_modeset()
1012 mode->hdisplay = mode->htotal = ssd130x->width; in ssd130x_init_modeset()
1013 mode->hsync_start = mode->hsync_end = ssd130x->width; in ssd130x_init_modeset()
1014 mode->vdisplay = mode->vtotal = ssd130x->height; in ssd130x_init_modeset()
1015 mode->vsync_start = mode->vsync_end = ssd130x->height; in ssd130x_init_modeset()
1016 mode->width_mm = 27; in ssd130x_init_modeset()
1017 mode->height_mm = 27; in ssd130x_init_modeset()
1019 max_width = max_t(unsigned long, mode->hdisplay, DRM_SHADOW_PLANE_MAX_WIDTH); in ssd130x_init_modeset()
1020 max_height = max_t(unsigned long, mode->vdisplay, DRM_SHADOW_PLANE_MAX_HEIGHT); in ssd130x_init_modeset()
1022 drm->mode_config.min_width = mode->hdisplay; in ssd130x_init_modeset()
1023 drm->mode_config.max_width = max_width; in ssd130x_init_modeset()
1024 drm->mode_config.min_height = mode->vdisplay; in ssd130x_init_modeset()
1025 drm->mode_config.max_height = max_height; in ssd130x_init_modeset()
1026 drm->mode_config.preferred_depth = 24; in ssd130x_init_modeset()
1027 drm->mode_config.funcs = &ssd130x_mode_config_funcs; in ssd130x_init_modeset()
1031 primary_plane = &ssd130x->primary_plane; in ssd130x_init_modeset()
1046 crtc = &ssd130x->crtc; in ssd130x_init_modeset()
1058 encoder = &ssd130x->encoder; in ssd130x_init_modeset()
1068 encoder->possible_crtcs = drm_crtc_mask(crtc); in ssd130x_init_modeset()
1072 connector = &ssd130x->connector; in ssd130x_init_modeset()
1095 struct device *dev = ssd130x->dev; in ssd130x_get_resources()
1097 ssd130x->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ssd130x_get_resources()
1098 if (IS_ERR(ssd130x->reset)) in ssd130x_get_resources()
1099 return dev_err_probe(dev, PTR_ERR(ssd130x->reset), in ssd130x_get_resources()
1102 ssd130x->vcc_reg = devm_regulator_get(dev, "vcc"); in ssd130x_get_resources()
1103 if (IS_ERR(ssd130x->vcc_reg)) in ssd130x_get_resources()
1104 return dev_err_probe(dev, PTR_ERR(ssd130x->vcc_reg), in ssd130x_get_resources()
1123 drm = &ssd130x->drm; in ssd130x_probe()
1125 ssd130x->dev = dev; in ssd130x_probe()
1126 ssd130x->regmap = regmap; in ssd130x_probe()
1127 ssd130x->device_info = device_get_match_data(dev); in ssd130x_probe()
1129 if (ssd130x->device_info->page_mode_only) in ssd130x_probe()
1130 ssd130x->page_address_mode = 1; in ssd130x_probe()
1144 bl->props.brightness = ssd130x->contrast; in ssd130x_probe()
1145 bl->props.max_brightness = MAX_CONTRAST; in ssd130x_probe()
1146 ssd130x->bl_dev = bl; in ssd130x_probe()
1164 drm_dev_unplug(&ssd130x->drm); in ssd130x_remove()
1170 drm_atomic_helper_shutdown(&ssd130x->drm); in ssd130x_shutdown()