coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sor.c File Reference
#include <console/console.h>
#include <stdint.h>
#include <delay.h>
#include <soc/addressmap.h>
#include <device/device.h>
#include <boot/tables.h>
#include <soc/nvidia/tegra/dc.h>
#include <soc/nvidia/tegra/types.h>
#include <soc/sor.h>
#include <soc/nvidia/tegra/displayport.h>
#include <soc/clk_rst.h>
#include <soc/clock.h>
#include "chip.h"
#include <soc/display.h>
Include dependency graph for sor.c:

Go to the source code of this file.

Macros

#define DEBUG_SOR   0
 
#define APBDEV_PMC_DPD_SAMPLE   (0x20)
 
#define APBDEV_PMC_DPD_SAMPLE_ON_DISABLE   (0)
 
#define APBDEV_PMC_DPD_SAMPLE_ON_ENABLE   (1)
 
#define APBDEV_PMC_SEL_DPD_TIM   (0x1c8)
 
#define APBDEV_PMC_SEL_DPD_TIM_SEL_DPD_TIM_DEFAULT   (0x7f)
 
#define APBDEV_PMC_IO_DPD2_REQ   (0x1c0)
 
#define APBDEV_PMC_IO_DPD2_REQ_LVDS_SHIFT   (25)
 
#define APBDEV_PMC_IO_DPD2_REQ_LVDS_OFF   (0 << 25)
 
#define APBDEV_PMC_IO_DPD2_REQ_LVDS_ON   (1 << 25)
 
#define APBDEV_PMC_IO_DPD2_REQ_CODE_SHIFT   (30)
 
#define APBDEV_PMC_IO_DPD2_REQ_CODE_DEFAULT_MASK   (0x3 << 30)
 
#define APBDEV_PMC_IO_DPD2_REQ_CODE_IDLE   (0 << 30)
 
#define APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_OFF   (1 << 30)
 
#define APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_ON   (2 << 30)
 
#define APBDEV_PMC_IO_DPD2_STATUS   (0x1c4)
 
#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_SHIFT   (25)
 
#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_OFF   (0 << 25)
 
#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_ON   (1 << 25)
 
#define DC_N_WINDOWS   5
 

Functions

static u32 tegra_sor_readl (struct tegra_dc_sor_data *sor, u32 reg)
 
static void tegra_sor_writel (struct tegra_dc_sor_data *sor, u32 reg, u32 val)
 
static void tegra_sor_write_field (struct tegra_dc_sor_data *sor, u32 reg, u32 mask, u32 val)
 
void tegra_dp_disable_tx_pu (struct tegra_dc_sor_data *sor)
 
void tegra_dp_set_pe_vs_pc (struct tegra_dc_sor_data *sor, u32 mask, u32 pe_reg, u32 vs_reg, u32 pc_reg, u8 pc_supported)
 
static u32 tegra_dc_sor_poll_register (struct tegra_dc_sor_data *sor, u32 reg, u32 mask, u32 exp_val, u32 poll_interval_us, u32 timeout_us)
 
int tegra_dc_sor_set_power_state (struct tegra_dc_sor_data *sor, int pu_pd)
 
void tegra_dc_sor_set_dp_linkctl (struct tegra_dc_sor_data *sor, int ena, u8 training_pattern, const struct tegra_dc_dp_link_config *link_cfg)
 
static int tegra_dc_sor_enable_lane_sequencer (struct tegra_dc_sor_data *sor, int pu, int is_lvds)
 
static int tegra_dc_sor_power_dplanes (struct tegra_dc_sor_data *sor, u32 lane_count, int pu)
 
void tegra_dc_sor_set_panel_power (struct tegra_dc_sor_data *sor, int power_up)
 
static void tegra_dc_sor_config_pwm (struct tegra_dc_sor_data *sor, u32 pwm_div, u32 pwm_dutycycle)
 
static void tegra_dc_sor_set_dp_mode (struct tegra_dc_sor_data *sor, const struct tegra_dc_dp_link_config *link_cfg)
 
static void tegra_dc_sor_super_update (struct tegra_dc_sor_data *sor)
 
static void tegra_dc_sor_update (struct tegra_dc_sor_data *sor)
 
static void tegra_dc_sor_io_set_dpd (struct tegra_dc_sor_data *sor, int up)
 
void tegra_dc_sor_set_internal_panel (struct tegra_dc_sor_data *sor, int is_int)
 
void tegra_dc_sor_read_link_config (struct tegra_dc_sor_data *sor, u8 *link_bw, u8 *lane_count)
 
void tegra_dc_sor_set_link_bandwidth (struct tegra_dc_sor_data *sor, u8 link_bw)
 
