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  cfg->lvds_interface_ctrl1 = 0x00;
63  if (disp_con == PF_DISPLCON_LVDS_DUAL) {
64  /* Turn on dual LVDS lane and clock. */
65  cfg->lvds_interface_ctrl1 |= 0x0b;
66  }
67  if (color_depth == PF_COLOR_DEPTH_6BIT) {
68  /* Use 18 bits per pixel. */
69  cfg->lvds_interface_ctrl1 |= 0x20;
70  }
71  /* 1 % clock spreading, 300 mV LVDS swing. */
72  cfg->lvds_interface_ctrl2 = 0x13;
73  /* No LVDS lane swap. */
74  cfg->lvds_interface_ctrl3 = 0x00;
75  /* Delay T2 (VDD to LVDS active) by 16 ms. */
76  cfg->t2_delay = 1;
77  /* 500 ms from LVDS to backlight active. */
78  cfg->t3_timing = 10;
79  /* 1 second re-power delay. */
80  cfg->t12_timing = 20;
81  /* 150 ms backlight off to LVDS inactive. */
82  cfg->t4_timing = 3;
83  /* Delay T5 (LVDS to VDD inactive) by 16 ms. */
84  cfg->t5_delay = 1;
85  /* Enable backlight control. */
86  cfg->backlight_ctrl = 0;
87 
88  return PTN_CFG_MODIFIED;
89 }
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