diff mbox

[10/13,NOT,FOR,REVIEW,NOW] clk: sunxi: Add CLK_SET_RATE_PARENT flag for H3 HDMI clock

Message ID 20170801131304.7741-11-icenowy@aosc.io (mailing list archive)
State RFC
Headers show

Commit Message

Icenowy Zheng Aug. 1, 2017, 1:13 p.m. UTC
From: Jernej Skrabec <jernej.skrabec@siol.net>

When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be set.

Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chen-Yu Tsai Aug. 4, 2017, 4:15 a.m. UTC | #1
Hi,

On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> From: Jernej Skrabec <jernej.skrabec@siol.net>
>
> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be set.
>
> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> index b1127e8629d9..2ebb3d865b01 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,              "avs",          "osc24M",
>
>  static const char * const hdmi_parents[] = { "pll-video" };
>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
> +                                0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);

Line is longer than 80 characters.

This looks independent enough so I've merged this for 4.14 with the
offending line wrapped and the following tag added:

Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")

ChenYu

>
>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
>                       0x154, BIT(31), 0);
> --
> 2.13.0
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Icenowy Zheng Aug. 4, 2017, 4:16 a.m. UTC | #2
于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>Hi,
>
>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>>
>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
>set.
>>
>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>>
>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> ---
>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> index b1127e8629d9..2ebb3d865b01 100644
>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,             
>"avs",          "osc24M",
>>
>>  static const char * const hdmi_parents[] = { "pll-video" };
>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>> +                                0x150, 0, 4, 24, 2, BIT(31),
>CLK_SET_RATE_PARENT);
>
>Line is longer than 80 characters.
>
>This looks independent enough so I've merged this for 4.14 with the
>offending line wrapped and the following tag added:
>
>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")

Please don't merge this now until Jernej send it.

>
>ChenYu
>
>>
>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
>>                       0x154, BIT(31), 0);
>> --
>> 2.13.0
>>
>> --
>> You received this message because you are subscribed to the Google
>Groups "linux-sunxi" group.
>> To unsubscribe from this group and stop receiving emails from it,
>send an email to linux-sunxi+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen-Yu Tsai Aug. 4, 2017, 4:29 a.m. UTC | #3
On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>
>
> 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>>Hi,
>>
>>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>>>
>>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
>>set.
>>>
>>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>>>
>>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>> ---
>>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> index b1127e8629d9..2ebb3d865b01 100644
>>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
>>"avs",          "osc24M",
>>>
>>>  static const char * const hdmi_parents[] = { "pll-video" };
>>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>>> +                                0x150, 0, 4, 24, 2, BIT(31),
>>CLK_SET_RATE_PARENT);
>>
>>Line is longer than 80 characters.
>>
>>This looks independent enough so I've merged this for 4.14 with the
>>offending line wrapped and the following tag added:
>>
>>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
>
> Please don't merge this now until Jernej send it.

(Dropped Rob, devicetree and dri mailing lists)

Hi Jernej,

Is it OK if we take this patch for the next release? Or rather,
if there anything blocking this patch?

Thanks
ChenYu

>
>>
>>ChenYu
>>
>>>
>>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
>>>                       0x154, BIT(31), 0);
>>> --
>>> 2.13.0
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>Groups "linux-sunxi" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>send an email to linux-sunxi+unsubscribe@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jernej Škrabec Aug. 4, 2017, 8:59 a.m. UTC | #4
Hi Chen-Yu,

Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
> >>Hi,
> >>
> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
> >>> 
> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
> >>
> >>set.
> >>
> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
> >>> 
> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> >>> ---
> >>> 
> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>> 
> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >>
> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >>
> >>> index b1127e8629d9..2ebb3d865b01 100644
> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
> >>
> >>"avs",          "osc24M",
> >>
> >>>  static const char * const hdmi_parents[] = { "pll-video" };
> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
> >>> 
> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
> >>
> >>CLK_SET_RATE_PARENT);
> >>
> >>Line is longer than 80 characters.
> >>
> >>This looks independent enough so I've merged this for 4.14 with the
> >>offending line wrapped and the following tag added:
> >>
> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
> >>
> > Please don't merge this now until Jernej send it.
> 
> (Dropped Rob, devicetree and dri mailing lists)
> 
> Hi Jernej,
> 
> Is it OK if we take this patch for the next release? Or rather,
> if there anything blocking this patch?

I just made last check now and this patch is indeed OK. Before merging, please 
read explanation below.

