Skip to content

Instantly share code, notes, and snippets.

@samueldr

samueldr/.diff Secret

Created September 10, 2021 00:51
Show Gist options
  • Save samueldr/07562d3d91c013bf2b0237e001374240 to your computer and use it in GitHub Desktop.
Save samueldr/07562d3d91c013bf2b0237e001374240 to your computer and use it in GitHub Desktop.
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 65508eb89ec99..1a73cd131ef98 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1435,9 +1435,17 @@ unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
int ret;
struct clk_rate_request req;
+printk("[TRACE:%s] rate = %ld;\n", __func__, rate);
+
+ if (WARN(rate == 0, "clk_hw_round_rate, rate is zero."))
+ return 0;
+
clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate);
req.rate = rate;
+printk("[TRACE:%s] clk_core_round_rate_nolock(%d, &req)\n", __func__);
+printk("[TRACE:%s] req.rate = %ld;\n", __func__, req.rate);
+
ret = clk_core_round_rate_nolock(hw->core, &req);
if (ret)
return 0;
diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c
index e6bcc0a7170c8..6ca377374b6cf 100644
--- a/drivers/clk/sunxi-ng/ccu_nm.c
+++ b/drivers/clk/sunxi-ng/ccu_nm.c
@@ -123,6 +123,8 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
struct ccu_nm *nm = hw_to_ccu_nm(hw);
struct _ccu_nm _nm;
+printk("[TRACE:%s] rate=%d, parent_rate=%d;\n", __func__, rate, parent_rate);
+
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
rate *= nm->fixed_post_div;
@@ -158,6 +160,7 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
_nm.max_m = nm->m.max ?: 1 << nm->m.width;
ccu_nm_find_best(*parent_rate, rate, &_nm);
+printk("[TRACE:%s] _nm.{ n = %d, m = %d, };\n", __func__, _nm.n, _nm.m);
rate = ccu_nm_calc_rate(*parent_rate, _nm.n, _nm.m);
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
diff --git a/drivers/gpu/drm/sun4i/sun4i_dotclock.c b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
index 417ade3d2565d..423121d4c37b3 100644
--- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
+++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
@@ -76,6 +76,8 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
u8 best_div = 1;
int i;
+printk("name=%s rate=%d\n", clk_hw_get_name(hw), clk_hw_get_rate(hw));
+
for (i = tcon->dclk_min_div; i <= tcon->dclk_max_div; i++) {
u64 ideal = (u64)rate * i;
unsigned long rounded;
@@ -90,6 +92,9 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
if (ideal > ULONG_MAX)
goto out;
+printk("[parent] name=%s rate=%d\n", clk_hw_get_name(clk_hw_get_parent(hw)), clk_hw_get_rate(clk_hw_get_parent(hw)));
+printk(" ideal = %lld\n", ideal);
+
rounded = clk_hw_round_rate(clk_hw_get_parent(hw),
ideal);
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 6cd63027f0d87..c575eb8983822 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -294,6 +294,7 @@ static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon,
const struct drm_display_mode *mode)
{
/* Configure the dot clock */
+printk("[TRACE] @%s: mode->crtc_clock * 1000 = %d\n", __func__, mode->crtc_clock * 1000);
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
/* Set the resolution */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment