Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Generic LVDS panel driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2016 Laurent Pinchart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2016 Renesas Electronics Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/of_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <video/display_timing.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <video/of_display_timing.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <video/videomode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <drm/drm_crtc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <drm/drm_panel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct panel_lvds {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct drm_panel panel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	const char *label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	unsigned int width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	unsigned int height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct videomode video_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	unsigned int bus_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	bool data_mirror;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct regulator *supply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct gpio_desc *enable_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct gpio_desc *reset_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	enum drm_panel_orientation orientation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static inline struct panel_lvds *to_panel_lvds(struct drm_panel *panel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return container_of(panel, struct panel_lvds, panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static int panel_lvds_unprepare(struct drm_panel *panel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct panel_lvds *lvds = to_panel_lvds(panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (lvds->enable_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		gpiod_set_value_cansleep(lvds->enable_gpio, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (lvds->supply)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		regulator_disable(lvds->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static int panel_lvds_prepare(struct drm_panel *panel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct panel_lvds *lvds = to_panel_lvds(panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (lvds->supply) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		err = regulator_enable(lvds->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			dev_err(lvds->dev, "failed to enable supply: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (lvds->enable_gpio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		gpiod_set_value_cansleep(lvds->enable_gpio, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static int panel_lvds_get_modes(struct drm_panel *panel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 				struct drm_connector *connector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct panel_lvds *lvds = to_panel_lvds(panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct drm_display_mode *mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	mode = drm_mode_create(connector->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if (!mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	drm_display_mode_from_videomode(&lvds->video_mode, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	drm_mode_probed_add(connector, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	connector->display_info.width_mm = lvds->width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	connector->display_info.height_mm = lvds->height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	drm_display_info_set_bus_formats(&connector->display_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 					 &lvds->bus_format, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	connector->display_info.bus_flags = lvds->data_mirror
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 					  ? DRM_BUS_FLAG_DATA_LSB_TO_MSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 					  : DRM_BUS_FLAG_DATA_MSB_TO_LSB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	drm_connector_set_panel_orientation(connector, lvds->orientation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static const struct drm_panel_funcs panel_lvds_funcs = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	.unprepare = panel_lvds_unprepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	.prepare = panel_lvds_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.get_modes = panel_lvds_get_modes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static int panel_lvds_parse_dt(struct panel_lvds *lvds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct device_node *np = lvds->dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct display_timing timing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	const char *mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	ret = of_drm_get_panel_orientation(np, &lvds->orientation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		dev_err(lvds->dev, "%pOF: failed to get orientation %d\n", np, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	ret = of_get_display_timing(np, "panel-timing", &timing);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		dev_err(lvds->dev, "%pOF: problems parsing panel-timing (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			np, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	videomode_from_timing(&timing, &lvds->video_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	ret = of_property_read_u32(np, "width-mm", &lvds->width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			np, "width-mm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	ret = of_property_read_u32(np, "height-mm", &lvds->height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			np, "height-mm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	of_property_read_string(np, "label", &lvds->label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ret = of_property_read_string(np, "data-mapping", &mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			np, "data-mapping");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (!strcmp(mapping, "jeida-18")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		lvds->bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	} else if (!strcmp(mapping, "jeida-24")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	} else if (!strcmp(mapping, "vesa-24")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			np, "data-mapping");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	lvds->data_mirror = of_property_read_bool(np, "data-mirror");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static int panel_lvds_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct panel_lvds *lvds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (!lvds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	lvds->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	ret = panel_lvds_parse_dt(lvds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	lvds->supply = devm_regulator_get_optional(lvds->dev, "power");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	if (IS_ERR(lvds->supply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		ret = PTR_ERR(lvds->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		if (ret != -ENODEV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			if (ret != -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				dev_err(lvds->dev, "failed to request regulator: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 					ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		lvds->supply = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* Get GPIOs and backlight controller. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	lvds->enable_gpio = devm_gpiod_get_optional(lvds->dev, "enable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 						     GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (IS_ERR(lvds->enable_gpio)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		ret = PTR_ERR(lvds->enable_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		dev_err(lvds->dev, "failed to request %s GPIO: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			"enable", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	lvds->reset_gpio = devm_gpiod_get_optional(lvds->dev, "reset",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 						     GPIOD_OUT_HIGH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (IS_ERR(lvds->reset_gpio)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		ret = PTR_ERR(lvds->reset_gpio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		dev_err(lvds->dev, "failed to request %s GPIO: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			"reset", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	 * TODO: Handle all power supplies specified in the DT node in a generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	 * way for panels that don't care about power supply ordering. LVDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	 * panels that require a specific power sequence will need a dedicated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	 * driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	/* Register the panel. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	drm_panel_init(&lvds->panel, lvds->dev, &panel_lvds_funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		       DRM_MODE_CONNECTOR_LVDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	ret = drm_panel_of_backlight(&lvds->panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	drm_panel_add(&lvds->panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	dev_set_drvdata(lvds->dev, lvds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static int panel_lvds_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct panel_lvds *lvds = dev_get_drvdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	drm_panel_remove(&lvds->panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	drm_panel_disable(&lvds->panel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static const struct of_device_id panel_lvds_of_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	{ .compatible = "panel-lvds", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	{ /* Sentinel */ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MODULE_DEVICE_TABLE(of, panel_lvds_of_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static struct platform_driver panel_lvds_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	.probe		= panel_lvds_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	.remove		= panel_lvds_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		.name	= "panel-lvds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		.of_match_table = panel_lvds_of_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) module_platform_driver(panel_lvds_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) MODULE_DESCRIPTION("LVDS Panel Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) MODULE_LICENSE("GPL");