* [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS
@ 2019-07-01 9:12 Neil Armstrong
2019-07-01 9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong
` (13 more replies)
0 siblings, 14 replies; 39+ messages in thread
From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw)
To: jbrunet, khilman
Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio,
linux-amlogic, linux-clk, linux-arm-kernel
The G12A/G12B Socs embeds a specific clock tree for each CPU cluster :
cpu_clk / cpub_clk
| \- cpu_clk_dyn
| | \- cpu_clk_premux0
| | |- cpu_clk_postmux0
| | | |- cpu_clk_dyn0_div
| | | \- xtal/fclk_div2/fclk_div3
| | \- xtal/fclk_div2/fclk_div3
| \- cpu_clk_premux1
| |- cpu_clk_postmux1
| | |- cpu_clk_dyn1_div
| | \- xtal/fclk_div2/fclk_div3
| \- xtal/fclk_div2/fclk_div3
\ sys_pll / sys1_pll
This patchset adds notifiers on cpu_clk / cpub_clk, cpu_clk_dyn,
cpu_clk_premux0 and sys_pll / sys1_pll to permit change frequency of
the CPU clock in a safe way as recommended by the vendor Documentation
and reference code.
This patchset :
- introduces needed core and meson clk changes
- adds support for the G12B second cluster clock measurer ids
- protects clock measurer from cooncurent measures
- adds the clock notifiers
- moves the G12A DT to a common g12a-common dtsi
- adds the G12A and G12B OPPs
- enables DVFS on all supported boards
Dependencies:
- PWM AO input order fix at [1]
- PWM enhancements from Martin at [2]
Changes since RFT/RFC v2 at [4]:
- Rebased on linux-amlogic v5.3/dt64 and clk-meson v5.3/drivers trees
- fixed mesure/measure in patch 5
- added Kevin's review tags
Changes since RFT/RFC v1 at [3]:
- Added EXPORT_SYMBOL_GPL() to clk_hw_set_parent
- Added missing static to g12b_cpub_clk_mux0_div_ops and g12a_cpu_clk_mux_nb
- Simplified g12a_cpu_clk_mux_notifier_cb() without switch/case
- Fixed typo in "this the current path" in g12a.c
- Fixed G12B dtsi by adding back the sdio quirk
- Fixed G12A dtsi unwanted sdio quirk removal
- Fixed various checkpatch errors
[1] https://patchwork.kernel.org/patch/11006835/
[2] https://patchwork.kernel.org/patch/11006835/
[3] https://patchwork.kernel.org/cover/11006929/
[4] https://patchwork.kernel.org/cover/11017273/
Neil Armstrong (14):
pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux
clk: core: introduce clk_hw_set_parent()
clk: meson: regmap: export regmap_div ops functions
clk: meson: eeclk: add setup callback
soc: amlogic: meson-clk-measure: protect measure with a mutex
soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk
clk: meson: g12a: add notifiers to handle cpu clock change
clk: meson: g12a: expose CPUB clock ID for G12B
arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi
arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux
arm64: dts: meson-g12a: add cpus OPP table
arm64: dts: meson-g12a: enable DVFS on G12A boards
arm64: dts: meson-g12b: add cpus OPP tables
arm64: dts: meson-g12b-odroid-n2: enable DVFS
.../boot/dts/amlogic/meson-g12-common.dtsi | 2416 ++++++++++++++++
.../boot/dts/amlogic/meson-g12a-sei510.dts | 55 +
.../boot/dts/amlogic/meson-g12a-u200.dts | 54 +
.../boot/dts/amlogic/meson-g12a-x96-max.dts | 52 +
arch/arm64/boot/dts/amlogic/meson-g12a.dtsi | 2455 +----------------
.../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 96 +
arch/arm64/boot/dts/amlogic/meson-g12b.dtsi | 145 +-
drivers/clk/clk.c | 6 +
drivers/clk/meson/clk-regmap.c | 10 +-
drivers/clk/meson/clk-regmap.h | 5 +
drivers/clk/meson/g12a.c | 500 +++-
drivers/clk/meson/meson-eeclk.c | 6 +
drivers/clk/meson/meson-eeclk.h | 1 +
drivers/pinctrl/meson/pinctrl-meson-g12a.c | 9 +
drivers/soc/amlogic/meson-clk-measure.c | 14 +-
include/dt-bindings/clock/g12a-clkc.h | 1 +
include/linux/clk-provider.h | 1 +
17 files changed, 3390 insertions(+), 2436 deletions(-)
create mode 100644 arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
--
2.21.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 39+ messages in thread* [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 22:56 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() Neil Armstrong ` (12 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add the missing pinmux for the pwm_a function on the GPIOE_2 pin. Reviewed-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/pinctrl/meson/pinctrl-meson-g12a.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c index d494492e98e9..f69af4fa7cf8 100644 --- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c +++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c @@ -801,6 +801,9 @@ static const unsigned int remote_ao_input_pins[] = { GPIOAO_5 }; /* ir_out */ static const unsigned int remote_ao_out_pins[] = { GPIOAO_4 }; +/* pwm_a_e */ +static const unsigned int pwm_a_e_pins[] = { GPIOE_2 }; + /* pwm_ao_a */ static const unsigned int pwm_ao_a_pins[] = { GPIOAO_11 }; static const unsigned int pwm_ao_a_hiz_pins[] = { GPIOAO_11 }; @@ -888,6 +891,7 @@ static struct meson_pmx_group meson_g12a_aobus_groups[] = { GROUP(i2c_ao_slave_sda, 3), GROUP(remote_ao_input, 1), GROUP(remote_ao_out, 1), + GROUP(pwm_a_e, 3), GROUP(pwm_ao_a, 3), GROUP(pwm_ao_a_hiz, 2), GROUP(pwm_ao_b, 3), @@ -1192,6 +1196,10 @@ static const char * const remote_ao_out_groups[] = { "remote_ao_out", }; +static const char * const pwm_a_e_groups[] = { + "pwm_a_e", +}; + static const char * const pwm_ao_a_groups[] = { "pwm_ao_a", "pwm_ao_a_hiz", }; @@ -1290,6 +1298,7 @@ static struct meson_pmx_func meson_g12a_aobus_functions[] = { FUNCTION(i2c_ao_slave), FUNCTION(remote_ao_input), FUNCTION(remote_ao_out), + FUNCTION(pwm_a_e), FUNCTION(pwm_ao_a), FUNCTION(pwm_ao_b), FUNCTION(pwm_ao_c), -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux 2019-07-01 9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong @ 2019-07-02 22:56 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 22:56 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Add the missing pinmux for the pwm_a function on the GPIOE_2 pin. > > Reviewed-by: Kevin Hilman <khilman@baylibre.com> > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> it's not documented anywhere but Amlogic's buildroot kernel (from buildroot-openlinux-A113-201901) uses the same bit so it seems correct. Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong 2019-07-01 9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:05 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 03/14] clk: meson: regmap: export regmap_div ops functions Neil Armstrong ` (11 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Introduce the clk_hw_set_parent() provider call to change parent of a clock by using the clk_hw pointers. This eases the clock reparenting from clock rate notifiers and implementing DVFS with simpler code avoiding the boilerplates functions as __clk_lookup(clk_hw_get_name()) then clk_set_parent(). Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/clk/clk.c | 6 ++++++ include/linux/clk-provider.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index aa51756fd4d6..06e1abe3391c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2490,6 +2490,12 @@ static int clk_core_set_parent_nolock(struct clk_core *core, return ret; } +int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *parent) +{ + return clk_core_set_parent_nolock(hw->core, parent->core); +} +EXPORT_SYMBOL_GPL(clk_hw_set_parent); + /** * clk_set_parent - switch the parent of a mux clk * @clk: the mux clk whose input we are switching diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index bb6118f79784..8a453380f9a4 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -812,6 +812,7 @@ unsigned int clk_hw_get_num_parents(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index); +int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *new_parent); unsigned int __clk_get_enable_count(struct clk *clk); unsigned long clk_hw_get_rate(const struct clk_hw *hw); unsigned long __clk_get_flags(struct clk *clk); -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() 2019-07-01 9:12 ` [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() Neil Armstrong @ 2019-07-02 23:05 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:05 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Introduce the clk_hw_set_parent() provider call to change parent of > a clock by using the clk_hw pointers. > > This eases the clock reparenting from clock rate notifiers and > implementing DVFS with simpler code avoiding the boilerplates > functions as __clk_lookup(clk_hw_get_name()) then clk_set_parent(). > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> for the same reason this is handy for the meson8b clock driver as well, so: Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 03/14] clk: meson: regmap: export regmap_div ops functions 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong 2019-07-01 9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong 2019-07-01 9:12 ` [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-01 9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong ` (10 subsequent siblings) 13 siblings, 0 replies; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel The G12A CPU Clock Postmux divider needs a custom div_set_rate() call. Export the clk_regmap_div_round_rate() and clk_regmap_div_recalc_rate() to be able to override the default clk_regmap_div_set_rate() callback. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/clk/meson/clk-regmap.c | 10 ++++++---- drivers/clk/meson/clk-regmap.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/clk/meson/clk-regmap.c b/drivers/clk/meson/clk-regmap.c index dcd1757cc5df..26c8c74a8cf0 100644 --- a/drivers/clk/meson/clk-regmap.c +++ b/drivers/clk/meson/clk-regmap.c @@ -56,8 +56,8 @@ const struct clk_ops clk_regmap_gate_ro_ops = { }; EXPORT_SYMBOL_GPL(clk_regmap_gate_ro_ops); -static unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, - unsigned long prate) +unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, + unsigned long prate) { struct clk_regmap *clk = to_clk_regmap(hw); struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); @@ -74,9 +74,10 @@ static unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, return divider_recalc_rate(hw, prate, val, div->table, div->flags, div->width); } +EXPORT_SYMBOL_GPL(clk_regmap_div_recalc_rate); -static long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) +long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *prate) { struct clk_regmap *clk = to_clk_regmap(hw); struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); @@ -100,6 +101,7 @@ static long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, return divider_round_rate(hw, rate, prate, div->table, div->width, div->flags); } +EXPORT_SYMBOL_GPL(clk_regmap_div_round_rate); static int clk_regmap_div_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) diff --git a/drivers/clk/meson/clk-regmap.h b/drivers/clk/meson/clk-regmap.h index 1dd0abe3ba91..d22b83fb9bad 100644 --- a/drivers/clk/meson/clk-regmap.h +++ b/drivers/clk/meson/clk-regmap.h @@ -78,6 +78,11 @@ clk_get_regmap_div_data(struct clk_regmap *clk) return (struct clk_regmap_div_data *)clk->data; } +unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, + unsigned long prate); +long clk_regmap_div_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *prate); + extern const struct clk_ops clk_regmap_divider_ops; extern const struct clk_ops clk_regmap_divider_ro_ops; -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (2 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 03/14] clk: meson: regmap: export regmap_div ops functions Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:16 ` Martin Blumenstingl 2019-07-03 14:17 ` Jerome Brunet 2019-07-01 9:12 ` [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex Neil Armstrong ` (9 subsequent siblings) 13 siblings, 2 replies; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add a setup() callback in the eeclk structure, to call an optional call() function at end of eeclk probe to setup clocks. It's used for the G12A clock controller to setup the CPU clock notifiers. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/clk/meson/meson-eeclk.c | 6 ++++++ drivers/clk/meson/meson-eeclk.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/clk/meson/meson-eeclk.c b/drivers/clk/meson/meson-eeclk.c index 6ba2094be257..81fd2abcd173 100644 --- a/drivers/clk/meson/meson-eeclk.c +++ b/drivers/clk/meson/meson-eeclk.c @@ -61,6 +61,12 @@ int meson_eeclkc_probe(struct platform_device *pdev) } } + if (data->setup) { + ret = data->setup(pdev); + if (ret) + return ret; + } + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, data->hw_onecell_data); } diff --git a/drivers/clk/meson/meson-eeclk.h b/drivers/clk/meson/meson-eeclk.h index 9ab5d6fa7ccb..7fdf424f71a6 100644 --- a/drivers/clk/meson/meson-eeclk.h +++ b/drivers/clk/meson/meson-eeclk.h @@ -20,6 +20,7 @@ struct meson_eeclkc_data { const struct reg_sequence *init_regs; unsigned int init_count; struct clk_hw_onecell_data *hw_onecell_data; + int (*setup)(struct platform_device *pdev); }; int meson_eeclkc_probe(struct platform_device *pdev); -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-01 9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong @ 2019-07-02 23:16 ` Martin Blumenstingl 2019-07-03 11:45 ` Neil Armstrong 2019-07-03 14:17 ` Jerome Brunet 1 sibling, 1 reply; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:16 UTC (permalink / raw) To: Neil Armstrong Cc: amergnat, khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet +Cc Alexandre Mergnat On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Add a setup() callback in the eeclk structure, to call an optional > call() function at end of eeclk probe to setup clocks. > > It's used for the G12A clock controller to setup the CPU clock notifiers. > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> this will probably work fine, but I want do double check first are we planning to get rid of meson-eeclk (mid-term)? Alex has some patches to get rid of all these IN_PREFIX logic. I'm asking because if we want to get rid of meson-eeclk it may be the time to do so now to have less logic to migrate later on Martin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-02 23:16 ` Martin Blumenstingl @ 2019-07-03 11:45 ` Neil Armstrong 2019-07-03 12:40 ` Jerome Brunet 0 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-03 11:45 UTC (permalink / raw) To: Martin Blumenstingl Cc: amergnat, khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On 03/07/2019 01:16, Martin Blumenstingl wrote: > +Cc Alexandre Mergnat > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >> >> Add a setup() callback in the eeclk structure, to call an optional >> call() function at end of eeclk probe to setup clocks. >> >> It's used for the G12A clock controller to setup the CPU clock notifiers. >> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > this will probably work fine, but I want do double check first > > are we planning to get rid of meson-eeclk (mid-term)? AFAIK no, but maybe I'm not aware of it ! Neil > Alex has some patches to get rid of all these IN_PREFIX logic. > I'm asking because if we want to get rid of meson-eeclk it may be the > time to do so now to have less logic to migrate later on > > > Martin > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-03 11:45 ` Neil Armstrong @ 2019-07-03 12:40 ` Jerome Brunet 2019-07-03 12:57 ` Martin Blumenstingl 0 siblings, 1 reply; 39+ messages in thread From: Jerome Brunet @ 2019-07-03 12:40 UTC (permalink / raw) To: Neil Armstrong, Martin Blumenstingl Cc: amergnat, khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On Wed 03 Jul 2019 at 13:45, Neil Armstrong <narmstrong@baylibre.com> wrote: > On 03/07/2019 01:16, Martin Blumenstingl wrote: >> +Cc Alexandre Mergnat >> >> On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >>> >>> Add a setup() callback in the eeclk structure, to call an optional >>> call() function at end of eeclk probe to setup clocks. >>> >>> It's used for the G12A clock controller to setup the CPU clock notifiers. >>> >>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> >> this will probably work fine, but I want do double check first >> >> are we planning to get rid of meson-eeclk (mid-term)? > > AFAIK no, but maybe I'm not aware of it ! > > Neil > >> Alex has some patches to get rid of all these IN_PREFIX logic. The prefix logic will go away with Alex's rework, so are the input clock But meson-eeclk, which is just a common probe function do avoid repeating the same things over and over, will stay >> I'm asking because if we want to get rid of meson-eeclk it may be the May I ask why ? >> time to do so now to have less logic to migrate later on >> >> >> Martin >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-03 12:40 ` Jerome Brunet @ 2019-07-03 12:57 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-03 12:57 UTC (permalink / raw) To: Jerome Brunet Cc: Neil Armstrong, khilman, amergnat, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On Wed, Jul 3, 2019 at 2:40 PM Jerome Brunet <jbrunet@baylibre.com> wrote: > > On Wed 03 Jul 2019 at 13:45, Neil Armstrong <narmstrong@baylibre.com> wrote: > > > On 03/07/2019 01:16, Martin Blumenstingl wrote: > >> +Cc Alexandre Mergnat > >> > >> On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > >>> > >>> Add a setup() callback in the eeclk structure, to call an optional > >>> call() function at end of eeclk probe to setup clocks. > >>> > >>> It's used for the G12A clock controller to setup the CPU clock notifiers. > >>> > >>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > >> this will probably work fine, but I want do double check first > >> > >> are we planning to get rid of meson-eeclk (mid-term)? > > > > AFAIK no, but maybe I'm not aware of it ! > > > > Neil > > > >> Alex has some patches to get rid of all these IN_PREFIX logic. > > The prefix logic will go away with Alex's rework, so are the input clock > But meson-eeclk, which is just a common probe function do avoid > repeating the same things over and over, will stay OK, thank you for clarifying this > >> I'm asking because if we want to get rid of meson-eeclk it may be the > > May I ask why ? I only remember that Stephen asked us to get rid of something in our clock code I was under the impression that it was meson-eeclk, but I cannot find it anymore (that means I'm mixing it up with some other topic) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-01 9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong 2019-07-02 23:16 ` Martin Blumenstingl @ 2019-07-03 14:17 ` Jerome Brunet 2019-07-26 14:50 ` Neil Armstrong 1 sibling, 1 reply; 39+ messages in thread From: Jerome Brunet @ 2019-07-03 14:17 UTC (permalink / raw) To: Neil Armstrong, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On Mon 01 Jul 2019 at 11:12, Neil Armstrong <narmstrong@baylibre.com> wrote: > Add a setup() callback in the eeclk structure, to call an optional > call() function at end of eeclk probe to setup clocks. > > It's used for the G12A clock controller to setup the CPU clock > notifiers. I'd prefer if you implement the probe function in the related controller have this probe function call meson_eeclkc_probe() for the common part In your case, I suppose it means implementing the g12a controller probe to deal with the notifiers > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > --- > drivers/clk/meson/meson-eeclk.c | 6 ++++++ > drivers/clk/meson/meson-eeclk.h | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/drivers/clk/meson/meson-eeclk.c b/drivers/clk/meson/meson-eeclk.c > index 6ba2094be257..81fd2abcd173 100644 > --- a/drivers/clk/meson/meson-eeclk.c > +++ b/drivers/clk/meson/meson-eeclk.c > @@ -61,6 +61,12 @@ int meson_eeclkc_probe(struct platform_device *pdev) > } > } > > + if (data->setup) { > + ret = data->setup(pdev); > + if (ret) > + return ret; > + } > + > return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > data->hw_onecell_data); > } > diff --git a/drivers/clk/meson/meson-eeclk.h b/drivers/clk/meson/meson-eeclk.h > index 9ab5d6fa7ccb..7fdf424f71a6 100644 > --- a/drivers/clk/meson/meson-eeclk.h > +++ b/drivers/clk/meson/meson-eeclk.h > @@ -20,6 +20,7 @@ struct meson_eeclkc_data { > const struct reg_sequence *init_regs; > unsigned int init_count; > struct clk_hw_onecell_data *hw_onecell_data; > + int (*setup)(struct platform_device *pdev); > }; > > int meson_eeclkc_probe(struct platform_device *pdev); > -- > 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-03 14:17 ` Jerome Brunet @ 2019-07-26 14:50 ` Neil Armstrong 2019-07-29 7:42 ` Jerome Brunet 0 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-26 14:50 UTC (permalink / raw) To: Jerome Brunet, khilman Cc: martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On 03/07/2019 16:17, Jerome Brunet wrote: > On Mon 01 Jul 2019 at 11:12, Neil Armstrong <narmstrong@baylibre.com> wrote: > >> Add a setup() callback in the eeclk structure, to call an optional >> call() function at end of eeclk probe to setup clocks. >> >> It's used for the G12A clock controller to setup the CPU clock >> notifiers. > > I'd prefer if you implement the probe function in the related controller > have this probe function call meson_eeclkc_probe() for the common part > > In your case, I suppose it means implementing the g12a controller probe > to deal with the notifiers Sure, but with this eeclk setup callback I can provide a different setup() callback for g12a and g12b (and later sm1), without this means adding a top data struct containing a setup() callback pointer and the soc meson_eeclkc_data struct to be able to call a setup() for each family like done actually, but this will broke eeclk since the match_data data won't be a meson_eeclkc_data() struct anymore. If you still prefer this, I can rework it like that. I'm rebasing all the stuff on v5.3-rc1 and plan to repost an updated version shortly, solving this would be easier. Neil > >> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> >> --- >> drivers/clk/meson/meson-eeclk.c | 6 ++++++ >> drivers/clk/meson/meson-eeclk.h | 1 + >> 2 files changed, 7 insertions(+) >> >> diff --git a/drivers/clk/meson/meson-eeclk.c b/drivers/clk/meson/meson-eeclk.c >> index 6ba2094be257..81fd2abcd173 100644 >> --- a/drivers/clk/meson/meson-eeclk.c >> +++ b/drivers/clk/meson/meson-eeclk.c >> @@ -61,6 +61,12 @@ int meson_eeclkc_probe(struct platform_device *pdev) >> } >> } >> >> + if (data->setup) { >> + ret = data->setup(pdev); >> + if (ret) >> + return ret; >> + } >> + >> return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, >> data->hw_onecell_data); >> } >> diff --git a/drivers/clk/meson/meson-eeclk.h b/drivers/clk/meson/meson-eeclk.h >> index 9ab5d6fa7ccb..7fdf424f71a6 100644 >> --- a/drivers/clk/meson/meson-eeclk.h >> +++ b/drivers/clk/meson/meson-eeclk.h >> @@ -20,6 +20,7 @@ struct meson_eeclkc_data { >> const struct reg_sequence *init_regs; >> unsigned int init_count; >> struct clk_hw_onecell_data *hw_onecell_data; >> + int (*setup)(struct platform_device *pdev); >> }; >> >> int meson_eeclkc_probe(struct platform_device *pdev); >> -- >> 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback 2019-07-26 14:50 ` Neil Armstrong @ 2019-07-29 7:42 ` Jerome Brunet 0 siblings, 0 replies; 39+ messages in thread From: Jerome Brunet @ 2019-07-29 7:42 UTC (permalink / raw) To: Neil Armstrong, khilman Cc: martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On Fri 26 Jul 2019 at 16:50, Neil Armstrong <narmstrong@baylibre.com> wrote: > On 03/07/2019 16:17, Jerome Brunet wrote: >> On Mon 01 Jul 2019 at 11:12, Neil Armstrong <narmstrong@baylibre.com> wrote: >> >>> Add a setup() callback in the eeclk structure, to call an optional >>> call() function at end of eeclk probe to setup clocks. >>> >>> It's used for the G12A clock controller to setup the CPU clock >>> notifiers. >> >> I'd prefer if you implement the probe function in the related controller >> have this probe function call meson_eeclkc_probe() for the common part >> >> In your case, I suppose it means implementing the g12a controller probe >> to deal with the notifiers > > Sure, but with this eeclk setup callback I can provide a different setup() callback > for g12a and g12b (and later sm1), without this means adding a top data struct > containing a setup() callback pointer and the soc meson_eeclkc_data struct to be able > to call a setup() for each family like done actually, but this will broke eeclk since > the match_data data won't be a meson_eeclkc_data() struct anymore. meson_eeclkc_probe is an helper we added to factorize common code out of the clock controllers we had. I don't like the idea to now add callback in it deal with the specifics of each SoCs. It feels like we are going in circles. I think SoC/controller specific stuff should be dealt with in related probe function of each clock controller which would then call the 'common helper' if necessary. If the common part interface needs to be reworked, maybe changing the parameters, I'm ok with it. > > If you still prefer this, I can rework it like that. > > I'm rebasing all the stuff on v5.3-rc1 and plan to repost an updated version > shortly, solving this would be easier. > > Neil > >> >>> >>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> >>> --- >>> drivers/clk/meson/meson-eeclk.c | 6 ++++++ >>> drivers/clk/meson/meson-eeclk.h | 1 + >>> 2 files changed, 7 insertions(+) >>> >>> diff --git a/drivers/clk/meson/meson-eeclk.c b/drivers/clk/meson/meson-eeclk.c >>> index 6ba2094be257..81fd2abcd173 100644 >>> --- a/drivers/clk/meson/meson-eeclk.c >>> +++ b/drivers/clk/meson/meson-eeclk.c >>> @@ -61,6 +61,12 @@ int meson_eeclkc_probe(struct platform_device *pdev) >>> } >>> } >>> >>> + if (data->setup) { >>> + ret = data->setup(pdev); >>> + if (ret) >>> + return ret; >>> + } >>> + >>> return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, >>> data->hw_onecell_data); >>> } >>> diff --git a/drivers/clk/meson/meson-eeclk.h b/drivers/clk/meson/meson-eeclk.h >>> index 9ab5d6fa7ccb..7fdf424f71a6 100644 >>> --- a/drivers/clk/meson/meson-eeclk.h >>> +++ b/drivers/clk/meson/meson-eeclk.h >>> @@ -20,6 +20,7 @@ struct meson_eeclkc_data { >>> const struct reg_sequence *init_regs; >>> unsigned int init_count; >>> struct clk_hw_onecell_data *hw_onecell_data; >>> + int (*setup)(struct platform_device *pdev); >>> }; >>> >>> int meson_eeclkc_probe(struct platform_device *pdev); >>> -- >>> 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (3 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:01 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Neil Armstrong ` (8 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel In order to protect clock measuring when multiple process asks for a measure, protect the main measure function with mutexes. Reviewed-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/soc/amlogic/meson-clk-measure.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c index 19d4cbc93a17..c470e24f1dfa 100644 --- a/drivers/soc/amlogic/meson-clk-measure.c +++ b/drivers/soc/amlogic/meson-clk-measure.c @@ -11,6 +11,8 @@ #include <linux/debugfs.h> #include <linux/regmap.h> +static DEFINE_MUTEX(measure_lock); + #define MSR_CLK_DUTY 0x0 #define MSR_CLK_REG0 0x4 #define MSR_CLK_REG1 0x8 @@ -360,6 +362,10 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, unsigned int val; int ret; + ret = mutex_lock_interruptible(&measure_lock); + if (ret) + return ret; + regmap_write(priv->regmap, MSR_CLK_REG0, 0); /* Set measurement duration */ @@ -377,8 +383,10 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, ret = regmap_read_poll_timeout(priv->regmap, MSR_CLK_REG0, val, !(val & MSR_BUSY), 10, 10000); - if (ret) + if (ret) { + mutex_unlock(&measure_lock); return ret; + } /* Disable */ regmap_update_bits(priv->regmap, MSR_CLK_REG0, MSR_ENABLE, 0); @@ -386,6 +394,8 @@ static int meson_measure_id(struct meson_msr_id *clk_msr_id, /* Get the value in multiple of gate time counts */ regmap_read(priv->regmap, MSR_CLK_REG2, &val); + mutex_unlock(&measure_lock); + if (val >= MSR_VAL_MASK) return -EINVAL; -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex 2019-07-01 9:12 ` [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex Neil Armstrong @ 2019-07-02 23:01 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:01 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Hi Neil, On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > In order to protect clock measuring when multiple process asks for > a measure, protect the main measure function with mutexes. > > Reviewed-by: Kevin Hilman <khilman@baylibre.com> > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > --- > drivers/soc/amlogic/meson-clk-measure.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c > index 19d4cbc93a17..c470e24f1dfa 100644 > --- a/drivers/soc/amlogic/meson-clk-measure.c > +++ b/drivers/soc/amlogic/meson-clk-measure.c > @@ -11,6 +11,8 @@ > #include <linux/debugfs.h> > #include <linux/regmap.h> > > +static DEFINE_MUTEX(measure_lock); I wonder if that should be part of struct meson_msr for consistency reasons apart from that: Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (4 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 22:58 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change Neil Armstrong ` (7 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add the G12B second CPU cluster CPU and SYS_PLL measure IDs. These IDs returns 0Hz on G12A. Reviewed-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/soc/amlogic/meson-clk-measure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c index c470e24f1dfa..f09b404b39d3 100644 --- a/drivers/soc/amlogic/meson-clk-measure.c +++ b/drivers/soc/amlogic/meson-clk-measure.c @@ -324,6 +324,8 @@ static struct meson_msr_id clk_msr_g12a[CLK_MSR_MAX] = { CLK_MSR_ID(84, "co_tx"), CLK_MSR_ID(89, "hdmi_todig"), CLK_MSR_ID(90, "hdmitx_sys"), + CLK_MSR_ID(91, "sys_cpub_div16"), + CLK_MSR_ID(92, "sys_pll_cpub_div16"), CLK_MSR_ID(94, "eth_phy_rx"), CLK_MSR_ID(95, "eth_phy_pll"), CLK_MSR_ID(96, "vpu_b"), -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk 2019-07-01 9:12 ` [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Neil Armstrong @ 2019-07-02 22:58 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 22:58 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Add the G12B second CPU cluster CPU and SYS_PLL measure IDs. > > These IDs returns 0Hz on G12A. > > Reviewed-by: Kevin Hilman <khilman@baylibre.com> > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (5 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:28 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B Neil Armstrong ` (6 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel In order to implement clock switching for the CLKID_CPU_CLK and CLKID_CPUB_CLK, notifiers are added on specific points of the clock tree : cpu_clk / cpub_clk | \- cpu_clk_dyn | | \- cpu_clk_premux0 | | |- cpu_clk_postmux0 | | | |- cpu_clk_dyn0_div | | | \- xtal/fclk_div2/fclk_div3 | | \- xtal/fclk_div2/fclk_div3 | \- cpu_clk_premux1 | |- cpu_clk_postmux1 | | |- cpu_clk_dyn1_div | | \- xtal/fclk_div2/fclk_div3 | \- xtal/fclk_div2/fclk_div3 \ sys_pll / sys1_pll This for each cluster, a single one for G12A, two for G12B. Each cpu_clk_premux1 tree is marked as read-only and CLK_SET_RATE_NO_REPARENT, to be used as "parking" clock in a safe clock frequency. A notifier is added on each cpu_clk_premux0 to detech when CCF want to change the frequency of the cpu_clk_dyn tree. In this notifier, the cpu_clk_premux1 tree is configured to use the xtal clock and then the cpu_clk_dyn is switch to cpu_clk_premux1 while CCF updates the cpu_clk_premux0 tree. A notifier is added on each sys_pll/sys1_pll to detect when CCF wants to change the PLL clock source of the cpu_clk. In this notifier, the cpu_clk is switched to cpu_clk_dyn while CCF updates the sys_pll/sys1_pll frequency. A third small notifier is added on each cpu_clk / cpub_clk and cpu_clk_dyn, add a small delay at PRE_RATE_CHANGE/POST_RATE_CHANGE to let the other notofiers change propagate before changing the cpu_clk_premux0 and sys_pll clock trees. This notifier set permits switching the cpu_clk / cpub_clk without any glitches and using a safe parking clock while switching between sub-GHz clocks using the cpu_clk_dyn tree. This setup has been tested and validated on the Amlogic G12A and G12B SoCs running the arm64 cpuburn at [1] and cycling between all the possible cpufreq translations of each cluster and checking the final frequency using the clock-measurer, script at [2]. [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- drivers/clk/meson/g12a.c | 500 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 468 insertions(+), 32 deletions(-) diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index db1c4ed9d54e..3d2c2ac9a46d 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -14,6 +14,7 @@ #include <linux/init.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/clk.h> #include "clk-input.h" #include "clk-mpll.h" @@ -85,16 +86,9 @@ static struct clk_regmap g12a_fixed_pll = { }, }; -/* - * Internal sys pll emulation configuration parameters - */ -static const struct reg_sequence g12a_sys_init_regs[] = { - { .reg = HHI_SYS_PLL_CNTL1, .def = 0x00000000 }, - { .reg = HHI_SYS_PLL_CNTL2, .def = 0x00000000 }, - { .reg = HHI_SYS_PLL_CNTL3, .def = 0x48681c00 }, - { .reg = HHI_SYS_PLL_CNTL4, .def = 0x88770290 }, - { .reg = HHI_SYS_PLL_CNTL5, .def = 0x39272000 }, - { .reg = HHI_SYS_PLL_CNTL6, .def = 0x56540000 }, +static const struct pll_mult_range g12a_sys_pll_mult_range = { + .min = 128, + .max = 250, }; static struct clk_regmap g12a_sys_pll_dco = { @@ -124,14 +118,15 @@ static struct clk_regmap g12a_sys_pll_dco = { .shift = 29, .width = 1, }, - .init_regs = g12a_sys_init_regs, - .init_count = ARRAY_SIZE(g12a_sys_init_regs), + .range = &g12a_sys_pll_mult_range, }, .hw.init = &(struct clk_init_data){ .name = "sys_pll_dco", - .ops = &meson_clk_pll_ro_ops, + .ops = &meson_clk_pll_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal" }, .num_parents = 1, + /* This clock feeds the CPU, avoid disabling it */ + .flags = CLK_IS_CRITICAL, }, }; @@ -144,9 +139,10 @@ static struct clk_regmap g12a_sys_pll = { }, .hw.init = &(struct clk_init_data){ .name = "sys_pll", - .ops = &clk_regmap_divider_ro_ops, + .ops = &clk_regmap_divider_ops, .parent_names = (const char *[]){ "sys_pll_dco" }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -177,12 +173,15 @@ static struct clk_regmap g12b_sys1_pll_dco = { .shift = 29, .width = 1, }, + .range = &g12a_sys_pll_mult_range, }, .hw.init = &(struct clk_init_data){ .name = "sys1_pll_dco", - .ops = &meson_clk_pll_ro_ops, + .ops = &meson_clk_pll_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal" }, .num_parents = 1, + /* This clock feeds the CPU, avoid disabling it */ + .flags = CLK_IS_CRITICAL, }, }; @@ -195,9 +194,10 @@ static struct clk_regmap g12b_sys1_pll = { }, .hw.init = &(struct clk_init_data){ .name = "sys1_pll", - .ops = &clk_regmap_divider_ro_ops, + .ops = &clk_regmap_divider_ops, .parent_names = (const char *[]){ "sys1_pll_dco" }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -266,7 +266,7 @@ static struct clk_regmap g12a_cpu_clk_premux0 = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn0_sel", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal", "fclk_div2", "fclk_div3" }, @@ -275,6 +275,38 @@ static struct clk_regmap g12a_cpu_clk_premux0 = { }; /* Datasheet names this field as "mux0_divn_tcnt" */ +#define SYS_CPU_DYN_ENABLE BIT(26) + +/* This divider uses bit 26 to take change in account */ +static int g12a_cpu_clk_mux0_div_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); + unsigned int val; + int ret; + + ret = divider_get_val(rate, parent_rate, div->table, div->width, + div->flags); + if (ret < 0) + return ret; + + val = (unsigned int)ret << div->shift; + + regmap_update_bits(clk->map, HHI_SYS_CPU_CLK_CNTL0, + SYS_CPU_DYN_ENABLE, SYS_CPU_DYN_ENABLE); + + return regmap_update_bits(clk->map, div->offset, + clk_div_mask(div->width) << div->shift | + SYS_CPU_DYN_ENABLE, val); +}; + +const struct clk_ops g12a_cpu_clk_mux0_div_ops = { + .recalc_rate = clk_regmap_div_recalc_rate, + .round_rate = clk_regmap_div_round_rate, + .set_rate = g12a_cpu_clk_mux0_div_set_rate, +}; + static struct clk_regmap g12a_cpu_clk_mux0_div = { .data = &(struct clk_regmap_div_data){ .offset = HHI_SYS_CPU_CLK_CNTL0, @@ -283,9 +315,10 @@ static struct clk_regmap g12a_cpu_clk_mux0_div = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn0_div", - .ops = &clk_regmap_divider_ro_ops, + .ops = &g12a_cpu_clk_mux0_div_ops, .parent_names = (const char *[]){ "cpu_clk_dyn0_sel" }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -298,10 +331,11 @@ static struct clk_regmap g12a_cpu_clk_postmux0 = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn0", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpu_clk_dyn0_sel", "cpu_clk_dyn0_div" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -314,11 +348,13 @@ static struct clk_regmap g12a_cpu_clk_premux1 = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn1_sel", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal", "fclk_div2", "fclk_div3" }, .num_parents = 3, + /* This sub-tree is used a parking clock */ + .flags = CLK_SET_RATE_NO_REPARENT, }, }; @@ -346,10 +382,12 @@ static struct clk_regmap g12a_cpu_clk_postmux1 = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn1", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpu_clk_dyn1_sel", "cpu_clk_dyn1_div" }, .num_parents = 2, + /* This sub-tree is used a parking clock */ + .flags = CLK_SET_RATE_NO_REPARENT, }, }; @@ -362,10 +400,11 @@ static struct clk_regmap g12a_cpu_clk_dyn = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk_dyn", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpu_clk_dyn0", "cpu_clk_dyn1" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -378,10 +417,11 @@ static struct clk_regmap g12a_cpu_clk = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpu_clk_dyn", "sys_pll" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -394,10 +434,11 @@ static struct clk_regmap g12b_cpu_clk = { }, .hw.init = &(struct clk_init_data){ .name = "cpu_clk", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpu_clk_dyn", "sys1_pll" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -410,7 +451,7 @@ static struct clk_regmap g12b_cpub_clk_premux0 = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn0_sel", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal", "fclk_div2", "fclk_div3" }, @@ -418,6 +459,37 @@ static struct clk_regmap g12b_cpub_clk_premux0 = { }, }; +/* This divider uses bit 26 to take change in account */ +static int g12b_cpub_clk_mux0_div_set_rate(struct clk_hw *hw, + unsigned long rate, + unsigned long parent_rate) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); + unsigned int val; + int ret; + + ret = divider_get_val(rate, parent_rate, div->table, div->width, + div->flags); + if (ret < 0) + return ret; + + val = (unsigned int)ret << div->shift; + + regmap_update_bits(clk->map, HHI_SYS_CPUB_CLK_CNTL, + SYS_CPU_DYN_ENABLE, SYS_CPU_DYN_ENABLE); + + return regmap_update_bits(clk->map, div->offset, + clk_div_mask(div->width) << div->shift | + SYS_CPU_DYN_ENABLE, val); +}; + +static const struct clk_ops g12b_cpub_clk_mux0_div_ops = { + .recalc_rate = clk_regmap_div_recalc_rate, + .round_rate = clk_regmap_div_round_rate, + .set_rate = g12b_cpub_clk_mux0_div_set_rate, +}; + /* Datasheet names this field as "mux0_divn_tcnt" */ static struct clk_regmap g12b_cpub_clk_mux0_div = { .data = &(struct clk_regmap_div_data){ @@ -427,9 +499,10 @@ static struct clk_regmap g12b_cpub_clk_mux0_div = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn0_div", - .ops = &clk_regmap_divider_ro_ops, + .ops = &g12b_cpub_clk_mux0_div_ops, .parent_names = (const char *[]){ "cpub_clk_dyn0_sel" }, .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -442,10 +515,11 @@ static struct clk_regmap g12b_cpub_clk_postmux0 = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn0", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpub_clk_dyn0_sel", "cpub_clk_dyn0_div" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -458,11 +532,13 @@ static struct clk_regmap g12b_cpub_clk_premux1 = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn1_sel", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ IN_PREFIX "xtal", "fclk_div2", "fclk_div3" }, .num_parents = 3, + /* This sub-tree is used a parking clock */ + .flags = CLK_SET_RATE_NO_REPARENT, }, }; @@ -490,10 +566,12 @@ static struct clk_regmap g12b_cpub_clk_postmux1 = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn1", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpub_clk_dyn1_sel", "cpub_clk_dyn1_div" }, .num_parents = 2, + /* This sub-tree is used a parking clock */ + .flags = CLK_SET_RATE_NO_REPARENT, }, }; @@ -506,10 +584,11 @@ static struct clk_regmap g12b_cpub_clk_dyn = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk_dyn", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpub_clk_dyn0", "cpub_clk_dyn1" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; @@ -522,13 +601,225 @@ static struct clk_regmap g12b_cpub_clk = { }, .hw.init = &(struct clk_init_data){ .name = "cpub_clk", - .ops = &clk_regmap_mux_ro_ops, + .ops = &clk_regmap_mux_ops, .parent_names = (const char *[]){ "cpub_clk_dyn", "sys_pll" }, .num_parents = 2, + .flags = CLK_SET_RATE_PARENT, }, }; +static int g12a_cpu_clk_mux_notifier_cb(struct notifier_block *nb, + unsigned long event, void *data) +{ + if (event == POST_RATE_CHANGE || event == PRE_RATE_CHANGE) { + /* Wait for clock propagation before/after changing the mux */ + udelay(100); + return NOTIFY_OK; + } + + return NOTIFY_DONE; +} + +static struct notifier_block g12a_cpu_clk_mux_nb = { + .notifier_call = g12a_cpu_clk_mux_notifier_cb, +}; + +struct g12a_cpu_clk_postmux_nb_data { + struct notifier_block nb; + struct clk_hw *xtal; + struct clk_hw *cpu_clk_dyn; + struct clk_hw *cpu_clk_postmux0; + struct clk_hw *cpu_clk_postmux1; + struct clk_hw *cpu_clk_premux1; +}; + +static int g12a_cpu_clk_postmux_notifier_cb(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct g12a_cpu_clk_postmux_nb_data *nb_data = + container_of(nb, struct g12a_cpu_clk_postmux_nb_data, nb); + + switch (event) { + case PRE_RATE_CHANGE: + /* + * This notifier means cpu_clk_postmux0 clock will be changed + * to feed cpu_clk, this is the current path : + * cpu_clk + * \- cpu_clk_dyn + * \- cpu_clk_postmux0 + * \- cpu_clk_muxX_div + * \- cpu_clk_premux0 + * \- fclk_div3 or fclk_div2 + * OR + * \- cpu_clk_premux0 + * \- fclk_div3 or fclk_div2 + */ + + /* Setup cpu_clk_premux1 to xtal */ + clk_hw_set_parent(nb_data->cpu_clk_premux1, + nb_data->xtal); + + /* Setup cpu_clk_postmux1 to bypass divider */ + clk_hw_set_parent(nb_data->cpu_clk_postmux1, + nb_data->cpu_clk_premux1); + + /* Switch to parking clk on cpu_clk_postmux1 */ + clk_hw_set_parent(nb_data->cpu_clk_dyn, + nb_data->cpu_clk_postmux1); + + /* + * Now, cpu_clk is 24MHz in the current path : + * cpu_clk + * \- cpu_clk_dyn + * \- cpu_clk_postmux1 + * \- cpu_clk_premux1 + * \- xtal + */ + + udelay(100); + + return NOTIFY_OK; + + case POST_RATE_CHANGE: + /* + * The cpu_clk_postmux0 has ben updated, now switch back + * cpu_clk_dyn to cpu_clk_postmux0 and take the changes + * in account. + */ + + /* Configure cpu_clk_dyn back to cpu_clk_postmux0 */ + clk_hw_set_parent(nb_data->cpu_clk_dyn, + nb_data->cpu_clk_postmux0); + + /* + * new path : + * cpu_clk + * \- cpu_clk_dyn + * \- cpu_clk_postmux0 + * \- cpu_clk_muxX_div + * \- cpu_clk_premux0 + * \- fclk_div3 or fclk_div2 + * OR + * \- cpu_clk_premux0 + * \- fclk_div3 or fclk_div2 + */ + + udelay(100); + + return NOTIFY_OK; + + default: + return NOTIFY_DONE; + } +} + +static struct g12a_cpu_clk_postmux_nb_data g12a_cpu_clk_postmux0_nb_data = { + .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw, + .cpu_clk_postmux0 = &g12a_cpu_clk_postmux0.hw, + .cpu_clk_postmux1 = &g12a_cpu_clk_postmux1.hw, + .cpu_clk_premux1 = &g12a_cpu_clk_premux1.hw, + .nb.notifier_call = g12a_cpu_clk_postmux_notifier_cb, +}; + +static struct g12a_cpu_clk_postmux_nb_data g12b_cpub_clk_postmux0_nb_data = { + .cpu_clk_dyn = &g12b_cpub_clk_dyn.hw, + .cpu_clk_postmux0 = &g12b_cpub_clk_postmux0.hw, + .cpu_clk_postmux1 = &g12b_cpub_clk_postmux1.hw, + .cpu_clk_premux1 = &g12b_cpub_clk_premux1.hw, + .nb.notifier_call = g12a_cpu_clk_postmux_notifier_cb, +}; + +struct g12a_sys_pll_nb_data { + struct notifier_block nb; + struct clk_hw *sys_pll; + struct clk_hw *cpu_clk; + struct clk_hw *cpu_clk_dyn; +}; + +static int g12a_sys_pll_notifier_cb(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct g12a_sys_pll_nb_data *nb_data = + container_of(nb, struct g12a_sys_pll_nb_data, nb); + + switch (event) { + case PRE_RATE_CHANGE: + /* + * This notifier means sys_pll clock will be changed + * to feed cpu_clk, this the current path : + * cpu_clk + * \- sys_pll + * \- sys_pll_dco + */ + + /* Configure cpu_clk to use cpu_clk_dyn */ + clk_hw_set_parent(nb_data->cpu_clk, + nb_data->cpu_clk_dyn); + + /* + * Now, cpu_clk uses the dyn path + * cpu_clk + * \- cpu_clk_dyn + * \- cpu_clk_dynX + * \- cpu_clk_dynX_sel + * \- cpu_clk_dynX_div + * \- xtal/fclk_div2/fclk_div3 + * \- xtal/fclk_div2/fclk_div3 + */ + + udelay(100); + + return NOTIFY_OK; + + case POST_RATE_CHANGE: + /* + * The sys_pll has ben updated, now switch back cpu_clk to + * sys_pll + */ + + /* Configure cpu_clk to use sys_pll */ + clk_hw_set_parent(nb_data->cpu_clk, + nb_data->sys_pll); + + udelay(100); + + /* new path : + * cpu_clk + * \- sys_pll + * \- sys_pll_dco + */ + + return NOTIFY_OK; + + default: + return NOTIFY_DONE; + } +} + +static struct g12a_sys_pll_nb_data g12a_sys_pll_nb_data = { + .sys_pll = &g12a_sys_pll.hw, + .cpu_clk = &g12a_cpu_clk.hw, + .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw, + .nb.notifier_call = g12a_sys_pll_notifier_cb, +}; + +/* G12B first CPU cluster uses sys1_pll */ +static struct g12a_sys_pll_nb_data g12b_cpu_clk_sys1_pll_nb_data = { + .sys_pll = &g12b_sys1_pll.hw, + .cpu_clk = &g12b_cpu_clk.hw, + .cpu_clk_dyn = &g12a_cpu_clk_dyn.hw, + .nb.notifier_call = g12a_sys_pll_notifier_cb, +}; + +/* G12B second CPU cluster uses sys_pll */ +static struct g12a_sys_pll_nb_data g12b_cpub_clk_sys_pll_nb_data = { + .sys_pll = &g12a_sys_pll.hw, + .cpu_clk = &g12b_cpub_clk.hw, + .cpu_clk_dyn = &g12b_cpub_clk_dyn.hw, + .nb.notifier_call = g12a_sys_pll_notifier_cb, +}; + static struct clk_regmap g12a_cpu_clk_div16_en = { .data = &(struct clk_regmap_gate_data){ .offset = HHI_SYS_CPU_CLK_CNTL1, @@ -3792,18 +4083,163 @@ static const struct reg_sequence g12a_init_regs[] = { { .reg = HHI_MPLL_CNTL0, .def = 0x00000543 }, }; +static int meson_g12a_dvfs_setup_common(struct platform_device *pdev, + struct clk_hw **hws) +{ + const char *notifier_clk_name; + struct clk *notifier_clk; + struct clk_hw *xtal; + int ret; + + xtal = clk_hw_get_parent_by_index(hws[CLKID_CPU_CLK_DYN1_SEL], 0); + + /* Setup clock notifier for cpu_clk_postmux0 */ + g12a_cpu_clk_postmux0_nb_data.xtal = xtal; + notifier_clk_name = clk_hw_get_name(&g12a_cpu_clk_postmux0.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, + &g12a_cpu_clk_postmux0_nb_data.nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpu_clk_postmux0 notifier\n"); + return ret; + } + + /* Setup clock notifier for cpu_clk_dyn mux */ + notifier_clk_name = clk_hw_get_name(&g12a_cpu_clk_dyn.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_cpu_clk_mux_nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpu_clk_dyn notifier\n"); + return ret; + } + + return 0; +} + +static int meson_g12b_dvfs_setup(struct platform_device *pdev) +{ + struct clk_hw **hws = g12b_hw_onecell_data.hws; + const char *notifier_clk_name; + struct clk *notifier_clk; + struct clk_hw *xtal; + int ret; + + ret = meson_g12a_dvfs_setup_common(pdev, hws); + if (ret) + return ret; + + xtal = clk_hw_get_parent_by_index(hws[CLKID_CPU_CLK_DYN1_SEL], 0); + + /* Setup clock notifier for cpu_clk mux */ + notifier_clk_name = clk_hw_get_name(&g12b_cpu_clk.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_cpu_clk_mux_nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpu_clk notifier\n"); + return ret; + } + + /* Setup clock notifier for sys1_pll */ + notifier_clk_name = clk_hw_get_name(&g12b_sys1_pll.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, + &g12b_cpu_clk_sys1_pll_nb_data.nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the sys1_pll notifier\n"); + return ret; + } + + /* Add notifiers for the second CPU cluster */ + + /* Setup clock notifier for cpub_clk_postmux0 */ + g12b_cpub_clk_postmux0_nb_data.xtal = xtal; + notifier_clk_name = clk_hw_get_name(&g12b_cpub_clk_postmux0.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, + &g12b_cpub_clk_postmux0_nb_data.nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpub_clk_postmux0 notifier\n"); + return ret; + } + + /* Setup clock notifier for cpub_clk_dyn mux */ + notifier_clk_name = clk_hw_get_name(&g12b_cpub_clk_dyn.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_cpu_clk_mux_nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpub_clk_dyn notifier\n"); + return ret; + } + + /* Setup clock notifier for cpub_clk mux */ + notifier_clk_name = clk_hw_get_name(&g12b_cpub_clk.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_cpu_clk_mux_nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpub_clk notifier\n"); + return ret; + } + + /* Setup clock notifier for sys_pll */ + notifier_clk_name = clk_hw_get_name(&g12a_sys_pll.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, + &g12b_cpub_clk_sys_pll_nb_data.nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the sys_pll notifier\n"); + return ret; + } + + return 0; +} + + +static int meson_g12a_dvfs_setup(struct platform_device *pdev) +{ + struct clk_hw **hws = g12a_hw_onecell_data.hws; + const char *notifier_clk_name; + struct clk *notifier_clk; + int ret; + + ret = meson_g12a_dvfs_setup_common(pdev, hws); + if (ret) + return ret; + + /* Setup clock notifier for cpu_clk mux */ + notifier_clk_name = clk_hw_get_name(&g12a_cpu_clk.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_cpu_clk_mux_nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the cpu_clk notifier\n"); + return ret; + } + + /* Setup clock notifier for sys_pll */ + notifier_clk_name = clk_hw_get_name(&g12a_sys_pll.hw); + notifier_clk = __clk_lookup(notifier_clk_name); + ret = clk_notifier_register(notifier_clk, &g12a_sys_pll_nb_data.nb); + if (ret) { + dev_err(&pdev->dev, "failed to register the sys_pll notifier\n"); + return ret; + } + + return 0; +} + static const struct meson_eeclkc_data g12a_clkc_data = { .regmap_clks = g12a_clk_regmaps, .regmap_clk_num = ARRAY_SIZE(g12a_clk_regmaps), .hw_onecell_data = &g12a_hw_onecell_data, .init_regs = g12a_init_regs, .init_count = ARRAY_SIZE(g12a_init_regs), + .setup = meson_g12a_dvfs_setup, }; static const struct meson_eeclkc_data g12b_clkc_data = { .regmap_clks = g12a_clk_regmaps, .regmap_clk_num = ARRAY_SIZE(g12a_clk_regmaps), - .hw_onecell_data = &g12b_hw_onecell_data + .hw_onecell_data = &g12b_hw_onecell_data, + .setup = meson_g12b_dvfs_setup, }; static const struct of_device_id clkc_match_table[] = { -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change 2019-07-01 9:12 ` [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change Neil Armstrong @ 2019-07-02 23:28 ` Martin Blumenstingl 2019-07-03 11:50 ` Neil Armstrong 2019-08-08 4:43 ` Stephen Boyd 0 siblings, 2 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:28 UTC (permalink / raw) To: sboyd, Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Hi Stephen, Hi Neil, On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > In order to implement clock switching for the CLKID_CPU_CLK and > CLKID_CPUB_CLK, notifiers are added on specific points of the > clock tree : > > cpu_clk / cpub_clk > | \- cpu_clk_dyn > | | \- cpu_clk_premux0 > | | |- cpu_clk_postmux0 > | | | |- cpu_clk_dyn0_div > | | | \- xtal/fclk_div2/fclk_div3 > | | \- xtal/fclk_div2/fclk_div3 > | \- cpu_clk_premux1 > | |- cpu_clk_postmux1 > | | |- cpu_clk_dyn1_div > | | \- xtal/fclk_div2/fclk_div3 > | \- xtal/fclk_div2/fclk_div3 > \ sys_pll / sys1_pll > > This for each cluster, a single one for G12A, two for G12B. > > Each cpu_clk_premux1 tree is marked as read-only and CLK_SET_RATE_NO_REPARENT, > to be used as "parking" clock in a safe clock frequency. it seems that this is one case where the "coordinated clocks" feature would come handy: [0] Stephen, do you know if those patches stopped in March or if there's still some ongoing effort to get them ready? [...] > -/* > - * Internal sys pll emulation configuration parameters > - */ > -static const struct reg_sequence g12a_sys_init_regs[] = { > - { .reg = HHI_SYS_PLL_CNTL1, .def = 0x00000000 }, > - { .reg = HHI_SYS_PLL_CNTL2, .def = 0x00000000 }, > - { .reg = HHI_SYS_PLL_CNTL3, .def = 0x48681c00 }, > - { .reg = HHI_SYS_PLL_CNTL4, .def = 0x88770290 }, > - { .reg = HHI_SYS_PLL_CNTL5, .def = 0x39272000 }, > - { .reg = HHI_SYS_PLL_CNTL6, .def = 0x56540000 }, > +static const struct pll_mult_range g12a_sys_pll_mult_range = { > + .min = 128, > + .max = 250, > }; > > static struct clk_regmap g12a_sys_pll_dco = { > @@ -124,14 +118,15 @@ static struct clk_regmap g12a_sys_pll_dco = { > .shift = 29, > .width = 1, > }, > - .init_regs = g12a_sys_init_regs, > - .init_count = ARRAY_SIZE(g12a_sys_init_regs), > + .range = &g12a_sys_pll_mult_range, Neil, I believe that this should be a separate patch with a description which explains why we don't need the "init regs" anymore > }, > .hw.init = &(struct clk_init_data){ > .name = "sys_pll_dco", > - .ops = &meson_clk_pll_ro_ops, > + .ops = &meson_clk_pll_ops, > .parent_names = (const char *[]){ IN_PREFIX "xtal" }, > .num_parents = 1, > + /* This clock feeds the CPU, avoid disabling it */ > + .flags = CLK_IS_CRITICAL, maybe we should have a separate patch for making the CPU clock tree mutable as well [...] > +/* This divider uses bit 26 to take change in account */ > +static int g12b_cpub_clk_mux0_div_set_rate(struct clk_hw *hw, > + unsigned long rate, > + unsigned long parent_rate) > +{ > + struct clk_regmap *clk = to_clk_regmap(hw); > + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); > + unsigned int val; > + int ret; > + > + ret = divider_get_val(rate, parent_rate, div->table, div->width, > + div->flags); > + if (ret < 0) > + return ret; > + > + val = (unsigned int)ret << div->shift; > + > + regmap_update_bits(clk->map, HHI_SYS_CPUB_CLK_CNTL, > + SYS_CPU_DYN_ENABLE, SYS_CPU_DYN_ENABLE); > + > + return regmap_update_bits(clk->map, div->offset, > + clk_div_mask(div->width) << div->shift | > + SYS_CPU_DYN_ENABLE, val); > +}; the public S922X datasheet doesn't mention bit 26 do I understand the semantics correctly?: - set SYS_CPU_DYN_ENABLE - update the divider - unset SYS_CPU_DYN_ENABLE too bad it's not a gate which we could model with CLK_SET_RATE_GATE/CLK_SET_RATE_UNGATE Martin [0] https://patchwork.kernel.org/patch/10838949/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change 2019-07-02 23:28 ` Martin Blumenstingl @ 2019-07-03 11:50 ` Neil Armstrong 2019-08-08 4:43 ` Stephen Boyd 1 sibling, 0 replies; 39+ messages in thread From: Neil Armstrong @ 2019-07-03 11:50 UTC (permalink / raw) To: Martin Blumenstingl, sboyd Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On 03/07/2019 01:28, Martin Blumenstingl wrote: > Hi Stephen, Hi Neil, > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >> >> In order to implement clock switching for the CLKID_CPU_CLK and >> CLKID_CPUB_CLK, notifiers are added on specific points of the >> clock tree : >> >> cpu_clk / cpub_clk >> | \- cpu_clk_dyn >> | | \- cpu_clk_premux0 >> | | |- cpu_clk_postmux0 >> | | | |- cpu_clk_dyn0_div >> | | | \- xtal/fclk_div2/fclk_div3 >> | | \- xtal/fclk_div2/fclk_div3 >> | \- cpu_clk_premux1 >> | |- cpu_clk_postmux1 >> | | |- cpu_clk_dyn1_div >> | | \- xtal/fclk_div2/fclk_div3 >> | \- xtal/fclk_div2/fclk_div3 >> \ sys_pll / sys1_pll >> >> This for each cluster, a single one for G12A, two for G12B. >> >> Each cpu_clk_premux1 tree is marked as read-only and CLK_SET_RATE_NO_REPARENT, >> to be used as "parking" clock in a safe clock frequency. > it seems that this is one case where the "coordinated clocks" feature > would come handy: [0] We could still migrate over it later on. > Stephen, do you know if those patches stopped in March or if there's > still some ongoing effort to get them ready? > > [...] >> -/* >> - * Internal sys pll emulation configuration parameters >> - */ >> -static const struct reg_sequence g12a_sys_init_regs[] = { >> - { .reg = HHI_SYS_PLL_CNTL1, .def = 0x00000000 }, >> - { .reg = HHI_SYS_PLL_CNTL2, .def = 0x00000000 }, >> - { .reg = HHI_SYS_PLL_CNTL3, .def = 0x48681c00 }, >> - { .reg = HHI_SYS_PLL_CNTL4, .def = 0x88770290 }, >> - { .reg = HHI_SYS_PLL_CNTL5, .def = 0x39272000 }, >> - { .reg = HHI_SYS_PLL_CNTL6, .def = 0x56540000 }, >> +static const struct pll_mult_range g12a_sys_pll_mult_range = { >> + .min = 128, >> + .max = 250, >> }; >> >> static struct clk_regmap g12a_sys_pll_dco = { >> @@ -124,14 +118,15 @@ static struct clk_regmap g12a_sys_pll_dco = { >> .shift = 29, >> .width = 1, >> }, >> - .init_regs = g12a_sys_init_regs, >> - .init_count = ARRAY_SIZE(g12a_sys_init_regs), >> + .range = &g12a_sys_pll_mult_range, > Neil, I believe that this should be a separate patch with a > description which explains why we don't need the "init regs" anymore Sure > >> }, >> .hw.init = &(struct clk_init_data){ >> .name = "sys_pll_dco", >> - .ops = &meson_clk_pll_ro_ops, >> + .ops = &meson_clk_pll_ops, >> .parent_names = (const char *[]){ IN_PREFIX "xtal" }, >> .num_parents = 1, >> + /* This clock feeds the CPU, avoid disabling it */ >> + .flags = CLK_IS_CRITICAL, > maybe we should have a separate patch for making the CPU clock tree > mutable as well Indeed > > [...] >> +/* This divider uses bit 26 to take change in account */ >> +static int g12b_cpub_clk_mux0_div_set_rate(struct clk_hw *hw, >> + unsigned long rate, >> + unsigned long parent_rate) >> +{ >> + struct clk_regmap *clk = to_clk_regmap(hw); >> + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); >> + unsigned int val; >> + int ret; >> + >> + ret = divider_get_val(rate, parent_rate, div->table, div->width, >> + div->flags); >> + if (ret < 0) >> + return ret; >> + >> + val = (unsigned int)ret << div->shift; >> + >> + regmap_update_bits(clk->map, HHI_SYS_CPUB_CLK_CNTL, >> + SYS_CPU_DYN_ENABLE, SYS_CPU_DYN_ENABLE); >> + >> + return regmap_update_bits(clk->map, div->offset, >> + clk_div_mask(div->width) << div->shift | >> + SYS_CPU_DYN_ENABLE, val); >> +}; > the public S922X datasheet doesn't mention bit 26 > do I understand the semantics correctly?: > - set SYS_CPU_DYN_ENABLE > - update the divider > - unset SYS_CPU_DYN_ENABLE Exact, it's how Amlogic uses it, seems the HW takes the divider value only on the "falling edge" of this bit ! > > too bad it's not a gate which we could model with > CLK_SET_RATE_GATE/CLK_SET_RATE_UNGATE Yep, but it only works when I write the new divider value *and* I remove the bit. It must be a glitch-free divider mechanism. Neil > > > Martin > > [0] https://patchwork.kernel.org/patch/10838949/ > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change 2019-07-02 23:28 ` Martin Blumenstingl 2019-07-03 11:50 ` Neil Armstrong @ 2019-08-08 4:43 ` Stephen Boyd 1 sibling, 0 replies; 39+ messages in thread From: Stephen Boyd @ 2019-08-08 4:43 UTC (permalink / raw) To: Martin Blumenstingl, Neil Armstrong, dbasehore Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Quoting Martin Blumenstingl (2019-07-02 16:28:55) > Hi Stephen, Hi Neil, > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > > > In order to implement clock switching for the CLKID_CPU_CLK and > > CLKID_CPUB_CLK, notifiers are added on specific points of the > > clock tree : > > > > cpu_clk / cpub_clk > > | \- cpu_clk_dyn > > | | \- cpu_clk_premux0 > > | | |- cpu_clk_postmux0 > > | | | |- cpu_clk_dyn0_div > > | | | \- xtal/fclk_div2/fclk_div3 > > | | \- xtal/fclk_div2/fclk_div3 > > | \- cpu_clk_premux1 > > | |- cpu_clk_postmux1 > > | | |- cpu_clk_dyn1_div > > | | \- xtal/fclk_div2/fclk_div3 > > | \- xtal/fclk_div2/fclk_div3 > > \ sys_pll / sys1_pll > > > > This for each cluster, a single one for G12A, two for G12B. > > > > Each cpu_clk_premux1 tree is marked as read-only and CLK_SET_RATE_NO_REPARENT, > > to be used as "parking" clock in a safe clock frequency. > it seems that this is one case where the "coordinated clocks" feature > would come handy: [0] > Stephen, do you know if those patches stopped in March or if there's > still some ongoing effort to get them ready? > Derek told me yesterday he wants to work on it again, but I don't know his timeline. If Derek doesn't reply here then maybe it can be picked up by someone else. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (6 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:03 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux Neil Armstrong ` (5 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Expose the CPUB clock id to add DVFS to the second CPU cluster of the Amlogic G12B SoC. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- include/dt-bindings/clock/g12a-clkc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/clock/g12a-clkc.h b/include/dt-bindings/clock/g12a-clkc.h index b6b127e45634..8ccc29ac7a72 100644 --- a/include/dt-bindings/clock/g12a-clkc.h +++ b/include/dt-bindings/clock/g12a-clkc.h @@ -137,5 +137,6 @@ #define CLKID_VDEC_HEVC 207 #define CLKID_VDEC_HEVCF 210 #define CLKID_TS 212 +#define CLKID_CPUB_CLK 224 #endif /* __G12A_CLKC_H */ -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B 2019-07-01 9:12 ` [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B Neil Armstrong @ 2019-07-02 23:03 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:03 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Expose the CPUB clock id to add DVFS to the second CPU cluster of > the Amlogic G12B SoC. > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (7 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:11 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table Neil Armstrong ` (4 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add the ao_pinctrl subnode for the pwm_a function on GPIOE_2. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi index 9f34004625e8..ab8a72a226df 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi @@ -1970,6 +1970,14 @@ }; }; + pwm_a_e_pins: pwm-a-e { + mux { + groups = "pwm_a_e"; + function = "pwm_a_e"; + bias-disable; + }; + }; + pwm_ao_a_pins: pwm-ao-a { mux { groups = "pwm_ao_a"; -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux 2019-07-01 9:12 ` [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux Neil Armstrong @ 2019-07-02 23:11 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:11 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Add the ao_pinctrl subnode for the pwm_a function on GPIOE_2. > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (8 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:47 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards Neil Armstrong ` (3 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add the OPP table taken from the vendor u200 and u211 DTS. The Amlogic G12A SoC seems to available in 3 types : - low-speed: up to 1,8GHz - mid-speed: up to 1,908GHz - high-speed: up to 2.1GHz And the S905X2 opp voltages are slightly higher than the S905D2 OPP voltages for the low-speed table. This adds the conservative OPP table with the S905X2 higher voltages and the maximum low-speed OPP frequency. The values were tested to be stable on an Amlogic U200 Reference Board, SeiRobotics SEI510 and X96 Max Set-Top-Boxes running the arm64 cpuburn at [1] and cycling between all the possible cpufreq translations and checking the final frequency using the clock-measurer, script at [2]. [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- arch/arm64/boot/dts/amlogic/meson-g12a.dtsi | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi index ac15967bb7fa..733a9d46fc4b 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi @@ -48,6 +48,66 @@ compatible = "cache"; }; }; + + cpu_opp_table: opp-table { + compatible = "operating-points-v2"; + opp-shared; + + opp-100000000 { + opp-hz = /bits/ 64 <100000000>; + opp-microvolt = <731000>; + }; + + opp-250000000 { + opp-hz = /bits/ 64 <250000000>; + opp-microvolt = <731000>; + }; + + opp-500000000 { + opp-hz = /bits/ 64 <500000000>; + opp-microvolt = <731000>; + }; + + opp-667000000 { + opp-hz = /bits/ 64 <666666666>; + opp-microvolt = <731000>; + }; + + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <731000>; + }; + + opp-1200000000 { + opp-hz = /bits/ 64 <1200000000>; + opp-microvolt = <731000>; + }; + + opp-1398000000 { + opp-hz = /bits/ 64 <1398000000>; + opp-microvolt = <761000>; + }; + + opp-1512000000 { + opp-hz = /bits/ 64 <1512000000>; + opp-microvolt = <791000>; + }; + + opp-1608000000 { + opp-hz = /bits/ 64 <1608000000>; + opp-microvolt = <831000>; + }; + + opp-1704000000 { + opp-hz = /bits/ 64 <1704000000>; + opp-microvolt = <861000>; + }; + + opp-1800000000 { + opp-hz = /bits/ 64 <1800000000>; + opp-microvolt = <981000>; + }; + }; }; &sd_emmc_a { -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table 2019-07-01 9:12 ` [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table Neil Armstrong @ 2019-07-02 23:47 ` Martin Blumenstingl 2019-07-03 11:53 ` Neil Armstrong 0 siblings, 1 reply; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:47 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Hi Neil, On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Add the OPP table taken from the vendor u200 and u211 DTS. > > The Amlogic G12A SoC seems to available in 3 types : > - low-speed: up to 1,8GHz > - mid-speed: up to 1,908GHz > - high-speed: up to 2.1GHz > > And the S905X2 opp voltages are slightly higher than the S905D2 > OPP voltages for the low-speed table. > > This adds the conservative OPP table with the S905X2 higher voltages > and the maximum low-speed OPP frequency. have you considered all three as separate voltage tables? you're other patches are assigning the OPP table to the CPU in the board.dts anyways, so it's easy to use different OPP tables for different boards _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table 2019-07-02 23:47 ` Martin Blumenstingl @ 2019-07-03 11:53 ` Neil Armstrong 2019-07-03 12:12 ` Martin Blumenstingl 0 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-03 11:53 UTC (permalink / raw) To: Martin Blumenstingl Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On 03/07/2019 01:47, Martin Blumenstingl wrote: > Hi Neil, > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >> >> Add the OPP table taken from the vendor u200 and u211 DTS. >> >> The Amlogic G12A SoC seems to available in 3 types : >> - low-speed: up to 1,8GHz >> - mid-speed: up to 1,908GHz >> - high-speed: up to 2.1GHz >> >> And the S905X2 opp voltages are slightly higher than the S905D2 >> OPP voltages for the low-speed table. >> >> This adds the conservative OPP table with the S905X2 higher voltages >> and the maximum low-speed OPP frequency. > have you considered all three as separate voltage tables? > you're other patches are assigning the OPP table to the CPU in the > board.dts anyways, so it's easy to use different OPP tables for > different boards We can't assume the board and the CPU type :-/ Kevin told me about cpufreq policy, where we could add a policy reading the eFUSE and changing the max frequency, then we could add the whole OPP table. Neil > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table 2019-07-03 11:53 ` Neil Armstrong @ 2019-07-03 12:12 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-03 12:12 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Hi Neil, On Wed, Jul 3, 2019 at 1:53 PM Neil Armstrong <narmstrong@baylibre.com> wrote: > > On 03/07/2019 01:47, Martin Blumenstingl wrote: > > Hi Neil, > > > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > >> > >> Add the OPP table taken from the vendor u200 and u211 DTS. > >> > >> The Amlogic G12A SoC seems to available in 3 types : > >> - low-speed: up to 1,8GHz > >> - mid-speed: up to 1,908GHz > >> - high-speed: up to 2.1GHz > >> > >> And the S905X2 opp voltages are slightly higher than the S905D2 > >> OPP voltages for the low-speed table. > >> > >> This adds the conservative OPP table with the S905X2 higher voltages > >> and the maximum low-speed OPP frequency. > > have you considered all three as separate voltage tables? > > you're other patches are assigning the OPP table to the CPU in the > > board.dts anyways, so it's easy to use different OPP tables for > > different boards > > We can't assume the board and the CPU type :-/ OK, should we assign the OPP table to the CPU cores then in the soc.dtsi (instead of board.dts like the other patches from this series do)? > Kevin told me about cpufreq policy, where we could add a policy reading the > eFUSE and changing the max frequency, then we could add the whole OPP table. we can still do that in a second step, so I'm all for starting with the "conservative" OPP table and then improve performance (by having detecting the SoC and using the correct OPP table) Martin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (9 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:43 ` Martin Blumenstingl 2019-07-01 9:12 ` [RFC/RFT v3 13/14] arm64: dts: meson-g12b: add cpus OPP tables Neil Armstrong ` (2 subsequent siblings) 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Enable DVFS for the U200, SEI520 and X96-Max Amlogic G12A based board by setting the clock, OPP and supply for each CPU cores. The CPU cluster power supply can achieve 0.73V to 1.01V using a PWM output clocked at 800KHz with an inverse duty-cycle. DVFS has been tested by running the arm64 cpuburn at [1] and cycling between all the possible cpufreq translations and checking the final frequency using the clock-measurer, script at [2]. [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- .../boot/dts/amlogic/meson-g12a-sei510.dts | 55 +++++++++++++++++++ .../boot/dts/amlogic/meson-g12a-u200.dts | 54 ++++++++++++++++++ .../boot/dts/amlogic/meson-g12a-x96-max.dts | 52 ++++++++++++++++++ 3 files changed, 161 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts index c7a87368850b..979449968a5f 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts @@ -129,6 +129,25 @@ enable-active-high; }; + vddcpu: regulator-vddcpu { + /* + * SY8120B1ABC DC/DC Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + vin-supply = <&dc_in>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + vddio_ao1v8: regulator-vddio_ao1v8 { compatible = "regulator-fixed"; regulator-name = "VDDIO_AO1V8"; @@ -297,6 +316,34 @@ status = "okay"; }; +&cpu0 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu2 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu3 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + &cvbs_vdac_port { cvbs_vdac_out: endpoint { remote-endpoint = <&cvbs_connector_in>; @@ -339,6 +386,14 @@ pinctrl-names = "default"; }; +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + &pwm_ef { status = "okay"; pinctrl-0 = <&pwm_e_pins>; diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts index 8551fbd4a488..2a324f0136e3 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12a-u200.dts @@ -129,6 +129,24 @@ regulator-always-on; }; + vddcpu: regulator-vddcpu { + /* + * MP8756GD Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + vin-supply = <&main_12v>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; }; &cec_AO { @@ -145,6 +163,34 @@ hdmi-phandle = <&hdmi_tx>; }; +&cpu0 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu2 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu3 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + &cvbs_vdac_port { cvbs_vdac_out: endpoint { remote-endpoint = <&cvbs_connector_in>; @@ -197,6 +243,14 @@ pinctrl-names = "default"; }; +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + /* SD card */ &sd_emmc_b { status = "okay"; diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a-x96-max.dts b/arch/arm64/boot/dts/amlogic/meson-g12a-x96-max.dts index fe4013cca876..c1e58a69d434 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12a-x96-max.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12a-x96-max.dts @@ -132,6 +132,22 @@ regulator-always-on; }; + vddcpu: regulator-vddcpu { + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + vin-supply = <&dc_in>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + sound { compatible = "amlogic,axg-sound-card"; model = "G12A-X96-MAX"; @@ -242,6 +258,34 @@ status = "okay"; }; +&cpu0 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu2 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu3 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + &cvbs_vdac_port { cvbs_vdac_out: endpoint { remote-endpoint = <&cvbs_connector_in>; @@ -279,6 +323,14 @@ pinctrl-names = "default"; }; +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + &ext_mdio { external_phy: ethernet-phy@0 { /* Realtek RTL8211F (0x001cc916) */ -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards 2019-07-01 9:12 ` [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards Neil Armstrong @ 2019-07-02 23:43 ` Martin Blumenstingl 0 siblings, 0 replies; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:43 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Enable DVFS for the U200, SEI520 and X96-Max Amlogic G12A based board > by setting the clock, OPP and supply for each CPU cores. > > The CPU cluster power supply can achieve 0.73V to 1.01V using a PWM > output clocked at 800KHz with an inverse duty-cycle. > > DVFS has been tested by running the arm64 cpuburn at [1] and cycling > between all the possible cpufreq translations and checking the final > frequency using the clock-measurer, script at [2]. > > [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S > [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* [RFC/RFT v3 13/14] arm64: dts: meson-g12b: add cpus OPP tables 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (10 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-01 9:12 ` [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS Neil Armstrong [not found] ` <20190701091258.3870-10-narmstrong@baylibre.com> 13 siblings, 0 replies; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Add the OPP table taken from the HardKernel Odroid-N2 DTS. The Amlogic G12B SoC seems to available in 2 types : - low-speed: Cortex-A73 Cluster up to 1,704GHz - high-speed: Cortex-A73 Cluster up to 2.208GHz The Cortex-A73 Cluster can be clocked up to 1,896GHz for both types. The Vendor Amlogic A311D OPP table are slighly different, with lower voltages than the HardKernel S922X tables but seems to be high-speed type. This adds the conservative OPP table with the S922X higher voltages and the maximum low-speed OPP frequency. The values were tested to be stable on an HardKernel Odroid-N2 board running the arm64 cpuburn at [1] and cycling between all the possible cpufreq translations for both clusters and checking the final frequency using the clock-measurer, script at [2]. [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- arch/arm64/boot/dts/amlogic/meson-g12b.dtsi | 115 ++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi index d5edbc1a1991..98ae8a7c8b41 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12b.dtsi @@ -95,6 +95,121 @@ compatible = "cache"; }; }; + + cpu_opp_table_0: opp-table-0 { + compatible = "operating-points-v2"; + opp-shared; + + opp-100000000 { + opp-hz = /bits/ 64 <100000000>; + opp-microvolt = <731000>; + }; + + opp-250000000 { + opp-hz = /bits/ 64 <250000000>; + opp-microvolt = <731000>; + }; + + opp-500000000 { + opp-hz = /bits/ 64 <500000000>; + opp-microvolt = <731000>; + }; + + opp-666666666 { + opp-hz = /bits/ 64 <666666666>; + opp-microvolt = <731000>; + }; + + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <731000>; + }; + + opp-1200000000 { + opp-hz = /bits/ 64 <1200000000>; + opp-microvolt = <731000>; + }; + + opp-1398000000 { + opp-hz = /bits/ 64 <1398000000>; + opp-microvolt = <761000>; + }; + + opp-1512000000 { + opp-hz = /bits/ 64 <1512000000>; + opp-microvolt = <791000>; + }; + + opp-1608000000 { + opp-hz = /bits/ 64 <1608000000>; + opp-microvolt = <831000>; + }; + + opp-1704000000 { + opp-hz = /bits/ 64 <1704000000>; + opp-microvolt = <861000>; + }; + + opp-1896000000 { + opp-hz = /bits/ 64 <1896000000>; + opp-microvolt = <981000>; + }; + }; + + cpub_opp_table_1: opp-table-1 { + compatible = "operating-points-v2"; + opp-shared; + + opp-100000000 { + opp-hz = /bits/ 64 <100000000>; + opp-microvolt = <751000>; + }; + + opp-250000000 { + opp-hz = /bits/ 64 <250000000>; + opp-microvolt = <751000>; + }; + + opp-500000000 { + opp-hz = /bits/ 64 <500000000>; + opp-microvolt = <751000>; + }; + + opp-666666666 { + opp-hz = /bits/ 64 <666666666>; + opp-microvolt = <751000>; + }; + + opp-1000000000 { + opp-hz = /bits/ 64 <1000000000>; + opp-microvolt = <751000>; + }; + + opp-1200000000 { + opp-hz = /bits/ 64 <1200000000>; + opp-microvolt = <771000>; + }; + + opp-1398000000 { + opp-hz = /bits/ 64 <1398000000>; + opp-microvolt = <791000>; + }; + + opp-1512000000 { + opp-hz = /bits/ 64 <1512000000>; + opp-microvolt = <821000>; + }; + + opp-1608000000 { + opp-hz = /bits/ 64 <1608000000>; + opp-microvolt = <861000>; + }; + + opp-1704000000 { + opp-hz = /bits/ 64 <1704000000>; + opp-microvolt = <891000>; + }; + }; }; &clkc { -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS 2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong ` (11 preceding siblings ...) 2019-07-01 9:12 ` [RFC/RFT v3 13/14] arm64: dts: meson-g12b: add cpus OPP tables Neil Armstrong @ 2019-07-01 9:12 ` Neil Armstrong 2019-07-02 23:45 ` Martin Blumenstingl [not found] ` <20190701091258.3870-10-narmstrong@baylibre.com> 13 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-01 9:12 UTC (permalink / raw) To: jbrunet, khilman Cc: Neil Armstrong, martin.blumenstingl, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel Enable DVFS for the Odroid-N2 by setting the clock, OPP and supply for each cores of each CPU clusters. The first cluster uses the "VDDCPU_B" power supply, and the second cluster uses the "VDDCPU_A" power supply. Each power supply can achieve 0.73V to 1.01V using 2 distinct PWM outputs clocked at 800KHz with an inverse duty-cycle. DVFS has been tested by running the arm64 cpuburn at [1] and cycling between all the possible cpufreq translations of each cluster and checking the final frequency using the clock-measurer, script at [2]. [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> --- .../boot/dts/amlogic/meson-g12b-odroid-n2.dts | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts index 81780ffcc7f0..75ff8a7e373d 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts +++ b/arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts @@ -114,6 +114,44 @@ /* FIXME: actually controlled by VDDCPU_B_EN */ }; + vddcpu_a: regulator-vddcpu-a { + /* + * MP8756GD Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU_A"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + vin-supply = <&main_12v>; + + pwms = <&pwm_ab 0 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + + vddcpu_b: regulator-vddcpu-b { + /* + * Silergy SY8120B1ABC Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU_B"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + vin-supply = <&main_12v>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + hub_5v: regulator-hub_5v { compatible = "regulator-fixed"; regulator-name = "HUB_5V"; @@ -245,6 +283,48 @@ status = "okay"; }; +&cpu0 { + cpu-supply = <&vddcpu_b>; + operating-points-v2 = <&cpu_opp_table_0>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu_b>; + operating-points-v2 = <&cpu_opp_table_0>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu100 { + cpu-supply = <&vddcpu_a>; + operating-points-v2 = <&cpub_opp_table_1>; + clocks = <&clkc CLKID_CPUB_CLK>; + clock-latency = <50000>; +}; + +&cpu101 { + cpu-supply = <&vddcpu_a>; + operating-points-v2 = <&cpub_opp_table_1>; + clocks = <&clkc CLKID_CPUB_CLK>; + clock-latency = <50000>; +}; + +&cpu102 { + cpu-supply = <&vddcpu_a>; + operating-points-v2 = <&cpub_opp_table_1>; + clocks = <&clkc CLKID_CPUB_CLK>; + clock-latency = <50000>; +}; + +&cpu103 { + cpu-supply = <&vddcpu_a>; + operating-points-v2 = <&cpub_opp_table_1>; + clocks = <&clkc CLKID_CPUB_CLK>; + clock-latency = <50000>; +}; + &ext_mdio { external_phy: ethernet-phy@0 { /* Realtek RTL8211F (0x001cc916) */ @@ -316,6 +396,22 @@ pinctrl-names = "default"; }; +&pwm_ab { + pinctrl-0 = <&pwm_a_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin0"; + status = "okay"; +}; + +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + /* SD card */ &sd_emmc_b { status = "okay"; -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS 2019-07-01 9:12 ` [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS Neil Armstrong @ 2019-07-02 23:45 ` Martin Blumenstingl 2019-07-03 11:54 ` Neil Armstrong 0 siblings, 1 reply; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:45 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > Enable DVFS for the Odroid-N2 by setting the clock, OPP and supply > for each cores of each CPU clusters. > > The first cluster uses the "VDDCPU_B" power supply, and the second > cluster uses the "VDDCPU_A" power supply. > > Each power supply can achieve 0.73V to 1.01V using 2 distinct PWM > outputs clocked at 800KHz with an inverse duty-cycle. > > DVFS has been tested by running the arm64 cpuburn at [1] and cycling > between all the possible cpufreq translations of each cluster and > checking the final frequency using the clock-measurer, script at [2]. > > [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S > [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f > > Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> [...] > + vddcpu_b: regulator-vddcpu-b { > + /* > + * Silergy SY8120B1ABC Regulator. > + */ interesting that they use different regulator ICs for CPU A and CPU B the public schematics confirm your comments _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS 2019-07-02 23:45 ` Martin Blumenstingl @ 2019-07-03 11:54 ` Neil Armstrong 0 siblings, 0 replies; 39+ messages in thread From: Neil Armstrong @ 2019-07-03 11:54 UTC (permalink / raw) To: Martin Blumenstingl Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On 03/07/2019 01:45, Martin Blumenstingl wrote: > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >> >> Enable DVFS for the Odroid-N2 by setting the clock, OPP and supply >> for each cores of each CPU clusters. >> >> The first cluster uses the "VDDCPU_B" power supply, and the second >> cluster uses the "VDDCPU_A" power supply. >> >> Each power supply can achieve 0.73V to 1.01V using 2 distinct PWM >> outputs clocked at 800KHz with an inverse duty-cycle. >> >> DVFS has been tested by running the arm64 cpuburn at [1] and cycling >> between all the possible cpufreq translations of each cluster and >> checking the final frequency using the clock-measurer, script at [2]. >> >> [1] https://github.com/ssvb/cpuburn-arm/blob/master/cpuburn-a53.S >> [2] https://gist.github.com/superna9999/d4de964dbc0f84b7d527e1df2ddea25f >> >> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> > Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> > > [...] >> + vddcpu_b: regulator-vddcpu-b { >> + /* >> + * Silergy SY8120B1ABC Regulator. >> + */ > interesting that they use different regulator ICs for CPU A and CPU B > the public schematics confirm your comments > Yep they use a Silergy one for VDDCPU_B on every schematics I have. The A311D VIM3 have a slightly different one, but still Silergy for VDDCPU_B. https://dl.khadas.com/Hardware/VIM3/Schematic/VIM3_V11_Sch.pdf Neil _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
[parent not found: <20190701091258.3870-10-narmstrong@baylibre.com>]
* Re: [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi [not found] ` <20190701091258.3870-10-narmstrong@baylibre.com> @ 2019-07-02 23:54 ` Martin Blumenstingl 2019-07-03 11:51 ` Neil Armstrong 0 siblings, 1 reply; 39+ messages in thread From: Martin Blumenstingl @ 2019-07-02 23:54 UTC (permalink / raw) To: Neil Armstrong Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet Hi Neil, On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: > > To simplify the representation of differences betweem the G12A and G12B > SoCs, move the common nodes into a meson-g12-common.dtsi file and > express the CPU nodes and differences in meson-g12a.dtsi and meson-g12b.dtsi. > > This separation will help for DVFS and future Amlogic SM1 Family support. > > The sd_emmc_a quirk is added in the g12a/g12b since since it's already > known the sd_emmc_a controller is fixed in the next SM1 SoC family. too bad they named the upcoming SoC family SM1 does it make sense to name this file "meson-g12a-g12b-sm1-common.dtsi" instead? do you know whether there will be a successor to G12B and what it's code-name will be? Martin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi 2019-07-02 23:54 ` [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi Martin Blumenstingl @ 2019-07-03 11:51 ` Neil Armstrong 2019-07-03 12:48 ` Jerome Brunet 0 siblings, 1 reply; 39+ messages in thread From: Neil Armstrong @ 2019-07-03 11:51 UTC (permalink / raw) To: Martin Blumenstingl Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel, jbrunet On 03/07/2019 01:54, Martin Blumenstingl wrote: > Hi Neil, > > On Mon, Jul 1, 2019 at 11:13 AM Neil Armstrong <narmstrong@baylibre.com> wrote: >> >> To simplify the representation of differences betweem the G12A and G12B >> SoCs, move the common nodes into a meson-g12-common.dtsi file and >> express the CPU nodes and differences in meson-g12a.dtsi and meson-g12b.dtsi. >> >> This separation will help for DVFS and future Amlogic SM1 Family support. >> >> The sd_emmc_a quirk is added in the g12a/g12b since since it's already >> known the sd_emmc_a controller is fixed in the next SM1 SoC family. > too bad they named the upcoming SoC family SM1 Yeah weird naming, but seems SM1 is the new "AI" oriented SoC family > > does it make sense to name this file "meson-g12a-g12b-sm1-common.dtsi" instead? > do you know whether there will be a successor to G12B and what it's > code-name will be? meson-g12a-g12b-sm1-common seems a bit long to me... We don't have naming of the future SoCs, since SM1 is only available on prototypes yet. Neil > > > Martin > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi 2019-07-03 11:51 ` Neil Armstrong @ 2019-07-03 12:48 ` Jerome Brunet 0 siblings, 0 replies; 39+ messages in thread From: Jerome Brunet @ 2019-07-03 12:48 UTC (permalink / raw) To: Neil Armstrong, Martin Blumenstingl Cc: khilman, linux-kernel, linux-gpio, linux-amlogic, linux-clk, linux-arm-kernel On Wed 03 Jul 2019 at 13:51, Neil Armstrong <narmstrong@baylibre.com> wrote: > On 03/07/2019 01:54, Martin Blumenstingl wrote: >> Hi Neil, >> [...] >> does it make sense to name this file "meson-g12a-g12b-sm1-common.dtsi" instead? >> do you know whether there will be a successor to G12B and what it's >> code-name will be? > > meson-g12a-g12b-sm1-common seems a bit long to me... +1 ... and what if the generation after that is compatible as well ? We extend the name again ? Such naming scheme does not scale. meson-g12-common.dtsi looks good to me. IMO, The fact the sm1 dtsi includes the file is enough to understand that sm1 derive from the g12a/b > > We don't have naming of the future SoCs, since SM1 is only available on > prototypes yet. > > Neil > >> >> >> Martin >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2019-08-08 4:43 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-01 9:12 [RFC/RFT v3 00/14] arm64: g12a: add support for DVFS Neil Armstrong
2019-07-01 9:12 ` [RFC/RFT v3 01/14] pinctrl: meson-g12a: add pwm_a on GPIOE_2 pinmux Neil Armstrong
2019-07-02 22:56 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 02/14] clk: core: introduce clk_hw_set_parent() Neil Armstrong
2019-07-02 23:05 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 03/14] clk: meson: regmap: export regmap_div ops functions Neil Armstrong
2019-07-01 9:12 ` [RFC/RFT v3 04/14] clk: meson: eeclk: add setup callback Neil Armstrong
2019-07-02 23:16 ` Martin Blumenstingl
2019-07-03 11:45 ` Neil Armstrong
2019-07-03 12:40 ` Jerome Brunet
2019-07-03 12:57 ` Martin Blumenstingl
2019-07-03 14:17 ` Jerome Brunet
2019-07-26 14:50 ` Neil Armstrong
2019-07-29 7:42 ` Jerome Brunet
2019-07-01 9:12 ` [RFC/RFT v3 05/14] soc: amlogic: meson-clk-measure: protect measure with a mutex Neil Armstrong
2019-07-02 23:01 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 06/14] soc: amlogic: meson-clk-measure: add G12B second cluster cpu clk Neil Armstrong
2019-07-02 22:58 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 07/14] clk: meson: g12a: add notifiers to handle cpu clock change Neil Armstrong
2019-07-02 23:28 ` Martin Blumenstingl
2019-07-03 11:50 ` Neil Armstrong
2019-08-08 4:43 ` Stephen Boyd
2019-07-01 9:12 ` [RFC/RFT v3 08/14] clk: meson: g12a: expose CPUB clock ID for G12B Neil Armstrong
2019-07-02 23:03 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 10/14] arm64: dts: meson-g12-common: add pwm_a on GPIOE_2 pinmux Neil Armstrong
2019-07-02 23:11 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 11/14] arm64: dts: meson-g12a: add cpus OPP table Neil Armstrong
2019-07-02 23:47 ` Martin Blumenstingl
2019-07-03 11:53 ` Neil Armstrong
2019-07-03 12:12 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 12/14] arm64: dts: meson-g12a: enable DVFS on G12A boards Neil Armstrong
2019-07-02 23:43 ` Martin Blumenstingl
2019-07-01 9:12 ` [RFC/RFT v3 13/14] arm64: dts: meson-g12b: add cpus OPP tables Neil Armstrong
2019-07-01 9:12 ` [RFC/RFT v3 14/14] arm64: dts: meson-g12b-odroid-n2: enable DVFS Neil Armstrong
2019-07-02 23:45 ` Martin Blumenstingl
2019-07-03 11:54 ` Neil Armstrong
[not found] ` <20190701091258.3870-10-narmstrong@baylibre.com>
2019-07-02 23:54 ` [RFC/RFT v3 09/14] arm64: dts: move common G12A & G12B modes to meson-g12-common.dtsi Martin Blumenstingl
2019-07-03 11:51 ` Neil Armstrong
2019-07-03 12:48 ` Jerome Brunet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).