void tegra_dc_sor_set_lane_count (struct tegra_dc_sor_data *sor, u8 lane_count)
 
static void tegra_sor_enable_edp_clock (struct tegra_dc_sor_data *sor)
 
static void tegra_dc_sor_power_up (struct tegra_dc_sor_data *sor, int is_lvds)
 
static void tegra_dc_sor_config_panel (struct tegra_dc_sor_data *sor, int is_lvds)
 
static void tegra_dc_sor_enable_dc (struct tegra_dc_sor_data *sor)
 
void tegra_dc_sor_enable_dp (struct tegra_dc_sor_data *sor)
 
void tegra_dc_sor_attach (struct tegra_dc_sor_data *sor)
 
void tegra_dc_sor_set_lane_parm (struct tegra_dc_sor_data *sor, const struct tegra_dc_dp_link_config *link_cfg)
 
void tegra_dc_sor_set_voltage_swing (struct tegra_dc_sor_data *sor)
 
void tegra_dc_sor_power_down_unused_lanes (struct tegra_dc_sor_data *sor)
 
void tegra_sor_precharge_lanes (struct tegra_dc_sor_data *sor)
 
static u32 tegra_dc_poll_register (void *reg, u32 mask, u32 exp_val, u32 poll_interval_us, u32 timeout_us)
 
static void tegra_dc_sor_general_act (struct display_controller *disp_ctrl)
 
static void tegra_dc_sor_disable_win_short_raster (struct display_controller *disp_ctrl, int *dc_reg_ctx)
 
static void tegra_dc_sor_restore_win_and_raster (struct display_controller *disp_ctrl, int *dc_reg_ctx)
 
static void tegra_dc_sor_enable_sor (struct tegra_dc_sor_data *sor, int enable)
 
void tegra_dc_detach (struct tegra_dc_sor_data *sor)
 

Variables

static struct tegra_dc_mode min_mode
 

Macro Definition Documentation

◆ APBDEV_PMC_DPD_SAMPLE

#define APBDEV_PMC_DPD_SAMPLE   (0x20)

Definition at line 24 of file sor.c.

◆ APBDEV_PMC_DPD_SAMPLE_ON_DISABLE

#define APBDEV_PMC_DPD_SAMPLE_ON_DISABLE   (0)

Definition at line 25 of file sor.c.

◆ APBDEV_PMC_DPD_SAMPLE_ON_ENABLE

#define APBDEV_PMC_DPD_SAMPLE_ON_ENABLE   (1)

Definition at line 26 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ

#define APBDEV_PMC_IO_DPD2_REQ   (0x1c0)

Definition at line 29 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_CODE_DEFAULT_MASK

#define APBDEV_PMC_IO_DPD2_REQ_CODE_DEFAULT_MASK   (0x3 << 30)

Definition at line 34 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_OFF

#define APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_OFF   (1 << 30)

Definition at line 36 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_ON

#define APBDEV_PMC_IO_DPD2_REQ_CODE_DPD_ON   (2 << 30)

Definition at line 37 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_CODE_IDLE

#define APBDEV_PMC_IO_DPD2_REQ_CODE_IDLE   (0 << 30)

Definition at line 35 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_CODE_SHIFT

#define APBDEV_PMC_IO_DPD2_REQ_CODE_SHIFT   (30)

Definition at line 33 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_LVDS_OFF

#define APBDEV_PMC_IO_DPD2_REQ_LVDS_OFF   (0 << 25)

Definition at line 31 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_LVDS_ON

#define APBDEV_PMC_IO_DPD2_REQ_LVDS_ON   (1 << 25)

Definition at line 32 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_REQ_LVDS_SHIFT

#define APBDEV_PMC_IO_DPD2_REQ_LVDS_SHIFT   (25)

Definition at line 30 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_STATUS

#define APBDEV_PMC_IO_DPD2_STATUS   (0x1c4)

Definition at line 38 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_STATUS_LVDS_OFF

#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_OFF   (0 << 25)

Definition at line 40 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_STATUS_LVDS_ON

#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_ON   (1 << 25)

Definition at line 41 of file sor.c.

◆ APBDEV_PMC_IO_DPD2_STATUS_LVDS_SHIFT

#define APBDEV_PMC_IO_DPD2_STATUS_LVDS_SHIFT   (25)

Definition at line 39 of file sor.c.

◆ APBDEV_PMC_SEL_DPD_TIM

#define APBDEV_PMC_SEL_DPD_TIM   (0x1c8)

Definition at line 27 of file sor.c.

◆ APBDEV_PMC_SEL_DPD_TIM_SEL_DPD_TIM_DEFAULT

#define APBDEV_PMC_SEL_DPD_TIM_SEL_DPD_TIM_DEFAULT   (0x7f)

