Lines Matching +full:regulator +full:- +full:v6

1 // SPDX-License-Identifier: GPL-2.0-only
6 * - 8-bit serial RGB interface
7 * - 24-bit parallel RGB interface
8 * - 8-bit ITU-R BT.601 interface
9 * - 8-bit ITU-R BT.656 interface
10 * - Up to 320RGBx240 dots resolution TFT LCD displays
11 * - Scaling, brightness and contrast
19 * Derived from drivers/drm/gpu/panel/panel-samsung-ld9040.c
28 #include <linux/regulator/consumer.h>
56 * VREG1 voltage regulator from 3.6V (0x00) to 6.0V (0x18) in 0.1V
64 /* 0 = right-to-left, 1 = left-to-right (default), horizontal flip */
66 /* 0 = down-to-up, 1 = up-to-down (default), vertical flip */
127 /* Formula A for YCbCR->RGB = 0, Formula B = 1 */
140 #define ILI9322_GLOBAL_RESET_ASSERT 0x00 /* bit 0 = 0 -> reset */
144 * Upper nybble, bits 4-7 are negative gamma
145 * Lower nybble, bits 0-3 are positive gamma
157 * enum ili9322_input - the format of the incoming signal to the panel
191 "8 bit ITU-R BT.656 720Y 360CbCr",
192 "8 bit ITU-R BT.656 640Y 320CbCr",
196 * struct ili9322_config - the system specific ILI9322 configuration
199 * @flip_horizontal: flip the image horizontally (right-to-left scan)
201 * @flip_vertical: flip the image vertically (down-to-up scan)
206 * @vreg1out_mv: the output in microvolts for the VREGOUT1 regulator used
214 * peak-to-peak amplitude of the communcation signals to the physical
231 * V2 = 16, V3 = 48, V4 = 96, V5 = 160, V6 = 208, V7 = 240 and V8 = 255.
237 * | V6
243 * +----------------------------------------------------------->
335 /* Just register 0 is read-only */ in ili9322_writeable_reg()
357 ret = regmap_write(ili->regmap, ILI9322_GLOBAL_RESET, in ili9322_init()
360 dev_err(ili->dev, "can't issue GRESET (%d)\n", ret); in ili9322_init()
364 /* Set up the main voltage regulator */ in ili9322_init()
365 if (ili->vreg1out != U8_MAX) { in ili9322_init()
366 ret = regmap_write(ili->regmap, ILI9322_VREG1_VOLTAGE, in ili9322_init()
367 ili->vreg1out); in ili9322_init()
369 dev_err(ili->dev, "can't set up VREG1OUT (%d)\n", ret); in ili9322_init()
374 if (ili->vcom_amplitude != U8_MAX) { in ili9322_init()
375 ret = regmap_write(ili->regmap, ILI9322_VCOM_AMP, in ili9322_init()
376 ili->vcom_amplitude); in ili9322_init()
378 dev_err(ili->dev, in ili9322_init()
384 if (ili->vcom_high != U8_MAX) { in ili9322_init()
385 ret = regmap_write(ili->regmap, ILI9322_VCOM_HIGH, in ili9322_init()
386 ili->vcom_high); in ili9322_init()
388 dev_err(ili->dev, "can't set up VCOM high (%d)\n", ret); in ili9322_init()
394 for (i = 0; i < ARRAY_SIZE(ili->gamma); i++) { in ili9322_init()
395 ret = regmap_write(ili->regmap, ILI9322_GAMMA_1 + i, in ili9322_init()
396 ili->gamma[i]); in ili9322_init()
398 dev_err(ili->dev, in ili9322_init()
410 if (ili->conf->dclk_active_high) in ili9322_init()
412 if (ili->conf->de_active_high) in ili9322_init()
414 if (ili->conf->hsync_active_high) in ili9322_init()
416 if (ili->conf->vsync_active_high) in ili9322_init()
418 ret = regmap_write(ili->regmap, ILI9322_POL, reg); in ili9322_init()
420 dev_err(ili->dev, "can't write POL register (%d)\n", ret); in ili9322_init()
428 reg = ili->conf->syncmode; in ili9322_init()
430 ret = regmap_write(ili->regmap, ILI9322_IF_CTRL, reg); in ili9322_init()
432 dev_err(ili->dev, "can't write IF CTRL register (%d)\n", ret); in ili9322_init()
437 reg = (ili->input << 4); in ili9322_init()
439 if (!ili->conf->flip_horizontal) in ili9322_init()
441 if (!ili->conf->flip_vertical) in ili9322_init()
444 ret = regmap_write(ili->regmap, ILI9322_ENTRY, reg); in ili9322_init()
446 dev_err(ili->dev, "can't write ENTRY reg (%d)\n", ret); in ili9322_init()
449 dev_info(ili->dev, "display is in %s mode, syncmode %02x\n", in ili9322_init()
450 ili9322_inputs[ili->input], in ili9322_init()
451 ili->conf->syncmode); in ili9322_init()
453 dev_info(ili->dev, "initialized display\n"); in ili9322_init()
459 * This power-on sequence if from the datasheet, page 57.
466 gpiod_set_value(ili->reset_gpio, 1); in ili9322_power_on()
468 ret = regulator_bulk_enable(ARRAY_SIZE(ili->supplies), ili->supplies); in ili9322_power_on()
470 dev_err(ili->dev, "unable to enable regulators\n"); in ili9322_power_on()
475 /* De-assert RESET */ in ili9322_power_on()
476 gpiod_set_value(ili->reset_gpio, 0); in ili9322_power_on()
485 return regulator_bulk_disable(ARRAY_SIZE(ili->supplies), ili->supplies); in ili9322_power_off()
493 ret = regmap_write(ili->regmap, ILI9322_POW_CTRL, in ili9322_disable()
496 dev_err(ili->dev, "unable to go to standby mode\n"); in ili9322_disable()
531 ret = regmap_write(ili->regmap, ILI9322_POW_CTRL, in ili9322_enable()
534 dev_err(ili->dev, "unable to enable panel\n"); in ili9322_enable()
641 struct drm_device *drm = connector->dev; in ili9322_get_modes()
645 info = &connector->display_info; in ili9322_get_modes()
646 info->width_mm = ili->conf->width_mm; in ili9322_get_modes()
647 info->height_mm = ili->conf->height_mm; in ili9322_get_modes()
648 if (ili->conf->dclk_active_high) in ili9322_get_modes()
649 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE; in ili9322_get_modes()
651 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE; in ili9322_get_modes()
653 if (ili->conf->de_active_high) in ili9322_get_modes()
654 info->bus_flags |= DRM_BUS_FLAG_DE_HIGH; in ili9322_get_modes()
656 info->bus_flags |= DRM_BUS_FLAG_DE_LOW; in ili9322_get_modes()
658 switch (ili->input) { in ili9322_get_modes()
686 dev_err(panel->dev, "bad mode or failed to add mode\n"); in ili9322_get_modes()
687 return -EINVAL; in ili9322_get_modes()
694 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in ili9322_get_modes()
697 if (ili->conf->hsync_active_high) in ili9322_get_modes()
698 mode->flags |= DRM_MODE_FLAG_PHSYNC; in ili9322_get_modes()
700 mode->flags |= DRM_MODE_FLAG_NHSYNC; in ili9322_get_modes()
701 if (ili->conf->vsync_active_high) in ili9322_get_modes()
702 mode->flags |= DRM_MODE_FLAG_PVSYNC; in ili9322_get_modes()
704 mode->flags |= DRM_MODE_FLAG_NVSYNC; in ili9322_get_modes()
706 mode->width_mm = ili->conf->width_mm; in ili9322_get_modes()
707 mode->height_mm = ili->conf->height_mm; in ili9322_get_modes()
723 struct device *dev = &spi->dev; in ili9322_probe()
733 return -ENOMEM; in ili9322_probe()
737 ili->dev = dev; in ili9322_probe()
743 ili->conf = of_device_get_match_data(dev); in ili9322_probe()
744 if (!ili->conf) { in ili9322_probe()
746 return -ENODEV; in ili9322_probe()
749 val = ili->conf->vreg1out_mv; in ili9322_probe()
752 ili->vreg1out = U8_MAX; in ili9322_probe()
756 return -EINVAL; in ili9322_probe()
760 return -EINVAL; in ili9322_probe()
764 return -EINVAL; in ili9322_probe()
766 val -= 3600; in ili9322_probe()
769 ili->vreg1out = val; in ili9322_probe()
772 val = ili->conf->vcom_high_percent; in ili9322_probe()
775 ili->vcom_high = U8_MAX; in ili9322_probe()
779 return -EINVAL; in ili9322_probe()
783 return -EINVAL; in ili9322_probe()
785 val -= 37; in ili9322_probe()
787 ili->vcom_high = val; in ili9322_probe()
790 val = ili->conf->vcom_amplitude_percent; in ili9322_probe()
793 ili->vcom_high = U8_MAX; in ili9322_probe()
797 return -EINVAL; in ili9322_probe()
801 return -EINVAL; in ili9322_probe()
803 val -= 70; in ili9322_probe()
806 ili->vcom_amplitude = val; in ili9322_probe()
809 for (i = 0; i < ARRAY_SIZE(ili->gamma); i++) { in ili9322_probe()
810 val = ili->conf->gamma_corr_neg[i]; in ili9322_probe()
816 val = ili->conf->gamma_corr_pos[i]; in ili9322_probe()
822 ili->gamma[i] = gamma; in ili9322_probe()
826 ili->supplies[0].supply = "vcc"; /* 2.7-3.6 V */ in ili9322_probe()
827 ili->supplies[1].supply = "iovcc"; /* 1.65-3.6V */ in ili9322_probe()
828 ili->supplies[2].supply = "vci"; /* 2.7-3.6V */ in ili9322_probe()
829 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ili->supplies), in ili9322_probe()
830 ili->supplies); in ili9322_probe()
833 ret = regulator_set_voltage(ili->supplies[0].consumer, in ili9322_probe()
837 ret = regulator_set_voltage(ili->supplies[1].consumer, in ili9322_probe()
841 ret = regulator_set_voltage(ili->supplies[2].consumer, in ili9322_probe()
846 ili->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in ili9322_probe()
847 if (IS_ERR(ili->reset_gpio)) { in ili9322_probe()
849 return PTR_ERR(ili->reset_gpio); in ili9322_probe()
852 spi->bits_per_word = 8; in ili9322_probe()
859 ili->regmap = devm_regmap_init(dev, &ili9322_regmap_bus, dev, in ili9322_probe()
861 if (IS_ERR(ili->regmap)) { in ili9322_probe()
863 return PTR_ERR(ili->regmap); in ili9322_probe()
866 ret = regmap_read(ili->regmap, ILI9322_CHIP_ID, &val); in ili9322_probe()
874 return -ENODEV; in ili9322_probe()
878 if (ili->conf->input == ILI9322_INPUT_UNKNOWN) { in ili9322_probe()
879 ret = regmap_read(ili->regmap, ILI9322_ENTRY, &val); in ili9322_probe()
885 ili->input = (val >> 4) & 0x0f; in ili9322_probe()
886 if (ili->input >= ILI9322_INPUT_UNKNOWN) in ili9322_probe()
887 ili->input = ILI9322_INPUT_UNKNOWN; in ili9322_probe()
889 ili->input = ili->conf->input; in ili9322_probe()
892 drm_panel_init(&ili->panel, dev, &ili9322_drm_funcs, in ili9322_probe()
895 drm_panel_add(&ili->panel); in ili9322_probe()
905 drm_panel_remove(&ili->panel); in ili9322_remove()
909 * The D-Link DIR-685 panel is marked LM918A01-1A SY-B4-091116-E0199
926 .compatible = "dlink,dir-685-panel",
941 .name = "panel-ilitek-ili9322",