coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
lcd_panel.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
6 #include <hwilib.h>
7 #include <types.h>
8 
9 /** \brief This function provides EDID data to the driver for DP2LVDS Bridge (PTN3460)
10  * @param edid_data pointer to EDID data in driver
11 */
12 enum cb_err mb_get_edid(uint8_t edid_data[0x80])
13 {
14  const char *hwi_block = "hwinfo.hex";
15 
16  if (hwilib_find_blocks(hwi_block) != CB_SUCCESS) {
17  printk(BIOS_ERR, "LCD: Info block \"%s\" not found!\n", hwi_block);
18  return CB_ERR;
19  }
20 
21  /* Get EDID data from hwinfo block */
22  if (hwilib_get_field(Edid, edid_data, PTN_EDID_LEN) != PTN_EDID_LEN) {
23  printk(BIOS_ERR, "LCD: No EDID data available in %s\n", hwi_block);
24  return CB_ERR;
25  }
26  return CB_SUCCESS;
27 }
28 
29 /** \brief This function provides EDID block [0..6] to the driver for DP2LVDS Bridge (PTN3460)
30  * which has to be used.
31 */
33 {
34  return 6; /* With this mainboard we use EDID block 6 for emulation in PTN3460. */
35 }
36 
37 /** \brief Function to enable mainboard to adjust the config data of PTN3460.
38  * @param *cfg_ptr Pointer to the PTN config structure to modify.
39  * @return -1 on error; PTN_CFG_MODIFIED if data was modified and needs to be updated.
40 */
42 {
43  const char *hwi_block = "hwinfo.hex";
44  uint8_t disp_con = 0, color_depth = 0;
45 
46  if (hwilib_find_blocks(hwi_block) != CB_SUCCESS) {
47  printk(BIOS_ERR, "LCD: Info block \"%s\" not found!\n", hwi_block);
48  return -1;
49  }
50 
51  if (hwilib_get_field(PF_DisplCon, &disp_con, sizeof(disp_con)) != sizeof(disp_con)) {
52  printk(BIOS_ERR, "LCD: Missing panel features from %s\n", hwi_block);
53  return -1;
54  }
55  if (hwilib_get_field(PF_Color_Depth, &color_depth,
56  sizeof(color_depth)) != sizeof(color_depth)) {
57  printk(BIOS_ERR, "LCD: Missing panel features from %s\n", hwi_block);
58  return -1;
59  }
60  /* Set up configuration data according to the hwinfo block we got. */
61  cfg->dp_interface_ctrl = 0x00;
62  /* Use odd-bus for clock distribution only. */
63  cfg->lvds_interface_ctrl1 = 0x01;
64  if (disp_con == PF_DISPLCON_LVDS_DUAL) {
65  /* Turn on dual LVDS lane and clock. */
66  cfg->lvds_interface_ctrl1 |= 0x0b;
67  }
68  if (color_depth == PF_COLOR_DEPTH_6BIT) {
69  /* Use 18 bits per pixel. */
70  cfg->lvds_interface_ctrl1 |= 0x20;
71  }
72  /* No clock spreading, 300 mV LVDS swing. */
73  cfg->lvds_interface_ctrl2 = 0x03;
74  /* Swap LVDS lanes (N vs. P). */
75  cfg->lvds_interface_ctrl3 = 0x04;
76  /* Delay T2 (VDD to LVDS active) by 16 ms. */
77  cfg->t2_delay = 1;
78  /* 500 ms from LVDS to backlight active. */
79  cfg->t3_timing = 10;
80  /* 1 second re-power delay. */
81  cfg->t12_timing = 20;
82  /* 150 ms backlight off to LVDS inactive. */
83  cfg->t4_timing = 3;
84  /* Delay T5 (LVDS to VDD inactive) by 16 ms. */
85  cfg->t5_delay = 1;
86  /* Enable backlight control. */
87  cfg->backlight_ctrl = 0;
88 
89  return PTN_CFG_MODIFIED;
90 }
cb_err
coreboot error codes
Definition: cb_err.h:15
@ CB_ERR
Generic error code.
Definition: cb_err.h:17
@ CB_SUCCESS
Call completed successfully.
Definition: cb_err.h:16
#define printk(level,...)
Definition: stdlib.h:16
color_depth
Definition: edp.h:577
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
uint8_t mb_select_edid_table(void)
This function provides EDID block [0..6] to the driver for DP2LVDS Bridge (PTN3460) which has to be u...
Definition: lcd_panel.c:32
int mb_adjust_cfg(struct ptn_3460_config *cfg)
Function to enable mainboard to adjust the config data of PTN3460.
Definition: lcd_panel.c:41
enum cb_err mb_get_edid(uint8_t edid_data[0x80])
This function provides EDID data to the driver for DP2LVDS Bridge (PTN3460)
Definition: lcd_panel.c:12
#define PTN_EDID_LEN
Definition: ptn3460.h:9
#define PTN_CFG_MODIFIED
Definition: ptn3460.h:19
unsigned char uint8_t
Definition: stdint.h:8
u8 lvds_interface_ctrl3
Definition: ptn3460.h:29
u8 dp_interface_ctrl
Definition: ptn3460.h:26
u8 backlight_ctrl
Definition: ptn3460.h:42
u8 lvds_interface_ctrl2
Definition: ptn3460.h:28
u8 lvds_interface_ctrl1
Definition: ptn3460.h:27