clk: meson: axg: add 32k clock generation
Subsystems (4)
Jerome Brunet
maintainerv2 cover clk: meson: axg: add 32k clock generation
The goal of this patchset is to add the internal generation of the 32768Hz clock within the axg AO clock controller.
This was initially added has the CEC clock on gxbb. To properly integrate it on the axg, a simpler 'dual divider' driver is added. Then gxbb AO clock controller is reworked to use it. Finally the 32k clock tree is added to the AXG.
This patchset *no longer* requires depends on this CCF change [0]. There is a work around in place until a solution gets merged in the framework.
Changes since v1: [1]
* Add work around for [0] in gxbb-aoclk
[0]: https://lkml.kernel.org/r/[email protected]
[1]: https://lkml.kernel.org/r/[email protected]
Jerome Brunet (5):
dt-bindings: clk: meson: add ao slow clock path ids
clk: meson: clean-up clock registration
clk: meson: add dual divider clock driver
clk: meson: gxbb-ao: replace cec-32k with the dual divider
clk: meson: axg-ao: add 32k generation subtree
drivers/clk/meson/Makefile | 4 +- drivers/clk/meson/axg-aoclk.c | 175 +++++++++++++++-- drivers/clk/meson/axg-aoclk.h | 13 +- drivers/clk/meson/clk-dualdiv.c | 130 ++++++++++++ drivers/clk/meson/clkc.h | 19 ++ drivers/clk/meson/gxbb-aoclk-32k.c | 193 ------------------ drivers/clk/meson/gxbb-aoclk.c | 251 +++++++++++++++++++----- drivers/clk/meson/gxbb-aoclk.h | 20 +- drivers/clk/meson/meson-aoclk.c | 15 +- include/dt-bindings/clock/axg-aoclkc.h | 7 +- include/dt-bindings/clock/gxbb-aoclkc.h | 7 + 11 files changed, 540 insertions(+), 294 deletions(-) create mode 100644 drivers/clk/meson/clk-dualdiv.c delete mode 100644 drivers/clk/meson/gxbb-aoclk-32k.c
Signature · 1 line
2.19.2
Jerome Brunet
maintainerPATCH v2 1/5 dt-bindings: clk: meson: add ao slow clock path ids
Add the CLKIDs for the slow clock generation path
--- include/dt-bindings/clock/axg-aoclkc.h | 7 ++++++- include/dt-bindings/clock/gxbb-aoclkc.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
include/dt-bindings/clock/axg-aoclkc.h +6 -1
@@ -21,6 +21,11 @@#define CLKID_AO_SAR_ADC_SEL 8#define CLKID_AO_SAR_ADC_DIV 9#define CLKID_AO_SAR_ADC_CLK 10 -#define CLKID_AO_ALT_XTAL 11 +#define CLKID_AO_CTS_OSCIN 11 +#define CLKID_AO_32K_PRE 12 +#define CLKID_AO_32K_DIV 13 +#define CLKID_AO_32K_SEL 14 +#define CLKID_AO_32K 15 +#define CLKID_AO_CTS_RTC_OSCIN 16#endif
include/dt-bindings/clock/gxbb-aoclkc.h +7 -0
@@ -63,5 +63,12 @@#define CLKID_AO_UART2 4#define CLKID_AO_IR_BLASTER 5#define CLKID_AO_CEC_32K 6 +#define CLKID_AO_CTS_OSCIN 7 +#define CLKID_AO_32K_PRE 8 +#define CLKID_AO_32K_DIV 9 +#define CLKID_AO_32K_SEL 10 +#define CLKID_AO_32K 11 +#define CLKID_AO_CTS_RTC_OSCIN 12 +#define CLKID_AO_CLK81 13#endif
Signature · 1 line
2.19.2
Jerome Brunet
maintainerPATCH v2 2/5 clk: meson: clean-up clock registration
In reply to Jerome BrunetOrder, ids and size between the table of regmap clocks and the onecell data table could be different.
Set regmap pointer in all the regmap clocks before starting the registration using the onecell data, to make sure we don't get into an incoherent situation.
--- drivers/clk/meson/meson-aoclk.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/clk/meson/meson-aoclk.c +10 -5
@@ -65,15 +65,20 @@ int meson_aoclkc_probe(struct platform_device *pdev)return ret; } -/* -* Populate regmap and register all clks -*/ -for (clkid =0 ; clkid < data->num_clks; clkid++) { +/* Populate regmap */ +for (clkid =0 ; clkid < data->num_clks; clkid++) data->clks[clkid]->map = regmap; +/* Register all clks */ +for (clkid =0 ; clkid < data->hw_data->num; clkid++) { +if (!data->hw_data->hws[clkid]) +continue ; + ret =devm_clk_hw_register (dev, data->hw_data->hws[clkid]); -if (ret) +if (ret) { +dev_err (dev,"Clock registration failed\n" );return ret; + } } return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
Signature · 1 line
2.19.2
Jerome Brunet
maintainerPATCH v2 3/5 clk: meson: add dual divider clock driver
In reply to Jerome BrunetAdd the dual divider driver. This special divider make a weighted average between 2 dividers to reach fractional divider values.
--- drivers/clk/meson/Makefile | 2 +- drivers/clk/meson/clk-dualdiv.c | 130 ++++++++++++++++++++++++++++++++ drivers/clk/meson/clkc.h | 19 +++++ 3 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/meson/clk-dualdiv.c
drivers/clk/meson/Makefile +1 -1
@@ -3,7 +3,7 @@ # obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o clk-phase.o vid-pll-div.o -obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-input.o +obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-input.o clk-dualdiv.o obj-$(CONFIG_COMMON_CLK_AMLOGIC_AUDIO) += clk-triphase.o sclk-div.o obj-$(CONFIG_COMMON_CLK_MESON_AO) += meson-aoclk.o obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
drivers/clk/meson/clk-dualdiv.c new file +130 -0
130 lines not on this page · raw message
drivers/clk/meson/clkc.h +19 -0
@@ -110,6 +110,23 @@ struct clk_regmap _name = { \ }, \ }; +struct meson_clk_dualdiv_param { +unsigned int n1; +unsigned int n2; +unsigned int m1; +unsigned int m2; +unsigned int dual; +}; + +struct meson_clk_dualdiv_data { +struct parm n1; +struct parm n2; +struct parm m1; +struct parm m2; +struct parm dual; +const struct meson_clk_dualdiv_param *table; +}; +/* clk_ops */ extern const struct clk_ops meson_clk_pll_ro_ops;extern const struct clk_ops meson_clk_pll_ops;
@@ -118,6 +135,8 @@ extern const struct clk_ops meson_clk_mpll_ro_ops;extern const struct clk_ops meson_clk_mpll_ops;extern const struct clk_ops meson_clk_phase_ops;extern const struct clk_ops meson_vid_pll_div_ro_ops; +extern const struct clk_ops meson_clk_dualdiv_ops; +extern const struct clk_ops meson_clk_dualdiv_ro_ops; struct clk_hw *meson_clk_hw_register_input(struct device *dev, const char *of_name,
Signature · 1 line
2.19.2
Jerome Brunet
maintainerPATCH v2 4/5 clk: meson: gxbb-ao: replace cec-32k with the dual divider
In reply to Jerome BrunetReplace the cec-32k clock of gxbb-ao with the simpler dual divider driver. The dual divider implements only the dividing part. All the other bits are now exposed using simple elements, such as gates and muxes
--- drivers/clk/meson/Makefile | 2 +- drivers/clk/meson/gxbb-aoclk-32k.c | 193 ---------------------- drivers/clk/meson/gxbb-aoclk.c | 251 +++++++++++++++++++++++------ drivers/clk/meson/gxbb-aoclk.h | 20 +-- 4 files changed, 204 insertions(+), 262 deletions(-) delete mode 100644 drivers/clk/meson/gxbb-aoclk-32k.c
drivers/clk/meson/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-input.o clk-dualdiv.o obj-$(CONFIG_COMMON_CLK_AMLOGIC_AUDIO) += clk-triphase.o sclk-div.o obj-$(CONFIG_COMMON_CLK_MESON_AO) += meson-aoclk.o obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o -obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o gxbb-aoclk-32k.o +obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o obj-$(CONFIG_COMMON_CLK_AXG) += axg.o axg-aoclk.o obj-$(CONFIG_COMMON_CLK_AXG_AUDIO) += axg-audio.o obj-$(CONFIG_COMMON_CLK_REGMAP_MESON) += clk-regmap.o
drivers/clk/meson/gxbb-aoclk-32k.c deleted +0 -193
193 lines not on this page · raw message
drivers/clk/meson/gxbb-aoclk.c +202 -49
297 lines not on this page · raw message
drivers/clk/meson/gxbb-aoclk.h +1 -19
@@ -7,25 +7,7 @@#ifndef __GXBB_AOCLKC_H#define __GXBB_AOCLKC_H -#define NR_CLKS 7 - -/* AO Configuration Clock registers offsets */ -#define AO_RTI_PWR_CNTL_REG1 0x0c -#define AO_RTI_PWR_CNTL_REG0 0x10 -#define AO_RTI_GEN_CNTL_REG0 0x40 -#define AO_OSCIN_CNTL 0x58 -#define AO_CRT_CLK_CNTL1 0x68 -#define AO_RTC_ALT_CLK_CNTL0 0x94 -#define AO_RTC_ALT_CLK_CNTL1 0x98 - -struct aoclk_cec_32k { -struct clk_hw hw; -struct regmap *regmap; -}; - -#define to_aoclk_cec_32k (_hw) container_of(_hw, struct aoclk_cec_32k, hw) - -extern const struct clk_ops meson_aoclk_cec_32k_ops; +#define NR_CLKS 14#include <dt-bindings/clock/gxbb-aoclkc.h> #include <dt-bindings/reset/gxbb-aoclkc.h>
Signature · 1 line
2.19.2
Jerome Brunet
maintainerPATCH v2 5/5 clk: meson: axg-ao: add 32k generation subtree
In reply to Jerome BrunetAdd the clock subtree generating the 32k clock in amlogic axg ao block.
--- drivers/clk/meson/axg-aoclk.c | 175 +++++++++++++++++++++++++++++++--- drivers/clk/meson/axg-aoclk.h | 13 +-- 2 files changed, 163 insertions(+), 25 deletions(-)
drivers/clk/meson/axg-aoclk.c +162 -13
@@ -12,10 +12,23 @@#include <linux/platform_device.h> #include <linux/reset-controller.h> #include <linux/mfd/syscon.h> -#include "clk-regmap.h" +#include "clkc.h" #include "meson-aoclk.h" #include "axg-aoclk.h" +/* +* AO Configuration Clock registers offsets +* Register offsets from the data sheet must be multiplied by 4. +*/ +#define AO_RTI_PWR_CNTL_REG1 0x0C +#define AO_RTI_PWR_CNTL_REG0 0x10 +#define AO_RTI_GEN_CNTL_REG0 0x40 +#define AO_OSCIN_CNTL 0x58 +#define AO_CRT_CLK_CNTL1 0x68 +#define AO_SAR_CLK 0x90 +#define AO_RTC_ALT_CLK_CNTL0 0x94 +#define AO_RTC_ALT_CLK_CNTL1 0x98 +#define AXG_AO_GATE (_name, _bit) \ static struct clk_regmap axg_aoclk_##_name = { \ .data = &(struct clk_regmap_gate_data) { \
@@ -39,17 +52,141 @@ AXG_AO_GATE(uart2, 5);AXG_AO_GATE (ir_blaster,6 );AXG_AO_GATE (saradc,7 ); +static struct clk_regmap axg_aoclk_cts_oscin = { + .data = &(struct clk_regmap_gate_data ){ + .offset =AO_RTI_PWR_CNTL_REG0 , + .bit_idx =14 , + }, + .hw.init = &(struct clk_init_data ){ + .name ="cts_oscin" , + .ops = &clk_regmap_gate_ro_ops, + .parent_names = (const char *[]){"xtal" }, + .num_parents =1 , + }, +}; + +static struct clk_regmap axg_aoclk_32k_pre = { + .data = &(struct clk_regmap_gate_data ){ + .offset =AO_RTC_ALT_CLK_CNTL0 , + .bit_idx =31 , + }, + .hw.init = &(struct clk_init_data ){ + .name ="axg_ao_32k_pre" , + .ops = &clk_regmap_gate_ops, + .parent_names = (const char *[]){"cts_oscin" }, + .num_parents =1 , + }, +}; + +static const struct meson_clk_dualdiv_param axg_32k_div_table[] = { + { + .dual =1 , + .n1 =733 , + .m1 =8 , + .n2 =732 , + .m2 =11 , + }, {} +}; + +static struct clk_regmap axg_aoclk_32k_div = { + .data = &(struct meson_clk_dualdiv_data ){ + .n1 = { + .reg_off =AO_RTC_ALT_CLK_CNTL0 , + .shift =0 , + .width =12 , + }, + .n2 = { + .reg_off =AO_RTC_ALT_CLK_CNTL0 , + .shift =12 , + .width =12 , + }, + .m1 = { + .reg_off =AO_RTC_ALT_CLK_CNTL1 , + .shift =0 , + .width =12 , + }, + .m2 = { + .reg_off =AO_RTC_ALT_CLK_CNTL1 , + .shift =12 , + .width =12 , + }, + .dual = { + .reg_off =AO_RTC_ALT_CLK_CNTL0 , + .shift =28 , + .width =1 , + }, + .table = axg_32k_div_table, + }, + .hw.init = &(struct clk_init_data ){ + .name ="axg_ao_32k_div" , + .ops = &meson_clk_dualdiv_ops, + .parent_names = (const char *[]){"axg_ao_32k_pre" }, + .num_parents =1 , + }, +}; + +static struct clk_regmap axg_aoclk_32k_sel = { + .data = &(struct clk_regmap_mux_data ) { + .offset =AO_RTC_ALT_CLK_CNTL1 , + .mask =0x1 , + .shift =24 , + .flags =CLK_MUX_ROUND_CLOSEST , + }, + .hw.init = &(struct clk_init_data ){ + .name ="axg_ao_32k_sel" , + .ops = &clk_regmap_mux_ops, + .parent_names = (const char *[]){"axg_ao_32k_div" , +"axg_ao_32k_pre" }, + .num_parents =2 , + .flags =CLK_SET_RATE_PARENT , + }, +}; + +static struct clk_regmap axg_aoclk_32k = { + .data = &(struct clk_regmap_gate_data ){ + .offset =AO_RTC_ALT_CLK_CNTL0 , + .bit_idx =30 , + }, + .hw.init = &(struct clk_init_data ){ + .name ="axg_ao_32k" , + .ops = &clk_regmap_gate_ops, + .parent_names = (const char *[]){"axg_ao_32k_sel" }, + .num_parents =1 , + .flags =CLK_SET_RATE_PARENT , + }, +}; + +static struct clk_regmap axg_aoclk_cts_rtc_oscin = { + .data = &(struct clk_regmap_mux_data ) { + .offset =AO_RTI_PWR_CNTL_REG0 , + .mask =0x1 , + .shift =10 , + .flags =CLK_MUX_ROUND_CLOSEST , + }, + .hw.init = &(struct clk_init_data ){ + .name ="axg_ao_cts_rtc_oscin" , + .ops = &clk_regmap_mux_ops, + .parent_names = (const char *[]){"axg_ao_32k" , +"axg_ext_32k" }, + .num_parents =2 , + .flags =CLK_SET_RATE_PARENT , + }, +}; +static struct clk_regmap axg_aoclk_clk81 = { .data = &(struct clk_regmap_mux_data ) { .offset =AO_RTI_PWR_CNTL_REG0 , .mask =0x1 , .shift =8 , + .flags =CLK_MUX_ROUND_CLOSEST , }, .hw.init = &(struct clk_init_data ){ .name ="axg_ao_clk81" , .ops = &clk_regmap_mux_ro_ops, - .parent_names = (const char *[]){"clk81" ,"ao_alt_xtal" }, + .parent_names = (const char *[]){"clk81" , +"axg_ao_cts_rtc_oscin" }, .num_parents =2 , + .flags =CLK_SET_RATE_PARENT , }, };
@@ -106,17 +243,23 @@ static const unsigned int axg_aoclk_reset[] = { };static struct clk_regmap *axg_aoclk_regmap[] = { - [CLKID_AO_REMOTE ] = &axg_aoclk_remote, - [CLKID_AO_I2C_MASTER ] = &axg_aoclk_i2c_master, - [CLKID_AO_I2C_SLAVE ] = &axg_aoclk_i2c_slave, - [CLKID_AO_UART1 ] = &axg_aoclk_uart1, - [CLKID_AO_UART2 ] = &axg_aoclk_uart2, - [CLKID_AO_IR_BLASTER ] = &axg_aoclk_ir_blaster, - [CLKID_AO_SAR_ADC ] = &axg_aoclk_saradc, - [CLKID_AO_CLK81 ] = &axg_aoclk_clk81, - [CLKID_AO_SAR_ADC_SEL ] = &axg_aoclk_saradc_mux, - [CLKID_AO_SAR_ADC_DIV ] = &axg_aoclk_saradc_div, - [CLKID_AO_SAR_ADC_CLK ] = &axg_aoclk_saradc_gate, + &axg_aoclk_remote, + &axg_aoclk_i2c_master, + &axg_aoclk_i2c_slave, + &axg_aoclk_uart1, + &axg_aoclk_uart2, + &axg_aoclk_ir_blaster, + &axg_aoclk_saradc, + &axg_aoclk_cts_oscin, + &axg_aoclk_32k_pre, + &axg_aoclk_32k_div, + &axg_aoclk_32k_sel, + &axg_aoclk_32k, + &axg_aoclk_cts_rtc_oscin, + &axg_aoclk_clk81, + &axg_aoclk_saradc_mux, + &axg_aoclk_saradc_div, + &axg_aoclk_saradc_gate, };static const struct clk_hw_onecell_data axg_aoclk_onecell_data = {
@@ -132,6 +275,12 @@ static const struct clk_hw_onecell_data axg_aoclk_onecell_data = { [CLKID_AO_SAR_ADC_SEL] = &axg_aoclk_saradc_mux.hw, [CLKID_AO_SAR_ADC_DIV] = &axg_aoclk_saradc_div.hw, [CLKID_AO_SAR_ADC_CLK] = &axg_aoclk_saradc_gate.hw, + [CLKID_AO_CTS_OSCIN] = &axg_aoclk_cts_oscin.hw, + [CLKID_AO_32K_PRE] = &axg_aoclk_32k_pre.hw, + [CLKID_AO_32K_DIV] = &axg_aoclk_32k_div.hw, + [CLKID_AO_32K_SEL] = &axg_aoclk_32k_sel.hw, + [CLKID_AO_32K] = &axg_aoclk_32k.hw, + [CLKID_AO_CTS_RTC_OSCIN] = &axg_aoclk_cts_rtc_oscin.hw, }, .num = NR_CLKS, };
drivers/clk/meson/axg-aoclk.h +1 -12
@@ -10,18 +10,7 @@#ifndef __AXG_AOCLKC_H#define __AXG_AOCLKC_H -#define NR_CLKS 11 -/* AO Configuration Clock registers offsets -* Register offsets from the data sheet must be multiplied by 4. -*/ -#define AO_RTI_PWR_CNTL_REG1 0x0C -#define AO_RTI_PWR_CNTL_REG0 0x10 -#define AO_RTI_GEN_CNTL_REG0 0x40 -#define AO_OSCIN_CNTL 0x58 -#define AO_CRT_CLK_CNTL1 0x68 -#define AO_SAR_CLK 0x90 -#define AO_RTC_ALT_CLK_CNTL0 0x94 -#define AO_RTC_ALT_CLK_CNTL1 0x98 +#define NR_CLKS 17#include <dt-bindings/clock/axg-aoclkc.h> #include <dt-bindings/reset/axg-aoclkc.h>
Signature · 1 line
2.19.2
Quoted 25 lines · Jerome Brunet
The goal of this patchset is to add the internal generation of the 32768Hz clock within the axg AO clock controller.
This was initially added has the CEC clock on gxbb. To properly integrate it on the axg, a simpler 'dual divider' driver is added. Then gxbb AO clock controller is reworked to use it. Finally the 32k clock tree is added to the AXG.
This patchset *no longer* requires depends on this CCF change [0]. There is a work around in place until a solution gets merged in the framework.
Changes since v1: [1]
* Add work around for [0] in gxbb-aoclk[0]: https://lkml.kernel.org/r/[email protected]
[1]: https://lkml.kernel.org/r/[email protected]Jerome Brunet (5):
dt-bindings: clk: meson: add ao slow clock path ids
clk: meson: clean-up clock registration
clk: meson: add dual divider clock driver
clk: meson: gxbb-ao: replace cec-32k with the dual divider
clk: meson: axg-ao: add 32k generation subtree
Quoted 15 lines
drivers/clk/meson/Makefile | 4 +- drivers/clk/meson/axg-aoclk.c | 175 +++++++++++++++-- drivers/clk/meson/axg-aoclk.h | 13 +- drivers/clk/meson/clk-dualdiv.c | 130 ++++++++++++ drivers/clk/meson/clkc.h | 19 ++ drivers/clk/meson/gxbb-aoclk-32k.c | 193 ------------------ drivers/clk/meson/gxbb-aoclk.c | 251 +++++++++++++++++++----- drivers/clk/meson/gxbb-aoclk.h | 20 +- drivers/clk/meson/meson-aoclk.c | 15 +- include/dt-bindings/clock/axg-aoclkc.h | 7 +- include/dt-bindings/clock/gxbb-aoclkc.h | 7 + 11 files changed, 540 insertions(+), 294 deletions(-) create mode 100644 drivers/clk/meson/clk-dualdiv.c delete mode 100644 drivers/clk/meson/gxbb-aoclk-32k.c
And applied to next/drivers for Linux 5.1
Neil