aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYixun Lan <yixun.lan@amlogic.com>2018-07-02 17:31:18 -0400
committerJerome Brunet <jbrunet@baylibre.com>2018-07-09 07:49:11 -0400
commitcddcb20b2bb36401e038d0ae41ba8a956d91f82e (patch)
treee2fcecaea7ea56f7dd808008f7066fd06307ae16
parent85ddc1a32cace10bc8b7dc5dfae98b6a1785fc0c (diff)
clk: meson-axg: add clocks required by pcie driver
Adding clocks for the pcie driver. Due to the ASIC design, the pcie controller re-use part of the mipi clock logic, so the mipi clock is also added. Tested-by: Jianxin Qin <jianxin.qin@amlogic.com> Signed-off-by: Yixun Lan <yixun.lan@amlogic.com> [amended to remove unnecessary locales] Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
-rw-r--r--drivers/clk/meson/axg.c145
-rw-r--r--drivers/clk/meson/axg.h6
2 files changed, 150 insertions, 1 deletions
diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c
index 3fb884db1b10..2d458092884a 100644
--- a/drivers/clk/meson/axg.c
+++ b/drivers/clk/meson/axg.c
@@ -625,6 +625,137 @@ static struct clk_regmap axg_mpll3 = {
625 }, 625 },
626}; 626};
627 627
628static const struct pll_rate_table axg_pcie_pll_rate_table[] = {
629 {
630 .rate = 100000000,
631 .m = 200,
632 .n = 3,
633 .od = 1,
634 .od2 = 3,
635 },
636 { /* sentinel */ },
637};
638
639static const struct reg_sequence axg_pcie_init_regs[] = {
640 { .reg = HHI_PCIE_PLL_CNTL, .def = 0x400106c8 },
641 { .reg = HHI_PCIE_PLL_CNTL1, .def = 0x0084a2aa },
642 { .reg = HHI_PCIE_PLL_CNTL2, .def = 0xb75020be },
643 { .reg = HHI_PCIE_PLL_CNTL3, .def = 0x0a47488e },
644 { .reg = HHI_PCIE_PLL_CNTL4, .def = 0xc000004d },
645 { .reg = HHI_PCIE_PLL_CNTL5, .def = 0x00078000 },
646 { .reg = HHI_PCIE_PLL_CNTL6, .def = 0x002323c6 },
647};
648
649static struct clk_regmap axg_pcie_pll = {
650 .data = &(struct meson_clk_pll_data){
651 .m = {
652 .reg_off = HHI_PCIE_PLL_CNTL,
653 .shift = 0,
654 .width = 9,
655 },
656 .n = {
657 .reg_off = HHI_PCIE_PLL_CNTL,
658 .shift = 9,
659 .width = 5,
660 },
661 .od = {
662 .reg_off = HHI_PCIE_PLL_CNTL,
663 .shift = 16,
664 .width = 2,
665 },
666 .od2 = {
667 .reg_off = HHI_PCIE_PLL_CNTL6,
668 .shift = 6,
669 .width = 2,
670 },
671 .frac = {
672 .reg_off = HHI_PCIE_PLL_CNTL1,
673 .shift = 0,
674 .width = 12,
675 },
676 .l = {
677 .reg_off = HHI_PCIE_PLL_CNTL,
678 .shift = 31,
679 .width = 1,
680 },
681 .rst = {
682 .reg_off = HHI_PCIE_PLL_CNTL,
683 .shift = 29,
684 .width = 1,
685 },
686 .table = axg_pcie_pll_rate_table,
687 .init_regs = axg_pcie_init_regs,
688 .init_count = ARRAY_SIZE(axg_pcie_init_regs),
689 },
690 .hw.init = &(struct clk_init_data){
691 .name = "pcie_pll",
692 .ops = &meson_clk_pll_ops,
693 .parent_names = (const char *[]){ "xtal" },
694 .num_parents = 1,
695 },
696};
697
698static struct clk_regmap axg_pcie_mux = {
699 .data = &(struct clk_regmap_mux_data){
700 .offset = HHI_PCIE_PLL_CNTL6,
701 .mask = 0x1,
702 .shift = 2,
703 },
704 .hw.init = &(struct clk_init_data){
705 .name = "pcie_mux",
706 .ops = &clk_regmap_mux_ops,
707 .parent_names = (const char *[]){ "mpll3", "pcie_pll" },
708 .num_parents = 2,
709 .flags = CLK_SET_RATE_PARENT,
710 },
711};
712
713static struct clk_regmap axg_pcie_ref = {
714 .data = &(struct clk_regmap_mux_data){
715 .offset = HHI_PCIE_PLL_CNTL6,
716 .mask = 0x1,
717 .shift = 1,
718 /* skip the parent 0, reserved for debug */
719 .table = (u32[]){ 1 },
720 },
721 .hw.init = &(struct clk_init_data){
722 .name = "pcie_ref",
723 .ops = &clk_regmap_mux_ops,
724 .parent_names = (const char *[]){ "pcie_mux" },
725 .num_parents = 1,
726 .flags = CLK_SET_RATE_PARENT,
727 },
728};
729
730static struct clk_regmap axg_pcie_cml_en0 = {
731 .data = &(struct clk_regmap_gate_data){
732 .offset = HHI_PCIE_PLL_CNTL6,
733 .bit_idx = 4,
734 },
735 .hw.init = &(struct clk_init_data) {
736 .name = "pcie_cml_en0",
737 .ops = &clk_regmap_gate_ops,
738 .parent_names = (const char *[]){ "pcie_ref" },
739 .num_parents = 1,
740 .flags = CLK_SET_RATE_PARENT,
741
742 },
743};
744
745static struct clk_regmap axg_pcie_cml_en1 = {
746 .data = &(struct clk_regmap_gate_data){
747 .offset = HHI_PCIE_PLL_CNTL6,
748 .bit_idx = 3,
749 },
750 .hw.init = &(struct clk_init_data) {
751 .name = "pcie_cml_en1",
752 .ops = &clk_regmap_gate_ops,
753 .parent_names = (const char *[]){ "pcie_ref" },
754 .num_parents = 1,
755 .flags = CLK_SET_RATE_PARENT,
756 },
757};
758
628static u32 mux_table_clk81[] = { 0, 2, 3, 4, 5, 6, 7 }; 759static u32 mux_table_clk81[] = { 0, 2, 3, 4, 5, 6, 7 };
629static const char * const clk81_parent_names[] = { 760static const char * const clk81_parent_names[] = {
630 "xtal", "fclk_div7", "mpll1", "mpll2", "fclk_div4", 761 "xtal", "fclk_div7", "mpll1", "mpll2", "fclk_div4",
@@ -820,6 +951,7 @@ static MESON_GATE(axg_mmc_pclk, HHI_GCLK_MPEG2, 11);
820static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25); 951static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25);
821static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26); 952static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
822static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30); 953static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30);
954static MESON_GATE(axg_mipi_enable, HHI_MIPI_CNTL0, 29);
823 955
824/* Always On (AO) domain gates */ 956/* Always On (AO) domain gates */
825 957
@@ -909,6 +1041,13 @@ static struct clk_hw_onecell_data axg_hw_onecell_data = {
909 [CLKID_FCLK_DIV4_DIV] = &axg_fclk_div4_div.hw, 1041 [CLKID_FCLK_DIV4_DIV] = &axg_fclk_div4_div.hw,
910 [CLKID_FCLK_DIV5_DIV] = &axg_fclk_div5_div.hw, 1042 [CLKID_FCLK_DIV5_DIV] = &axg_fclk_div5_div.hw,
911 [CLKID_FCLK_DIV7_DIV] = &axg_fclk_div7_div.hw, 1043 [CLKID_FCLK_DIV7_DIV] = &axg_fclk_div7_div.hw,
1044 [CLKID_PCIE_PLL] = &axg_pcie_pll.hw,
1045 [CLKID_PCIE_MUX] = &axg_pcie_mux.hw,
1046 [CLKID_PCIE_REF] = &axg_pcie_ref.hw,
1047 [CLKID_PCIE_CML_EN0] = &axg_pcie_cml_en0.hw,
1048 [CLKID_PCIE_CML_EN1] = &axg_pcie_cml_en1.hw,
1049 [CLKID_MIPI_ENABLE] = &axg_mipi_enable.hw,
1050
912 [NR_CLKS] = NULL, 1051 [NR_CLKS] = NULL,
913 }, 1052 },
914 .num = NR_CLKS, 1053 .num = NR_CLKS,
@@ -987,6 +1126,12 @@ static struct clk_regmap *const axg_clk_regmaps[] = {
987 &axg_fclk_div4, 1126 &axg_fclk_div4,
988 &axg_fclk_div5, 1127 &axg_fclk_div5,
989 &axg_fclk_div7, 1128 &axg_fclk_div7,
1129 &axg_pcie_pll,
1130 &axg_pcie_mux,
1131 &axg_pcie_ref,
1132 &axg_pcie_cml_en0,
1133 &axg_pcie_cml_en1,
1134 &axg_mipi_enable,
990}; 1135};
991 1136
992static const struct of_device_id clkc_match_table[] = { 1137static const struct of_device_id clkc_match_table[] = {
diff --git a/drivers/clk/meson/axg.h b/drivers/clk/meson/axg.h
index b421df6a7ea0..6e55ebd6c77d 100644
--- a/drivers/clk/meson/axg.h
+++ b/drivers/clk/meson/axg.h
@@ -16,6 +16,7 @@
16 * Register offsets from the data sheet must be multiplied by 4 before 16 * Register offsets from the data sheet must be multiplied by 4 before
17 * adding them to the base address to get the right value. 17 * adding them to the base address to get the right value.
18 */ 18 */
19#define HHI_MIPI_CNTL0 0x00
19#define HHI_GP0_PLL_CNTL 0x40 20#define HHI_GP0_PLL_CNTL 0x40
20#define HHI_GP0_PLL_CNTL2 0x44 21#define HHI_GP0_PLL_CNTL2 0x44
21#define HHI_GP0_PLL_CNTL3 0x48 22#define HHI_GP0_PLL_CNTL3 0x48
@@ -127,8 +128,11 @@
127#define CLKID_FCLK_DIV4_DIV 73 128#define CLKID_FCLK_DIV4_DIV 73
128#define CLKID_FCLK_DIV5_DIV 74 129#define CLKID_FCLK_DIV5_DIV 74
129#define CLKID_FCLK_DIV7_DIV 75 130#define CLKID_FCLK_DIV7_DIV 75
131#define CLKID_PCIE_PLL 76
132#define CLKID_PCIE_MUX 77
133#define CLKID_PCIE_REF 78
130 134
131#define NR_CLKS 76 135#define NR_CLKS 82
132 136
133/* include the CLKIDs that have been made part of the DT binding */ 137/* include the CLKIDs that have been made part of the DT binding */
134#include <dt-bindings/clock/axg-clkc.h> 138#include <dt-bindings/clock/axg-clkc.h>