Lines Matching refs:ctx
306 static int s6e63m0_clear_error(struct s6e63m0 *ctx) in s6e63m0_clear_error() argument
308 int ret = ctx->error; in s6e63m0_clear_error()
310 ctx->error = 0; in s6e63m0_clear_error()
314 static void s6e63m0_dcs_read(struct s6e63m0 *ctx, const u8 cmd, u8 *data) in s6e63m0_dcs_read() argument
316 if (ctx->error < 0) in s6e63m0_dcs_read()
319 ctx->error = ctx->dcs_read(ctx->dev, ctx->transport_data, cmd, data); in s6e63m0_dcs_read()
322 static void s6e63m0_dcs_write(struct s6e63m0 *ctx, const u8 *data, size_t len) in s6e63m0_dcs_write() argument
324 if (ctx->error < 0 || len == 0) in s6e63m0_dcs_write()
327 ctx->error = ctx->dcs_write(ctx->dev, ctx->transport_data, data, len); in s6e63m0_dcs_write()
330 #define s6e63m0_dcs_write_seq_static(ctx, seq ...) \ argument
333 s6e63m0_dcs_write(ctx, d, ARRAY_SIZE(d)); \
336 static int s6e63m0_check_lcd_type(struct s6e63m0 *ctx) in s6e63m0_check_lcd_type() argument
341 s6e63m0_dcs_read(ctx, MCS_READ_ID1, &id1); in s6e63m0_check_lcd_type()
342 s6e63m0_dcs_read(ctx, MCS_READ_ID2, &id2); in s6e63m0_check_lcd_type()
343 s6e63m0_dcs_read(ctx, MCS_READ_ID3, &id3); in s6e63m0_check_lcd_type()
345 ret = s6e63m0_clear_error(ctx); in s6e63m0_check_lcd_type()
347 dev_err(ctx->dev, "error checking LCD type (%d)\n", ret); in s6e63m0_check_lcd_type()
348 ctx->lcd_type = 0x00; in s6e63m0_check_lcd_type()
352 dev_info(ctx->dev, "MTP ID: %02x %02x %02x\n", id1, id2, id3); in s6e63m0_check_lcd_type()
361 dev_info(ctx->dev, "detected LCD panel AMS397GE MIPI M2\n"); in s6e63m0_check_lcd_type()
362 ctx->elvss_pulse = id3; in s6e63m0_check_lcd_type()
366 dev_info(ctx->dev, "detected LCD panel AMS397GE MIPI SM2\n"); in s6e63m0_check_lcd_type()
367 ctx->elvss_pulse = id3; in s6e63m0_check_lcd_type()
370 dev_info(ctx->dev, "unknown LCD panel type %02x\n", id2); in s6e63m0_check_lcd_type()
372 ctx->elvss_pulse = 0x16; in s6e63m0_check_lcd_type()
376 ctx->lcd_type = id2; in s6e63m0_check_lcd_type()
381 static void s6e63m0_init(struct s6e63m0 *ctx) in s6e63m0_init() argument
390 if (ctx->dsi_mode) in s6e63m0_init()
391 s6e63m0_dcs_write_seq_static(ctx, MCS_PANELCTL, in s6e63m0_init()
395 s6e63m0_dcs_write_seq_static(ctx, MCS_PANELCTL, in s6e63m0_init()
399 s6e63m0_dcs_write_seq_static(ctx, MCS_DISCTL, in s6e63m0_init()
401 s6e63m0_dcs_write_seq_static(ctx, MCS_IFCTL, in s6e63m0_init()
404 s6e63m0_dcs_write_seq_static(ctx, MCS_PGAMMACTL, in s6e63m0_init()
409 s6e63m0_dcs_write_seq_static(ctx, MCS_PGAMMACTL, in s6e63m0_init()
412 s6e63m0_dcs_write_seq_static(ctx, MCS_SRCCTL, in s6e63m0_init()
414 s6e63m0_dcs_write_seq_static(ctx, MCS_PENTILE_1, 0x6c); in s6e63m0_init()
416 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_Y_RED, in s6e63m0_init()
423 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_X_RED, in s6e63m0_init()
428 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_Y_GREEN, in s6e63m0_init()
435 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_X_GREEN, in s6e63m0_init()
440 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_Y_BLUE, in s6e63m0_init()
447 s6e63m0_dcs_write_seq_static(ctx, MCS_GAMMA_DELTA_X_BLUE, in s6e63m0_init()
452 s6e63m0_dcs_write_seq_static(ctx, MCS_BCMODE, in s6e63m0_init()
458 s6e63m0_dcs_write_seq_static(ctx, MCS_TEMP_SWIRE, in s6e63m0_init()
461 s6e63m0_dcs_write_seq_static(ctx, MCS_MIECTL1, in s6e63m0_init()
464 s6e63m0_dcs_write_seq_static(ctx, MCS_ELVSS_ON, in s6e63m0_init()
468 static int s6e63m0_power_on(struct s6e63m0 *ctx) in s6e63m0_power_on() argument
472 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e63m0_power_on()
479 gpiod_set_value(ctx->reset_gpio, 1); in s6e63m0_power_on()
481 gpiod_set_value(ctx->reset_gpio, 0); in s6e63m0_power_on()
487 static int s6e63m0_power_off(struct s6e63m0 *ctx) in s6e63m0_power_off() argument
491 gpiod_set_value(ctx->reset_gpio, 1); in s6e63m0_power_off()
494 ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e63m0_power_off()
503 struct s6e63m0 *ctx = panel_to_s6e63m0(panel); in s6e63m0_disable() local
505 if (!ctx->enabled) in s6e63m0_disable()
508 backlight_disable(ctx->bl_dev); in s6e63m0_disable()
510 s6e63m0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_OFF); in s6e63m0_disable()
512 s6e63m0_dcs_write_seq_static(ctx, MIPI_DCS_ENTER_SLEEP_MODE); in s6e63m0_disable()
515 ctx->enabled = false; in s6e63m0_disable()
522 struct s6e63m0 *ctx = panel_to_s6e63m0(panel); in s6e63m0_unprepare() local
525 if (!ctx->prepared) in s6e63m0_unprepare()
528 s6e63m0_clear_error(ctx); in s6e63m0_unprepare()
530 ret = s6e63m0_power_off(ctx); in s6e63m0_unprepare()
534 ctx->prepared = false; in s6e63m0_unprepare()
541 struct s6e63m0 *ctx = panel_to_s6e63m0(panel); in s6e63m0_prepare() local
544 if (ctx->prepared) in s6e63m0_prepare()
547 ret = s6e63m0_power_on(ctx); in s6e63m0_prepare()
552 s6e63m0_dcs_write_seq_static(ctx, MCS_LEVEL_2_KEY, 0x5a, 0x5a); in s6e63m0_prepare()
554 s6e63m0_dcs_write_seq_static(ctx, MCS_MTP_KEY, 0x5a, 0x5a); in s6e63m0_prepare()
556 ret = s6e63m0_check_lcd_type(ctx); in s6e63m0_prepare()
560 s6e63m0_init(ctx); in s6e63m0_prepare()
562 ret = s6e63m0_clear_error(ctx); in s6e63m0_prepare()
567 ctx->prepared = true; in s6e63m0_prepare()
574 struct s6e63m0 *ctx = panel_to_s6e63m0(panel); in s6e63m0_enable() local
576 if (ctx->enabled) in s6e63m0_enable()
579 s6e63m0_dcs_write_seq_static(ctx, MIPI_DCS_EXIT_SLEEP_MODE); in s6e63m0_enable()
581 s6e63m0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_ON); in s6e63m0_enable()
584 s6e63m0_dcs_write_seq_static(ctx, MCS_ERROR_CHECK, in s6e63m0_enable()
589 backlight_enable(ctx->bl_dev); in s6e63m0_enable()
591 ctx->enabled = true; in s6e63m0_enable()
635 struct s6e63m0 *ctx = bl_get_data(bd); in s6e63m0_set_brightness() local
643 elvss_val = ctx->elvss_pulse + s6e63m0_elvss_offsets[i]; in s6e63m0_set_brightness()
651 s6e63m0_dcs_write(ctx, elvss_cmd_set, 5); in s6e63m0_set_brightness()
655 s6e63m0_dcs_write(ctx, s6e63m0_acl[i], in s6e63m0_set_brightness()
659 s6e63m0_dcs_write(ctx, s6e63m0_gamma_22[brightness], in s6e63m0_set_brightness()
661 s6e63m0_dcs_write_seq_static(ctx, MCS_PGAMMACTL, 0x03); in s6e63m0_set_brightness()
664 return s6e63m0_clear_error(ctx); in s6e63m0_set_brightness()
671 static int s6e63m0_backlight_register(struct s6e63m0 *ctx, u32 max_brightness) in s6e63m0_backlight_register() argument
678 struct device *dev = ctx->dev; in s6e63m0_backlight_register()
681 ctx->bl_dev = devm_backlight_device_register(dev, "panel", dev, ctx, in s6e63m0_backlight_register()
684 if (IS_ERR(ctx->bl_dev)) { in s6e63m0_backlight_register()
685 ret = PTR_ERR(ctx->bl_dev); in s6e63m0_backlight_register()
697 struct s6e63m0 *ctx; in s6e63m0_probe() local
701 ctx = devm_kzalloc(dev, sizeof(struct s6e63m0), GFP_KERNEL); in s6e63m0_probe()
702 if (!ctx) in s6e63m0_probe()
705 ctx->transport_data = trsp; in s6e63m0_probe()
706 ctx->dsi_mode = dsi_mode; in s6e63m0_probe()
707 ctx->dcs_read = dcs_read; in s6e63m0_probe()
708 ctx->dcs_write = dcs_write; in s6e63m0_probe()
709 dev_set_drvdata(dev, ctx); in s6e63m0_probe()
711 ctx->dev = dev; in s6e63m0_probe()
712 ctx->enabled = false; in s6e63m0_probe()
713 ctx->prepared = false; in s6e63m0_probe()
723 ctx->supplies[0].supply = "vdd3"; in s6e63m0_probe()
724 ctx->supplies[1].supply = "vci"; in s6e63m0_probe()
725 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), in s6e63m0_probe()
726 ctx->supplies); in s6e63m0_probe()
732 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in s6e63m0_probe()
733 if (IS_ERR(ctx->reset_gpio)) { in s6e63m0_probe()
734 dev_err(dev, "cannot get reset-gpios %ld\n", PTR_ERR(ctx->reset_gpio)); in s6e63m0_probe()
735 return PTR_ERR(ctx->reset_gpio); in s6e63m0_probe()
738 drm_panel_init(&ctx->panel, dev, &s6e63m0_drm_funcs, in s6e63m0_probe()
742 ret = s6e63m0_backlight_register(ctx, max_brightness); in s6e63m0_probe()
746 drm_panel_add(&ctx->panel); in s6e63m0_probe()
754 struct s6e63m0 *ctx = dev_get_drvdata(dev); in s6e63m0_remove() local
756 drm_panel_remove(&ctx->panel); in s6e63m0_remove()