aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Brunet <jbrunet@baylibre.com>2018-02-12 09:58:38 -0500
committerNeil Armstrong <narmstrong@baylibre.com>2018-03-13 05:04:01 -0400
commit2513a28c108b0584989927195ba5230e296762ec (patch)
tree12827fb990ac6f12d709a4c387d12937dd702090
parentf06ddd2852b3f45cf37e2abd6b0de4f9cec80f0f (diff)
clk: meson: migrate muxes to clk_regmap
Move meson8b, gxbb and axg clocks using clk_mux to clk_regmap Also remove a few useless tables in the process Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
-rw-r--r--drivers/clk/meson/axg.c60
-rw-r--r--drivers/clk/meson/gxbb.c310
-rw-r--r--drivers/clk/meson/meson8b.c27
3 files changed, 184 insertions, 213 deletions
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index f8b8ff2eba6c..9f0c36e12cb8 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -418,16 +418,16 @@ static const char * const clk81_parent_names[] = {
418 "fclk_div3", "fclk_div5" 418 "fclk_div3", "fclk_div5"
419}; 419};
420 420
421static struct clk_mux axg_mpeg_clk_sel = { 421static struct clk_regmap axg_mpeg_clk_sel = {
422 .reg = (void *)HHI_MPEG_CLK_CNTL, 422 .data = &(struct clk_regmap_mux_data){
423 .mask = 0x7, 423 .offset = HHI_MPEG_CLK_CNTL,
424 .shift = 12, 424 .mask = 0x7,
425 .flags = CLK_MUX_READ_ONLY, 425 .shift = 12,
426 .table = mux_table_clk81, 426 .table = mux_table_clk81,
427 .lock = &meson_clk_lock, 427 },
428 .hw.init = &(struct clk_init_data){ 428 .hw.init = &(struct clk_init_data){
429 .name = "mpeg_clk_sel", 429 .name = "mpeg_clk_sel",
430 .ops = &clk_mux_ro_ops, 430 .ops = &clk_regmap_mux_ro_ops,
431 .parent_names = clk81_parent_names, 431 .parent_names = clk81_parent_names,
432 .num_parents = ARRAY_SIZE(clk81_parent_names), 432 .num_parents = ARRAY_SIZE(clk81_parent_names),
433 }, 433 },
@@ -474,14 +474,15 @@ static const char * const axg_sd_emmc_clk0_parent_names[] = {
474}; 474};
475 475
476/* SDcard clock */ 476/* SDcard clock */
477static struct clk_mux axg_sd_emmc_b_clk0_sel = { 477static struct clk_regmap axg_sd_emmc_b_clk0_sel = {
478 .reg = (void *)HHI_SD_EMMC_CLK_CNTL, 478 .data = &(struct clk_regmap_mux_data){
479 .mask = 0x7, 479 .offset = HHI_SD_EMMC_CLK_CNTL,
480 .shift = 25, 480 .mask = 0x7,
481 .lock = &meson_clk_lock, 481 .shift = 25,
482 },
482 .hw.init = &(struct clk_init_data) { 483 .hw.init = &(struct clk_init_data) {
483 .name = "sd_emmc_b_clk0_sel", 484 .name = "sd_emmc_b_clk0_sel",
484 .ops = &clk_mux_ops, 485 .ops = &clk_regmap_mux_ops,
485 .parent_names = axg_sd_emmc_clk0_parent_names, 486 .parent_names = axg_sd_emmc_clk0_parent_names,
486 .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names), 487 .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
487 .flags = CLK_SET_RATE_PARENT, 488 .flags = CLK_SET_RATE_PARENT,
@@ -519,14 +520,15 @@ static struct clk_regmap axg_sd_emmc_b_clk0 = {
519}; 520};
520 521
521/* EMMC/NAND clock */ 522/* EMMC/NAND clock */
522static struct clk_mux axg_sd_emmc_c_clk0_sel = { 523static struct clk_regmap axg_sd_emmc_c_clk0_sel = {
523 .reg = (void *)HHI_NAND_CLK_CNTL, 524 .data = &(struct clk_regmap_mux_data){
524 .mask = 0x7, 525 .offset = HHI_NAND_CLK_CNTL,
525 .shift = 9, 526 .mask = 0x7,
526 .lock = &meson_clk_lock, 527 .shift = 9,
528 },
527 .hw.init = &(struct clk_init_data) { 529 .hw.init = &(struct clk_init_data) {
528 .name = "sd_emmc_c_clk0_sel", 530 .name = "sd_emmc_c_clk0_sel",
529 .ops = &clk_mux_ops, 531 .ops = &clk_regmap_mux_ops,
530 .parent_names = axg_sd_emmc_clk0_parent_names, 532 .parent_names = axg_sd_emmc_clk0_parent_names,
531 .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names), 533 .num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_names),
532 .flags = CLK_SET_RATE_PARENT, 534 .flags = CLK_SET_RATE_PARENT,
@@ -703,12 +705,6 @@ static struct meson_clk_mpll *const axg_clk_mplls[] = {
703 &axg_mpll3, 705 &axg_mpll3,
704}; 706};
705 707
706static struct clk_mux *const axg_clk_muxes[] = {
707 &axg_mpeg_clk_sel,
708 &axg_sd_emmc_b_clk0_sel,
709 &axg_sd_emmc_c_clk0_sel,
710};
711
712static struct clk_regmap *const axg_clk_regmaps[] = { 708static struct clk_regmap *const axg_clk_regmaps[] = {
713 &axg_clk81, 709 &axg_clk81,
714 &axg_ddr, 710 &axg_ddr,
@@ -760,6 +756,9 @@ static struct clk_regmap *const axg_clk_regmaps[] = {
760 &axg_mpeg_clk_div, 756 &axg_mpeg_clk_div,
761 &axg_sd_emmc_b_clk0_div, 757 &axg_sd_emmc_b_clk0_div,
762 &axg_sd_emmc_c_clk0_div, 758 &axg_sd_emmc_c_clk0_div,
759 &axg_mpeg_clk_sel,
760 &axg_sd_emmc_b_clk0_sel,
761 &axg_sd_emmc_c_clk0_sel,
763}; 762};
764 763
765struct clkc_data { 764struct clkc_data {
@@ -767,8 +766,6 @@ struct clkc_data {
767 unsigned int clk_mplls_count; 766 unsigned int clk_mplls_count;
768 struct meson_clk_pll *const *clk_plls; 767 struct meson_clk_pll *const *clk_plls;
769 unsigned int clk_plls_count; 768 unsigned int clk_plls_count;
770 struct clk_mux *const *clk_muxes;
771 unsigned int clk_muxes_count;
772 struct clk_hw_onecell_data *hw_onecell_data; 769 struct clk_hw_onecell_data *hw_onecell_data;
773}; 770};
774 771
@@ -777,8 +774,6 @@ static const struct clkc_data axg_clkc_data = {
777 .clk_mplls_count = ARRAY_SIZE(axg_clk_mplls), 774 .clk_mplls_count = ARRAY_SIZE(axg_clk_mplls),
778 .clk_plls = axg_clk_plls, 775 .clk_plls = axg_clk_plls,
779 .clk_plls_count = ARRAY_SIZE(axg_clk_plls), 776 .clk_plls_count = ARRAY_SIZE(axg_clk_plls),
780 .clk_muxes = axg_clk_muxes,
781 .clk_muxes_count = ARRAY_SIZE(axg_clk_muxes),
782 .hw_onecell_data = &axg_hw_onecell_data, 777 .hw_onecell_data = &axg_hw_onecell_data,
783}; 778};
784 779
@@ -829,11 +824,6 @@ static int axg_clkc_probe(struct platform_device *pdev)
829 for (i = 0; i < clkc_data->clk_mplls_count; i++) 824 for (i = 0; i < clkc_data->clk_mplls_count; i++)
830 clkc_data->clk_mplls[i]->base = clk_base; 825 clkc_data->clk_mplls[i]->base = clk_base;
831 826
832 /* Populate base address for muxes */
833 for (i = 0; i < clkc_data->clk_muxes_count; i++)
834 clkc_data->clk_muxes[i]->reg = clk_base +
835 (u64)clkc_data->clk_muxes[i]->reg;
836
837 /* Populate regmap for the regmap backed clocks */ 827 /* Populate regmap for the regmap backed clocks */
838 for (i = 0; i < ARRAY_SIZE(axg_clk_regmaps); i++) 828 for (i = 0; i < ARRAY_SIZE(axg_clk_regmaps); i++)
839 axg_clk_regmaps[i]->map = map; 829 axg_clk_regmaps[i]->map = map;
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index ec515dc71476..d9f426265774 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -583,16 +583,16 @@ static const char * const clk81_parent_names[] = {
583 "fclk_div3", "fclk_div5" 583 "fclk_div3", "fclk_div5"
584}; 584};
585 585
586static struct clk_mux gxbb_mpeg_clk_sel = { 586static struct clk_regmap gxbb_mpeg_clk_sel = {
587 .reg = (void *)HHI_MPEG_CLK_CNTL, 587 .data = &(struct clk_regmap_mux_data){
588 .mask = 0x7, 588 .offset = HHI_MPEG_CLK_CNTL,
589 .shift = 12, 589 .mask = 0x7,
590 .flags = CLK_MUX_READ_ONLY, 590 .shift = 12,
591 .table = mux_table_clk81, 591 .table = mux_table_clk81,
592 .lock = &meson_clk_lock, 592 },
593 .hw.init = &(struct clk_init_data){ 593 .hw.init = &(struct clk_init_data){
594 .name = "mpeg_clk_sel", 594 .name = "mpeg_clk_sel",
595 .ops = &clk_mux_ro_ops, 595 .ops = &clk_regmap_mux_ro_ops,
596 /* 596 /*
597 * bits 14:12 selects from 8 possible parents: 597 * bits 14:12 selects from 8 possible parents:
598 * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2, 598 * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2,
@@ -634,14 +634,15 @@ static struct clk_regmap gxbb_clk81 = {
634 }, 634 },
635}; 635};
636 636
637static struct clk_mux gxbb_sar_adc_clk_sel = { 637static struct clk_regmap gxbb_sar_adc_clk_sel = {
638 .reg = (void *)HHI_SAR_CLK_CNTL, 638 .data = &(struct clk_regmap_mux_data){
639 .mask = 0x3, 639 .offset = HHI_SAR_CLK_CNTL,
640 .shift = 9, 640 .mask = 0x3,
641 .lock = &meson_clk_lock, 641 .shift = 9,
642 },
642 .hw.init = &(struct clk_init_data){ 643 .hw.init = &(struct clk_init_data){
643 .name = "sar_adc_clk_sel", 644 .name = "sar_adc_clk_sel",
644 .ops = &clk_mux_ops, 645 .ops = &clk_regmap_mux_ops,
645 /* NOTE: The datasheet doesn't list the parents for bit 10 */ 646 /* NOTE: The datasheet doesn't list the parents for bit 10 */
646 .parent_names = (const char *[]){ "xtal", "clk81", }, 647 .parent_names = (const char *[]){ "xtal", "clk81", },
647 .num_parents = 2, 648 .num_parents = 2,
@@ -681,21 +682,20 @@ static struct clk_regmap gxbb_sar_adc_clk = {
681 * muxed by a glitch-free switch. 682 * muxed by a glitch-free switch.
682 */ 683 */
683 684
684static u32 mux_table_mali_0_1[] = {0, 1, 2, 3, 4, 5, 6, 7};
685static const char * const gxbb_mali_0_1_parent_names[] = { 685static const char * const gxbb_mali_0_1_parent_names[] = {
686 "xtal", "gp0_pll", "mpll2", "mpll1", "fclk_div7", 686 "xtal", "gp0_pll", "mpll2", "mpll1", "fclk_div7",
687 "fclk_div4", "fclk_div3", "fclk_div5" 687 "fclk_div4", "fclk_div3", "fclk_div5"
688}; 688};
689 689
690static struct clk_mux gxbb_mali_0_sel = { 690static struct clk_regmap gxbb_mali_0_sel = {
691 .reg = (void *)HHI_MALI_CLK_CNTL, 691 .data = &(struct clk_regmap_mux_data){
692 .mask = 0x7, 692 .offset = HHI_MALI_CLK_CNTL,
693 .shift = 9, 693 .mask = 0x7,
694 .table = mux_table_mali_0_1, 694 .shift = 9,
695 .lock = &meson_clk_lock, 695 },
696 .hw.init = &(struct clk_init_data){ 696 .hw.init = &(struct clk_init_data){
697 .name = "mali_0_sel", 697 .name = "mali_0_sel",
698 .ops = &clk_mux_ops, 698 .ops = &clk_regmap_mux_ops,
699 /* 699 /*
700 * bits 10:9 selects from 8 possible parents: 700 * bits 10:9 selects from 8 possible parents:
701 * xtal, gp0_pll, mpll2, mpll1, fclk_div7, 701 * xtal, gp0_pll, mpll2, mpll1, fclk_div7,
@@ -736,15 +736,15 @@ static struct clk_regmap gxbb_mali_0 = {
736 }, 736 },
737}; 737};
738 738
739static struct clk_mux gxbb_mali_1_sel = { 739static struct clk_regmap gxbb_mali_1_sel = {
740 .reg = (void *)HHI_MALI_CLK_CNTL, 740 .data = &(struct clk_regmap_mux_data){
741 .mask = 0x7, 741 .offset = HHI_MALI_CLK_CNTL,
742 .shift = 25, 742 .mask = 0x7,
743 .table = mux_table_mali_0_1, 743 .shift = 25,
744 .lock = &meson_clk_lock, 744 },
745 .hw.init = &(struct clk_init_data){ 745 .hw.init = &(struct clk_init_data){
746 .name = "mali_1_sel", 746 .name = "mali_1_sel",
747 .ops = &clk_mux_ops, 747 .ops = &clk_regmap_mux_ops,
748 /* 748 /*
749 * bits 10:9 selects from 8 possible parents: 749 * bits 10:9 selects from 8 possible parents:
750 * xtal, gp0_pll, mpll2, mpll1, fclk_div7, 750 * xtal, gp0_pll, mpll2, mpll1, fclk_div7,
@@ -785,36 +785,35 @@ static struct clk_regmap gxbb_mali_1 = {
785 }, 785 },
786}; 786};
787 787
788static u32 mux_table_mali[] = {0, 1};
789static const char * const gxbb_mali_parent_names[] = { 788static const char * const gxbb_mali_parent_names[] = {
790 "mali_0", "mali_1" 789 "mali_0", "mali_1"
791}; 790};
792 791
793static struct clk_mux gxbb_mali = { 792static struct clk_regmap gxbb_mali = {
794 .reg = (void *)HHI_MALI_CLK_CNTL, 793 .data = &(struct clk_regmap_mux_data){
795 .mask = 1, 794 .offset = HHI_MALI_CLK_CNTL,
796 .shift = 31, 795 .mask = 1,
797 .table = mux_table_mali, 796 .shift = 31,
798 .lock = &meson_clk_lock, 797 },
799 .hw.init = &(struct clk_init_data){ 798 .hw.init = &(struct clk_init_data){
800 .name = "mali", 799 .name = "mali",
801 .ops = &clk_mux_ops, 800 .ops = &clk_regmap_mux_ops,
802 .parent_names = gxbb_mali_parent_names, 801 .parent_names = gxbb_mali_parent_names,
803 .num_parents = 2, 802 .num_parents = 2,
804 .flags = CLK_SET_RATE_NO_REPARENT, 803 .flags = CLK_SET_RATE_NO_REPARENT,
805 }, 804 },
806}; 805};
807 806
808static struct clk_mux gxbb_cts_amclk_sel = { 807static struct clk_regmap gxbb_cts_amclk_sel = {
809 .reg = (void *) HHI_AUD_CLK_CNTL, 808 .data = &(struct clk_regmap_mux_data){
810 .mask = 0x3, 809 .offset = HHI_AUD_CLK_CNTL,
811 .shift = 9, 810 .mask = 0x3,
812 /* Default parent unknown (register reset value: 0) */ 811 .shift = 9,
813 .table = (u32[]){ 1, 2, 3 }, 812 .table = (u32[]){ 1, 2, 3 },
814 .lock = &meson_clk_lock, 813 },
815 .hw.init = &(struct clk_init_data){ 814 .hw.init = &(struct clk_init_data){
816 .name = "cts_amclk_sel", 815 .name = "cts_amclk_sel",
817 .ops = &clk_mux_ops, 816 .ops = &clk_regmap_mux_ops,
818 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" }, 817 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" },
819 .num_parents = 3, 818 .num_parents = 3,
820 .flags = CLK_SET_RATE_PARENT, 819 .flags = CLK_SET_RATE_PARENT,
@@ -852,16 +851,16 @@ static struct clk_regmap gxbb_cts_amclk = {
852 }, 851 },
853}; 852};
854 853
855static struct clk_mux gxbb_cts_mclk_i958_sel = { 854static struct clk_regmap gxbb_cts_mclk_i958_sel = {
856 .reg = (void *)HHI_AUD_CLK_CNTL2, 855 .data = &(struct clk_regmap_mux_data){
857 .mask = 0x3, 856 .offset = HHI_AUD_CLK_CNTL2,
858 .shift = 25, 857 .mask = 0x3,
859 /* Default parent unknown (register reset value: 0) */ 858 .shift = 25,
860 .table = (u32[]){ 1, 2, 3 }, 859 .table = (u32[]){ 1, 2, 3 },
861 .lock = &meson_clk_lock, 860 },
862 .hw.init = &(struct clk_init_data) { 861 .hw.init = &(struct clk_init_data) {
863 .name = "cts_mclk_i958_sel", 862 .name = "cts_mclk_i958_sel",
864 .ops = &clk_mux_ops, 863 .ops = &clk_regmap_mux_ops,
865 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" }, 864 .parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" },
866 .num_parents = 3, 865 .num_parents = 3,
867 .flags = CLK_SET_RATE_PARENT, 866 .flags = CLK_SET_RATE_PARENT,
@@ -898,14 +897,15 @@ static struct clk_regmap gxbb_cts_mclk_i958 = {
898 }, 897 },
899}; 898};
900 899
901static struct clk_mux gxbb_cts_i958 = { 900static struct clk_regmap gxbb_cts_i958 = {
902 .reg = (void *)HHI_AUD_CLK_CNTL2, 901 .data = &(struct clk_regmap_mux_data){
903 .mask = 0x1, 902 .offset = HHI_AUD_CLK_CNTL2,
904 .shift = 27, 903 .mask = 0x1,
905 .lock = &meson_clk_lock, 904 .shift = 27,
906 .hw.init = &(struct clk_init_data){ 905 },
906 .hw.init = &(struct clk_init_data){
907 .name = "cts_i958", 907 .name = "cts_i958",
908 .ops = &clk_mux_ops, 908 .ops = &clk_regmap_mux_ops,
909 .parent_names = (const char *[]){ "cts_amclk", "cts_mclk_i958" }, 909 .parent_names = (const char *[]){ "cts_amclk", "cts_mclk_i958" },
910 .num_parents = 2, 910 .num_parents = 2,
911 /* 911 /*
@@ -949,14 +949,15 @@ static const char * const gxbb_32k_clk_parent_names[] = {
949 "xtal", "cts_slow_oscin", "fclk_div3", "fclk_div5" 949 "xtal", "cts_slow_oscin", "fclk_div3", "fclk_div5"
950}; 950};
951 951
952static struct clk_mux gxbb_32k_clk_sel = { 952static struct clk_regmap gxbb_32k_clk_sel = {
953 .reg = (void *)HHI_32K_CLK_CNTL, 953 .data = &(struct clk_regmap_mux_data){
954 .mask = 0x3, 954 .offset = HHI_32K_CLK_CNTL,
955 .shift = 16, 955 .mask = 0x3,
956 .lock = &meson_clk_lock, 956 .shift = 16,
957 .hw.init = &(struct clk_init_data){ 957 },
958 .hw.init = &(struct clk_init_data){
958 .name = "32k_clk_sel", 959 .name = "32k_clk_sel",
959 .ops = &clk_mux_ops, 960 .ops = &clk_regmap_mux_ops,
960 .parent_names = gxbb_32k_clk_parent_names, 961 .parent_names = gxbb_32k_clk_parent_names,
961 .num_parents = 4, 962 .num_parents = 4,
962 .flags = CLK_SET_RATE_PARENT, 963 .flags = CLK_SET_RATE_PARENT,
@@ -975,14 +976,15 @@ static const char * const gxbb_sd_emmc_clk0_parent_names[] = {
975}; 976};
976 977
977/* SDIO clock */ 978/* SDIO clock */
978static struct clk_mux gxbb_sd_emmc_a_clk0_sel = { 979static struct clk_regmap gxbb_sd_emmc_a_clk0_sel = {
979 .reg = (void *)HHI_SD_EMMC_CLK_CNTL, 980 .data = &(struct clk_regmap_mux_data){
980 .mask = 0x7, 981 .offset = HHI_SD_EMMC_CLK_CNTL,
981 .shift = 9, 982 .mask = 0x7,
982 .lock = &meson_clk_lock, 983 .shift = 9,
984 },
983 .hw.init = &(struct clk_init_data) { 985 .hw.init = &(struct clk_init_data) {
984 .name = "sd_emmc_a_clk0_sel", 986 .name = "sd_emmc_a_clk0_sel",
985 .ops = &clk_mux_ops, 987 .ops = &clk_regmap_mux_ops,
986 .parent_names = gxbb_sd_emmc_clk0_parent_names, 988 .parent_names = gxbb_sd_emmc_clk0_parent_names,
987 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), 989 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
988 .flags = CLK_SET_RATE_PARENT, 990 .flags = CLK_SET_RATE_PARENT,
@@ -1020,14 +1022,15 @@ static struct clk_regmap gxbb_sd_emmc_a_clk0 = {
1020}; 1022};
1021 1023
1022/* SDcard clock */ 1024/* SDcard clock */
1023static struct clk_mux gxbb_sd_emmc_b_clk0_sel = { 1025static struct clk_regmap gxbb_sd_emmc_b_clk0_sel = {
1024 .reg = (void *)HHI_SD_EMMC_CLK_CNTL, 1026 .data = &(struct clk_regmap_mux_data){
1025 .mask = 0x7, 1027 .offset = HHI_SD_EMMC_CLK_CNTL,
1026 .shift = 25, 1028 .mask = 0x7,
1027 .lock = &meson_clk_lock, 1029 .shift = 25,
1030 },
1028 .hw.init = &(struct clk_init_data) { 1031 .hw.init = &(struct clk_init_data) {
1029 .name = "sd_emmc_b_clk0_sel", 1032 .name = "sd_emmc_b_clk0_sel",
1030 .ops = &clk_mux_ops, 1033 .ops = &clk_regmap_mux_ops,
1031 .parent_names = gxbb_sd_emmc_clk0_parent_names, 1034 .parent_names = gxbb_sd_emmc_clk0_parent_names,
1032 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), 1035 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
1033 .flags = CLK_SET_RATE_PARENT, 1036 .flags = CLK_SET_RATE_PARENT,
@@ -1065,14 +1068,15 @@ static struct clk_regmap gxbb_sd_emmc_b_clk0 = {
1065}; 1068};
1066 1069
1067/* EMMC/NAND clock */ 1070/* EMMC/NAND clock */
1068static struct clk_mux gxbb_sd_emmc_c_clk0_sel = { 1071static struct clk_regmap gxbb_sd_emmc_c_clk0_sel = {
1069 .reg = (void *)HHI_NAND_CLK_CNTL, 1072 .data = &(struct clk_regmap_mux_data){
1070 .mask = 0x7, 1073 .offset = HHI_NAND_CLK_CNTL,
1071 .shift = 9, 1074 .mask = 0x7,
1072 .lock = &meson_clk_lock, 1075 .shift = 9,
1076 },
1073 .hw.init = &(struct clk_init_data) { 1077 .hw.init = &(struct clk_init_data) {
1074 .name = "sd_emmc_c_clk0_sel", 1078 .name = "sd_emmc_c_clk0_sel",
1075 .ops = &clk_mux_ops, 1079 .ops = &clk_regmap_mux_ops,
1076 .parent_names = gxbb_sd_emmc_clk0_parent_names, 1080 .parent_names = gxbb_sd_emmc_clk0_parent_names,
1077 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), 1081 .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names),
1078 .flags = CLK_SET_RATE_PARENT, 1082 .flags = CLK_SET_RATE_PARENT,
@@ -1111,20 +1115,19 @@ static struct clk_regmap gxbb_sd_emmc_c_clk0 = {
1111 1115
1112/* VPU Clock */ 1116/* VPU Clock */
1113 1117
1114static u32 mux_table_vpu[] = {0, 1, 2, 3};
1115static const char * const gxbb_vpu_parent_names[] = { 1118static const char * const gxbb_vpu_parent_names[] = {
1116 "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7" 1119 "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7"
1117}; 1120};
1118 1121
1119static struct clk_mux gxbb_vpu_0_sel = { 1122static struct clk_regmap gxbb_vpu_0_sel = {
1120 .reg = (void *)HHI_VPU_CLK_CNTL, 1123 .data = &(struct clk_regmap_mux_data){
1121 .mask = 0x3, 1124 .offset = HHI_VPU_CLK_CNTL,
1122 .shift = 9, 1125 .mask = 0x3,
1123 .lock = &meson_clk_lock, 1126 .shift = 9,
1124 .table = mux_table_vpu, 1127 },
1125 .hw.init = &(struct clk_init_data){ 1128 .hw.init = &(struct clk_init_data){
1126 .name = "vpu_0_sel", 1129 .name = "vpu_0_sel",
1127 .ops = &clk_mux_ops, 1130 .ops = &clk_regmap_mux_ops,
1128 /* 1131 /*
1129 * bits 9:10 selects from 4 possible parents: 1132 * bits 9:10 selects from 4 possible parents:
1130 * fclk_div4, fclk_div3, fclk_div5, fclk_div7, 1133 * fclk_div4, fclk_div3, fclk_div5, fclk_div7,
@@ -1164,15 +1167,15 @@ static struct clk_regmap gxbb_vpu_0 = {
1164 }, 1167 },
1165}; 1168};
1166 1169
1167static struct clk_mux gxbb_vpu_1_sel = { 1170static struct clk_regmap gxbb_vpu_1_sel = {
1168 .reg = (void *)HHI_VPU_CLK_CNTL, 1171 .data = &(struct clk_regmap_mux_data){
1169 .mask = 0x3, 1172 .offset = HHI_VPU_CLK_CNTL,
1170 .shift = 25, 1173 .mask = 0x3,
1171 .lock = &meson_clk_lock, 1174 .shift = 25,
1172 .table = mux_table_vpu, 1175 },
1173 .hw.init = &(struct clk_init_data){ 1176 .hw.init = &(struct clk_init_data){
1174 .name = "vpu_1_sel", 1177 .name = "vpu_1_sel",
1175 .ops = &clk_mux_ops, 1178 .ops = &clk_regmap_mux_ops,
1176 /* 1179 /*
1177 * bits 25:26 selects from 4 possible parents: 1180 * bits 25:26 selects from 4 possible parents:
1178 * fclk_div4, fclk_div3, fclk_div5, fclk_div7, 1181 * fclk_div4, fclk_div3, fclk_div5, fclk_div7,
@@ -1212,14 +1215,15 @@ static struct clk_regmap gxbb_vpu_1 = {
1212 }, 1215 },
1213}; 1216};
1214 1217
1215static struct clk_mux gxbb_vpu = { 1218static struct clk_regmap gxbb_vpu = {
1216 .reg = (void *)HHI_VPU_CLK_CNTL, 1219 .data = &(struct clk_regmap_mux_data){
1217 .mask = 1, 1220 .offset = HHI_VPU_CLK_CNTL,
1218 .shift = 31, 1221 .mask = 1,
1219 .lock = &meson_clk_lock, 1222 .shift = 31,
1223 },
1220 .hw.init = &(struct clk_init_data){ 1224 .hw.init = &(struct clk_init_data){
1221 .name = "vpu", 1225 .name = "vpu",
1222 .ops = &clk_mux_ops, 1226 .ops = &clk_regmap_mux_ops,
1223 /* 1227 /*
1224 * bit 31 selects from 2 possible parents: 1228 * bit 31 selects from 2 possible parents:
1225 * vpu_0 or vpu_1 1229 * vpu_0 or vpu_1
@@ -1232,20 +1236,19 @@ static struct clk_mux gxbb_vpu = {
1232 1236
1233/* VAPB Clock */ 1237/* VAPB Clock */
1234 1238
1235static u32 mux_table_vapb[] = {0, 1, 2, 3};
1236static const char * const gxbb_vapb_parent_names[] = { 1239static const char * const gxbb_vapb_parent_names[] = {
1237 "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7" 1240 "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7"
1238}; 1241};
1239 1242
1240static struct clk_mux gxbb_vapb_0_sel = { 1243static struct clk_regmap gxbb_vapb_0_sel = {
1241 .reg = (void *)HHI_VAPBCLK_CNTL, 1244 .data = &(struct clk_regmap_mux_data){
1242 .mask = 0x3, 1245 .offset = HHI_VAPBCLK_CNTL,
1243 .shift = 9, 1246 .mask = 0x3,
1244 .lock = &meson_clk_lock, 1247 .shift = 9,
1245 .table = mux_table_vapb, 1248 },
1246 .hw.init = &(struct clk_init_data){ 1249 .hw.init = &(struct clk_init_data){
1247 .name = "vapb_0_sel", 1250 .name = "vapb_0_sel",
1248 .ops = &clk_mux_ops, 1251 .ops = &clk_regmap_mux_ops,
1249 /* 1252 /*
1250 * bits 9:10 selects from 4 possible parents: 1253 * bits 9:10 selects from 4 possible parents:
1251 * fclk_div4, fclk_div3, fclk_div5, fclk_div7, 1254 * fclk_div4, fclk_div3, fclk_div5, fclk_div7,
@@ -1285,15 +1288,15 @@ static struct clk_regmap gxbb_vapb_0 = {
1285 }, 1288 },
1286}; 1289};
1287 1290
1288static struct clk_mux gxbb_vapb_1_sel = { 1291static struct clk_regmap gxbb_vapb_1_sel = {
1289 .reg = (void *)HHI_VAPBCLK_CNTL, 1292 .data = &(struct clk_regmap_mux_data){
1290 .mask = 0x3, 1293 .offset = HHI_VAPBCLK_CNTL,
1291 .shift = 25, 1294 .mask = 0x3,
1292 .lock = &meson_clk_lock, 1295 .shift = 25,
1293 .table = mux_table_vapb, 1296 },
1294 .hw.init = &(struct clk_init_data){ 1297 .hw.init = &(struct clk_init_data){
1295 .name = "vapb_1_sel", 1298 .name = "vapb_1_sel",
1296 .ops = &clk_mux_ops, 1299 .ops = &clk_regmap_mux_ops,
1297 /* 1300 /*
1298 * bits 25:26 selects from 4 possible parents: 1301 * bits 25:26 selects from 4 possible parents:
1299 * fclk_div4, fclk_div3, fclk_div5, fclk_div7, 1302 * fclk_div4, fclk_div3, fclk_div5, fclk_div7,
@@ -1333,14 +1336,15 @@ static struct clk_regmap gxbb_vapb_1 = {
1333 }, 1336 },
1334}; 1337};
1335 1338
1336static struct clk_mux gxbb_vapb_sel = { 1339static struct clk_regmap gxbb_vapb_sel = {
1337 .reg = (void *)HHI_VAPBCLK_CNTL, 1340 .data = &(struct clk_regmap_mux_data){
1338 .mask = 1, 1341 .offset = HHI_VAPBCLK_CNTL,
1339 .shift = 31, 1342 .mask = 1,
1340 .lock = &meson_clk_lock, 1343 .shift = 31,
1344 },
1341 .hw.init = &(struct clk_init_data){ 1345 .hw.init = &(struct clk_init_data){
1342 .name = "vapb_sel", 1346 .name = "vapb_sel",
1343 .ops = &clk_mux_ops, 1347 .ops = &clk_regmap_mux_ops,
1344 /* 1348 /*
1345 * bit 31 selects from 2 possible parents: 1349 * bit 31 selects from 2 possible parents:
1346 * vapb_0 or vapb_1 1350 * vapb_0 or vapb_1
@@ -1773,27 +1777,6 @@ static struct meson_clk_mpll *const gxbb_clk_mplls[] = {
1773 &gxbb_mpll2, 1777 &gxbb_mpll2,
1774}; 1778};
1775 1779
1776static struct clk_mux *const gxbb_clk_muxes[] = {
1777 &gxbb_mpeg_clk_sel,
1778 &gxbb_sar_adc_clk_sel,
1779 &gxbb_mali_0_sel,
1780 &gxbb_mali_1_sel,
1781 &gxbb_mali,
1782 &gxbb_cts_amclk_sel,
1783 &gxbb_cts_mclk_i958_sel,
1784 &gxbb_cts_i958,
1785 &gxbb_32k_clk_sel,
1786 &gxbb_sd_emmc_a_clk0_sel,
1787 &gxbb_sd_emmc_b_clk0_sel,
1788 &gxbb_sd_emmc_c_clk0_sel,
1789 &gxbb_vpu_0_sel,
1790 &gxbb_vpu_1_sel,
1791 &gxbb_vpu,
1792 &gxbb_vapb_0_sel,
1793 &gxbb_vapb_1_sel,
1794 &gxbb_vapb_sel,
1795};
1796
1797static struct meson_clk_audio_divider *const gxbb_audio_dividers[] = { 1780static struct meson_clk_audio_divider *const gxbb_audio_dividers[] = {
1798 &gxbb_cts_amclk_div, 1781 &gxbb_cts_amclk_div,
1799}; 1782};
@@ -1908,6 +1891,24 @@ static struct clk_regmap *const gx_clk_regmaps[] = {
1908 &gxbb_vpu_1_div, 1891 &gxbb_vpu_1_div,
1909 &gxbb_vapb_0_div, 1892 &gxbb_vapb_0_div,
1910 &gxbb_vapb_1_div, 1893 &gxbb_vapb_1_div,
1894 &gxbb_mpeg_clk_sel,
1895 &gxbb_sar_adc_clk_sel,
1896 &gxbb_mali_0_sel,
1897 &gxbb_mali_1_sel,
1898 &gxbb_mali,
1899 &gxbb_cts_amclk_sel,
1900 &gxbb_cts_mclk_i958_sel,
1901 &gxbb_cts_i958,
1902 &gxbb_32k_clk_sel,
1903 &gxbb_sd_emmc_a_clk0_sel,
1904 &gxbb_sd_emmc_b_clk0_sel,
1905 &gxbb_sd_emmc_c_clk0_sel,
1906 &gxbb_vpu_0_sel,
1907 &gxbb_vpu_1_sel,
1908 &gxbb_vpu,
1909 &gxbb_vapb_0_sel,
1910 &gxbb_vapb_1_sel,
1911 &gxbb_vapb_sel,
1911}; 1912};
1912 1913
1913struct clkc_data { 1914struct clkc_data {
@@ -1915,8 +1916,6 @@ struct clkc_data {
1915 unsigned int clk_mplls_count; 1916 unsigned int clk_mplls_count;
1916 struct meson_clk_pll *const *clk_plls; 1917 struct meson_clk_pll *const *clk_plls;
1917 unsigned int clk_plls_count; 1918 unsigned int clk_plls_count;
1918 struct clk_mux *const *clk_muxes;
1919 unsigned int clk_muxes_count;
1920 struct meson_clk_audio_divider *const *clk_audio_dividers; 1919 struct meson_clk_audio_divider *const *clk_audio_dividers;
1921 unsigned int clk_audio_dividers_count; 1920 unsigned int clk_audio_dividers_count;
1922 struct clk_hw_onecell_data *hw_onecell_data; 1921 struct clk_hw_onecell_data *hw_onecell_data;
@@ -1927,8 +1926,6 @@ static const struct clkc_data gxbb_clkc_data = {
1927 .clk_mplls_count = ARRAY_SIZE(gxbb_clk_mplls), 1926 .clk_mplls_count = ARRAY_SIZE(gxbb_clk_mplls),
1928 .clk_plls = gxbb_clk_plls, 1927 .clk_plls = gxbb_clk_plls,
1929 .clk_plls_count = ARRAY_SIZE(gxbb_clk_plls), 1928 .clk_plls_count = ARRAY_SIZE(gxbb_clk_plls),
1930 .clk_muxes = gxbb_clk_muxes,
1931 .clk_muxes_count = ARRAY_SIZE(gxbb_clk_muxes),
1932 .clk_audio_dividers = gxbb_audio_dividers, 1929 .clk_audio_dividers = gxbb_audio_dividers,
1933 .clk_audio_dividers_count = ARRAY_SIZE(gxbb_audio_dividers), 1930 .clk_audio_dividers_count = ARRAY_SIZE(gxbb_audio_dividers),
1934 .hw_onecell_data = &gxbb_hw_onecell_data, 1931 .hw_onecell_data = &gxbb_hw_onecell_data,
@@ -1939,8 +1936,6 @@ static const struct clkc_data gxl_clkc_data = {
1939 .clk_mplls_count = ARRAY_SIZE(gxbb_clk_mplls), 1936 .clk_mplls_count = ARRAY_SIZE(gxbb_clk_mplls),
1940 .clk_plls = gxl_clk_plls, 1937 .clk_plls = gxl_clk_plls,
1941 .clk_plls_count = ARRAY_SIZE(gxl_clk_plls), 1938 .clk_plls_count = ARRAY_SIZE(gxl_clk_plls),
1942 .clk_muxes = gxbb_clk_muxes,
1943 .clk_muxes_count = ARRAY_SIZE(gxbb_clk_muxes),
1944 .clk_audio_dividers = gxbb_audio_dividers, 1939 .clk_audio_dividers = gxbb_audio_dividers,
1945 .clk_audio_dividers_count = ARRAY_SIZE(gxbb_audio_dividers), 1940 .clk_audio_dividers_count = ARRAY_SIZE(gxbb_audio_dividers),
1946 .hw_onecell_data = &gxl_hw_onecell_data, 1941 .hw_onecell_data = &gxl_hw_onecell_data,
@@ -1993,11 +1988,6 @@ static int gxbb_clkc_probe(struct platform_device *pdev)
1993 for (i = 0; i < clkc_data->clk_mplls_count; i++) 1988 for (i = 0; i < clkc_data->clk_mplls_count; i++)
1994 clkc_data->clk_mplls[i]->base = clk_base; 1989 clkc_data->clk_mplls[i]->base = clk_base;
1995 1990
1996 /* Populate base address for muxes */
1997 for (i = 0; i < clkc_data->clk_muxes_count; i++)
1998 clkc_data->clk_muxes[i]->reg = clk_base +
1999 (u64)clkc_data->clk_muxes[i]->reg;
2000
2001 /* Populate base address for the audio dividers */ 1991 /* Populate base address for the audio dividers */
2002 for (i = 0; i < clkc_data->clk_audio_dividers_count; i++) 1992 for (i = 0; i < clkc_data->clk_audio_dividers_count; i++)
2003 clkc_data->clk_audio_dividers[i]->base = clk_base; 1993 clkc_data->clk_audio_dividers[i]->base = clk_base;
diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
index e9c5278072cd..e643f7556f5e 100644
--- a/drivers/clk/meson/meson8b.c
+++ b/drivers/clk/meson/meson8b.c
@@ -370,17 +370,16 @@ static struct meson_clk_cpu meson8b_cpu_clk = {
370}; 370};
371 371
372static u32 mux_table_clk81[] = { 6, 5, 7 }; 372static u32 mux_table_clk81[] = { 6, 5, 7 };
373 373static struct clk_regmap meson8b_mpeg_clk_sel = {
374struct clk_mux meson8b_mpeg_clk_sel = { 374 .data = &(struct clk_regmap_mux_data){
375 .reg = (void *)HHI_MPEG_CLK_CNTL, 375 .offset = HHI_MPEG_CLK_CNTL,
376 .mask = 0x7, 376 .mask = 0x7,
377 .shift = 12, 377 .shift = 12,
378 .flags = CLK_MUX_READ_ONLY, 378 .table = mux_table_clk81,
379 .table = mux_table_clk81, 379 },
380 .lock = &meson_clk_lock,
381 .hw.init = &(struct clk_init_data){ 380 .hw.init = &(struct clk_init_data){
382 .name = "mpeg_clk_sel", 381 .name = "mpeg_clk_sel",
383 .ops = &clk_mux_ro_ops, 382 .ops = &clk_regmap_mux_ro_ops,
384 /* 383 /*
385 * FIXME bits 14:12 selects from 8 possible parents: 384 * FIXME bits 14:12 selects from 8 possible parents:
386 * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2, 385 * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2,
@@ -620,10 +619,6 @@ static struct meson_clk_mpll *const meson8b_clk_mplls[] = {
620 &meson8b_mpll2, 619 &meson8b_mpll2,
621}; 620};
622 621
623static struct clk_mux *const meson8b_clk_muxes[] = {
624 &meson8b_mpeg_clk_sel,
625};
626
627static struct clk_regmap *const meson8b_clk_regmaps[] = { 622static struct clk_regmap *const meson8b_clk_regmaps[] = {
628 &meson8b_clk81, 623 &meson8b_clk81,
629 &meson8b_ddr, 624 &meson8b_ddr,
@@ -704,6 +699,7 @@ static struct clk_regmap *const meson8b_clk_regmaps[] = {
704 &meson8b_ao_ahb_bus, 699 &meson8b_ao_ahb_bus,
705 &meson8b_ao_iface, 700 &meson8b_ao_iface,
706 &meson8b_mpeg_clk_div, 701 &meson8b_mpeg_clk_div,
702 &meson8b_mpeg_clk_sel,
707}; 703};
708 704
709static const struct meson8b_clk_reset_line { 705static const struct meson8b_clk_reset_line {
@@ -837,11 +833,6 @@ static int meson8b_clkc_probe(struct platform_device *pdev)
837 /* Populate the base address for CPU clk */ 833 /* Populate the base address for CPU clk */
838 meson8b_cpu_clk.base = clk_base; 834 meson8b_cpu_clk.base = clk_base;
839 835
840 /* Populate base address for muxes */
841 for (i = 0; i < ARRAY_SIZE(meson8b_clk_muxes); i++)
842 meson8b_clk_muxes[i]->reg = clk_base +
843 (u32)meson8b_clk_muxes[i]->reg;
844
845 /* Populate regmap for the regmap backed clocks */ 836 /* Populate regmap for the regmap backed clocks */
846 for (i = 0; i < ARRAY_SIZE(meson8b_clk_regmaps); i++) 837 for (i = 0; i < ARRAY_SIZE(meson8b_clk_regmaps); i++)
847 meson8b_clk_regmaps[i]->map = map; 838 meson8b_clk_regmaps[i]->map = map;