From 04dd17822334871b23ea2862f7798fb0e0007777 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Sat, 11 May 2024 08:53:19 +0000
Subject: [PATCH] change otg to host mode
---
u-boot/drivers/video/drm/max96755f.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/u-boot/drivers/video/drm/max96755f.c b/u-boot/drivers/video/drm/max96755f.c
index e09849f..1e0ec08 100644
--- a/u-boot/drivers/video/drm/max96755f.c
+++ b/u-boot/drivers/video/drm/max96755f.c
@@ -9,6 +9,7 @@
#include <i2c.h>
#include <max96755f.h>
#include <video_bridge.h>
+#include <drm/drm_mipi_dsi.h>
#include <dm/of_access.h>
#include <linux/media-bus-format.h>
@@ -21,9 +22,18 @@
struct drm_display_mode *mode = &priv->mode;
u32 hfp, hsa, hbp, hact;
u32 vact, vsa, vfp, vbp;
+ u8 lane_map;
dm_i2c_reg_clrset(priv->dev, 0x0331, NUM_LANES,
FIELD_PREP(NUM_LANES, priv->num_lanes - 1));
+
+ lane_map = (priv->dsi_lane_map[0] & 0xff) << 4 |
+ (priv->dsi_lane_map[1] & 0xff) << 6 |
+ (priv->dsi_lane_map[2] & 0xff) << 0 |
+ (priv->dsi_lane_map[3] & 0xff) << 2;
+
+ dm_i2c_reg_write(priv->dev, 0x0332, lane_map);
+
if (!priv->dpi_deskew_en)
return;
@@ -148,11 +158,26 @@
.detect = max96755f_bridge_detect,
};
+static int max96755f_bridge_bind(struct udevice *dev)
+{
+ struct mipi_dsi_device *device = dev_get_platdata(dev);
+
+ device->dev = dev;
+ device->lanes = dev_read_u32_default(dev, "dsi,lanes", 4);
+ device->format = dev_read_u32_default(dev, "dsi,format",
+ MIPI_DSI_FMT_RGB888);
+ device->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
+ device->channel = dev_read_u32_default(dev, "reg", 0);
+
+ return 0;
+}
+
static int max96755f_bridge_probe(struct udevice *dev)
{
struct rockchip_bridge *bridge;
struct max96755f_priv *priv = dev_get_priv(dev->parent);
- int ret;
+ const struct device_node *np = ofnode_to_np(dev->node);
+ int i, len, ret;
bridge = calloc(1, sizeof(*bridge));
if (!bridge)
@@ -165,6 +190,24 @@
priv->num_lanes = dev_read_u32_default(dev, "dsi,lanes", 4);
priv->dv_swp_ab = dev_read_bool(dev, "vd-swap-ab");
priv->dpi_deskew_en = dev_read_bool(dev, "dpi-deskew-en");
+
+ for ( i = 0; i < priv->num_lanes; i++)
+ priv->dsi_lane_map[i] = i;
+
+ if (of_find_property(np, "maxim,dsi-lane-map", &len)) {
+ len /= sizeof(u32);
+ if (priv->num_lanes != len) {
+ printf("invalid number of lane map\n");
+ return -EINVAL;
+ }
+ }
+
+ ret = of_read_u32_array(np, "maxim,dsi-lane-map",
+ priv->dsi_lane_map, priv->num_lanes);
+ if (ret) {
+ printf("get dsi lane map failed\n");
+ return -EINVAL;
+ }
ret = gpio_request_by_name(dev, "lock-gpios", 0, &priv->lock_gpio,
GPIOD_IS_IN);
@@ -186,4 +229,6 @@
.id = UCLASS_VIDEO_BRIDGE,
.of_match = max96755f_bridge_of_match,
.probe = max96755f_bridge_probe,
+ .bind = max96755f_bridge_bind,
+ .platdata_auto_alloc_size = sizeof(struct mipi_dsi_device),
};
--
Gitblit v1.6.2