clk: Add fractional scale clock support
PATCH v2 1/1 clk: Add fractional scale clock support
This patch adds fractional scale clock support.
Fractional scale clock is implemented for a single register field.
Output rate = parent_rate * scale / denominator
For example, for 1 / 8 fractional scale, denominator will be 8 and scale will be computed and programmed accordingly.
v2
* Fix compile error by using DIV_ROUND_UP_ULL() macro
* Remove DT binding document
* Remove DT clk_fractional_scale_init() function
v1
* Initial
--- drivers/clk/Makefile | 1 + drivers/clk/clk-fractional-scale.c | 195 +++++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 41 ++++++++ 3 files changed, 237 insertions(+) create mode 100644 drivers/clk/clk-fractional-scale.c
drivers/clk/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_COMMON_CLK) += clk-multiplier.o obj-$(CONFIG_COMMON_CLK) += clk-mux.o obj-$(CONFIG_COMMON_CLK) += clk-composite.o obj-$(CONFIG_COMMON_CLK) += clk-fractional-divider.o +obj-$(CONFIG_COMMON_CLK) += clk-fractional-scale.o obj-$(CONFIG_COMMON_CLK) += clk-gpio.o ifeq ($(CONFIG_OF), y) obj-$(CONFIG_COMMON_CLK) += clk-conf.o
drivers/clk/clk-fractional-scale.c new file +195 -0
195 lines not on this page · raw message
include/linux/clk-provider.h +41 -0
47 lines not on this page · raw message
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAFHUOYxS-aZGE-W8Oaop6hgfvd6MsvJ_N+GHTYdOzQZhH7hUPA@mail.gmail.com
Sorry I replied offlist before. Pressed the wrong key.
Quoted 9 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.
Quoted 8 lines
Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominator
Ok so the difference is that the denominator is a fixed value? Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider? Or we can add a flag to the clk-fractional-divider code to handle this minor difference.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Hi Stephen,
Quoted 15 lines · Stephen Boyd
Sorry I replied offlist before. Pressed the wrong key.
Quoted 12 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)
Quoted 7 lines
Quoted 5 lines
For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominatorOk so the difference is that the denominator is a fixed value?
The major difference is a fixed denominator.
Another difference is:
In case CLK_FRACTIONAL_SCALE_INVERTED=1, the freq_out is calculated as below
Freq_out = Freq_parent * (fixed_denominator - multiplier) / fixed_denominator.
Quoted 2 lines
Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider?
Because of CLK_FRACTIONAL_SCALE_INVERTED flag, I don't know how to model as a clk-multiplier. And how to pass the fixed denominator into a clk-multiplier.
Quoted 2 lines
Or we can add a flag to the
clk-fractional-divider code to handle this minor difference.
This driver is used 2 register fields for numerator, denominator and calculates both of them.
Do you think I can integrate this fractional scale into it ?
Thanks
Hoan
Quoted 4 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 43 lines · Hoan Tran
Hi Stephen,
Quoted 15 lines · Stephen Boyd
Sorry I replied offlist before. Pressed the wrong key.
Quoted 12 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)Quoted 7 lines
Quoted 5 lines
For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominatorOk so the difference is that the denominator is a fixed value?
The major difference is a fixed denominator.
Another difference is:
In case CLK_FRACTIONAL_SCALE_INVERTED=1, thefreq_outis calculated as below
Freq_out=Freq_parent* (fixed_denominator- multiplier) /fixed_denominator.Quoted 2 lines
Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider?
Because of
CLK_FRACTIONAL_SCALE_INVERTEDflag, I don't know how to model as a clk-multiplier. And how to pass the fixed denominator into a clk-multiplier.Quoted 2 lines
Or we can add a flag to the
clk-fractional-divider code to handle this minor difference.
Quoted 7 lines
This driver is used 2 register fields for numerator, denominator and calculates both of them.
Do you think I can integrate this fractional scale into it ?Thanks
Hoan
Hi Stephen,
Do you have any comments ?
Thanks
Hoan
Quoted 5 lines
Quoted 5 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 52 lines · Hoan Tran
Quoted 43 lines · Hoan Tran
Hi Stephen,
Quoted 15 lines · Stephen Boyd
Sorry I replied offlist before. Pressed the wrong key.
Quoted 12 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)Quoted 7 lines
Quoted 5 lines
For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominatorOk so the difference is that the denominator is a fixed value?
The major difference is a fixed denominator.
Another difference is:
In case CLK_FRACTIONAL_SCALE_INVERTED=1, thefreq_outis calculated as below
Freq_out=Freq_parent* (fixed_denominator- multiplier) /fixed_denominator.Quoted 2 lines
Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider?
Because of
CLK_FRACTIONAL_SCALE_INVERTEDflag, I don't know how to model as a clk-multiplier. And how to pass the fixed denominator into a clk-multiplier.Quoted 2 lines
Or we can add a flag to the
clk-fractional-divider code to handle this minor difference.Quoted 7 lines
This driver is used 2 register fields for numerator, denominator and calculates both of them.
Do you think I can integrate this fractional scale into it ?Thanks
Hoan
Quoted 13 lines
Hi Stephen,
Do you have any comments ?
Thanks
HoanQuoted 5 lines
Quoted 5 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Hi Stephen,
Do you have any comments or suggestions on this patch ?
Thanks
Hoan
Sorry I was away for some time.
Quoted 33 lines · Hoan Tran
Quoted 32 lines · Hoan Tran
Quoted 31 lines · Hoan Tran
Hi Stephen,
Quoted 15 lines · Stephen Boyd
Sorry I replied offlist before. Pressed the wrong key.
Quoted 12 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)Quoted 7 lines
Quoted 5 lines
For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominatorOk so the difference is that the denominator is a fixed value?
The major difference is a fixed denominator.
Another difference is:
In case CLK_FRACTIONAL_SCALE_INVERTED=1, thefreq_outis calculated as below
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Freq_out=Freq_parent* (fixed_denominator- multiplier) /fixed_denominator.Quoted 2 lines
Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider?
Because of
CLK_FRACTIONAL_SCALE_INVERTEDflag, I don't know how to model as a clk-multiplier. And how to pass the fixed denominator into a clk-multiplier.
Would it be possible to add a flag to clk-multiplier to handle the inverted case? I haven't seen anyone else with hardware like that though, so perhaps the implementation should just go into the vendor specific clk driver instead of being written as a "basic clk type".
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 45 lines · Stephen Boyd
Sorry I was away for some time.
Quoted 33 lines · Hoan Tran
Quoted 32 lines · Hoan Tran
Quoted 31 lines · Hoan Tran
Hi Stephen,
Quoted 15 lines · Stephen Boyd
Sorry I replied offlist before. Pressed the wrong key.
Quoted 12 lines · Hoan Tran
Quoted 3 lines · Stephen Boyd
How is this different from
clk-fractional-divider.c?This is a driver which clock output is multiplied with a fixed fractional scale (denominator).
A field inside a register is used to configure the multiplier.Example: With fractional scale is 1/8.
Freq_out=Freq_parent* multiplier * (1/8)Quoted 7 lines
Quoted 5 lines
For fractional-divider, there are 2 fields of a register are used which
- A field for numerator
- A field for denominatorFreq_out=Freq_parent* numerator / denominatorOk so the difference is that the denominator is a fixed value?
The major difference is a fixed denominator.
Another difference is:
In case CLK_FRACTIONAL_SCALE_INVERTED=1, thefreq_outis calculated as belowQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Freq_out=Freq_parent* (fixed_denominator- multiplier) /fixed_denominator.Quoted 2 lines
Perhaps that can be modeled as a clk-multiplier that is used as the only parent of a fixed divider?
Because of
CLK_FRACTIONAL_SCALE_INVERTEDflag, I don't know how to model as a clk-multiplier. And how to pass the fixed denominator into a clk-multiplier.
Quoted 5 lines
Would it be possible to add a flag to clk-multiplier to handle the inverted case? I haven't seen anyone else with hardware like that though, so perhaps the implementation should just go into the vendor specific clk driver instead of being written as a "basic clk type".
Yes, I'll move it into our clk-xgene driver.
Thanks
Hoan
Quoted 4 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project