1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
7 #include <linux/gpio/consumer.h>
9 #include <linux/interrupt.h>
10 #include <linux/iopoll.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/mutex.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/regulator/consumer.h>
16 #include <linux/slab.h>
17 #include <linux/types.h>
18 #include <linux/workqueue.h>
20 #include <linux/of_gpio.h>
21 #include <linux/of_graph.h>
22 #include <linux/of_platform.h>
24 #include <drm/drm_atomic_helper.h>
25 #include <drm/drm_bridge.h>
26 #include <drm/drm_crtc_helper.h>
27 #include <drm/drm_dp_helper.h>
28 #include <drm/drm_edid.h>
29 #include <drm/drm_mipi_dsi.h>
30 #include <drm/drm_of.h>
31 #include <drm/drm_panel.h>
32 #include <drm/drm_print.h>
33 #include <drm/drm_probe_helper.h>
35 #include <media/v4l2-fwnode.h>
36 #include <sound/hdmi-codec.h>
37 #include <video/display_timing.h>
42 * There is a sync issue while access I2C register between AP(CPU) and
43 * internal firmware(OCM), to avoid the race condition, AP should access
44 * the reserved slave address before slave address occurs changes.
46 static int i2c_access_workaround(struct anx7625_data *ctx,
47 struct i2c_client *client)
50 struct device *dev = &client->dev;
53 if (client == ctx->last_client)
56 ctx->last_client = client;
58 if (client == ctx->i2c.tcpc_client)
59 offset = RSVD_00_ADDR;
60 else if (client == ctx->i2c.tx_p0_client)
61 offset = RSVD_D1_ADDR;
62 else if (client == ctx->i2c.tx_p1_client)
63 offset = RSVD_60_ADDR;
64 else if (client == ctx->i2c.rx_p0_client)
65 offset = RSVD_39_ADDR;
66 else if (client == ctx->i2c.rx_p1_client)
67 offset = RSVD_7F_ADDR;
69 offset = RSVD_00_ADDR;
71 ret = i2c_smbus_write_byte_data(client, offset, 0x00);
74 "fail to access i2c id=%x\n:%x",
75 client->addr, offset);
80 static int anx7625_reg_read(struct anx7625_data *ctx,
81 struct i2c_client *client, u8 reg_addr)
84 struct device *dev = &client->dev;
86 i2c_access_workaround(ctx, client);
88 ret = i2c_smbus_read_byte_data(client, reg_addr);
90 DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
91 client->addr, reg_addr);
96 static int anx7625_reg_block_read(struct anx7625_data *ctx,
97 struct i2c_client *client,
98 u8 reg_addr, u8 len, u8 *buf)
101 struct device *dev = &client->dev;
103 i2c_access_workaround(ctx, client);
105 ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
107 DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
108 client->addr, reg_addr);
113 static int anx7625_reg_write(struct anx7625_data *ctx,
114 struct i2c_client *client,
115 u8 reg_addr, u8 reg_val)
118 struct device *dev = &client->dev;
120 i2c_access_workaround(ctx, client);
122 ret = i2c_smbus_write_byte_data(client, reg_addr, reg_val);
125 DRM_DEV_ERROR(dev, "fail to write i2c id=%x\n:%x",
126 client->addr, reg_addr);
131 static int anx7625_write_or(struct anx7625_data *ctx,
132 struct i2c_client *client,
137 val = anx7625_reg_read(ctx, client, offset);
141 return anx7625_reg_write(ctx, client, offset, (val | (mask)));
144 static int anx7625_write_and(struct anx7625_data *ctx,
145 struct i2c_client *client,
150 val = anx7625_reg_read(ctx, client, offset);
154 return anx7625_reg_write(ctx, client, offset, (val & (mask)));
157 static int anx7625_write_and_or(struct anx7625_data *ctx,
158 struct i2c_client *client,
159 u8 offset, u8 and_mask, u8 or_mask)
163 val = anx7625_reg_read(ctx, client, offset);
167 return anx7625_reg_write(ctx, client,
168 offset, (val & and_mask) | (or_mask));
171 static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
175 ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
176 AUDIO_CONTROL_REGISTER, 0x80);
177 for (i = 0; i < 13; i++)
178 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
179 VIDEO_BIT_MATRIX_12 + i,
185 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
187 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS);
190 static int wait_aux_op_finish(struct anx7625_data *ctx)
192 struct device *dev = &ctx->client->dev;
196 ret = readx_poll_timeout(anx7625_read_ctrl_status_p0,
198 (!(val & AP_AUX_CTRL_OP_EN) || (val < 0)),
202 DRM_DEV_ERROR(dev, "aux operation fail!\n");
206 val = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client,
208 if (val < 0 || (val & 0x0F)) {
209 DRM_DEV_ERROR(dev, "aux status %02x\n", val);
216 static int anx7625_video_mute_control(struct anx7625_data *ctx,
222 /* Set mute on flag */
223 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
224 AP_AV_STATUS, AP_MIPI_MUTE);
225 /* Clear mipi RX en */
226 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
227 AP_AV_STATUS, (u8)~AP_MIPI_RX_EN);
230 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
231 AP_AV_STATUS, (u8)~AP_MIPI_MUTE);
233 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
234 AP_AV_STATUS, AP_MIPI_RX_EN);
240 /* Reduction of fraction a/b */
241 static void anx7625_reduction_of_a_fraction(unsigned long *a, unsigned long *b)
243 unsigned long gcd_num;
244 unsigned long tmp_a, tmp_b;
247 gcd_num = gcd(*a, *b);
254 while ((*a > MAX_UNSIGNED_24BIT) || (*b > MAX_UNSIGNED_24BIT)) {
261 * In the end, make a, b larger to have higher ODFC PLL
262 * output frequency accuracy
264 while ((*a < MAX_UNSIGNED_24BIT) && (*b < MAX_UNSIGNED_24BIT)) {
273 static int anx7625_calculate_m_n(u32 pixelclock,
278 if (pixelclock > PLL_OUT_FREQ_ABS_MAX / POST_DIVIDER_MIN) {
279 /* Pixel clock frequency is too high */
280 DRM_ERROR("pixelclock too high, act(%d), maximum(%lu)\n",
282 PLL_OUT_FREQ_ABS_MAX / POST_DIVIDER_MIN);
286 if (pixelclock < PLL_OUT_FREQ_ABS_MIN / POST_DIVIDER_MAX) {
287 /* Pixel clock frequency is too low */
288 DRM_ERROR("pixelclock too low, act(%d), maximum(%lu)\n",
290 PLL_OUT_FREQ_ABS_MIN / POST_DIVIDER_MAX);
294 for (*post_divider = 1;
295 pixelclock < (PLL_OUT_FREQ_MIN / (*post_divider));)
298 if (*post_divider > POST_DIVIDER_MAX) {
299 for (*post_divider = 1;
301 (PLL_OUT_FREQ_ABS_MIN / (*post_divider)));)
304 if (*post_divider > POST_DIVIDER_MAX) {
305 DRM_ERROR("cannot find property post_divider(%d)\n",
311 /* Patch to improve the accuracy */
312 if (*post_divider == 7) {
313 /* 27,000,000 is not divisible by 7 */
315 } else if (*post_divider == 11) {
316 /* 27,000,000 is not divisible by 11 */
318 } else if ((*post_divider == 13) || (*post_divider == 14)) {
319 /* 27,000,000 is not divisible by 13 or 14 */
323 if (pixelclock * (*post_divider) > PLL_OUT_FREQ_ABS_MAX) {
324 DRM_ERROR("act clock(%u) large than maximum(%lu)\n",
325 pixelclock * (*post_divider),
326 PLL_OUT_FREQ_ABS_MAX);
331 *n = XTAL_FRQ / (*post_divider);
333 anx7625_reduction_of_a_fraction(m, n);
338 static int anx7625_odfc_config(struct anx7625_data *ctx,
342 struct device *dev = &ctx->client->dev;
344 /* Config input reference clock frequency 27MHz/19.2MHz */
345 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_16,
346 ~(REF_CLK_27000KHZ << MIPI_FREF_D_IND));
347 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_16,
348 (REF_CLK_27000KHZ << MIPI_FREF_D_IND));
350 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client,
351 MIPI_DIGITAL_PLL_8, 0x0f);
352 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_8,
355 /* Add patch for MIS2-125 (5pcs ANX7625 fail ATE MBIST test) */
356 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7,
357 ~MIPI_PLL_VCO_TUNE_REG_VAL);
360 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7,
362 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_7,
366 DRM_DEV_ERROR(dev, "IO error.\n");
372 * The MIPI source video data exist large variation (e.g. 59Hz ~ 61Hz),
373 * anx7625 defined K ratio for matching MIPI input video clock and
374 * DP output video clock. Increase K value can match bigger video data
375 * variation. IVO panel has small variation than DP CTS spec, need
376 * decrease the K value.
378 static int anx7625_set_k_value(struct anx7625_data *ctx)
380 struct edid *edid = (struct edid *)ctx->slimport_edid_p.edid_raw_data;
382 if (edid->mfg_id[0] == IVO_MID0 && edid->mfg_id[1] == IVO_MID1)
383 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
384 MIPI_DIGITAL_ADJ_1, 0x3B);
386 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
387 MIPI_DIGITAL_ADJ_1, 0x3D);
390 static int anx7625_dsi_video_timing_config(struct anx7625_data *ctx)
392 struct device *dev = &ctx->client->dev;
398 ret = anx7625_calculate_m_n(ctx->dt.pixelclock.min * 1000,
399 &m, &n, &post_divider);
402 DRM_DEV_ERROR(dev, "cannot get property m n value.\n");
406 DRM_DEV_DEBUG_DRIVER(dev, "compute M(%lu), N(%lu), divider(%d).\n",
409 /* Configure pixel clock */
410 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, PIXEL_CLOCK_L,
411 (ctx->dt.pixelclock.min / 1000) & 0xFF);
412 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, PIXEL_CLOCK_H,
413 (ctx->dt.pixelclock.min / 1000) >> 8);
415 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client,
416 MIPI_LANE_CTRL_0, 0xfc);
417 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client,
418 MIPI_LANE_CTRL_0, ctx->pdata.mipi_lanes - 1);
421 htotal = ctx->dt.hactive.min + ctx->dt.hfront_porch.min +
422 ctx->dt.hback_porch.min + ctx->dt.hsync_len.min;
423 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
424 HORIZONTAL_TOTAL_PIXELS_L, htotal & 0xFF);
425 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
426 HORIZONTAL_TOTAL_PIXELS_H, htotal >> 8);
428 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
429 HORIZONTAL_ACTIVE_PIXELS_L, ctx->dt.hactive.min & 0xFF);
430 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
431 HORIZONTAL_ACTIVE_PIXELS_H, ctx->dt.hactive.min >> 8);
433 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
434 HORIZONTAL_FRONT_PORCH_L, ctx->dt.hfront_porch.min);
435 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
436 HORIZONTAL_FRONT_PORCH_H,
437 ctx->dt.hfront_porch.min >> 8);
439 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
440 HORIZONTAL_SYNC_WIDTH_L, ctx->dt.hsync_len.min);
441 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
442 HORIZONTAL_SYNC_WIDTH_H, ctx->dt.hsync_len.min >> 8);
444 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
445 HORIZONTAL_BACK_PORCH_L, ctx->dt.hback_porch.min);
446 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
447 HORIZONTAL_BACK_PORCH_H, ctx->dt.hback_porch.min >> 8);
449 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, ACTIVE_LINES_L,
450 ctx->dt.vactive.min);
451 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client, ACTIVE_LINES_H,
452 ctx->dt.vactive.min >> 8);
454 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
455 VERTICAL_FRONT_PORCH, ctx->dt.vfront_porch.min);
457 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
458 VERTICAL_SYNC_WIDTH, ctx->dt.vsync_len.min);
460 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p2_client,
461 VERTICAL_BACK_PORCH, ctx->dt.vback_porch.min);
463 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
464 MIPI_PLL_M_NUM_23_16, (m >> 16) & 0xff);
465 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
466 MIPI_PLL_M_NUM_15_8, (m >> 8) & 0xff);
467 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
468 MIPI_PLL_M_NUM_7_0, (m & 0xff));
470 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
471 MIPI_PLL_N_NUM_23_16, (n >> 16) & 0xff);
472 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
473 MIPI_PLL_N_NUM_15_8, (n >> 8) & 0xff);
474 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, MIPI_PLL_N_NUM_7_0,
477 anx7625_set_k_value(ctx);
479 ret |= anx7625_odfc_config(ctx, post_divider - 1);
482 DRM_DEV_ERROR(dev, "mipi dsi setup IO error.\n");
487 static int anx7625_swap_dsi_lane3(struct anx7625_data *ctx)
490 struct device *dev = &ctx->client->dev;
492 /* Swap MIPI-DSI data lane 3 P and N */
493 val = anx7625_reg_read(ctx, ctx->i2c.rx_p1_client, MIPI_SWAP);
495 DRM_DEV_ERROR(dev, "IO error : access MIPI_SWAP.\n");
499 val |= (1 << MIPI_SWAP_CH3);
500 return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client, MIPI_SWAP, val);
503 static int anx7625_api_dsi_config(struct anx7625_data *ctx)
507 struct device *dev = &ctx->client->dev;
509 /* Swap MIPI-DSI data lane 3 P and N */
510 ret = anx7625_swap_dsi_lane3(ctx);
512 DRM_DEV_ERROR(dev, "IO error : swap dsi lane 3 fail.\n");
516 /* DSI clock settings */
517 val = (0 << MIPI_HS_PWD_CLK) |
518 (0 << MIPI_HS_RT_CLK) |
520 (1 << MIPI_CLK_RT_MANUAL_PD_EN) |
521 (1 << MIPI_CLK_HS_MANUAL_PD_EN) |
522 (0 << MIPI_CLK_DET_DET_BYPASS) |
523 (0 << MIPI_CLK_MISS_CTRL) |
524 (0 << MIPI_PD_LPTX_CH_MANUAL_PD_EN);
525 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
526 MIPI_PHY_CONTROL_3, val);
529 * Decreased HS prepare timing delay from 160ns to 80ns work with
530 * a) Dragon board 810 series (Qualcomm AP)
531 * b) Moving Pixel DSI source (PG3A pattern generator +
532 * P332 D-PHY Probe) default D-PHY timing
535 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
536 MIPI_TIME_HS_PRPR, 0x10);
539 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_18,
540 SELECT_DSI << MIPI_DPI_SELECT);
542 ret |= anx7625_dsi_video_timing_config(ctx);
544 DRM_DEV_ERROR(dev, "dsi video timing config fail\n");
548 /* Toggle m, n ready */
549 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_6,
550 ~(MIPI_M_NUM_READY | MIPI_N_NUM_READY));
551 usleep_range(1000, 1100);
552 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, MIPI_DIGITAL_PLL_6,
553 MIPI_M_NUM_READY | MIPI_N_NUM_READY);
555 /* Configure integer stable register */
556 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
557 MIPI_VIDEO_STABLE_CNT, 0x02);
558 /* Power on MIPI RX */
559 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
560 MIPI_LANE_CTRL_10, 0x00);
561 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
562 MIPI_LANE_CTRL_10, 0x80);
565 DRM_DEV_ERROR(dev, "IO error : mipi dsi enable init fail.\n");
570 static int anx7625_dsi_config(struct anx7625_data *ctx)
572 struct device *dev = &ctx->client->dev;
575 DRM_DEV_DEBUG_DRIVER(dev, "config dsi.\n");
578 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
579 R_DSC_CTRL_0, ~DSC_EN);
581 ret |= anx7625_api_dsi_config(ctx);
584 DRM_DEV_ERROR(dev, "IO error : api dsi config error.\n");
589 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
590 AP_AV_STATUS, AP_MIPI_RX_EN);
591 /* Clear mute flag */
592 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
593 AP_AV_STATUS, (u8)~AP_MIPI_MUTE);
595 DRM_DEV_ERROR(dev, "IO error : enable mipi rx fail.\n");
597 DRM_DEV_DEBUG_DRIVER(dev, "success to config DSI\n");
602 static int anx7625_api_dpi_config(struct anx7625_data *ctx)
604 struct device *dev = &ctx->client->dev;
605 u16 freq = ctx->dt.pixelclock.min / 1000;
608 /* configure pixel clock */
609 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
610 PIXEL_CLOCK_L, freq & 0xFF);
611 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
612 PIXEL_CLOCK_H, (freq >> 8));
615 /* set to DPI PLL module sel */
616 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
617 MIPI_DIGITAL_PLL_9, 0x20);
618 /* power down MIPI */
619 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
620 MIPI_LANE_CTRL_10, 0x08);
621 /* enable DPI mode */
622 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
623 MIPI_DIGITAL_PLL_18, 0x1C);
625 ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
626 VIDEO_CONTROL_0, 0x06);
628 DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n");
633 static int anx7625_dpi_config(struct anx7625_data *ctx)
635 struct device *dev = &ctx->client->dev;
638 DRM_DEV_DEBUG_DRIVER(dev, "config dpi\n");
641 ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
642 R_DSC_CTRL_0, ~DSC_EN);
644 DRM_DEV_ERROR(dev, "IO error : disable dsc failed.\n");
648 ret = anx7625_config_bit_matrix(ctx);
650 DRM_DEV_ERROR(dev, "config bit matrix failed.\n");
654 ret = anx7625_api_dpi_config(ctx);
656 DRM_DEV_ERROR(dev, "mipi phy(dpi) setup failed.\n");
661 ret = anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
662 AP_AV_STATUS, AP_MIPI_RX_EN);
663 /* clear mute flag */
664 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
665 AP_AV_STATUS, (u8)~AP_MIPI_MUTE);
667 DRM_DEV_ERROR(dev, "IO error : enable mipi rx failed.\n");
672 static void anx7625_dp_start(struct anx7625_data *ctx)
675 struct device *dev = &ctx->client->dev;
677 if (!ctx->display_timing_valid) {
678 DRM_DEV_ERROR(dev, "mipi not set display timing yet.\n");
682 if (ctx->pdata.is_dpi)
683 ret = anx7625_dpi_config(ctx);
685 ret = anx7625_dsi_config(ctx);
688 DRM_DEV_ERROR(dev, "MIPI phy setup error.\n");
691 static void anx7625_dp_stop(struct anx7625_data *ctx)
693 struct device *dev = &ctx->client->dev;
696 DRM_DEV_DEBUG_DRIVER(dev, "stop dp output\n");
699 * Video disable: 0x72:08 bit 7 = 0;
700 * Audio disable: 0x70:87 bit 0 = 0;
702 ret = anx7625_write_and(ctx, ctx->i2c.tx_p0_client, 0x87, 0xfe);
703 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, 0x08, 0x7f);
705 ret |= anx7625_video_mute_control(ctx, 1);
707 DRM_DEV_ERROR(dev, "IO error : mute video fail\n");
710 static int sp_tx_rst_aux(struct anx7625_data *ctx)
714 ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client, RST_CTRL2,
716 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, RST_CTRL2,
721 static int sp_tx_aux_wr(struct anx7625_data *ctx, u8 offset)
725 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
726 AP_AUX_BUFF_START, offset);
727 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
728 AP_AUX_COMMAND, 0x04);
729 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
730 AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
731 return (ret | wait_aux_op_finish(ctx));
734 static int sp_tx_aux_rd(struct anx7625_data *ctx, u8 len_cmd)
738 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
739 AP_AUX_COMMAND, len_cmd);
740 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
741 AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
742 return (ret | wait_aux_op_finish(ctx));
745 static int sp_tx_get_edid_block(struct anx7625_data *ctx)
748 struct device *dev = &ctx->client->dev;
750 sp_tx_aux_wr(ctx, 0x7e);
751 sp_tx_aux_rd(ctx, 0x01);
752 c = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_BUFF_START);
754 DRM_DEV_ERROR(dev, "IO error : access AUX BUFF.\n");
758 DRM_DEV_DEBUG_DRIVER(dev, " EDID Block = %d\n", c + 1);
760 if (c > MAX_EDID_BLOCK)
766 static int edid_read(struct anx7625_data *ctx,
767 u8 offset, u8 *pblock_buf)
770 struct device *dev = &ctx->client->dev;
772 for (cnt = 0; cnt <= EDID_TRY_CNT; cnt++) {
773 sp_tx_aux_wr(ctx, offset);
774 /* Set I2C read com 0x01 mot = 0 and read 16 bytes */
775 ret = sp_tx_aux_rd(ctx, 0xf1);
778 ret = sp_tx_rst_aux(ctx);
779 DRM_DEV_DEBUG_DRIVER(dev, "edid read fail, reset!\n");
781 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
783 MAX_DPCD_BUFFER_SIZE,
790 if (cnt > EDID_TRY_CNT)
796 static int segments_edid_read(struct anx7625_data *ctx,
797 u8 segment, u8 *buf, u8 offset)
801 struct device *dev = &ctx->client->dev;
803 /* Write address only */
804 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
805 AP_AUX_ADDR_7_0, 0x30);
806 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
807 AP_AUX_COMMAND, 0x04);
808 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
810 AP_AUX_CTRL_ADDRONLY | AP_AUX_CTRL_OP_EN);
812 ret |= wait_aux_op_finish(ctx);
813 /* Write segment address */
814 ret |= sp_tx_aux_wr(ctx, segment);
816 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
817 AP_AUX_ADDR_7_0, 0x50);
819 DRM_DEV_ERROR(dev, "IO error : aux initial fail.\n");
823 for (cnt = 0; cnt <= EDID_TRY_CNT; cnt++) {
824 sp_tx_aux_wr(ctx, offset);
825 /* Set I2C read com 0x01 mot = 0 and read 16 bytes */
826 ret = sp_tx_aux_rd(ctx, 0xf1);
829 ret = sp_tx_rst_aux(ctx);
830 DRM_DEV_ERROR(dev, "segment read fail, reset!\n");
832 ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
834 MAX_DPCD_BUFFER_SIZE, buf);
840 if (cnt > EDID_TRY_CNT)
846 static int sp_tx_edid_read(struct anx7625_data *ctx,
847 u8 *pedid_blocks_buf)
850 int count, blocks_num;
851 u8 pblock_buf[MAX_DPCD_BUFFER_SIZE];
853 int g_edid_break = 0;
855 struct device *dev = &ctx->client->dev;
857 /* Address initial */
858 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
859 AP_AUX_ADDR_7_0, 0x50);
860 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
861 AP_AUX_ADDR_15_8, 0);
862 ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
863 AP_AUX_ADDR_19_16, 0xf0);
865 DRM_DEV_ERROR(dev, "access aux channel IO error.\n");
869 blocks_num = sp_tx_get_edid_block(ctx);
879 for (i = 0; i < 8; i++) {
880 offset = (i + count * 8) * MAX_DPCD_BUFFER_SIZE;
881 g_edid_break = edid_read(ctx, offset,
884 if (g_edid_break < 0)
887 memcpy(&pedid_blocks_buf[offset],
889 MAX_DPCD_BUFFER_SIZE);
896 for (j = 0; j < 8; j++) {
897 edid_pos = (j + count * 8) *
898 MAX_DPCD_BUFFER_SIZE;
900 if (g_edid_break == 1)
903 ret = segments_edid_read(ctx, count / 2,
908 memcpy(&pedid_blocks_buf[edid_pos],
910 MAX_DPCD_BUFFER_SIZE);
911 offset = offset + 0x10;
918 for (j = 0; j < 8; j++) {
919 edid_pos = (j + count * 8) *
920 MAX_DPCD_BUFFER_SIZE;
921 if (g_edid_break == 1)
924 ret = segments_edid_read(ctx, count / 2,
929 memcpy(&pedid_blocks_buf[edid_pos],
931 MAX_DPCD_BUFFER_SIZE);
932 offset = offset + 0x10;
942 } while (blocks_num >= count);
944 /* Check edid data */
945 if (!drm_edid_is_valid((struct edid *)pedid_blocks_buf)) {
946 DRM_DEV_ERROR(dev, "WARNING! edid check fail!\n");
950 /* Reset aux channel */
951 ret = sp_tx_rst_aux(ctx);
953 DRM_DEV_ERROR(dev, "Failed to reset aux channel!\n");
957 return (blocks_num + 1);
960 static void anx7625_power_on(struct anx7625_data *ctx)
962 struct device *dev = &ctx->client->dev;
965 if (!ctx->pdata.low_power_mode) {
966 DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
970 for (i = 0; i < ARRAY_SIZE(ctx->pdata.supplies); i++) {
971 ret = regulator_enable(ctx->pdata.supplies[i].consumer);
973 DRM_DEV_DEBUG_DRIVER(dev, "cannot enable supply %d: %d\n",
977 usleep_range(2000, 2100);
980 usleep_range(11000, 12000);
982 /* Power on pin enable */
983 gpiod_set_value(ctx->pdata.gpio_p_on, 1);
984 usleep_range(10000, 11000);
985 /* Power reset pin enable */
986 gpiod_set_value(ctx->pdata.gpio_reset, 1);
987 usleep_range(10000, 11000);
989 DRM_DEV_DEBUG_DRIVER(dev, "power on !\n");
992 for (--i; i >= 0; i--)
993 regulator_disable(ctx->pdata.supplies[i].consumer);
996 static void anx7625_power_standby(struct anx7625_data *ctx)
998 struct device *dev = &ctx->client->dev;
1001 if (!ctx->pdata.low_power_mode) {
1002 DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
1006 gpiod_set_value(ctx->pdata.gpio_reset, 0);
1007 usleep_range(1000, 1100);
1008 gpiod_set_value(ctx->pdata.gpio_p_on, 0);
1009 usleep_range(1000, 1100);
1011 ret = regulator_bulk_disable(ARRAY_SIZE(ctx->pdata.supplies),
1012 ctx->pdata.supplies);
1014 DRM_DEV_DEBUG_DRIVER(dev, "cannot disable supplies %d\n", ret);
1016 DRM_DEV_DEBUG_DRIVER(dev, "power down\n");
1019 /* Basic configurations of ANX7625 */
1020 static void anx7625_config(struct anx7625_data *ctx)
1022 anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
1023 XTAL_FRQ_SEL, XTAL_FRQ_27M);
1026 static void anx7625_disable_pd_protocol(struct anx7625_data *ctx)
1028 struct device *dev = &ctx->client->dev;
1031 /* Reset main ocm */
1032 ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, 0x88, 0x40);
1034 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
1035 AP_AV_STATUS, AP_DISABLE_PD);
1036 /* Release main ocm */
1037 ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, 0x88, 0x00);
1040 DRM_DEV_DEBUG_DRIVER(dev, "disable PD feature fail.\n");
1042 DRM_DEV_DEBUG_DRIVER(dev, "disable PD feature succeeded.\n");
1045 static int anx7625_ocm_loading_check(struct anx7625_data *ctx)
1048 struct device *dev = &ctx->client->dev;
1050 /* Check interface workable */
1051 ret = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client,
1054 DRM_DEV_ERROR(dev, "IO error : access flash load.\n");
1057 if ((ret & FLASH_LOAD_STA_CHK) != FLASH_LOAD_STA_CHK)
1060 anx7625_disable_pd_protocol(ctx);
1062 DRM_DEV_DEBUG_DRIVER(dev, "Firmware ver %02x%02x,",
1063 anx7625_reg_read(ctx,
1064 ctx->i2c.rx_p0_client,
1066 anx7625_reg_read(ctx,
1067 ctx->i2c.rx_p0_client,
1069 DRM_DEV_DEBUG_DRIVER(dev, "Driver version %s\n",
1070 ANX7625_DRV_VERSION);
1075 static void anx7625_power_on_init(struct anx7625_data *ctx)
1079 for (retry_count = 0; retry_count < 3; retry_count++) {
1080 anx7625_power_on(ctx);
1081 anx7625_config(ctx);
1083 for (i = 0; i < OCM_LOADING_TIME; i++) {
1084 if (!anx7625_ocm_loading_check(ctx))
1086 usleep_range(1000, 1100);
1088 anx7625_power_standby(ctx);
1092 static void anx7625_init_gpio(struct anx7625_data *platform)
1094 struct device *dev = &platform->client->dev;
1096 DRM_DEV_DEBUG_DRIVER(dev, "init gpio\n");
1098 /* Gpio for chip power enable */
1099 platform->pdata.gpio_p_on =
1100 devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
1101 /* Gpio for chip reset */
1102 platform->pdata.gpio_reset =
1103 devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
1105 if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) {
1106 platform->pdata.low_power_mode = 1;
1107 DRM_DEV_DEBUG_DRIVER(dev, "low power mode, pon %d, reset %d.\n",
1108 desc_to_gpio(platform->pdata.gpio_p_on),
1109 desc_to_gpio(platform->pdata.gpio_reset));
1111 platform->pdata.low_power_mode = 0;
1112 DRM_DEV_DEBUG_DRIVER(dev, "not low power mode.\n");
1116 static void anx7625_stop_dp_work(struct anx7625_data *ctx)
1118 ctx->hpd_status = 0;
1119 ctx->hpd_high_cnt = 0;
1120 ctx->display_timing_valid = 0;
1123 static void anx7625_start_dp_work(struct anx7625_data *ctx)
1126 struct device *dev = &ctx->client->dev;
1128 if (ctx->hpd_high_cnt >= 2) {
1129 DRM_DEV_DEBUG_DRIVER(dev, "filter useless HPD\n");
1133 ctx->hpd_status = 1;
1134 ctx->hpd_high_cnt++;
1136 /* Not support HDCP */
1137 ret = anx7625_write_and(ctx, ctx->i2c.rx_p1_client, 0xee, 0x9f);
1140 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xec, 0x10);
1141 /* Interrupt for DRM */
1142 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client, 0xff, 0x01);
1144 DRM_DEV_ERROR(dev, "fail to setting HDCP/auth\n");
1148 ret = anx7625_reg_read(ctx, ctx->i2c.rx_p1_client, 0x86);
1152 DRM_DEV_DEBUG_DRIVER(dev, "Secure OCM version=%02x\n", ret);
1155 static int anx7625_read_hpd_status_p0(struct anx7625_data *ctx)
1157 return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, SYSTEM_STSTUS);
1160 static void anx7625_hpd_polling(struct anx7625_data *ctx)
1163 struct device *dev = &ctx->client->dev;
1165 /* Interrupt mode, no need poll HPD status, just return */
1166 if (ctx->pdata.intp_irq)
1169 ret = readx_poll_timeout(anx7625_read_hpd_status_p0,
1171 ((val & HPD_STATUS) || (val < 0)),
1175 DRM_DEV_ERROR(dev, "no hpd.\n");
1179 DRM_DEV_DEBUG_DRIVER(dev, "system status: 0x%x. HPD raise up.\n", val);
1180 anx7625_reg_write(ctx, ctx->i2c.tcpc_client,
1181 INTR_ALERT_1, 0xFF);
1182 anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
1183 INTERFACE_CHANGE_INT, 0);
1185 anx7625_start_dp_work(ctx);
1187 if (!ctx->pdata.panel_bridge && ctx->bridge_attached)
1188 drm_helper_hpd_irq_event(ctx->bridge.dev);
1191 static void anx7625_remove_edid(struct anx7625_data *ctx)
1193 ctx->slimport_edid_p.edid_block_num = -1;
1196 static void anx7625_dp_adjust_swing(struct anx7625_data *ctx)
1200 for (i = 0; i < ctx->pdata.dp_lane0_swing_reg_cnt; i++)
1201 anx7625_reg_write(ctx, ctx->i2c.tx_p1_client,
1202 DP_TX_LANE0_SWING_REG0 + i,
1203 ctx->pdata.lane0_reg_data[i] & 0xFF);
1205 for (i = 0; i < ctx->pdata.dp_lane1_swing_reg_cnt; i++)
1206 anx7625_reg_write(ctx, ctx->i2c.tx_p1_client,
1207 DP_TX_LANE1_SWING_REG0 + i,
1208 ctx->pdata.lane1_reg_data[i] & 0xFF);
1211 static void dp_hpd_change_handler(struct anx7625_data *ctx, bool on)
1213 struct device *dev = &ctx->client->dev;
1216 DRM_DEV_DEBUG_DRIVER(dev, "dp_hpd_change_default_func: %d\n",
1220 DRM_DEV_DEBUG_DRIVER(dev, " HPD low\n");
1221 anx7625_remove_edid(ctx);
1222 anx7625_stop_dp_work(ctx);
1224 DRM_DEV_DEBUG_DRIVER(dev, " HPD high\n");
1225 anx7625_start_dp_work(ctx);
1226 anx7625_dp_adjust_swing(ctx);
1230 static int anx7625_hpd_change_detect(struct anx7625_data *ctx)
1232 int intr_vector, status;
1233 struct device *dev = &ctx->client->dev;
1235 status = anx7625_reg_write(ctx, ctx->i2c.tcpc_client,
1236 INTR_ALERT_1, 0xFF);
1238 DRM_DEV_ERROR(dev, "cannot clear alert reg.\n");
1242 intr_vector = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client,
1243 INTERFACE_CHANGE_INT);
1244 if (intr_vector < 0) {
1245 DRM_DEV_ERROR(dev, "cannot access interrupt change reg.\n");
1248 DRM_DEV_DEBUG_DRIVER(dev, "0x7e:0x44=%x\n", intr_vector);
1249 status = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
1250 INTERFACE_CHANGE_INT,
1251 intr_vector & (~intr_vector));
1253 DRM_DEV_ERROR(dev, "cannot clear interrupt change reg.\n");
1257 if (!(intr_vector & HPD_STATUS_CHANGE))
1260 status = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client,
1263 DRM_DEV_ERROR(dev, "cannot clear interrupt status.\n");
1267 DRM_DEV_DEBUG_DRIVER(dev, "0x7e:0x45=%x\n", status);
1268 dp_hpd_change_handler(ctx, status & HPD_STATUS);
1273 static void anx7625_work_func(struct work_struct *work)
1276 struct anx7625_data *ctx = container_of(work,
1277 struct anx7625_data, work);
1279 mutex_lock(&ctx->lock);
1281 if (pm_runtime_suspended(&ctx->client->dev))
1284 event = anx7625_hpd_change_detect(ctx);
1288 if (ctx->bridge_attached)
1289 drm_helper_hpd_irq_event(ctx->bridge.dev);
1292 mutex_unlock(&ctx->lock);
1295 static irqreturn_t anx7625_intr_hpd_isr(int irq, void *data)
1297 struct anx7625_data *ctx = (struct anx7625_data *)data;
1299 queue_work(ctx->workqueue, &ctx->work);
1304 static int anx7625_get_swing_setting(struct device *dev,
1305 struct anx7625_platform_data *pdata)
1309 if (of_get_property(dev->of_node,
1310 "analogix,lane0-swing", &num_regs)) {
1311 if (num_regs > DP_TX_SWING_REG_CNT)
1312 num_regs = DP_TX_SWING_REG_CNT;
1314 pdata->dp_lane0_swing_reg_cnt = num_regs;
1315 of_property_read_u32_array(dev->of_node, "analogix,lane0-swing",
1316 pdata->lane0_reg_data, num_regs);
1319 if (of_get_property(dev->of_node,
1320 "analogix,lane1-swing", &num_regs)) {
1321 if (num_regs > DP_TX_SWING_REG_CNT)
1322 num_regs = DP_TX_SWING_REG_CNT;
1324 pdata->dp_lane1_swing_reg_cnt = num_regs;
1325 of_property_read_u32_array(dev->of_node, "analogix,lane1-swing",
1326 pdata->lane1_reg_data, num_regs);
1332 static int anx7625_parse_dt(struct device *dev,
1333 struct anx7625_platform_data *pdata)
1335 struct device_node *np = dev->of_node, *ep0;
1336 struct drm_panel *panel;
1338 int bus_type, mipi_lanes;
1340 anx7625_get_swing_setting(dev, pdata);
1342 pdata->is_dpi = 1; /* default dpi mode */
1343 pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
1344 if (!pdata->mipi_host_node) {
1345 DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
1349 bus_type = V4L2_FWNODE_BUS_TYPE_PARALLEL;
1350 mipi_lanes = MAX_LANES_SUPPORT;
1351 ep0 = of_graph_get_endpoint_by_regs(np, 0, 0);
1353 if (of_property_read_u32(ep0, "bus-type", &bus_type))
1356 mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes");
1359 if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */
1362 pdata->mipi_lanes = mipi_lanes;
1363 if (pdata->mipi_lanes > MAX_LANES_SUPPORT || pdata->mipi_lanes <= 0)
1364 pdata->mipi_lanes = MAX_LANES_SUPPORT;
1367 DRM_DEV_DEBUG_DRIVER(dev, "found MIPI DPI host node.\n");
1369 DRM_DEV_DEBUG_DRIVER(dev, "found MIPI DSI host node.\n");
1371 if (of_property_read_bool(np, "analogix,audio-enable"))
1372 pdata->audio_en = 1;
1374 ret = drm_of_find_panel_or_bridge(np, 1, 0, &panel, NULL);
1383 pdata->panel_bridge = devm_drm_panel_bridge_add(dev, panel);
1384 if (IS_ERR(pdata->panel_bridge))
1385 return PTR_ERR(pdata->panel_bridge);
1386 DRM_DEV_DEBUG_DRIVER(dev, "get panel node.\n");
1391 static inline struct anx7625_data *bridge_to_anx7625(struct drm_bridge *bridge)
1393 return container_of(bridge, struct anx7625_data, bridge);
1396 static struct edid *anx7625_get_edid(struct anx7625_data *ctx)
1398 struct device *dev = &ctx->client->dev;
1399 struct s_edid_data *p_edid = &ctx->slimport_edid_p;
1403 edid = kmalloc(FOUR_BLOCK_SIZE, GFP_KERNEL);
1405 DRM_DEV_ERROR(dev, "Fail to allocate buffer\n");
1409 if (ctx->slimport_edid_p.edid_block_num > 0) {
1410 memcpy(edid, ctx->slimport_edid_p.edid_raw_data,
1412 return (struct edid *)edid;
1415 pm_runtime_get_sync(dev);
1416 edid_num = sp_tx_edid_read(ctx, p_edid->edid_raw_data);
1417 pm_runtime_put_sync(dev);
1420 DRM_DEV_ERROR(dev, "Fail to read EDID: %d\n", edid_num);
1425 p_edid->edid_block_num = edid_num;
1427 memcpy(edid, ctx->slimport_edid_p.edid_raw_data, FOUR_BLOCK_SIZE);
1428 return (struct edid *)edid;
1431 static enum drm_connector_status anx7625_sink_detect(struct anx7625_data *ctx)
1433 struct device *dev = &ctx->client->dev;
1435 DRM_DEV_DEBUG_DRIVER(dev, "sink detect\n");
1437 if (ctx->pdata.panel_bridge)
1438 return connector_status_connected;
1440 return ctx->hpd_status ? connector_status_connected :
1441 connector_status_disconnected;
1444 static int anx7625_audio_hw_params(struct device *dev, void *data,
1445 struct hdmi_codec_daifmt *fmt,
1446 struct hdmi_codec_params *params)
1448 struct anx7625_data *ctx = dev_get_drvdata(dev);
1452 if (fmt->fmt != HDMI_DSP_A) {
1453 DRM_DEV_ERROR(dev, "only supports DSP_A\n");
1457 DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
1458 params->sample_rate, params->sample_width,
1459 params->cea.channels);
1461 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
1462 AUDIO_CHANNEL_STATUS_6,
1467 switch (params->sample_width) {
1469 wl = AUDIO_W_LEN_16_20MAX;
1472 wl = AUDIO_W_LEN_18_20MAX;
1475 wl = AUDIO_W_LEN_20_20MAX;
1478 wl = AUDIO_W_LEN_24_24MAX;
1481 DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
1482 params->sample_width);
1485 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
1486 AUDIO_CHANNEL_STATUS_5,
1490 switch (params->cea.channels) {
1504 DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
1505 params->cea.channels);
1508 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
1509 AUDIO_CHANNEL_STATUS_6, 0x1f, ch << 5);
1511 ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
1512 AUDIO_CHANNEL_STATUS_6, AUDIO_LAYOUT);
1514 ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
1515 AUDIO_CHANNEL_STATUS_6, ~AUDIO_LAYOUT);
1518 switch (params->sample_rate) {
1520 rate = AUDIO_FS_32K;
1523 rate = AUDIO_FS_441K;
1526 rate = AUDIO_FS_48K;
1529 rate = AUDIO_FS_882K;
1532 rate = AUDIO_FS_96K;
1535 rate = AUDIO_FS_1764K;
1538 rate = AUDIO_FS_192K;
1541 DRM_DEV_DEBUG_DRIVER(dev, "sample rate: %d not support",
1542 params->sample_rate);
1545 ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
1546 AUDIO_CHANNEL_STATUS_4,
1548 ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
1549 AP_AV_STATUS, AP_AUDIO_CHG);
1551 DRM_DEV_ERROR(dev, "IO error : config audio.\n");
1558 static void anx7625_audio_shutdown(struct device *dev, void *data)
1560 DRM_DEV_DEBUG_DRIVER(dev, "stop audio\n");
1563 static int anx7625_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
1564 struct device_node *endpoint)
1566 struct of_endpoint of_ep;
1569 ret = of_graph_parse_endpoint(endpoint, &of_ep);
1574 * HDMI sound should be located at external DPI port
1575 * Didn't have good way to check where is internal(DSI)
1576 * or external(DPI) bridge
1582 anx7625_audio_update_connector_status(struct anx7625_data *ctx,
1583 enum drm_connector_status status)
1585 if (ctx->plugged_cb && ctx->codec_dev) {
1586 ctx->plugged_cb(ctx->codec_dev,
1587 status == connector_status_connected);
1591 static int anx7625_audio_hook_plugged_cb(struct device *dev, void *data,
1592 hdmi_codec_plugged_cb fn,
1593 struct device *codec_dev)
1595 struct anx7625_data *ctx = data;
1597 ctx->plugged_cb = fn;
1598 ctx->codec_dev = codec_dev;
1599 anx7625_audio_update_connector_status(ctx, anx7625_sink_detect(ctx));
1604 static const struct hdmi_codec_ops anx7625_codec_ops = {
1605 .hw_params = anx7625_audio_hw_params,
1606 .audio_shutdown = anx7625_audio_shutdown,
1607 .get_dai_id = anx7625_hdmi_i2s_get_dai_id,
1608 .hook_plugged_cb = anx7625_audio_hook_plugged_cb,
1611 static void anx7625_unregister_audio(struct anx7625_data *ctx)
1613 struct device *dev = &ctx->client->dev;
1615 if (ctx->audio_pdev) {
1616 platform_device_unregister(ctx->audio_pdev);
1617 ctx->audio_pdev = NULL;
1620 DRM_DEV_DEBUG_DRIVER(dev, "unbound to %s", HDMI_CODEC_DRV_NAME);
1623 static int anx7625_register_audio(struct device *dev, struct anx7625_data *ctx)
1625 struct hdmi_codec_pdata codec_data = {
1626 .ops = &anx7625_codec_ops,
1627 .max_i2s_channels = 8,
1632 ctx->audio_pdev = platform_device_register_data(dev,
1633 HDMI_CODEC_DRV_NAME,
1634 PLATFORM_DEVID_AUTO,
1636 sizeof(codec_data));
1638 if (IS_ERR(ctx->audio_pdev))
1639 return PTR_ERR(ctx->audio_pdev);
1641 DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
1646 static int anx7625_attach_dsi(struct anx7625_data *ctx)
1648 struct mipi_dsi_device *dsi;
1649 struct device *dev = &ctx->client->dev;
1650 struct mipi_dsi_host *host;
1651 const struct mipi_dsi_device_info info = {
1658 DRM_DEV_DEBUG_DRIVER(dev, "attach dsi\n");
1660 host = of_find_mipi_dsi_host_by_node(ctx->pdata.mipi_host_node);
1662 DRM_DEV_ERROR(dev, "fail to find dsi host.\n");
1666 dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
1668 DRM_DEV_ERROR(dev, "fail to create dsi device.\n");
1672 dsi->lanes = ctx->pdata.mipi_lanes;
1673 dsi->format = MIPI_DSI_FMT_RGB888;
1674 dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
1675 MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1676 MIPI_DSI_MODE_VIDEO_HSE;
1678 ret = devm_mipi_dsi_attach(dev, dsi);
1680 DRM_DEV_ERROR(dev, "fail to attach dsi to host.\n");
1686 DRM_DEV_DEBUG_DRIVER(dev, "attach dsi succeeded.\n");
1691 static int anx7625_bridge_attach(struct drm_bridge *bridge,
1692 enum drm_bridge_attach_flags flags)
1694 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1696 struct device *dev = &ctx->client->dev;
1698 DRM_DEV_DEBUG_DRIVER(dev, "drm attach\n");
1699 if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
1702 if (!bridge->encoder) {
1703 DRM_DEV_ERROR(dev, "Parent encoder object not found");
1707 if (ctx->pdata.panel_bridge) {
1708 err = drm_bridge_attach(bridge->encoder,
1709 ctx->pdata.panel_bridge,
1710 &ctx->bridge, flags);
1715 ctx->bridge_attached = 1;
1720 static enum drm_mode_status
1721 anx7625_bridge_mode_valid(struct drm_bridge *bridge,
1722 const struct drm_display_info *info,
1723 const struct drm_display_mode *mode)
1725 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1726 struct device *dev = &ctx->client->dev;
1728 DRM_DEV_DEBUG_DRIVER(dev, "drm mode checking\n");
1730 /* Max 1200p at 5.4 Ghz, one lane, pixel clock 300M */
1731 if (mode->clock > SUPPORT_PIXEL_CLOCK) {
1732 DRM_DEV_DEBUG_DRIVER(dev,
1733 "drm mode invalid, pixelclock too high.\n");
1734 return MODE_CLOCK_HIGH;
1737 DRM_DEV_DEBUG_DRIVER(dev, "drm mode valid.\n");
1742 static void anx7625_bridge_mode_set(struct drm_bridge *bridge,
1743 const struct drm_display_mode *old_mode,
1744 const struct drm_display_mode *mode)
1746 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1747 struct device *dev = &ctx->client->dev;
1749 DRM_DEV_DEBUG_DRIVER(dev, "drm mode set\n");
1751 ctx->dt.pixelclock.min = mode->clock;
1752 ctx->dt.hactive.min = mode->hdisplay;
1753 ctx->dt.hsync_len.min = mode->hsync_end - mode->hsync_start;
1754 ctx->dt.hfront_porch.min = mode->hsync_start - mode->hdisplay;
1755 ctx->dt.hback_porch.min = mode->htotal - mode->hsync_end;
1756 ctx->dt.vactive.min = mode->vdisplay;
1757 ctx->dt.vsync_len.min = mode->vsync_end - mode->vsync_start;
1758 ctx->dt.vfront_porch.min = mode->vsync_start - mode->vdisplay;
1759 ctx->dt.vback_porch.min = mode->vtotal - mode->vsync_end;
1761 ctx->display_timing_valid = 1;
1763 DRM_DEV_DEBUG_DRIVER(dev, "pixelclock(%d).\n", ctx->dt.pixelclock.min);
1764 DRM_DEV_DEBUG_DRIVER(dev, "hactive(%d), hsync(%d), hfp(%d), hbp(%d)\n",
1765 ctx->dt.hactive.min,
1766 ctx->dt.hsync_len.min,
1767 ctx->dt.hfront_porch.min,
1768 ctx->dt.hback_porch.min);
1769 DRM_DEV_DEBUG_DRIVER(dev, "vactive(%d), vsync(%d), vfp(%d), vbp(%d)\n",
1770 ctx->dt.vactive.min,
1771 ctx->dt.vsync_len.min,
1772 ctx->dt.vfront_porch.min,
1773 ctx->dt.vback_porch.min);
1774 DRM_DEV_DEBUG_DRIVER(dev, "hdisplay(%d),hsync_start(%d).\n",
1777 DRM_DEV_DEBUG_DRIVER(dev, "hsync_end(%d),htotal(%d).\n",
1780 DRM_DEV_DEBUG_DRIVER(dev, "vdisplay(%d),vsync_start(%d).\n",
1783 DRM_DEV_DEBUG_DRIVER(dev, "vsync_end(%d),vtotal(%d).\n",
1788 static bool anx7625_bridge_mode_fixup(struct drm_bridge *bridge,
1789 const struct drm_display_mode *mode,
1790 struct drm_display_mode *adj)
1792 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1793 struct device *dev = &ctx->client->dev;
1794 u32 hsync, hfp, hbp, hblanking;
1795 u32 adj_hsync, adj_hfp, adj_hbp, adj_hblanking, delta_adj;
1796 u32 vref, adj_clock;
1798 DRM_DEV_DEBUG_DRIVER(dev, "drm mode fixup set\n");
1800 /* No need fixup for external monitor */
1801 if (!ctx->pdata.panel_bridge)
1804 hsync = mode->hsync_end - mode->hsync_start;
1805 hfp = mode->hsync_start - mode->hdisplay;
1806 hbp = mode->htotal - mode->hsync_end;
1807 hblanking = mode->htotal - mode->hdisplay;
1809 DRM_DEV_DEBUG_DRIVER(dev, "before mode fixup\n");
1810 DRM_DEV_DEBUG_DRIVER(dev, "hsync(%d), hfp(%d), hbp(%d), clock(%d)\n",
1811 hsync, hfp, hbp, adj->clock);
1812 DRM_DEV_DEBUG_DRIVER(dev, "hsync_start(%d), hsync_end(%d), htot(%d)\n",
1813 adj->hsync_start, adj->hsync_end, adj->htotal);
1818 adj_hblanking = hblanking;
1820 /* HFP needs to be even */
1826 /* HBP needs to be even */
1832 /* HSYNC needs to be even */
1834 if (adj_hblanking < hblanking)
1841 * Once illegal timing detected, use default HFP, HSYNC, HBP
1842 * This adjusting made for built-in eDP panel, for the externel
1843 * DP monitor, may need return false.
1845 if (hblanking < HBLANKING_MIN || (hfp < HP_MIN && hbp < HP_MIN)) {
1846 adj_hsync = SYNC_LEN_DEF;
1847 adj_hfp = HFP_HBP_DEF;
1848 adj_hbp = HFP_HBP_DEF;
1849 vref = adj->clock * 1000 / (adj->htotal * adj->vtotal);
1850 if (hblanking < HBLANKING_MIN) {
1851 delta_adj = HBLANKING_MIN - hblanking;
1852 adj_clock = vref * delta_adj * adj->vtotal;
1853 adj->clock += DIV_ROUND_UP(adj_clock, 1000);
1855 delta_adj = hblanking - HBLANKING_MIN;
1856 adj_clock = vref * delta_adj * adj->vtotal;
1857 adj->clock -= DIV_ROUND_UP(adj_clock, 1000);
1860 DRM_WARN("illegal hblanking timing, use default.\n");
1861 DRM_WARN("hfp(%d), hbp(%d), hsync(%d).\n", hfp, hbp, hsync);
1862 } else if (adj_hfp < HP_MIN) {
1863 /* Adjust hfp if hfp less than HP_MIN */
1864 delta_adj = HP_MIN - adj_hfp;
1868 * Balance total HBlanking pixel, if HBP does not have enough
1869 * space, adjust HSYNC length, otherwise adjust HBP
1871 if ((adj_hbp - delta_adj) < HP_MIN)
1872 /* HBP not enough space */
1873 adj_hsync -= delta_adj;
1875 adj_hbp -= delta_adj;
1876 } else if (adj_hbp < HP_MIN) {
1877 delta_adj = HP_MIN - adj_hbp;
1881 * Balance total HBlanking pixel, if HBP hasn't enough space,
1882 * adjust HSYNC length, otherwize adjust HBP
1884 if ((adj_hfp - delta_adj) < HP_MIN)
1885 /* HFP not enough space */
1886 adj_hsync -= delta_adj;
1888 adj_hfp -= delta_adj;
1891 DRM_DEV_DEBUG_DRIVER(dev, "after mode fixup\n");
1892 DRM_DEV_DEBUG_DRIVER(dev, "hsync(%d), hfp(%d), hbp(%d), clock(%d)\n",
1893 adj_hsync, adj_hfp, adj_hbp, adj->clock);
1895 /* Reconstruct timing */
1896 adj->hsync_start = adj->hdisplay + adj_hfp;
1897 adj->hsync_end = adj->hsync_start + adj_hsync;
1898 adj->htotal = adj->hsync_end + adj_hbp;
1899 DRM_DEV_DEBUG_DRIVER(dev, "hsync_start(%d), hsync_end(%d), htot(%d)\n",
1900 adj->hsync_start, adj->hsync_end, adj->htotal);
1905 static void anx7625_bridge_enable(struct drm_bridge *bridge)
1907 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1908 struct device *dev = &ctx->client->dev;
1910 DRM_DEV_DEBUG_DRIVER(dev, "drm enable\n");
1912 pm_runtime_get_sync(dev);
1914 anx7625_dp_start(ctx);
1917 static void anx7625_bridge_disable(struct drm_bridge *bridge)
1919 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1920 struct device *dev = &ctx->client->dev;
1922 DRM_DEV_DEBUG_DRIVER(dev, "drm disable\n");
1924 anx7625_dp_stop(ctx);
1926 pm_runtime_put_sync(dev);
1929 static enum drm_connector_status
1930 anx7625_bridge_detect(struct drm_bridge *bridge)
1932 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1933 struct device *dev = &ctx->client->dev;
1935 DRM_DEV_DEBUG_DRIVER(dev, "drm bridge detect\n");
1937 return anx7625_sink_detect(ctx);
1940 static struct edid *anx7625_bridge_get_edid(struct drm_bridge *bridge,
1941 struct drm_connector *connector)
1943 struct anx7625_data *ctx = bridge_to_anx7625(bridge);
1944 struct device *dev = &ctx->client->dev;
1946 DRM_DEV_DEBUG_DRIVER(dev, "drm bridge get edid\n");
1948 return anx7625_get_edid(ctx);
1951 static const struct drm_bridge_funcs anx7625_bridge_funcs = {
1952 .attach = anx7625_bridge_attach,
1953 .disable = anx7625_bridge_disable,
1954 .mode_valid = anx7625_bridge_mode_valid,
1955 .mode_set = anx7625_bridge_mode_set,
1956 .mode_fixup = anx7625_bridge_mode_fixup,
1957 .enable = anx7625_bridge_enable,
1958 .detect = anx7625_bridge_detect,
1959 .get_edid = anx7625_bridge_get_edid,
1962 static int anx7625_register_i2c_dummy_clients(struct anx7625_data *ctx,
1963 struct i2c_client *client)
1965 ctx->i2c.tx_p0_client = i2c_new_dummy_device(client->adapter,
1967 if (!ctx->i2c.tx_p0_client)
1970 ctx->i2c.tx_p1_client = i2c_new_dummy_device(client->adapter,
1972 if (!ctx->i2c.tx_p1_client)
1975 ctx->i2c.tx_p2_client = i2c_new_dummy_device(client->adapter,
1977 if (!ctx->i2c.tx_p2_client)
1980 ctx->i2c.rx_p0_client = i2c_new_dummy_device(client->adapter,
1982 if (!ctx->i2c.rx_p0_client)
1985 ctx->i2c.rx_p1_client = i2c_new_dummy_device(client->adapter,
1987 if (!ctx->i2c.rx_p1_client)
1990 ctx->i2c.rx_p2_client = i2c_new_dummy_device(client->adapter,
1992 if (!ctx->i2c.rx_p2_client)
1995 ctx->i2c.tcpc_client = i2c_new_dummy_device(client->adapter,
1996 TCPC_INTERFACE_ADDR >> 1);
1997 if (!ctx->i2c.tcpc_client)
2003 i2c_unregister_device(ctx->i2c.rx_p2_client);
2005 i2c_unregister_device(ctx->i2c.rx_p1_client);
2007 i2c_unregister_device(ctx->i2c.rx_p0_client);
2009 i2c_unregister_device(ctx->i2c.tx_p2_client);
2011 i2c_unregister_device(ctx->i2c.tx_p1_client);
2013 i2c_unregister_device(ctx->i2c.tx_p0_client);
2018 static void anx7625_unregister_i2c_dummy_clients(struct anx7625_data *ctx)
2020 i2c_unregister_device(ctx->i2c.tx_p0_client);
2021 i2c_unregister_device(ctx->i2c.tx_p1_client);
2022 i2c_unregister_device(ctx->i2c.tx_p2_client);
2023 i2c_unregister_device(ctx->i2c.rx_p0_client);
2024 i2c_unregister_device(ctx->i2c.rx_p1_client);
2025 i2c_unregister_device(ctx->i2c.rx_p2_client);
2026 i2c_unregister_device(ctx->i2c.tcpc_client);
2029 static int __maybe_unused anx7625_runtime_pm_suspend(struct device *dev)
2031 struct anx7625_data *ctx = dev_get_drvdata(dev);
2033 mutex_lock(&ctx->lock);
2035 anx7625_stop_dp_work(ctx);
2036 anx7625_power_standby(ctx);
2038 mutex_unlock(&ctx->lock);
2043 static int __maybe_unused anx7625_runtime_pm_resume(struct device *dev)
2045 struct anx7625_data *ctx = dev_get_drvdata(dev);
2047 mutex_lock(&ctx->lock);
2049 anx7625_power_on_init(ctx);
2050 anx7625_hpd_polling(ctx);
2052 mutex_unlock(&ctx->lock);
2057 static int __maybe_unused anx7625_resume(struct device *dev)
2059 struct anx7625_data *ctx = dev_get_drvdata(dev);
2061 if (!ctx->pdata.intp_irq)
2064 if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
2065 enable_irq(ctx->pdata.intp_irq);
2066 anx7625_runtime_pm_resume(dev);
2072 static int __maybe_unused anx7625_suspend(struct device *dev)
2074 struct anx7625_data *ctx = dev_get_drvdata(dev);
2076 if (!ctx->pdata.intp_irq)
2079 if (!pm_runtime_enabled(dev) || !pm_runtime_suspended(dev)) {
2080 anx7625_runtime_pm_suspend(dev);
2081 disable_irq(ctx->pdata.intp_irq);
2087 static const struct dev_pm_ops anx7625_pm_ops = {
2088 SET_SYSTEM_SLEEP_PM_OPS(anx7625_suspend, anx7625_resume)
2089 SET_RUNTIME_PM_OPS(anx7625_runtime_pm_suspend,
2090 anx7625_runtime_pm_resume, NULL)
2093 static int anx7625_i2c_probe(struct i2c_client *client,
2094 const struct i2c_device_id *id)
2096 struct anx7625_data *platform;
2097 struct anx7625_platform_data *pdata;
2099 struct device *dev = &client->dev;
2101 if (!i2c_check_functionality(client->adapter,
2102 I2C_FUNC_SMBUS_I2C_BLOCK)) {
2103 DRM_DEV_ERROR(dev, "anx7625's i2c bus doesn't support\n");
2107 platform = kzalloc(sizeof(*platform), GFP_KERNEL);
2109 DRM_DEV_ERROR(dev, "fail to allocate driver data\n");
2113 pdata = &platform->pdata;
2115 ret = anx7625_parse_dt(dev, pdata);
2117 if (ret != -EPROBE_DEFER)
2118 DRM_DEV_ERROR(dev, "fail to parse DT : %d\n", ret);
2122 platform->client = client;
2123 i2c_set_clientdata(client, platform);
2125 pdata->supplies[0].supply = "vdd10";
2126 pdata->supplies[1].supply = "vdd18";
2127 pdata->supplies[2].supply = "vdd33";
2128 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pdata->supplies),
2131 DRM_DEV_ERROR(dev, "fail to get power supplies: %d\n", ret);
2134 anx7625_init_gpio(platform);
2136 mutex_init(&platform->lock);
2138 platform->pdata.intp_irq = client->irq;
2139 if (platform->pdata.intp_irq) {
2140 INIT_WORK(&platform->work, anx7625_work_func);
2141 platform->workqueue = alloc_workqueue("anx7625_work",
2142 WQ_FREEZABLE | WQ_MEM_RECLAIM, 1);
2143 if (!platform->workqueue) {
2144 DRM_DEV_ERROR(dev, "fail to create work queue\n");
2149 ret = devm_request_threaded_irq(dev, platform->pdata.intp_irq,
2150 NULL, anx7625_intr_hpd_isr,
2151 IRQF_TRIGGER_FALLING |
2153 "anx7625-intp", platform);
2155 DRM_DEV_ERROR(dev, "fail to request irq\n");
2160 if (anx7625_register_i2c_dummy_clients(platform, client) != 0) {
2162 DRM_DEV_ERROR(dev, "fail to reserve I2C bus.\n");
2166 pm_runtime_enable(dev);
2168 if (!platform->pdata.low_power_mode) {
2169 anx7625_disable_pd_protocol(platform);
2170 pm_runtime_get_sync(dev);
2173 /* Add work function */
2174 if (platform->pdata.intp_irq)
2175 queue_work(platform->workqueue, &platform->work);
2177 platform->bridge.funcs = &anx7625_bridge_funcs;
2178 platform->bridge.of_node = client->dev.of_node;
2179 platform->bridge.ops = DRM_BRIDGE_OP_EDID;
2180 if (!platform->pdata.panel_bridge)
2181 platform->bridge.ops |= DRM_BRIDGE_OP_HPD |
2182 DRM_BRIDGE_OP_DETECT;
2183 platform->bridge.type = platform->pdata.panel_bridge ?
2184 DRM_MODE_CONNECTOR_eDP :
2185 DRM_MODE_CONNECTOR_DisplayPort;
2187 drm_bridge_add(&platform->bridge);
2189 if (!platform->pdata.is_dpi) {
2190 ret = anx7625_attach_dsi(platform);
2192 DRM_DEV_ERROR(dev, "Fail to attach to dsi : %d\n", ret);
2193 goto unregister_bridge;
2197 if (platform->pdata.audio_en)
2198 anx7625_register_audio(dev, platform);
2200 DRM_DEV_DEBUG_DRIVER(dev, "probe done\n");
2205 drm_bridge_remove(&platform->bridge);
2207 if (!platform->pdata.low_power_mode)
2208 pm_runtime_put_sync_suspend(&client->dev);
2210 anx7625_unregister_i2c_dummy_clients(platform);
2213 if (platform->workqueue)
2214 destroy_workqueue(platform->workqueue);
2222 static int anx7625_i2c_remove(struct i2c_client *client)
2224 struct anx7625_data *platform = i2c_get_clientdata(client);
2226 drm_bridge_remove(&platform->bridge);
2228 if (platform->pdata.intp_irq)
2229 destroy_workqueue(platform->workqueue);
2231 if (!platform->pdata.low_power_mode)
2232 pm_runtime_put_sync_suspend(&client->dev);
2234 anx7625_unregister_i2c_dummy_clients(platform);
2236 if (platform->pdata.audio_en)
2237 anx7625_unregister_audio(platform);
2243 static const struct i2c_device_id anx7625_id[] = {
2248 MODULE_DEVICE_TABLE(i2c, anx7625_id);
2250 static const struct of_device_id anx_match_table[] = {
2251 {.compatible = "analogix,anx7625",},
2254 MODULE_DEVICE_TABLE(of, anx_match_table);
2256 static struct i2c_driver anx7625_driver = {
2259 .of_match_table = anx_match_table,
2260 .pm = &anx7625_pm_ops,
2262 .probe = anx7625_i2c_probe,
2263 .remove = anx7625_i2c_remove,
2265 .id_table = anx7625_id,
2268 module_i2c_driver(anx7625_driver);
2270 MODULE_DESCRIPTION("MIPI2DP anx7625 driver");
2272 MODULE_LICENSE("GPL v2");
2273 MODULE_VERSION(ANX7625_DRV_VERSION);