Background:
According to H3 datasheet and BSP driver, HDMI clock has M factor (divider) to 
correctly set pixel clock to desired value. However, Jens Kuske discovered 
that this factor doesn't play any role whatsoever and instead, division factor 
set in PHY registers is the important one. I confirmed that on BSP kernel by 
tying M factor to 0. Both, HDMI video and audio, still worked correctly.

So that flag is necessary to set pll-video to pixel clock * div factor. I can 
also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and document 
discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to this patch, 
just in case, to be on the safe side, I can add pll-video clock phandle to the 
dt node. However, as far as I know, that might prevent selecting another 
parent on SoCs where HDMI clock has multiple parents.

Regards,
Jernej

> 
> Thanks
> ChenYu
> 
> >>ChenYu
> >>
> >>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
> >>>  
> >>>                       0x154, BIT(31), 0);
> >>> 
> >>> --
> >>> 2.13.0
> >>> 
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>
> >>Groups "linux-sunxi" group.
> >>
> >>> To unsubscribe from this group and stop receiving emails from it,
> >>
> >>send an email to linux-sunxi+unsubscribe@googlegroups.com.
> >>
> >>> For more options, visit https://groups.google.com/d/optout.
> > 
> > --
> > You received this message because you are subscribed to the Google Groups
> > "linux-sunxi" group. To unsubscribe from this group and stop receiving
> > emails from it, send an email to
> > linux-sunxi+unsubscribe@googlegroups.com. For more options, visit
> > https://groups.google.com/d/optout.
> 
> --
> You received this message because you are subscribed to the Google Groups
> "linux-sunxi" group. To unsubscribe from this group and stop receiving
> emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Icenowy Zheng Aug. 4, 2017, 9:03 a.m. UTC | #5
于 2017年8月4日 GMT+08:00 下午4:59:03, "Jernej Škrabec" <jernej.skrabec@siol.net> 写到:
>Hi Chen-Yu,
>
>Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
>> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io>
>wrote:
>> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>> >>Hi,
>> >>
>> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io>
>wrote:
>> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>> >>> 
>> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to
>be
>> >>
>> >>set.
>> >>
>> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>> >>> 
>> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> >>> ---
>> >>> 
>> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>> 
>> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>
>> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>
>> >>> index b1127e8629d9..2ebb3d865b01 100644
>> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
>> >>
>> >>"avs",          "osc24M",
>> >>
>> >>>  static const char * const hdmi_parents[] = { "pll-video" };
>> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>> >>> 
>> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
>> >>
>> >>CLK_SET_RATE_PARENT);
>> >>
>> >>Line is longer than 80 characters.
>> >>
>> >>This looks independent enough so I've merged this for 4.14 with the
>> >>offending line wrapped and the following tag added:
>> >>
>> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
>> >>
>> > Please don't merge this now until Jernej send it.
>> 
>> (Dropped Rob, devicetree and dri mailing lists)
>> 
>> Hi Jernej,
>> 
>> Is it OK if we take this patch for the next release? Or rather,
>> if there anything blocking this patch?
>
>I just made last check now and this patch is indeed OK. Before merging,
>please 
>read explanation below.
>
>Background:
>According to H3 datasheet and BSP driver, HDMI clock has M factor
>(divider) to 
>correctly set pixel clock to desired value. However, Jens Kuske
>discovered 
>that this factor doesn't play any role whatsoever and instead, division
>factor 
>set in PHY registers is the important one. I confirmed that on BSP
>kernel by 
>tying M factor to 0. Both, HDMI video and audio, still worked
>correctly.
>
>So that flag is necessary to set pll-video to pixel clock * div factor.
>I can 
>also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and
>document 
>discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to this
>patch, 
>just in case, to be on the safe side, I can add pll-video clock phandle
>to the 
>dt node. However, as far as I know, that might prevent selecting
>another 
>parent on SoCs where HDMI clock has multiple parents.

Unfortunately A64 is this situation -- A64 TCON1/HDMI clocks can
use pll-video0/1 as parent, but TCON0 can only use pll-video0 or
pll-mipi (also a downstream clock of pll-video0), and by default
TCON1/HDMI also uses pll-video0.

Because of this I have never succeeded in multihead (LCD+HDMI)
on Pinebook.