Definition at line 28 of file sor.c.

◆ DC_N_WINDOWS

#define DC_N_WINDOWS   5

Definition at line 43 of file sor.c.

◆ DEBUG_SOR

#define DEBUG_SOR   0

Definition at line 22 of file sor.c.

Function Documentation

◆ tegra_dc_detach()

◆ tegra_dc_poll_register()

static u32 tegra_dc_poll_register ( void reg,
u32  mask,
u32  exp_val,
u32  poll_interval_us,
u32  timeout_us 
)
static

Definition at line 914 of file sor.c.

References mask, READL(), and udelay().

Here is the call graph for this function:

◆ tegra_dc_sor_attach()

◆ tegra_dc_sor_config_panel()

◆ tegra_dc_sor_config_pwm()

static void tegra_dc_sor_config_pwm ( struct tegra_dc_sor_data sor,
u32  pwm_div,
u32  pwm_dutycycle 
)
static

◆ tegra_dc_sor_disable_win_short_raster()

◆ tegra_dc_sor_enable_dc()

static void tegra_dc_sor_enable_dc ( struct tegra_dc_sor_data sor)
static

Definition at line 651 of file sor.c.

References tegra_dc::base, display_controller::cmd, tegra_dc_sor_data::dc, display_controller::disp, dc_cmd_reg::disp_cmd, DISP_CTRL_MODE_C_DISPLAY, dc_disp_reg::disp_timing_opt, READL(), dc_cmd_reg::state_access, VSYNC_H_POSITION, WRITE_MUX_ACTIVE, and WRITEL().

Referenced by tegra_dc_sor_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_enable_dp()

◆ tegra_dc_sor_enable_lane_sequencer()

◆ tegra_dc_sor_enable_sor()

static void tegra_dc_sor_enable_sor ( struct tegra_dc_sor_data sor,
int  enable 
)
static

Definition at line 1030 of file sor.c.

References tegra_dc::base, tegra_dc_sor_data::dc, display_controller::disp, dc_disp_reg::disp_win_opt, READL(), SOR_ENABLE, and WRITEL().

Referenced by tegra_dc_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_general_act()

static void tegra_dc_sor_general_act ( struct display_controller disp_ctrl)
static

Definition at line 935 of file sor.c.

Referenced by tegra_dc_detach().

Here is the caller graph for this function:

◆ tegra_dc_sor_io_set_dpd()

◆ tegra_dc_sor_poll_register()

static u32 tegra_dc_sor_poll_register ( struct tegra_dc_sor_data sor,
u32  reg,
u32  mask,
u32  exp_val,
u32  poll_interval_us,
u32  timeout_us 
)
static

Definition at line 90 of file sor.c.

References BIOS_ERR, mask, printk, tegra_sor_readl(), and udelay().

Referenced by tegra_dc_detach(), tegra_dc_sor_attach(), tegra_dc_sor_config_pwm(), tegra_dc_sor_enable_dp(), tegra_dc_sor_enable_lane_sequencer(), and tegra_dc_sor_set_power_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_power_down_unused_lanes()

◆ tegra_dc_sor_power_dplanes()

static int tegra_dc_sor_power_dplanes ( struct tegra_dc_sor_data sor,
u32  lane_count,
int  pu 
)
static

◆ tegra_dc_sor_power_up()

◆ tegra_dc_sor_read_link_config()

◆ tegra_dc_sor_restore_win_and_raster()

static void tegra_dc_sor_restore_win_and_raster ( struct display_controller disp_ctrl,
int *  dc_reg_ctx 
)
static

◆ tegra_dc_sor_set_dp_linkctl()

◆ tegra_dc_sor_set_dp_mode()

◆ tegra_dc_sor_set_internal_panel()

void tegra_dc_sor_set_internal_panel ( struct tegra_dc_sor_data sor,
int  is_int 
)

Definition at line 366 of file sor.c.

References NV_SOR_DP_SPARE, NV_SOR_DP_SPARE_PANEL_INTERNAL, NV_SOR_DP_SPARE_SEQ_ENABLE_YES, NV_SOR_DP_SPARE_SOR_CLK_SEL_MACRO_SORCLK, tegra_dc_sor_data::portnum, tegra_sor_readl(), and tegra_sor_writel().

Referenced by tegra_dc_dp_set_assr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_set_lane_count()

void tegra_dc_sor_set_lane_count ( struct tegra_dc_sor_data sor,
u8  lane_count 
)

Definition at line 417 of file sor.c.

References BIOS_ERR, NV_SOR_DP_LINKCTL, NV_SOR_DP_LINKCTL_LANECOUNT_FOUR, NV_SOR_DP_LINKCTL_LANECOUNT_MASK, NV_SOR_DP_LINKCTL_LANECOUNT_ONE, NV_SOR_DP_LINKCTL_LANECOUNT_TWO, tegra_dc_sor_data::portnum, printk, tegra_sor_readl(), and tegra_sor_writel().

