Re: [PATCH v2 3/4] clk: meson: axg: add Video Clocks

2020-10-26 Thread Jerome Brunet


On Tue 15 Sep 2020 at 14:45, Neil Armstrong  wrote:

> Add the clocks entries used in the video clock path, the clock path
> is doubled to permit having different synchronized clocks for different
> parts of the video pipeline.
>
> The AXG only has a single ENCL CTS clock and even if VCLK exist along VCLK2,
> only VCLK2 is used since it clocks the MIPI DSI IP directly.
>
> All dividers are flagged with CLK_GET_RATE_NOCACHE, and all gates are flagged
> with CLK_IGNORE_UNUSED since they are currently directly handled by the
> Meson DRM Driver.
> Once the DRM Driver is fully migrated to using the Common Clock Framework
> to handle the video clock tree, the CLK_GET_RATE_NOCACHE and CLK_IGNORE_UNUSED
> will be dropped.

As Kevin suggested on v1, I also would welcome some details on the
plan get there. Adding clocks like this can only treated as a temporary
work around.

>
> Signed-off-by: Neil Armstrong 
> ---
>  drivers/clk/meson/axg.c | 753 
>  drivers/clk/meson/axg.h |  21 +-
>  2 files changed, 773 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
> index 13fc0006f63d..a4e8949297cf 100644
> --- a/drivers/clk/meson/axg.c
> +++ b/drivers/clk/meson/axg.c
> @@ -1026,6 +1026,683 @@ static struct clk_regmap axg_sd_emmc_c_clk0 = {
>   },
>  };
>  
> +/* VPU Clock */
> +
> +static const struct clk_hw *axg_vpu_parent_hws[] = {
> + _fclk_div4.hw,
> + _fclk_div3.hw,
> + _fclk_div5.hw,
> + _fclk_div7.hw,
> +};
> +
> +static struct clk_regmap axg_vpu_0_sel = {
> + .data = &(struct clk_regmap_mux_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .mask = 0x3,
> + .shift = 9,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "vpu_0_sel",
> + .ops = _regmap_mux_ops,
> + .parent_hws = axg_vpu_parent_hws,
> + .num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
> + /* We need a specific parent for VPU clock source, let it be 
> set in DT */
> + .flags = CLK_SET_RATE_NO_REPARENT,
> + },
> +};
> +
> +static struct clk_regmap axg_vpu_0_div = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .shift = 0,
> + .width = 7,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "vpu_0_div",
> + .ops = _regmap_divider_ops,
> + .parent_hws = (const struct clk_hw *[]) { _vpu_0_sel.hw },
> + .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> + },
> +};
> +
> +static struct clk_regmap axg_vpu_0 = {
> + .data = &(struct clk_regmap_gate_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .bit_idx = 8,
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "vpu_0",
> + .ops = _regmap_gate_ops,
> + .parent_hws = (const struct clk_hw *[]) { _vpu_0_div.hw },
> + .num_parents = 1,
> + /*
> +  * We want to avoid CCF to disable the VPU clock if
> +  * display has been set by Bootloader
> +  */
> + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
> + },
> +};
> +
> +static struct clk_regmap axg_vpu_1_sel = {
> + .data = &(struct clk_regmap_mux_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .mask = 0x3,
> + .shift = 25,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "vpu_1_sel",
> + .ops = _regmap_mux_ops,
> + .parent_hws = axg_vpu_parent_hws,
> + .num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
> + /* We need a specific parent for VPU clock source, let it be 
> set in DT */
> + .flags = CLK_SET_RATE_NO_REPARENT,
> + },
> +};
> +
> +static struct clk_regmap axg_vpu_1_div = {
> + .data = &(struct clk_regmap_div_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .shift = 16,
> + .width = 7,
> + },
> + .hw.init = &(struct clk_init_data){
> + .name = "vpu_1_div",
> + .ops = _regmap_divider_ops,
> + .parent_hws = (const struct clk_hw *[]) { _vpu_1_sel.hw },
> + .num_parents = 1,
> + .flags = CLK_SET_RATE_PARENT,
> + },
> +};
> +
> +static struct clk_regmap axg_vpu_1 = {
> + .data = &(struct clk_regmap_gate_data){
> + .offset = HHI_VPU_CLK_CNTL,
> + .bit_idx = 24,
> + },
> + .hw.init = &(struct clk_init_data) {
> + .name = "vpu_1",
> + .ops = _regmap_gate_ops,
> + .parent_hws = (const struct clk_hw *[]) { _vpu_1_div.hw },
> + .num_parents = 1,
> + /*
> +  * We want to avoid CCF to disable the VPU clock if
> +  * display has been set by Bootloader
> +  */
> + .flags = 

[PATCH v2 3/4] clk: meson: axg: add Video Clocks

2020-09-15 Thread Neil Armstrong
Add the clocks entries used in the video clock path, the clock path
is doubled to permit having different synchronized clocks for different
parts of the video pipeline.

The AXG only has a single ENCL CTS clock and even if VCLK exist along VCLK2,
only VCLK2 is used since it clocks the MIPI DSI IP directly.

All dividers are flagged with CLK_GET_RATE_NOCACHE, and all gates are flagged
with CLK_IGNORE_UNUSED since they are currently directly handled by the
Meson DRM Driver.
Once the DRM Driver is fully migrated to using the Common Clock Framework
to handle the video clock tree, the CLK_GET_RATE_NOCACHE and CLK_IGNORE_UNUSED
will be dropped.

Signed-off-by: Neil Armstrong 
---
 drivers/clk/meson/axg.c | 753 
 drivers/clk/meson/axg.h |  21 +-
 2 files changed, 773 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 13fc0006f63d..a4e8949297cf 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -1026,6 +1026,683 @@ static struct clk_regmap axg_sd_emmc_c_clk0 = {
},
 };
 
+/* VPU Clock */
+
+static const struct clk_hw *axg_vpu_parent_hws[] = {
+   _fclk_div4.hw,
+   _fclk_div3.hw,
+   _fclk_div5.hw,
+   _fclk_div7.hw,
+};
+
+static struct clk_regmap axg_vpu_0_sel = {
+   .data = &(struct clk_regmap_mux_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .mask = 0x3,
+   .shift = 9,
+   },
+   .hw.init = &(struct clk_init_data){
+   .name = "vpu_0_sel",
+   .ops = _regmap_mux_ops,
+   .parent_hws = axg_vpu_parent_hws,
+   .num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
+   /* We need a specific parent for VPU clock source, let it be 
set in DT */
+   .flags = CLK_SET_RATE_NO_REPARENT,
+   },
+};
+
+static struct clk_regmap axg_vpu_0_div = {
+   .data = &(struct clk_regmap_div_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .shift = 0,
+   .width = 7,
+   },
+   .hw.init = &(struct clk_init_data){
+   .name = "vpu_0_div",
+   .ops = _regmap_divider_ops,
+   .parent_hws = (const struct clk_hw *[]) { _vpu_0_sel.hw },
+   .num_parents = 1,
+   .flags = CLK_SET_RATE_PARENT,
+   },
+};
+
+static struct clk_regmap axg_vpu_0 = {
+   .data = &(struct clk_regmap_gate_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .bit_idx = 8,
+   },
+   .hw.init = &(struct clk_init_data) {
+   .name = "vpu_0",
+   .ops = _regmap_gate_ops,
+   .parent_hws = (const struct clk_hw *[]) { _vpu_0_div.hw },
+   .num_parents = 1,
+   /*
+* We want to avoid CCF to disable the VPU clock if
+* display has been set by Bootloader
+*/
+   .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
+   },
+};
+
+static struct clk_regmap axg_vpu_1_sel = {
+   .data = &(struct clk_regmap_mux_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .mask = 0x3,
+   .shift = 25,
+   },
+   .hw.init = &(struct clk_init_data){
+   .name = "vpu_1_sel",
+   .ops = _regmap_mux_ops,
+   .parent_hws = axg_vpu_parent_hws,
+   .num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
+   /* We need a specific parent for VPU clock source, let it be 
set in DT */
+   .flags = CLK_SET_RATE_NO_REPARENT,
+   },
+};
+
+static struct clk_regmap axg_vpu_1_div = {
+   .data = &(struct clk_regmap_div_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .shift = 16,
+   .width = 7,
+   },
+   .hw.init = &(struct clk_init_data){
+   .name = "vpu_1_div",
+   .ops = _regmap_divider_ops,
+   .parent_hws = (const struct clk_hw *[]) { _vpu_1_sel.hw },
+   .num_parents = 1,
+   .flags = CLK_SET_RATE_PARENT,
+   },
+};
+
+static struct clk_regmap axg_vpu_1 = {
+   .data = &(struct clk_regmap_gate_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .bit_idx = 24,
+   },
+   .hw.init = &(struct clk_init_data) {
+   .name = "vpu_1",
+   .ops = _regmap_gate_ops,
+   .parent_hws = (const struct clk_hw *[]) { _vpu_1_div.hw },
+   .num_parents = 1,
+   /*
+* We want to avoid CCF to disable the VPU clock if
+* display has been set by Bootloader
+*/
+   .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
+   },
+};
+
+static struct clk_regmap axg_vpu = {
+   .data = &(struct clk_regmap_mux_data){
+   .offset = HHI_VPU_CLK_CNTL,
+   .mask = 1,
+   .shift = 31,
+   },
+   .hw.init = &(struct clk_init_data){
+