>
>Regards,
>Jernej
>
>> 
>> Thanks
>> ChenYu
>> 
>> >>ChenYu
>> >>
>> >>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
>> >>>  
>> >>>                       0x154, BIT(31), 0);
>> >>> 
>> >>> --
>> >>> 2.13.0
>> >>> 
>> >>> --
>> >>> You received this message because you are subscribed to the
>Google
>> >>
>> >>Groups "linux-sunxi" group.
>> >>
>> >>> To unsubscribe from this group and stop receiving emails from it,
>> >>
>> >>send an email to linux-sunxi+unsubscribe@googlegroups.com.
>> >>
>> >>> For more options, visit https://groups.google.com/d/optout.
>> > 
>> > --
>> > You received this message because you are subscribed to the Google
>Groups
>> > "linux-sunxi" group. To unsubscribe from this group and stop
>receiving
>> > emails from it, send an email to
>> > linux-sunxi+unsubscribe@googlegroups.com. For more options, visit
>> > https://groups.google.com/d/optout.
>> 
>> --
>> You received this message because you are subscribed to the Google
>Groups
>> "linux-sunxi" group. To unsubscribe from this group and stop
>receiving
>> emails from it, send an email to
>linux-sunxi+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen-Yu Tsai Aug. 4, 2017, 9:27 a.m. UTC | #6
On Fri, Aug 4, 2017 at 4:59 PM, Jernej Škrabec <jernej.skrabec@siol.net> wrote:
> Hi Chen-Yu,
>
> Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
>> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>> >>Hi,
>> >>
>> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>> >>>
>> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
>> >>
>> >>set.
>> >>
>> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>> >>>
>> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> >>> ---
>> >>>
>> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>
>> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>
>> >>> index b1127e8629d9..2ebb3d865b01 100644
>> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
>> >>
>> >>"avs",          "osc24M",
>> >>
>> >>>  static const char * const hdmi_parents[] = { "pll-video" };
>> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>> >>>
>> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
>> >>
>> >>CLK_SET_RATE_PARENT);
>> >>
>> >>Line is longer than 80 characters.
>> >>
>> >>This looks independent enough so I've merged this for 4.14 with the
>> >>offending line wrapped and the following tag added:
>> >>
>> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
>> >>
>> > Please don't merge this now until Jernej send it.
>>
>> (Dropped Rob, devicetree and dri mailing lists)
>>
>> Hi Jernej,
>>
>> Is it OK if we take this patch for the next release? Or rather,
>> if there anything blocking this patch?
>
> I just made last check now and this patch is indeed OK. Before merging, please
> read explanation below.

Ack.

>
> Background:
> According to H3 datasheet and BSP driver, HDMI clock has M factor (divider) to
> correctly set pixel clock to desired value. However, Jens Kuske discovered
> that this factor doesn't play any role whatsoever and instead, division factor
> set in PHY registers is the important one. I confirmed that on BSP kernel by
> tying M factor to 0. Both, HDMI video and audio, still worked correctly.

Great. Sounds like what we have on A31 and earlier SoCs.

>
> So that flag is necessary to set pll-video to pixel clock * div factor. I can
> also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and document
> discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to this patch,
> just in case, to be on the safe side, I can add pll-video clock phandle to the
> dt node. However, as far as I know, that might prevent selecting another
> parent on SoCs where HDMI clock has multiple parents.

It could be that the HDMI clock only drives the DW-HDMI sampler and other
internal logic, while the PHY takes the PLL input directly for the TMDS
clock? I'm not sure how you could verify this though. Maybe increase M
to the maximum, and see if there is any tearing or other artifacts?
Ideally we could just ask Allwinner...

You should change it to SUNXI_CCU_MUX_WITH_GATE if you want to change it.
If there are mux bits, even if there's only one valid setting, you should
still have the mux, so the kernel can actually correct any invalid settings
that may be incorrectly programmed into the hardware by the bootloader or
user. This would be a separate patch.

How we support other SoCs really depends on whether the TMDS clock bits
have a mux or not, or whether they are connected to the HDMI mod clock
in any way.

Regards
ChenYu

