summaryrefslogtreecommitdiff
path: root/src/mainboard/google/kukui/panel_anx7625.c
blob: 90a041b42a384ed91f799e149979b7148b472b36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <delay.h>
#include <drivers/analogix/anx7625/anx7625.h>
#include <edid.h>
#include <gpio.h>
#include <soc/dsi.h>
#include <soc/i2c.h>

#include "panel.h"

#define ANX7625_I2C_BUS 4

static struct panel_serializable_data anx7625_data = {
	.init = { PANEL_END },
};

static void dummy_power_on(void)
{
	/*
	 * The panel has been already powered on when getting panel information
	 * so we should do nothing here.
	 */
}

static void start_anx7625(void)
{
	if (anx7625_dp_start(ANX7625_I2C_BUS, &anx7625_data.edid) < 0)
		printk(BIOS_ERR, "Can't start display via ANX7625.\n");
}

static struct panel_description anx7625_panel = {
	.s = &anx7625_data,
	.orientation = LB_FB_ORIENTATION_NORMAL,
	.power_on = dummy_power_on,
	.post_power_on = start_anx7625,
};

static void power_on_anx7625(void)
{
	/* Disable backlight before turning on bridge */
	gpio_output(GPIO(PERIPHERAL_EN13), 0);
	gpio_output(GPIO(DISP_PWM), 0);

	/* Turn on bridge */
	gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 0);
	gpio_output(GPIO_PP1200_MIPIBRDG_EN, 1);
	gpio_output(GPIO_VDDIO_MIPIBRDG_EN, 1);
	gpio_output(GPIO_PP1800_LCM_EN, 1);
	mdelay(2);
	gpio_output(GPIO_MIPIBRDG_PWRDN_L_1V8, 1);
	mdelay(10);
	gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 1);
	gpio_output(GPIO_PP3300_LCM_EN, 1);
}

struct panel_description *get_panel_description(int panel_id)
{
	/* To read panel EDID, we have to first power on anx7625. */
	power_on_anx7625();

	mtk_i2c_bus_init(ANX7625_I2C_BUS);

	if (anx7625_init(ANX7625_I2C_BUS)) {
		printk(BIOS_ERR, "Can't init ANX7625 bridge.\n");
		return NULL;
	}

	if (anx7625_dp_get_edid(ANX7625_I2C_BUS, &anx7625_data.edid)) {
		printk(BIOS_ERR, "Can't get panel's edid.\n");
		return NULL;
	}
	return &anx7625_panel;
}

void mtk_dsi_override_phy_timing(struct mtk_phy_timing *timing)
{
	timing->da_hs_trail += 9;
}