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>
5 #include <device/pci_ops.h>
7 #include <hwilib.h>
8 #include <soc/pci_devs.h>
9 #include <types.h>
10 
11 static void igd_disable(void)
12 {
13  struct device *root_dev = pcidev_path_on_root(SA_DEVFN_ROOT);
14  uint8_t deven;
15  uint16_t ggc;
16 
17  /* GMCH Graphics Control Register */
18  ggc = pci_read_config16(root_dev, 0x50);
19  /* Set size of Graphics Translation Table Memory (GGMS) [7:6]
20  * to 0 and select 0 MB for Graphics Memory (GMS) [15:8]. */
21  ggc &= ~(0xffc0);
22  /* Disable IGD VGA (IVD). */
23  ggc |= 0x2;
24  pci_write_config16(root_dev, 0x50, ggc);
25  /* Device Enable Register */
26  deven = pci_read_config8(root_dev, 0x54);
27  /* Disable IGD device (D2F0EN). */
28  deven &= ~(0x10);
29  pci_write_config8(root_dev, 0x54, deven);
30 }
31 
32 /** \brief This function provides EDID data to the driver for DP2LVDS Bridge (PTN3460)
33  * @param edid_data pointer to EDID data in driver
34 */
35 enum cb_err mb_get_edid(uint8_t edid_data[0x80])
36 {
37  const char *hwi_block = "hwinfo.hex";
38 
39  if (hwilib_find_blocks(hwi_block) != CB_SUCCESS) {
40  printk(BIOS_ERR, "LCD: Info block \"%s\" not found!\n", hwi_block);
41  return CB_ERR;
42  }
43 
44  /* Get EDID data from hwinfo block */
45  if (hwilib_get_field(Edid, edid_data, PTN_EDID_LEN) != PTN_EDID_LEN) {
46  /* Disable IGD to avoid panel failures. */
47  igd_disable();
48  printk(BIOS_ERR, "LCD: No EDID data available in %s\n", hwi_block);
49  return CB_ERR;
50  }
51  return CB_SUCCESS;
52 }
53 
54 /** \brief This function provides EDID block [0..6] to the driver for DP2LVDS Bridge (PTN3460)
55  * which has to be used.
56 */
58 {
59  return 6; /* With this mainboard we use EDID block 6 for emulation in PTN3460. */
60 }
61 
62 /** \brief Function to enable mainboard to adjust the config data of PTN3460.
63  * @param *cfg_ptr Pointer to the PTN config structure to modify.
64  * @return -1 on error; PTN_CFG_MODIFIED if data was modified and needs to be updated.
65 */
67 {
68  const char *hwi_block = "hwinfo.hex";
69  uint8_t disp_con = 0, color_depth = 0;
70 
71  if (hwilib_find_blocks(hwi_block) != CB_SUCCESS) {
72  printk(BIOS_ERR, "LCD: Info block \"%s\" not found!\n", hwi_block);
73  return -1;
74  }
75 
76  if (hwilib_get_field(PF_DisplCon, &disp_con, sizeof(disp_con)) != sizeof(disp_con)) {
77  printk(BIOS_ERR, "LCD: Missing panel features from %s\n", hwi_block);
78  return -1;
79  }
80  if (hwilib_get_field(PF_Color_Depth, &color_depth,
81  sizeof(color_depth)) != sizeof(color_depth)) {
82  printk(BIOS_ERR, "LCD: Missing panel features from %s\n", hwi_block);
83  return -1;
84  }
85  /* Set up configuration data according to the hwinfo block we got. */
86  cfg->dp_interface_ctrl = 0x00;
87  /* Drive LVDS clock for single mode on odd bus per default. */
88  cfg->lvds_interface_ctrl1 = 0x01;
89  if (disp_con == PF_DISPLCON_LVDS_DUAL) {
90  /* Turn on dual LVDS lane and clock. */
91  cfg->lvds_interface_ctrl1 |= 0x0b;
92  }
93  if (color_depth == PF_COLOR_DEPTH_6BIT) {
94  /* Use 18 bits per pixel. */
95  cfg->lvds_interface_ctrl1 |= 0x20;
96  }
97  /* 1 % clock spreading, 300 mV LVDS swing. */
98  cfg->lvds_interface_ctrl2 = 0x13;
99  /* No LVDS lane swap. */
100  cfg->lvds_interface_ctrl3 = 0x00;
101  /* Delay T2 (VDD to LVDS active) by 16 ms. */
102  cfg->t2_delay = 1;
103  /* 500 ms from LVDS to backlight active. */
104  cfg->t3_timing = 10;
105  /* 1 second re-power delay. */
106  cfg->t12_timing = 20;
107  /* 150 ms backlight off to LVDS inactive. */
108  cfg->t4_timing = 3;
109  /* Delay T5 (LVDS to VDD inactive) by 16 ms. */
110  cfg->t5_delay = 1;
111  /* Enable backlight control. */
112  cfg->backlight_ctrl = 0;
113 
114  return PTN_CFG_MODIFIED;
115 }
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
DEVTREE_CONST struct device * pcidev_path_on_root(pci_devfn_t devfn)
Definition: device_const.c:255
color_depth
Definition: edp.h:577
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#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
static void igd_disable(void)
Definition: lcd_panel.c:11
#define PTN_EDID_LEN
Definition: ptn3460.h:9
#define PTN_CFG_MODIFIED
Definition: ptn3460.h:19
#define SA_DEVFN_ROOT
Definition: pci_devs.h:23
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:107
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