>
> Regards,
> Jernej
>
>>
>> Thanks
>> ChenYu
>>
>> >>ChenYu
>> >>
>> >>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
>> >>>
>> >>>                       0x154, BIT(31), 0);
>> >>>
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen-Yu Tsai Aug. 4, 2017, 9:39 a.m. UTC | #7
On Fri, Aug 4, 2017 at 5:03 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>
>
> 于 2017年8月4日 GMT+08:00 下午4:59:03, "Jernej Škrabec" <jernej.skrabec@siol.net> 写到:
>>Hi Chen-Yu,
>>
>>Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
>>> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io>
>>wrote:
>>> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>>> >>Hi,
>>> >>
>>> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io>
>>wrote:
>>> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>>> >>>
>>> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to
>>be
>>> >>
>>> >>set.
>>> >>
>>> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>>> >>>
>>> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>>> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>> >>> ---
>>> >>>
>>> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> >>>
>>> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> >>
>>> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> >>
>>> >>> index b1127e8629d9..2ebb3d865b01 100644
>>> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>>> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
>>> >>
>>> >>"avs",          "osc24M",
>>> >>
>>> >>>  static const char * const hdmi_parents[] = { "pll-video" };
>>> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>>> >>>
>>> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>>> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
>>> >>
>>> >>CLK_SET_RATE_PARENT);
>>> >>
>>> >>Line is longer than 80 characters.
>>> >>
>>> >>This looks independent enough so I've merged this for 4.14 with the
>>> >>offending line wrapped and the following tag added:
>>> >>
>>> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
>>> >>
>>> > Please don't merge this now until Jernej send it.
>>>
>>> (Dropped Rob, devicetree and dri mailing lists)
>>>
>>> Hi Jernej,
>>>
>>> Is it OK if we take this patch for the next release? Or rather,
>>> if there anything blocking this patch?
>>
>>I just made last check now and this patch is indeed OK. Before merging,
>>please
>>read explanation below.
>>
>>Background:
>>According to H3 datasheet and BSP driver, HDMI clock has M factor
>>(divider) to
>>correctly set pixel clock to desired value. However, Jens Kuske
>>discovered
>>that this factor doesn't play any role whatsoever and instead, division
>>factor
>>set in PHY registers is the important one. I confirmed that on BSP
>>kernel by
>>tying M factor to 0. Both, HDMI video and audio, still worked
>>correctly.
>>
>>So that flag is necessary to set pll-video to pixel clock * div factor.
>>I can
>>also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and
>>document
>>discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to this
>>patch,
>>just in case, to be on the safe side, I can add pll-video clock phandle
>>to the
>>dt node. However, as far as I know, that might prevent selecting
>>another
>>parent on SoCs where HDMI clock has multiple parents.
>
> Unfortunately A64 is this situation -- A64 TCON1/HDMI clocks can
> use pll-video0/1 as parent, but TCON0 can only use pll-video0 or
> pll-mipi (also a downstream clock of pll-video0), and by default
> TCON1/HDMI also uses pll-video0.
>
> Because of this I have never succeeded in multihead (LCD+HDMI)
> on Pinebook.

Multihead support hasn't been tested, despite all the patches I've
done to try and support it. I had to do some more to get HDMI and
LCD working together on the A31. And even then there are still
issues.

The current (as of Maxime's sunxi-drm/for-next branch) issues are

  - Two outputs with incompatible dot clocks will step on each
    other, instead of switching to another PLL. Maxime seems to
    have some patches to prevent this.

  - Engine and TCON pairing in a fully connected display system
    is (still) broken. You will end up tying both TCON with the
    same engine. I have patches to fix this in my a31-hdmi-v2
    branch.

You can work around both issues, the first one by adding
CLK_SET_RATE_NO_REPARENT to the TCON clocks, and forcing the
TCON parents at ccu probe time. The second one can be worked
around by removing the extra unused connections between mixer0
and TCON1, and vice versa.

This should at least allow you to test your hardware.

Regards
ChenYu
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jernej Škrabec Aug. 4, 2017, 1:49 p.m. UTC | #8
Hi Chen-Yu,

Dne petek, 04. avgust 2017 ob 11:27:33 CEST je Chen-Yu Tsai napisal(a):
> On Fri, Aug 4, 2017 at 4:59 PM, Jernej Škrabec <jernej.skrabec@siol.net> 
wrote:
> > Hi Chen-Yu,
> > 
> > Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
> >> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> >> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
> >> >>Hi,
> >> >>
> >> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> >> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
> >> >>> 
> >> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
> >> >>
> >> >>set.
> >> >>
> >> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
> >> >>> 
> >> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> >> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> >> >>> ---
> >> >>> 
> >> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
> >> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >>> 
> >> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >> >>
> >> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >> >>
> >> >>> index b1127e8629d9..2ebb3d865b01 100644
> >> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
> >> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
> >> >>
> >> >>"avs",          "osc24M",
> >> >>
> >> >>>  static const char * const hdmi_parents[] = { "pll-video" };
> >> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
> >> >>> 
> >> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
> >> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
> >> >>
> >> >>CLK_SET_RATE_PARENT);
> >> >>
> >> >>Line is longer than 80 characters.
> >> >>
> >> >>This looks independent enough so I've merged this for 4.14 with the
> >> >>offending line wrapped and the following tag added:
> >> >>
> >> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
> >> >>
> >> > Please don't merge this now until Jernej send it.
> >> 
> >> (Dropped Rob, devicetree and dri mailing lists)
> >> 
> >> Hi Jernej,
> >> 
> >> Is it OK if we take this patch for the next release? Or rather,
> >> if there anything blocking this patch?
> > 
> > I just made last check now and this patch is indeed OK. Before merging,
> > please read explanation below.
> 
> Ack.
> 
> > Background:
> > According to H3 datasheet and BSP driver, HDMI clock has M factor
> > (divider) to correctly set pixel clock to desired value. However, Jens
> > Kuske discovered that this factor doesn't play any role whatsoever and
> > instead, division factor set in PHY registers is the important one. I
> > confirmed that on BSP kernel by tying M factor to 0. Both, HDMI video and
> > audio, still worked correctly.
> Great. Sounds like what we have on A31 and earlier SoCs.
> 
> > So that flag is necessary to set pll-video to pixel clock * div factor. I
> > can also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and
> > document discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to
> > this patch, just in case, to be on the safe side, I can add pll-video
> > clock phandle to the dt node. However, as far as I know, that might
> > prevent selecting another parent on SoCs where HDMI clock has multiple
> > parents.
> 
> It could be that the HDMI clock only drives the DW-HDMI sampler and other
> internal logic, while the PHY takes the PLL input directly for the TMDS
> clock? I'm not sure how you could verify this though. Maybe increase M
> to the maximum, and see if there is any tearing or other artifacts?
> Ideally we could just ask Allwinner...

