coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dsi_phy_pll.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/mmio.h>
4 #include <stdint.h>
5 #include <edid.h>
6 #include <soc/clock.h>
7 #include <soc/display/mdssreg.h>
9 
10 #define VCO_DELAY_USEC 1
11 
12 /* Bit definition of SSC control registers */
13 #define SSC_CENTER BIT(0)
14 #define SSC_EN BIT(1)
15 
16 struct dsi_pll_regs {
23 };
24 
25 static void dsi_pll_init_val(void)
26 {
64 }
65 
67  unsigned long rate)
68 {
69  u32 frac_bits = 18;
70  u64 pll_freq;
71  u64 divider;
72  u64 dec, dec_multiple;
73  u32 frac;
74  u64 multiplier;
75 
76  pll_freq = rate;
77  divider = SRC_XO_HZ * 2;
78 
79  multiplier = 1 << frac_bits;
80  dec_multiple = (pll_freq * multiplier) / divider;
81  frac = dec_multiple % multiplier;
82 
83  dec = dec_multiple / multiplier;
84  if (pll_freq <= 1900UL * MHz)
85  regs->pll_prop_gain_rate = 8;
86  else if (pll_freq <= 3000UL * MHz)
87  regs->pll_prop_gain_rate = 10;
88  else
89  regs->pll_prop_gain_rate = 12;
90 
91  if (pll_freq < 1100UL * MHz)
92  regs->pll_clock_inverters = 8;
93  else
94  regs->pll_clock_inverters = 0;
95 
96  regs->decimal_div_start = dec;
97  regs->frac_div_start_low = (frac & 0xff);
98  regs->frac_div_start_mid = (frac & 0xff00) >> 8;
99  regs->frac_div_start_high = (frac & 0x30000) >> 16;
100 }
101 
102 static void dsi_pll_commit(struct dsi_pll_regs *reg)
103 {
113 }
114 
115 static void dsi_pll_config_hzindep_reg(struct dsi_pll_regs *reg)
116 {
135 }
136 
138 {
139  struct dsi_pll_regs regs;
140 
145 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
#define MHz
Definition: helpers.h:80
static void dsi_pll_commit(struct dsi_pll_regs *reg)
Definition: dsi_phy_pll.c:102
void dsi_phy_pll_vco_10nm_set_rate(unsigned long rate)
Definition: dsi_phy_pll.c:137
static void dsi_pll_init_val(void)
Definition: dsi_phy_pll.c:25
static void dsi_pll_config_hzindep_reg(struct dsi_pll_regs *reg)
Definition: dsi_phy_pll.c:115
static void dsi_pll_calc_dec_frac(struct dsi_pll_regs *regs, unsigned long rate)
Definition: dsi_phy_pll.c:66
static struct dsi_phy_pll_qlink_regs *const phy_pll_qlink
Definition: mdssreg.h:453
#define SRC_XO_HZ
Definition: clock.h:10
uint64_t u64
Definition: stdint.h:54
uint32_t u32
Definition: stdint.h:51
u32 decimal_div_start
Definition: dsi_phy_pll.c:18
u32 pll_prop_gain_rate
Definition: dsi_phy_pll.c:17
u32 frac_div_start_high
Definition: dsi_phy_pll.c:21
u32 frac_div_start_mid
Definition: dsi_phy_pll.c:20
u32 frac_div_start_low
Definition: dsi_phy_pll.c:19
u32 pll_clock_inverters
Definition: dsi_phy_pll.c:22
Definition: pll.c:262