hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/drivers/video/drm/max96755f.c
....@@ -9,6 +9,7 @@
99 #include <i2c.h>
1010 #include <max96755f.h>
1111 #include <video_bridge.h>
12
+#include <drm/drm_mipi_dsi.h>
1213 #include <dm/of_access.h>
1314 #include <linux/media-bus-format.h>
1415
....@@ -21,9 +22,18 @@
2122 struct drm_display_mode *mode = &priv->mode;
2223 u32 hfp, hsa, hbp, hact;
2324 u32 vact, vsa, vfp, vbp;
25
+ u8 lane_map;
2426
2527 dm_i2c_reg_clrset(priv->dev, 0x0331, NUM_LANES,
2628 FIELD_PREP(NUM_LANES, priv->num_lanes - 1));
29
+
30
+ lane_map = (priv->dsi_lane_map[0] & 0xff) << 4 |
31
+ (priv->dsi_lane_map[1] & 0xff) << 6 |
32
+ (priv->dsi_lane_map[2] & 0xff) << 0 |
33
+ (priv->dsi_lane_map[3] & 0xff) << 2;
34
+
35
+ dm_i2c_reg_write(priv->dev, 0x0332, lane_map);
36
+
2737 if (!priv->dpi_deskew_en)
2838 return;
2939
....@@ -148,11 +158,26 @@
148158 .detect = max96755f_bridge_detect,
149159 };
150160
161
+static int max96755f_bridge_bind(struct udevice *dev)
162
+{
163
+ struct mipi_dsi_device *device = dev_get_platdata(dev);
164
+
165
+ device->dev = dev;
166
+ device->lanes = dev_read_u32_default(dev, "dsi,lanes", 4);
167
+ device->format = dev_read_u32_default(dev, "dsi,format",
168
+ MIPI_DSI_FMT_RGB888);
169
+ device->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
170
+ device->channel = dev_read_u32_default(dev, "reg", 0);
171
+
172
+ return 0;
173
+}
174
+
151175 static int max96755f_bridge_probe(struct udevice *dev)
152176 {
153177 struct rockchip_bridge *bridge;
154178 struct max96755f_priv *priv = dev_get_priv(dev->parent);
155
- int ret;
179
+ const struct device_node *np = ofnode_to_np(dev->node);
180
+ int i, len, ret;
156181
157182 bridge = calloc(1, sizeof(*bridge));
158183 if (!bridge)
....@@ -165,6 +190,24 @@
165190 priv->num_lanes = dev_read_u32_default(dev, "dsi,lanes", 4);
166191 priv->dv_swp_ab = dev_read_bool(dev, "vd-swap-ab");
167192 priv->dpi_deskew_en = dev_read_bool(dev, "dpi-deskew-en");
193
+
194
+ for ( i = 0; i < priv->num_lanes; i++)
195
+ priv->dsi_lane_map[i] = i;
196
+
197
+ if (of_find_property(np, "maxim,dsi-lane-map", &len)) {
198
+ len /= sizeof(u32);
199
+ if (priv->num_lanes != len) {
200
+ printf("invalid number of lane map\n");
201
+ return -EINVAL;
202
+ }
203
+ }
204
+
205
+ ret = of_read_u32_array(np, "maxim,dsi-lane-map",
206
+ priv->dsi_lane_map, priv->num_lanes);
207
+ if (ret) {
208
+ printf("get dsi lane map failed\n");
209
+ return -EINVAL;
210
+ }
168211
169212 ret = gpio_request_by_name(dev, "lock-gpios", 0, &priv->lock_gpio,
170213 GPIOD_IS_IN);
....@@ -186,4 +229,6 @@
186229 .id = UCLASS_VIDEO_BRIDGE,
187230 .of_match = max96755f_bridge_of_match,
188231 .probe = max96755f_bridge_probe,
232
+ .bind = max96755f_bridge_bind,
233
+ .platdata_auto_alloc_size = sizeof(struct mipi_dsi_device),
189234 };