I just made quick test with maximum divider and everything seems to be ok. 
Unfortunately, I don't have time to do extensive test.

I will forward the question to Tl Lim and let's see if he can get the answer, 
since the situation for A64 is completely the same.

> 
> You should change it to SUNXI_CCU_MUX_WITH_GATE if you want to change it.
> If there are mux bits, even if there's only one valid setting, you should
> still have the mux, so the kernel can actually correct any invalid settings
> that may be incorrectly programmed into the hardware by the bootloader or
> user. This would be a separate patch.

I will leave it as it is for now. Will you still merge the patch?

Regards,
Jernej

> 
> How we support other SoCs really depends on whether the TMDS clock bits
> have a mux or not, or whether they are connected to the HDMI mod clock
> in any way.
> 
> Regards
> ChenYu
> 
> > Regards,
> > Jernej
> > 
> >> Thanks
> >> ChenYu
> >> 
> >> >>ChenYu
> >> >>
> >> >>>  static SUNXI_CCU_GATE(hdmi_ddc_clk,    "hdmi-ddc",     "osc24M",
> >> >>>  
> >> >>>                       0x154, BIT(31), 0);
> 
> --
> You received this message because you are subscribed to the Google Groups
> "linux-sunxi" group. To unsubscribe from this group and stop receiving
> emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chen-Yu Tsai Aug. 4, 2017, 2:16 p.m. UTC | #9
On Fri, Aug 4, 2017 at 9:49 PM, Jernej Škrabec <jernej.skrabec@siol.net> wrote:
> Hi Chen-Yu,
>
> Dne petek, 04. avgust 2017 ob 11:27:33 CEST je Chen-Yu Tsai napisal(a):
>> On Fri, Aug 4, 2017 at 4:59 PM, Jernej Škrabec <jernej.skrabec@siol.net>
> wrote:
>> > Hi Chen-Yu,
>> >
>> > Dne petek, 04. avgust 2017 ob 06:29:50 CEST je Chen-Yu Tsai napisal(a):
>> >> On Fri, Aug 4, 2017 at 12:16 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> >> > 于 2017年8月4日 GMT+08:00 下午12:15:27, Chen-Yu Tsai <wens@csie.org> 写到:
>> >> >>Hi,
>> >> >>
>> >> >>On Tue, Aug 1, 2017 at 9:13 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> >> >>> From: Jernej Skrabec <jernej.skrabec@siol.net>
>> >> >>>
>> >> >>> When setting the HDMI clock of H3, the PLL_VIDEO clock needs to be
>> >> >>
>> >> >>set.
>> >> >>
>> >> >>> Add CLK_SET_RATE_PARENT flag for H3 HDMI clock.
>> >> >>>
>> >> >>> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
>> >> >>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> >> >>> ---
>> >> >>>
>> >> >>>  drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
>> >> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >> >>>
>> >> >>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >> >>
>> >> >>b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >> >>
>> >> >>> index b1127e8629d9..2ebb3d865b01 100644
>> >> >>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >> >>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
>> >> >>> @@ -474,7 +474,7 @@ static SUNXI_CCU_GATE(avs_clk,
>> >> >>
>> >> >>"avs",          "osc24M",
>> >> >>
>> >> >>>  static const char * const hdmi_parents[] = { "pll-video" };
>> >> >>>  static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
>> >> >>>
>> >> >>> -                                0x150, 0, 4, 24, 2, BIT(31), 0);
>> >> >>> +                                0x150, 0, 4, 24, 2, BIT(31),
>> >> >>
>> >> >>CLK_SET_RATE_PARENT);
>> >> >>
>> >> >>Line is longer than 80 characters.
>> >> >>
>> >> >>This looks independent enough so I've merged this for 4.14 with the
>> >> >>offending line wrapped and the following tag added:
>> >> >>
>> >> >>Fixes: 0577e4853bfb ("clk: sunxi-ng: Add H3 clocks")
>> >> >>
>> >> > Please don't merge this now until Jernej send it.
>> >>
>> >> (Dropped Rob, devicetree and dri mailing lists)
>> >>
>> >> Hi Jernej,
>> >>
>> >> Is it OK if we take this patch for the next release? Or rather,
>> >> if there anything blocking this patch?
>> >
>> > I just made last check now and this patch is indeed OK. Before merging,
>> > please read explanation below.
>>
>> Ack.
>>
>> > Background:
>> > According to H3 datasheet and BSP driver, HDMI clock has M factor
>> > (divider) to correctly set pixel clock to desired value. However, Jens
>> > Kuske discovered that this factor doesn't play any role whatsoever and
>> > instead, division factor set in PHY registers is the important one. I
>> > confirmed that on BSP kernel by tying M factor to 0. Both, HDMI video and
>> > audio, still worked correctly.
>> Great. Sounds like what we have on A31 and earlier SoCs.
>>
>> > So that flag is necessary to set pll-video to pixel clock * div factor. I
>> > can also change HDMI clock type to SUNXI_CCU_GATE (without M factor) and
>> > document discrepancy with datasheet in ccu-sun8i-h3.c. Alternatively to
>> > this patch, just in case, to be on the safe side, I can add pll-video
>> > clock phandle to the dt node. However, as far as I know, that might
>> > prevent selecting another parent on SoCs where HDMI clock has multiple
>> > parents.
>>
>> It could be that the HDMI clock only drives the DW-HDMI sampler and other
>> internal logic, while the PHY takes the PLL input directly for the TMDS
>> clock? I'm not sure how you could verify this though. Maybe increase M
>> to the maximum, and see if there is any tearing or other artifacts?
>> Ideally we could just ask Allwinner...
>
> I just made quick test with maximum divider and everything seems to be ok.
> Unfortunately, I don't have time to do extensive test.
>
> I will forward the question to Tl Lim and let's see if he can get the answer,
> since the situation for A64 is completely the same.

That would be much appreciated.

>>
>> You should change it to SUNXI_CCU_MUX_WITH_GATE if you want to change it.
>> If there are mux bits, even if there's only one valid setting, you should
>> still have the mux, so the kernel can actually correct any invalid settings
>> that may be incorrectly programmed into the hardware by the bootloader or
>> user. This would be a separate patch.
>
> I will leave it as it is for now. Will you still merge the patch?

I'll drop it for now. Although we have this how A10s and A31, the hardware
is not wired to actually use, as I mentioned above. We can do something
about it once we have a better understanding of the hardware.

Thanks for all the explanation and testing.

Regards
ChenYu
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
index b1127e8629d9..2ebb3d865b01 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
@@ -474,7 +474,7 @@  static SUNXI_CCU_GATE(avs_clk,		"avs",		"osc24M",
 
 static const char * const hdmi_parents[] = { "pll-video" };
 static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", hdmi_parents,
-				 0x150, 0, 4, 24, 2, BIT(31), 0);
+				 0x150, 0, 4, 24, 2, BIT(31), CLK_SET_RATE_PARENT);
 
 static SUNXI_CCU_GATE(hdmi_ddc_clk,	"hdmi-ddc",	"osc24M",
 		      0x154, BIT(31), 0);