Referenced by tegra_dp_set_lane_count().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_set_lane_parm()

◆ tegra_dc_sor_set_link_bandwidth()

void tegra_dc_sor_set_link_bandwidth ( struct tegra_dc_sor_data sor,
u8  link_bw 
)

Definition at line 410 of file sor.c.

References NV_SOR_CLK_CNTRL, NV_SOR_CLK_CNTRL_DP_LINK_SPEED_MASK, NV_SOR_CLK_CNTRL_DP_LINK_SPEED_SHIFT, and tegra_sor_write_field().

Referenced by tegra_dp_set_link_bandwidth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_set_panel_power()

void tegra_dc_sor_set_panel_power ( struct tegra_dc_sor_data sor,
int  power_up 
)

Definition at line 244 of file sor.c.

References NV_SOR_DP_PADCTL, NV_SOR_DP_PADCTL_PAD_CAL_PD_POWERDOWN, NV_SOR_DP_PADCTL_PAD_CAL_PD_POWERUP, tegra_dc_sor_data::portnum, tegra_sor_readl(), and tegra_sor_writel().

Referenced by dp_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_set_power_state()

int tegra_dc_sor_set_power_state ( struct tegra_dc_sor_data sor,
int  pu_pd 
)

◆ tegra_dc_sor_set_voltage_swing()

void tegra_dc_sor_set_voltage_swing ( struct tegra_dc_sor_data sor)

Definition at line 817 of file sor.c.

References BIOS_WARNING, tegra_dc_dp_link_config::link_bw, tegra_dc_sor_data::link_cfg, NV_SOR_LANE_DRIVE_CURRENT, NV_SOR_PR, tegra_dc_sor_data::portnum, printk, SOR_LINK_SPEED_G1_62, SOR_LINK_SPEED_G2_7, SOR_LINK_SPEED_G5_4, and tegra_sor_writel().

Referenced by tegra_dp_do_link_training().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_super_update()

static void tegra_dc_sor_super_update ( struct tegra_dc_sor_data sor)
inlinestatic

Definition at line 310 of file sor.c.

References NV_SOR_SUPER_STATE0, and tegra_sor_writel().

Referenced by tegra_dc_detach(), and tegra_dc_sor_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dc_sor_update()

static void tegra_dc_sor_update ( struct tegra_dc_sor_data sor)
inlinestatic

Definition at line 317 of file sor.c.

References NV_SOR_STATE0, and tegra_sor_writel().

Referenced by tegra_dc_sor_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dp_disable_tx_pu()

void tegra_dp_disable_tx_pu ( struct tegra_dc_sor_data sor)

Definition at line 68 of file sor.c.

References NV_SOR_DP_PADCTL, NV_SOR_DP_PADCTL_TX_PU_DISABLE, NV_SOR_DP_PADCTL_TX_PU_MASK, tegra_dc_sor_data::portnum, and tegra_sor_write_field().

Referenced by tegra_dp_lt_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_dp_set_pe_vs_pc()

void tegra_dp_set_pe_vs_pc ( struct tegra_dc_sor_data sor,
u32  mask,
u32  pe_reg,
u32  vs_reg,
u32  pc_reg,
u8  pc_supported 
)

Definition at line 76 of file sor.c.

References mask, NV_SOR_DC, NV_SOR_POSTCURSOR, NV_SOR_PR, tegra_dc_sor_data::portnum, and tegra_sor_write_field().

Referenced by tegra_dp_lt_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_sor_enable_edp_clock()

static void tegra_sor_enable_edp_clock ( struct tegra_dc_sor_data sor)
static

Definition at line 444 of file sor.c.

References sor_clock_start().

Referenced by tegra_dc_sor_enable_dp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tegra_sor_precharge_lanes()

◆ tegra_sor_readl()

◆ tegra_sor_write_field()

static void tegra_sor_write_field ( struct tegra_dc_sor_data sor,
u32  reg,
u32  mask,
u32  val 
)
inlinestatic

◆ tegra_sor_writel()

Variable Documentation

◆ min_mode

struct tegra_dc_mode min_mode
static
Initial value:
= {
.h_ref_to_sync = 0,
.v_ref_to_sync = 1,
.h_sync_width = 1,
.v_sync_width = 1,
.h_back_porch = 20,
.v_back_porch = 0,
.h_active = 16,
.v_active = 16,
.h_front_porch = 1,
.v_front_porch = 2,
}

Definition at line 935 of file sor.c.

Referenced by tegra_dc_sor_disable_win_short_raster().