Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: meson: meson8b: Initialize the HDMI PLL registers

Add the reg_sequence to initialize the HDMI PLL with the settings for
a video mode that doesn't require PLL internal clock doubling. These
settings are taken from the 3.10 vendor kernel's driver for the 2970MHz
PLL setting used for the 1080P video mode. This puts the PLL into a
defined state and the Linux kernel can take over.
While not all bits for this PLL are implemented using these "defaults"
and then applying M, N and FRAC seems to work fine.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20210713232510.3057750-5-martin.blumenstingl@googlemail.com

authored by

Martin Blumenstingl and committed by
Jerome Brunet
040e165b bb855735

+48 -5
+36 -4
drivers/clk/meson/meson8b.c
··· 118 118 }, 119 119 }; 120 120 121 + static struct clk_fixed_factor hdmi_pll_dco_in = { 122 + .mult = 2, 123 + .div = 1, 124 + .hw.init = &(struct clk_init_data){ 125 + .name = "hdmi_pll_dco_in", 126 + .ops = &clk_fixed_factor_ops, 127 + .parent_data = &(const struct clk_parent_data) { 128 + .fw_name = "xtal", 129 + .index = -1, 130 + }, 131 + .num_parents = 1, 132 + }, 133 + }; 134 + 135 + /* 136 + * Taken from the vendor driver for the 2970/2975MHz (both only differ in the 137 + * FRAC part in HHI_VID_PLL_CNTL2) where these values are identical for Meson8, 138 + * Meson8b and Meson8m2. This doubles the input (or output - it's not clear 139 + * which one but the result is the same) clock. The vendor driver additionally 140 + * has the following comment about: "optimise HPLL VCO 2.97GHz performance". 141 + */ 142 + static const struct reg_sequence meson8b_hdmi_pll_init_regs[] = { 143 + { .reg = HHI_VID_PLL_CNTL2, .def = 0x69c84000 }, 144 + { .reg = HHI_VID_PLL_CNTL3, .def = 0x8a46c023 }, 145 + { .reg = HHI_VID_PLL_CNTL4, .def = 0x4123b100 }, 146 + { .reg = HHI_VID_PLL_CNTL5, .def = 0x00012385 }, 147 + { .reg = HHI_VID2_PLL_CNTL2, .def = 0x0430a800 }, 148 + }; 149 + 121 150 static const struct pll_params_table hdmi_pll_params_table[] = { 122 151 PLL_PARAMS(40, 1), 123 152 PLL_PARAMS(42, 1), ··· 201 172 .width = 1, 202 173 }, 203 174 .table = hdmi_pll_params_table, 175 + .init_regs = meson8b_hdmi_pll_init_regs, 176 + .init_count = ARRAY_SIZE(meson8b_hdmi_pll_init_regs), 204 177 }, 205 178 .hw.init = &(struct clk_init_data){ 206 179 /* sometimes also called "HPLL" or "HPLL PLL" */ 207 180 .name = "hdmi_pll_dco", 208 181 .ops = &meson_clk_pll_ro_ops, 209 - .parent_data = &(const struct clk_parent_data) { 210 - .fw_name = "xtal", 211 - .name = "xtal", 212 - .index = -1, 182 + .parent_hws = (const struct clk_hw *[]) { 183 + &hdmi_pll_dco_in.hw 213 184 }, 214 185 .num_parents = 1, 215 186 }, ··· 2974 2945 [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw, 2975 2946 [CLKID_CTS_I958] = &meson8b_cts_i958.hw, 2976 2947 [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw, 2948 + [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw, 2977 2949 [CLK_NR_CLKS] = NULL, 2978 2950 }, 2979 2951 .num = CLK_NR_CLKS, ··· 3193 3163 [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw, 3194 3164 [CLKID_CTS_I958] = &meson8b_cts_i958.hw, 3195 3165 [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw, 3166 + [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw, 3196 3167 [CLK_NR_CLKS] = NULL, 3197 3168 }, 3198 3169 .num = CLK_NR_CLKS, ··· 3414 3383 [CLKID_CTS_MCLK_I958] = &meson8b_cts_mclk_i958.hw, 3415 3384 [CLKID_CTS_I958] = &meson8b_cts_i958.hw, 3416 3385 [CLKID_VID_PLL_LVDS_EN] = &meson8b_vid_pll_lvds_en.hw, 3386 + [CLKID_HDMI_PLL_DCO_IN] = &hdmi_pll_dco_in.hw, 3417 3387 [CLK_NR_CLKS] = NULL, 3418 3388 }, 3419 3389 .num = CLK_NR_CLKS,
+12 -1
drivers/clk/meson/meson8b.h
··· 51 51 #define HHI_SYS_PLL_CNTL 0x300 /* 0xc0 offset in data sheet */ 52 52 #define HHI_VID_PLL_CNTL 0x320 /* 0xc8 offset in data sheet */ 53 53 #define HHI_VID_PLL_CNTL2 0x324 /* 0xc9 offset in data sheet */ 54 + #define HHI_VID_PLL_CNTL3 0x328 /* 0xca offset in data sheet */ 55 + #define HHI_VID_PLL_CNTL4 0x32c /* 0xcb offset in data sheet */ 56 + #define HHI_VID_PLL_CNTL5 0x330 /* 0xcc offset in data sheet */ 57 + #define HHI_VID_PLL_CNTL6 0x334 /* 0xcd offset in data sheet */ 58 + #define HHI_VID2_PLL_CNTL 0x380 /* 0xe0 offset in data sheet */ 59 + #define HHI_VID2_PLL_CNTL2 0x384 /* 0xe1 offset in data sheet */ 60 + #define HHI_VID2_PLL_CNTL3 0x388 /* 0xe2 offset in data sheet */ 61 + #define HHI_VID2_PLL_CNTL4 0x38c /* 0xe3 offset in data sheet */ 62 + #define HHI_VID2_PLL_CNTL5 0x390 /* 0xe4 offset in data sheet */ 63 + #define HHI_VID2_PLL_CNTL6 0x394 /* 0xe5 offset in data sheet */ 54 64 55 65 /* 56 66 * MPLL register offeset taken from the S905 datasheet. Vendor kernel source ··· 183 173 #define CLKID_VCLK_EN 214 184 174 #define CLKID_VCLK2_EN 215 185 175 #define CLKID_VID_PLL_LVDS_EN 216 176 + #define CLKID_HDMI_PLL_DCO_IN 217 186 177 187 - #define CLK_NR_CLKS 217 178 + #define CLK_NR_CLKS 218 188 179 189 180 /* 190 181 * include the CLKID and RESETID that have