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)  * THC63LVD1024 LVDS to parallel data DRM bridge driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2018 Jacopo Mondi <jacopo+renesas@jmondi.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/of_graph.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <drm/drm_bridge.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <drm/drm_panel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) enum thc63_ports {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	THC63_LVDS_IN0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	THC63_LVDS_IN1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	THC63_RGB_OUT0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	THC63_RGB_OUT1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) struct thc63_dev {
^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) 	struct regulator *vcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct gpio_desc *pdwn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct gpio_desc *oe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct drm_bridge bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct drm_bridge *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct drm_bridge_timings timings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static inline struct thc63_dev *to_thc63(struct drm_bridge *bridge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	return container_of(bridge, struct thc63_dev, bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static int thc63_attach(struct drm_bridge *bridge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			enum drm_bridge_attach_flags flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct thc63_dev *thc63 = to_thc63(bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return drm_bridge_attach(bridge->encoder, thc63->next, bridge, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static enum drm_mode_status thc63_mode_valid(struct drm_bridge *bridge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 					const struct drm_display_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 					const struct drm_display_mode *mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct thc63_dev *thc63 = to_thc63(bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	unsigned int min_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	unsigned int max_freq;
^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) 	 * The THC63LVD1024 pixel rate range is 8 to 135 MHz in all modes but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 * dual-in, single-out where it is 40 to 150 MHz. As dual-in, dual-out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 * isn't supported by the driver yet, simply derive the limits from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 * input mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (thc63->timings.dual_link) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		min_freq = 40000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		max_freq = 150000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		min_freq = 8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		max_freq = 135000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	if (mode->clock < min_freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		return MODE_CLOCK_LOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (mode->clock > max_freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		return MODE_CLOCK_HIGH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return MODE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static void thc63_enable(struct drm_bridge *bridge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct thc63_dev *thc63 = to_thc63(bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	ret = regulator_enable(thc63->vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		dev_err(thc63->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			"Failed to enable regulator \"vcc\": %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	gpiod_set_value(thc63->pdwn, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	gpiod_set_value(thc63->oe, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static void thc63_disable(struct drm_bridge *bridge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct thc63_dev *thc63 = to_thc63(bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	gpiod_set_value(thc63->oe, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	gpiod_set_value(thc63->pdwn, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	ret = regulator_disable(thc63->vcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		dev_err(thc63->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			"Failed to disable regulator \"vcc\": %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static const struct drm_bridge_funcs thc63_bridge_func = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	.attach	= thc63_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.mode_valid = thc63_mode_valid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.enable = thc63_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.disable = thc63_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int thc63_parse_dt(struct thc63_dev *thc63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct device_node *endpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct device_node *remote;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 						 THC63_RGB_OUT0, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (!endpoint) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			THC63_RGB_OUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	remote = of_graph_get_remote_port_parent(endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	of_node_put(endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (!remote) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			THC63_RGB_OUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (!of_device_is_available(remote)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			THC63_RGB_OUT0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		of_node_put(remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	thc63->next = of_drm_find_bridge(remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	of_node_put(remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (!thc63->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 						 THC63_LVDS_IN1, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if (endpoint) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		remote = of_graph_get_remote_port_parent(endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		of_node_put(endpoint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		if (remote) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			if (of_device_is_available(remote))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 				thc63->timings.dual_link = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			of_node_put(remote);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	dev_dbg(thc63->dev, "operating in %s-link mode\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		thc63->timings.dual_link ? "dual" : "single");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static int thc63_gpio_init(struct thc63_dev *thc63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	thc63->oe = devm_gpiod_get_optional(thc63->dev, "oe", GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	if (IS_ERR(thc63->oe)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		dev_err(thc63->dev, "Unable to get \"oe-gpios\": %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			PTR_ERR(thc63->oe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return PTR_ERR(thc63->oe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	thc63->pdwn = devm_gpiod_get_optional(thc63->dev, "powerdown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 					      GPIOD_OUT_HIGH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (IS_ERR(thc63->pdwn)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		dev_err(thc63->dev, "Unable to get \"powerdown-gpios\": %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			PTR_ERR(thc63->pdwn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		return PTR_ERR(thc63->pdwn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static int thc63_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	struct thc63_dev *thc63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	thc63 = devm_kzalloc(&pdev->dev, sizeof(*thc63), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (!thc63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	thc63->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	platform_set_drvdata(pdev, thc63);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	thc63->vcc = devm_regulator_get_optional(thc63->dev, "vcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (IS_ERR(thc63->vcc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		if (PTR_ERR(thc63->vcc) == -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			return -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		dev_err(thc63->dev, "Unable to get \"vcc\" supply: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			PTR_ERR(thc63->vcc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return PTR_ERR(thc63->vcc);
^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) 	ret = thc63_gpio_init(thc63);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	ret = thc63_parse_dt(thc63);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	if (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) 	thc63->bridge.driver_private = thc63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	thc63->bridge.of_node = pdev->dev.of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	thc63->bridge.funcs = &thc63_bridge_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	thc63->bridge.timings = &thc63->timings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	drm_bridge_add(&thc63->bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static int thc63_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	struct thc63_dev *thc63 = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	drm_bridge_remove(&thc63->bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static const struct of_device_id thc63_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	{ .compatible = "thine,thc63lvd1024", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MODULE_DEVICE_TABLE(of, thc63_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static struct platform_driver thc63_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	.probe	= thc63_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	.remove	= thc63_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		.name		= "thc63lvd1024",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		.of_match_table	= thc63_match,
^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) module_platform_driver(thc63_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MODULE_AUTHOR("Jacopo Mondi <jacopo@jmondi.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MODULE_DESCRIPTION("Thine THC63LVD1024 LVDS decoder DRM bridge driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MODULE_LICENSE("GPL v2");