summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2019-08-26 03:25:37 -0400
committerJerome Brunet <jbrunet@baylibre.com>2019-08-26 05:04:42 -0400
commit2edccd319fdef9bc35c06fe4150b21099ac99579 (patch)
tree0779a793486bd173ebdc03ce7cd5d92d48c888b2
parent3dd02b7334ecdea6cd5b0bd371a9c958f326c1ce (diff)
clk: meson: g12a: add support for SM1 DynamIQ Shared Unit clock
The Amlogic SM1 DynamIQ Shared Unit has a dedicated clock tree similar to the CPU clock tree with a supplementaty mux to select the CPU0 clock instead. Leave this as read-only since it's set up by the early boot stages. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
-rw-r--r--drivers/clk/meson/g12a.c184
-rw-r--r--drivers/clk/meson/g12a.h15
2 files changed, 198 insertions, 1 deletions
diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c
index 34dfac4b4dc6..e00df17f800a 100644
--- a/drivers/clk/meson/g12a.c
+++ b/drivers/clk/meson/g12a.c
@@ -676,6 +676,172 @@ static struct clk_regmap g12b_cpub_clk = {
676 }, 676 },
677}; 677};
678 678
679static struct clk_regmap sm1_gp1_pll;
680
681/* Datasheet names this field as "premux0" */
682static struct clk_regmap sm1_dsu_clk_premux0 = {
683 .data = &(struct clk_regmap_mux_data){
684 .offset = HHI_SYS_CPU_CLK_CNTL5,
685 .mask = 0x3,
686 .shift = 0,
687 },
688 .hw.init = &(struct clk_init_data){
689 .name = "dsu_clk_dyn0_sel",
690 .ops = &clk_regmap_mux_ro_ops,
691 .parent_data = (const struct clk_parent_data []) {
692 { .fw_name = "xtal", },
693 { .hw = &g12a_fclk_div2.hw },
694 { .hw = &g12a_fclk_div3.hw },
695 { .hw = &sm1_gp1_pll.hw },
696 },
697 .num_parents = 4,
698 },
699};
700
701/* Datasheet names this field as "premux1" */
702static struct clk_regmap sm1_dsu_clk_premux1 = {
703 .data = &(struct clk_regmap_mux_data){
704 .offset = HHI_SYS_CPU_CLK_CNTL5,
705 .mask = 0x3,
706 .shift = 16,
707 },
708 .hw.init = &(struct clk_init_data){
709 .name = "dsu_clk_dyn1_sel",
710 .ops = &clk_regmap_mux_ro_ops,
711 .parent_data = (const struct clk_parent_data []) {
712 { .fw_name = "xtal", },
713 { .hw = &g12a_fclk_div2.hw },
714 { .hw = &g12a_fclk_div3.hw },
715 { .hw = &sm1_gp1_pll.hw },
716 },
717 .num_parents = 4,
718 },
719};
720
721/* Datasheet names this field as "Mux0_divn_tcnt" */
722static struct clk_regmap sm1_dsu_clk_mux0_div = {
723 .data = &(struct clk_regmap_div_data){
724 .offset = HHI_SYS_CPU_CLK_CNTL5,
725 .shift = 4,
726 .width = 6,
727 },
728 .hw.init = &(struct clk_init_data){
729 .name = "dsu_clk_dyn0_div",
730 .ops = &clk_regmap_divider_ro_ops,
731 .parent_hws = (const struct clk_hw *[]) {
732 &sm1_dsu_clk_premux0.hw
733 },
734 .num_parents = 1,
735 },
736};
737
738/* Datasheet names this field as "postmux0" */
739static struct clk_regmap sm1_dsu_clk_postmux0 = {
740 .data = &(struct clk_regmap_mux_data){
741 .offset = HHI_SYS_CPU_CLK_CNTL5,
742 .mask = 0x1,
743 .shift = 2,
744 },
745 .hw.init = &(struct clk_init_data){
746 .name = "dsu_clk_dyn0",
747 .ops = &clk_regmap_mux_ro_ops,
748 .parent_hws = (const struct clk_hw *[]) {
749 &sm1_dsu_clk_premux0.hw,
750 &sm1_dsu_clk_mux0_div.hw,
751 },
752 .num_parents = 2,
753 },
754};
755
756/* Datasheet names this field as "Mux1_divn_tcnt" */
757static struct clk_regmap sm1_dsu_clk_mux1_div = {
758 .data = &(struct clk_regmap_div_data){
759 .offset = HHI_SYS_CPU_CLK_CNTL5,
760 .shift = 20,
761 .width = 6,
762 },
763 .hw.init = &(struct clk_init_data){
764 .name = "dsu_clk_dyn1_div",
765 .ops = &clk_regmap_divider_ro_ops,
766 .parent_hws = (const struct clk_hw *[]) {
767 &sm1_dsu_clk_premux1.hw
768 },
769 .num_parents = 1,
770 },
771};
772
773/* Datasheet names this field as "postmux1" */
774static struct clk_regmap sm1_dsu_clk_postmux1 = {
775 .data = &(struct clk_regmap_mux_data){
776 .offset = HHI_SYS_CPU_CLK_CNTL5,
777 .mask = 0x1,
778 .shift = 18,
779 },
780 .hw.init = &(struct clk_init_data){
781 .name = "dsu_clk_dyn1",
782 .ops = &clk_regmap_mux_ro_ops,
783 .parent_hws = (const struct clk_hw *[]) {
784 &sm1_dsu_clk_premux1.hw,
785 &sm1_dsu_clk_mux1_div.hw,
786 },
787 .num_parents = 2,
788 },
789};
790
791/* Datasheet names this field as "Final_dyn_mux_sel" */
792static struct clk_regmap sm1_dsu_clk_dyn = {
793 .data = &(struct clk_regmap_mux_data){
794 .offset = HHI_SYS_CPU_CLK_CNTL5,
795 .mask = 0x1,
796 .shift = 10,
797 },
798 .hw.init = &(struct clk_init_data){
799 .name = "dsu_clk_dyn",
800 .ops = &clk_regmap_mux_ro_ops,
801 .parent_hws = (const struct clk_hw *[]) {
802 &sm1_dsu_clk_postmux0.hw,
803 &sm1_dsu_clk_postmux1.hw,
804 },
805 .num_parents = 2,
806 },
807};
808
809/* Datasheet names this field as "Final_mux_sel" */
810static struct clk_regmap sm1_dsu_final_clk = {
811 .data = &(struct clk_regmap_mux_data){
812 .offset = HHI_SYS_CPU_CLK_CNTL5,
813 .mask = 0x1,
814 .shift = 11,
815 },
816 .hw.init = &(struct clk_init_data){
817 .name = "dsu_clk_final",
818 .ops = &clk_regmap_mux_ro_ops,
819 .parent_hws = (const struct clk_hw *[]) {
820 &sm1_dsu_clk_dyn.hw,
821 &g12a_sys_pll.hw,
822 },
823 .num_parents = 2,
824 },
825};
826
827/* Datasheet names this field as "Cpu_clk_sync_mux_sel" bit 4 */
828static struct clk_regmap sm1_dsu_clk = {
829 .data = &(struct clk_regmap_mux_data){
830 .offset = HHI_SYS_CPU_CLK_CNTL6,
831 .mask = 0x1,
832 .shift = 27,
833 },
834 .hw.init = &(struct clk_init_data){
835 .name = "dsu_clk",
836 .ops = &clk_regmap_mux_ro_ops,
837 .parent_hws = (const struct clk_hw *[]) {
838 &g12a_cpu_clk.hw,
839 &sm1_dsu_final_clk.hw,
840 },
841 .num_parents = 2,
842 },
843};
844
679static int g12a_cpu_clk_mux_notifier_cb(struct notifier_block *nb, 845static int g12a_cpu_clk_mux_notifier_cb(struct notifier_block *nb,
680 unsigned long event, void *data) 846 unsigned long event, void *data)
681{ 847{
@@ -4401,6 +4567,15 @@ static struct clk_hw_onecell_data sm1_hw_onecell_data = {
4401 [CLKID_TS] = &g12a_ts.hw, 4567 [CLKID_TS] = &g12a_ts.hw,
4402 [CLKID_GP1_PLL_DCO] = &sm1_gp1_pll_dco.hw, 4568 [CLKID_GP1_PLL_DCO] = &sm1_gp1_pll_dco.hw,
4403 [CLKID_GP1_PLL] = &sm1_gp1_pll.hw, 4569 [CLKID_GP1_PLL] = &sm1_gp1_pll.hw,
4570 [CLKID_DSU_CLK_DYN0_SEL] = &sm1_dsu_clk_premux0.hw,
4571 [CLKID_DSU_CLK_DYN0_DIV] = &sm1_dsu_clk_premux1.hw,
4572 [CLKID_DSU_CLK_DYN0] = &sm1_dsu_clk_mux0_div.hw,
4573 [CLKID_DSU_CLK_DYN1_SEL] = &sm1_dsu_clk_postmux0.hw,
4574 [CLKID_DSU_CLK_DYN1_DIV] = &sm1_dsu_clk_mux1_div.hw,
4575 [CLKID_DSU_CLK_DYN1] = &sm1_dsu_clk_postmux1.hw,
4576 [CLKID_DSU_CLK_DYN] = &sm1_dsu_clk_dyn.hw,
4577 [CLKID_DSU_CLK_FINAL] = &sm1_dsu_final_clk.hw,
4578 [CLKID_DSU_CLK] = &sm1_dsu_clk.hw,
4404 [NR_CLKS] = NULL, 4579 [NR_CLKS] = NULL,
4405 }, 4580 },
4406 .num = NR_CLKS, 4581 .num = NR_CLKS,
@@ -4623,6 +4798,15 @@ static struct clk_regmap *const g12a_clk_regmaps[] = {
4623 &g12b_cpub_clk_trace, 4798 &g12b_cpub_clk_trace,
4624 &sm1_gp1_pll_dco, 4799 &sm1_gp1_pll_dco,
4625 &sm1_gp1_pll, 4800 &sm1_gp1_pll,
4801 &sm1_dsu_clk_premux0,
4802 &sm1_dsu_clk_premux1,
4803 &sm1_dsu_clk_mux0_div,
4804 &sm1_dsu_clk_postmux0,
4805 &sm1_dsu_clk_mux1_div,
4806 &sm1_dsu_clk_postmux1,
4807 &sm1_dsu_clk_dyn,
4808 &sm1_dsu_final_clk,
4809 &sm1_dsu_clk,
4626}; 4810};
4627 4811
4628static const struct reg_sequence g12a_init_regs[] = { 4812static const struct reg_sequence g12a_init_regs[] = {
diff --git a/drivers/clk/meson/g12a.h b/drivers/clk/meson/g12a.h
index e426b4121b7a..6804fcced6b5 100644
--- a/drivers/clk/meson/g12a.h
+++ b/drivers/clk/meson/g12a.h
@@ -80,6 +80,11 @@
80#define HHI_SYS_CPUB_CLK_CNTL1 0x200 80#define HHI_SYS_CPUB_CLK_CNTL1 0x200
81#define HHI_SYS_CPUB_CLK_CNTL 0x208 81#define HHI_SYS_CPUB_CLK_CNTL 0x208
82#define HHI_VPU_CLKB_CNTL 0x20C 82#define HHI_VPU_CLKB_CNTL 0x20C
83#define HHI_SYS_CPU_CLK_CNTL2 0x210
84#define HHI_SYS_CPU_CLK_CNTL3 0x214
85#define HHI_SYS_CPU_CLK_CNTL4 0x218
86#define HHI_SYS_CPU_CLK_CNTL5 0x21c
87#define HHI_SYS_CPU_CLK_CNTL6 0x220
83#define HHI_GEN_CLK_CNTL 0x228 88#define HHI_GEN_CLK_CNTL 0x228
84#define HHI_VDIN_MEAS_CLK_CNTL 0x250 89#define HHI_VDIN_MEAS_CLK_CNTL 0x250
85#define HHI_MIPIDSI_PHY_CLK_CNTL 0x254 90#define HHI_MIPIDSI_PHY_CLK_CNTL 0x254
@@ -242,8 +247,16 @@
242#define CLKID_CPUB_CLK_TRACE_SEL 240 247#define CLKID_CPUB_CLK_TRACE_SEL 240
243#define CLKID_CPUB_CLK_TRACE 241 248#define CLKID_CPUB_CLK_TRACE 241
244#define CLKID_GP1_PLL_DCO 242 249#define CLKID_GP1_PLL_DCO 242
250#define CLKID_DSU_CLK_DYN0_SEL 244
251#define CLKID_DSU_CLK_DYN0_DIV 245
252#define CLKID_DSU_CLK_DYN0 246
253#define CLKID_DSU_CLK_DYN1_SEL 247
254#define CLKID_DSU_CLK_DYN1_DIV 248
255#define CLKID_DSU_CLK_DYN1 249
256#define CLKID_DSU_CLK_DYN 250
257#define CLKID_DSU_CLK_FINAL 251
245 258
246#define NR_CLKS 244 259#define NR_CLKS 253
247 260
248/* include the CLKIDs that have been made part of the DT binding */ 261/* include the CLKIDs that have been made part of the DT binding */
249#include <dt-bindings/clock/g12a-clkc.h> 262#include <dt-bindings/clock/g12a-clkc.h>