Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2015 Endless Mobile, Inc.
0004  * Author: Carlo Caione <carlo@endlessm.com>
0005  *
0006  * Copyright (c) 2016 BayLibre, Inc.
0007  * Michael Turquette <mturquette@baylibre.com>
0008  */
0009 
0010 #include <linux/clk.h>
0011 #include <linux/clk-provider.h>
0012 #include <linux/init.h>
0013 #include <linux/mfd/syscon.h>
0014 #include <linux/of_address.h>
0015 #include <linux/reset-controller.h>
0016 #include <linux/slab.h>
0017 #include <linux/regmap.h>
0018 
0019 #include "meson8b.h"
0020 #include "clk-regmap.h"
0021 #include "clk-pll.h"
0022 #include "clk-mpll.h"
0023 
0024 static DEFINE_SPINLOCK(meson_clk_lock);
0025 
0026 struct meson8b_clk_reset {
0027     struct reset_controller_dev reset;
0028     struct regmap *regmap;
0029 };
0030 
0031 static const struct pll_params_table sys_pll_params_table[] = {
0032     PLL_PARAMS(50, 1),
0033     PLL_PARAMS(51, 1),
0034     PLL_PARAMS(52, 1),
0035     PLL_PARAMS(53, 1),
0036     PLL_PARAMS(54, 1),
0037     PLL_PARAMS(55, 1),
0038     PLL_PARAMS(56, 1),
0039     PLL_PARAMS(57, 1),
0040     PLL_PARAMS(58, 1),
0041     PLL_PARAMS(59, 1),
0042     PLL_PARAMS(60, 1),
0043     PLL_PARAMS(61, 1),
0044     PLL_PARAMS(62, 1),
0045     PLL_PARAMS(63, 1),
0046     PLL_PARAMS(64, 1),
0047     PLL_PARAMS(65, 1),
0048     PLL_PARAMS(66, 1),
0049     PLL_PARAMS(67, 1),
0050     PLL_PARAMS(68, 1),
0051     PLL_PARAMS(84, 1),
0052     { /* sentinel */ },
0053 };
0054 
0055 static struct clk_regmap meson8b_fixed_pll_dco = {
0056     .data = &(struct meson_clk_pll_data){
0057         .en = {
0058             .reg_off = HHI_MPLL_CNTL,
0059             .shift   = 30,
0060             .width   = 1,
0061         },
0062         .m = {
0063             .reg_off = HHI_MPLL_CNTL,
0064             .shift   = 0,
0065             .width   = 9,
0066         },
0067         .n = {
0068             .reg_off = HHI_MPLL_CNTL,
0069             .shift   = 9,
0070             .width   = 5,
0071         },
0072         .frac = {
0073             .reg_off = HHI_MPLL_CNTL2,
0074             .shift   = 0,
0075             .width   = 12,
0076         },
0077         .l = {
0078             .reg_off = HHI_MPLL_CNTL,
0079             .shift   = 31,
0080             .width   = 1,
0081         },
0082         .rst = {
0083             .reg_off = HHI_MPLL_CNTL,
0084             .shift   = 29,
0085             .width   = 1,
0086         },
0087     },
0088     .hw.init = &(struct clk_init_data){
0089         .name = "fixed_pll_dco",
0090         .ops = &meson_clk_pll_ro_ops,
0091         .parent_data = &(const struct clk_parent_data) {
0092             .fw_name = "xtal",
0093             .name = "xtal",
0094             .index = -1,
0095         },
0096         .num_parents = 1,
0097     },
0098 };
0099 
0100 static struct clk_regmap meson8b_fixed_pll = {
0101     .data = &(struct clk_regmap_div_data){
0102         .offset = HHI_MPLL_CNTL,
0103         .shift = 16,
0104         .width = 2,
0105         .flags = CLK_DIVIDER_POWER_OF_TWO,
0106     },
0107     .hw.init = &(struct clk_init_data){
0108         .name = "fixed_pll",
0109         .ops = &clk_regmap_divider_ro_ops,
0110         .parent_hws = (const struct clk_hw *[]) {
0111             &meson8b_fixed_pll_dco.hw
0112         },
0113         .num_parents = 1,
0114         /*
0115          * This clock won't ever change at runtime so
0116          * CLK_SET_RATE_PARENT is not required
0117          */
0118     },
0119 };
0120 
0121 static struct clk_fixed_factor hdmi_pll_dco_in = {
0122     .mult = 2,
0123     .div = 1,
0124     .hw.init = &(struct clk_init_data){
0125         .name = "hdmi_pll_dco_in",
0126         .ops = &clk_fixed_factor_ops,
0127         .parent_data = &(const struct clk_parent_data) {
0128             .fw_name = "xtal",
0129             .index = -1,
0130         },
0131         .num_parents = 1,
0132     },
0133 };
0134 
0135 /*
0136  * Taken from the vendor driver for the 2970/2975MHz (both only differ in the
0137  * FRAC part in HHI_VID_PLL_CNTL2) where these values are identical for Meson8,
0138  * Meson8b and Meson8m2. This doubles the input (or output - it's not clear
0139  * which one but the result is the same) clock. The vendor driver additionally
0140  * has the following comment about: "optimise HPLL VCO 2.97GHz performance".
0141  */
0142 static const struct reg_sequence meson8b_hdmi_pll_init_regs[] = {
0143     { .reg = HHI_VID_PLL_CNTL2, .def = 0x69c84000 },
0144     { .reg = HHI_VID_PLL_CNTL3, .def = 0x8a46c023 },
0145     { .reg = HHI_VID_PLL_CNTL4, .def = 0x4123b100 },
0146     { .reg = HHI_VID_PLL_CNTL5, .def = 0x00012385 },
0147     { .reg = HHI_VID2_PLL_CNTL2,    .def = 0x0430a800 },
0148 };
0149 
0150 static const struct pll_params_table hdmi_pll_params_table[] = {
0151     PLL_PARAMS(40, 1),
0152     PLL_PARAMS(42, 1),
0153     PLL_PARAMS(44, 1),
0154     PLL_PARAMS(45, 1),
0155     PLL_PARAMS(49, 1),
0156     PLL_PARAMS(52, 1),
0157     PLL_PARAMS(54, 1),
0158     PLL_PARAMS(56, 1),
0159     PLL_PARAMS(59, 1),
0160     PLL_PARAMS(60, 1),
0161     PLL_PARAMS(61, 1),
0162     PLL_PARAMS(62, 1),
0163     PLL_PARAMS(64, 1),
0164     PLL_PARAMS(66, 1),
0165     PLL_PARAMS(68, 1),
0166     PLL_PARAMS(71, 1),
0167     PLL_PARAMS(82, 1),
0168     { /* sentinel */ }
0169 };
0170 
0171 static struct clk_regmap meson8b_hdmi_pll_dco = {
0172     .data = &(struct meson_clk_pll_data){
0173         .en = {
0174             .reg_off = HHI_VID_PLL_CNTL,
0175             .shift   = 30,
0176             .width   = 1,
0177         },
0178         .m = {
0179             .reg_off = HHI_VID_PLL_CNTL,
0180             .shift   = 0,
0181             .width   = 9,
0182         },
0183         .n = {
0184             .reg_off = HHI_VID_PLL_CNTL,
0185             .shift   = 10,
0186             .width   = 5,
0187         },
0188         .frac = {
0189             .reg_off = HHI_VID_PLL_CNTL2,
0190             .shift   = 0,
0191             .width   = 12,
0192         },
0193         .l = {
0194             .reg_off = HHI_VID_PLL_CNTL,
0195             .shift   = 31,
0196             .width   = 1,
0197         },
0198         .rst = {
0199             .reg_off = HHI_VID_PLL_CNTL,
0200             .shift   = 29,
0201             .width   = 1,
0202         },
0203         .table = hdmi_pll_params_table,
0204         .init_regs = meson8b_hdmi_pll_init_regs,
0205         .init_count = ARRAY_SIZE(meson8b_hdmi_pll_init_regs),
0206     },
0207     .hw.init = &(struct clk_init_data){
0208         /* sometimes also called "HPLL" or "HPLL PLL" */
0209         .name = "hdmi_pll_dco",
0210         .ops = &meson_clk_pll_ops,
0211         .parent_hws = (const struct clk_hw *[]) {
0212             &hdmi_pll_dco_in.hw
0213         },
0214         .num_parents = 1,
0215     },
0216 };
0217 
0218 static struct clk_regmap meson8b_hdmi_pll_lvds_out = {
0219     .data = &(struct clk_regmap_div_data){
0220         .offset = HHI_VID_PLL_CNTL,
0221         .shift = 16,
0222         .width = 2,
0223         .flags = CLK_DIVIDER_POWER_OF_TWO,
0224     },
0225     .hw.init = &(struct clk_init_data){
0226         .name = "hdmi_pll_lvds_out",
0227         .ops = &clk_regmap_divider_ops,
0228         .parent_hws = (const struct clk_hw *[]) {
0229             &meson8b_hdmi_pll_dco.hw
0230         },
0231         .num_parents = 1,
0232         .flags = CLK_SET_RATE_PARENT,
0233     },
0234 };
0235 
0236 static struct clk_regmap meson8b_hdmi_pll_hdmi_out = {
0237     .data = &(struct clk_regmap_div_data){
0238         .offset = HHI_VID_PLL_CNTL,
0239         .shift = 18,
0240         .width = 2,
0241         .flags = CLK_DIVIDER_POWER_OF_TWO,
0242     },
0243     .hw.init = &(struct clk_init_data){
0244         .name = "hdmi_pll_hdmi_out",
0245         .ops = &clk_regmap_divider_ops,
0246         .parent_hws = (const struct clk_hw *[]) {
0247             &meson8b_hdmi_pll_dco.hw
0248         },
0249         .num_parents = 1,
0250         .flags = CLK_SET_RATE_PARENT,
0251     },
0252 };
0253 
0254 static struct clk_regmap meson8b_sys_pll_dco = {
0255     .data = &(struct meson_clk_pll_data){
0256         .en = {
0257             .reg_off = HHI_SYS_PLL_CNTL,
0258             .shift   = 30,
0259             .width   = 1,
0260         },
0261         .m = {
0262             .reg_off = HHI_SYS_PLL_CNTL,
0263             .shift   = 0,
0264             .width   = 9,
0265         },
0266         .n = {
0267             .reg_off = HHI_SYS_PLL_CNTL,
0268             .shift   = 9,
0269             .width   = 5,
0270         },
0271         .l = {
0272             .reg_off = HHI_SYS_PLL_CNTL,
0273             .shift   = 31,
0274             .width   = 1,
0275         },
0276         .rst = {
0277             .reg_off = HHI_SYS_PLL_CNTL,
0278             .shift   = 29,
0279             .width   = 1,
0280         },
0281         .table = sys_pll_params_table,
0282     },
0283     .hw.init = &(struct clk_init_data){
0284         .name = "sys_pll_dco",
0285         .ops = &meson_clk_pll_ops,
0286         .parent_data = &(const struct clk_parent_data) {
0287             .fw_name = "xtal",
0288             .name = "xtal",
0289             .index = -1,
0290         },
0291         .num_parents = 1,
0292     },
0293 };
0294 
0295 static struct clk_regmap meson8b_sys_pll = {
0296     .data = &(struct clk_regmap_div_data){
0297         .offset = HHI_SYS_PLL_CNTL,
0298         .shift = 16,
0299         .width = 2,
0300         .flags = CLK_DIVIDER_POWER_OF_TWO,
0301     },
0302     .hw.init = &(struct clk_init_data){
0303         .name = "sys_pll",
0304         .ops = &clk_regmap_divider_ops,
0305         .parent_hws = (const struct clk_hw *[]) {
0306             &meson8b_sys_pll_dco.hw
0307         },
0308         .num_parents = 1,
0309         .flags = CLK_SET_RATE_PARENT,
0310     },
0311 };
0312 
0313 static struct clk_fixed_factor meson8b_fclk_div2_div = {
0314     .mult = 1,
0315     .div = 2,
0316     .hw.init = &(struct clk_init_data){
0317         .name = "fclk_div2_div",
0318         .ops = &clk_fixed_factor_ops,
0319         .parent_hws = (const struct clk_hw *[]) {
0320             &meson8b_fixed_pll.hw
0321         },
0322         .num_parents = 1,
0323     },
0324 };
0325 
0326 static struct clk_regmap meson8b_fclk_div2 = {
0327     .data = &(struct clk_regmap_gate_data){
0328         .offset = HHI_MPLL_CNTL6,
0329         .bit_idx = 27,
0330     },
0331     .hw.init = &(struct clk_init_data){
0332         .name = "fclk_div2",
0333         .ops = &clk_regmap_gate_ops,
0334         .parent_hws = (const struct clk_hw *[]) {
0335             &meson8b_fclk_div2_div.hw
0336         },
0337         .num_parents = 1,
0338     },
0339 };
0340 
0341 static struct clk_fixed_factor meson8b_fclk_div3_div = {
0342     .mult = 1,
0343     .div = 3,
0344     .hw.init = &(struct clk_init_data){
0345         .name = "fclk_div3_div",
0346         .ops = &clk_fixed_factor_ops,
0347         .parent_hws = (const struct clk_hw *[]) {
0348             &meson8b_fixed_pll.hw
0349         },
0350         .num_parents = 1,
0351     },
0352 };
0353 
0354 static struct clk_regmap meson8b_fclk_div3 = {
0355     .data = &(struct clk_regmap_gate_data){
0356         .offset = HHI_MPLL_CNTL6,
0357         .bit_idx = 28,
0358     },
0359     .hw.init = &(struct clk_init_data){
0360         .name = "fclk_div3",
0361         .ops = &clk_regmap_gate_ops,
0362         .parent_hws = (const struct clk_hw *[]) {
0363             &meson8b_fclk_div3_div.hw
0364         },
0365         .num_parents = 1,
0366     },
0367 };
0368 
0369 static struct clk_fixed_factor meson8b_fclk_div4_div = {
0370     .mult = 1,
0371     .div = 4,
0372     .hw.init = &(struct clk_init_data){
0373         .name = "fclk_div4_div",
0374         .ops = &clk_fixed_factor_ops,
0375         .parent_hws = (const struct clk_hw *[]) {
0376             &meson8b_fixed_pll.hw
0377         },
0378         .num_parents = 1,
0379     },
0380 };
0381 
0382 static struct clk_regmap meson8b_fclk_div4 = {
0383     .data = &(struct clk_regmap_gate_data){
0384         .offset = HHI_MPLL_CNTL6,
0385         .bit_idx = 29,
0386     },
0387     .hw.init = &(struct clk_init_data){
0388         .name = "fclk_div4",
0389         .ops = &clk_regmap_gate_ops,
0390         .parent_hws = (const struct clk_hw *[]) {
0391             &meson8b_fclk_div4_div.hw
0392         },
0393         .num_parents = 1,
0394     },
0395 };
0396 
0397 static struct clk_fixed_factor meson8b_fclk_div5_div = {
0398     .mult = 1,
0399     .div = 5,
0400     .hw.init = &(struct clk_init_data){
0401         .name = "fclk_div5_div",
0402         .ops = &clk_fixed_factor_ops,
0403         .parent_hws = (const struct clk_hw *[]) {
0404             &meson8b_fixed_pll.hw
0405         },
0406         .num_parents = 1,
0407     },
0408 };
0409 
0410 static struct clk_regmap meson8b_fclk_div5 = {
0411     .data = &(struct clk_regmap_gate_data){
0412         .offset = HHI_MPLL_CNTL6,
0413         .bit_idx = 30,
0414     },
0415     .hw.init = &(struct clk_init_data){
0416         .name = "fclk_div5",
0417         .ops = &clk_regmap_gate_ops,
0418         .parent_hws = (const struct clk_hw *[]) {
0419             &meson8b_fclk_div5_div.hw
0420         },
0421         .num_parents = 1,
0422     },
0423 };
0424 
0425 static struct clk_fixed_factor meson8b_fclk_div7_div = {
0426     .mult = 1,
0427     .div = 7,
0428     .hw.init = &(struct clk_init_data){
0429         .name = "fclk_div7_div",
0430         .ops = &clk_fixed_factor_ops,
0431         .parent_hws = (const struct clk_hw *[]) {
0432             &meson8b_fixed_pll.hw
0433         },
0434         .num_parents = 1,
0435     },
0436 };
0437 
0438 static struct clk_regmap meson8b_fclk_div7 = {
0439     .data = &(struct clk_regmap_gate_data){
0440         .offset = HHI_MPLL_CNTL6,
0441         .bit_idx = 31,
0442     },
0443     .hw.init = &(struct clk_init_data){
0444         .name = "fclk_div7",
0445         .ops = &clk_regmap_gate_ops,
0446         .parent_hws = (const struct clk_hw *[]) {
0447             &meson8b_fclk_div7_div.hw
0448         },
0449         .num_parents = 1,
0450     },
0451 };
0452 
0453 static struct clk_regmap meson8b_mpll_prediv = {
0454     .data = &(struct clk_regmap_div_data){
0455         .offset = HHI_MPLL_CNTL5,
0456         .shift = 12,
0457         .width = 1,
0458     },
0459     .hw.init = &(struct clk_init_data){
0460         .name = "mpll_prediv",
0461         .ops = &clk_regmap_divider_ro_ops,
0462         .parent_hws = (const struct clk_hw *[]) {
0463             &meson8b_fixed_pll.hw
0464         },
0465         .num_parents = 1,
0466     },
0467 };
0468 
0469 static struct clk_regmap meson8b_mpll0_div = {
0470     .data = &(struct meson_clk_mpll_data){
0471         .sdm = {
0472             .reg_off = HHI_MPLL_CNTL7,
0473             .shift   = 0,
0474             .width   = 14,
0475         },
0476         .sdm_en = {
0477             .reg_off = HHI_MPLL_CNTL7,
0478             .shift   = 15,
0479             .width   = 1,
0480         },
0481         .n2 = {
0482             .reg_off = HHI_MPLL_CNTL7,
0483             .shift   = 16,
0484             .width   = 9,
0485         },
0486         .ssen = {
0487             .reg_off = HHI_MPLL_CNTL,
0488             .shift   = 25,
0489             .width   = 1,
0490         },
0491         .lock = &meson_clk_lock,
0492     },
0493     .hw.init = &(struct clk_init_data){
0494         .name = "mpll0_div",
0495         .ops = &meson_clk_mpll_ops,
0496         .parent_hws = (const struct clk_hw *[]) {
0497             &meson8b_mpll_prediv.hw
0498         },
0499         .num_parents = 1,
0500     },
0501 };
0502 
0503 static struct clk_regmap meson8b_mpll0 = {
0504     .data = &(struct clk_regmap_gate_data){
0505         .offset = HHI_MPLL_CNTL7,
0506         .bit_idx = 14,
0507     },
0508     .hw.init = &(struct clk_init_data){
0509         .name = "mpll0",
0510         .ops = &clk_regmap_gate_ops,
0511         .parent_hws = (const struct clk_hw *[]) {
0512             &meson8b_mpll0_div.hw
0513         },
0514         .num_parents = 1,
0515         .flags = CLK_SET_RATE_PARENT,
0516     },
0517 };
0518 
0519 static struct clk_regmap meson8b_mpll1_div = {
0520     .data = &(struct meson_clk_mpll_data){
0521         .sdm = {
0522             .reg_off = HHI_MPLL_CNTL8,
0523             .shift   = 0,
0524             .width   = 14,
0525         },
0526         .sdm_en = {
0527             .reg_off = HHI_MPLL_CNTL8,
0528             .shift   = 15,
0529             .width   = 1,
0530         },
0531         .n2 = {
0532             .reg_off = HHI_MPLL_CNTL8,
0533             .shift   = 16,
0534             .width   = 9,
0535         },
0536         .lock = &meson_clk_lock,
0537     },
0538     .hw.init = &(struct clk_init_data){
0539         .name = "mpll1_div",
0540         .ops = &meson_clk_mpll_ops,
0541         .parent_hws = (const struct clk_hw *[]) {
0542             &meson8b_mpll_prediv.hw
0543         },
0544         .num_parents = 1,
0545     },
0546 };
0547 
0548 static struct clk_regmap meson8b_mpll1 = {
0549     .data = &(struct clk_regmap_gate_data){
0550         .offset = HHI_MPLL_CNTL8,
0551         .bit_idx = 14,
0552     },
0553     .hw.init = &(struct clk_init_data){
0554         .name = "mpll1",
0555         .ops = &clk_regmap_gate_ops,
0556         .parent_hws = (const struct clk_hw *[]) {
0557             &meson8b_mpll1_div.hw
0558         },
0559         .num_parents = 1,
0560         .flags = CLK_SET_RATE_PARENT,
0561     },
0562 };
0563 
0564 static struct clk_regmap meson8b_mpll2_div = {
0565     .data = &(struct meson_clk_mpll_data){
0566         .sdm = {
0567             .reg_off = HHI_MPLL_CNTL9,
0568             .shift   = 0,
0569             .width   = 14,
0570         },
0571         .sdm_en = {
0572             .reg_off = HHI_MPLL_CNTL9,
0573             .shift   = 15,
0574             .width   = 1,
0575         },
0576         .n2 = {
0577             .reg_off = HHI_MPLL_CNTL9,
0578             .shift   = 16,
0579             .width   = 9,
0580         },
0581         .lock = &meson_clk_lock,
0582     },
0583     .hw.init = &(struct clk_init_data){
0584         .name = "mpll2_div",
0585         .ops = &meson_clk_mpll_ops,
0586         .parent_hws = (const struct clk_hw *[]) {
0587             &meson8b_mpll_prediv.hw
0588         },
0589         .num_parents = 1,
0590     },
0591 };
0592 
0593 static struct clk_regmap meson8b_mpll2 = {
0594     .data = &(struct clk_regmap_gate_data){
0595         .offset = HHI_MPLL_CNTL9,
0596         .bit_idx = 14,
0597     },
0598     .hw.init = &(struct clk_init_data){
0599         .name = "mpll2",
0600         .ops = &clk_regmap_gate_ops,
0601         .parent_hws = (const struct clk_hw *[]) {
0602             &meson8b_mpll2_div.hw
0603         },
0604         .num_parents = 1,
0605         .flags = CLK_SET_RATE_PARENT,
0606     },
0607 };
0608 
0609 static u32 mux_table_clk81[]    = { 6, 5, 7 };
0610 static struct clk_regmap meson8b_mpeg_clk_sel = {
0611     .data = &(struct clk_regmap_mux_data){
0612         .offset = HHI_MPEG_CLK_CNTL,
0613         .mask = 0x7,
0614         .shift = 12,
0615         .table = mux_table_clk81,
0616     },
0617     .hw.init = &(struct clk_init_data){
0618         .name = "mpeg_clk_sel",
0619         .ops = &clk_regmap_mux_ro_ops,
0620         /*
0621          * FIXME bits 14:12 selects from 8 possible parents:
0622          * xtal, 1'b0 (wtf), fclk_div7, mpll_clkout1, mpll_clkout2,
0623          * fclk_div4, fclk_div3, fclk_div5
0624          */
0625         .parent_hws = (const struct clk_hw *[]) {
0626             &meson8b_fclk_div3.hw,
0627             &meson8b_fclk_div4.hw,
0628             &meson8b_fclk_div5.hw,
0629         },
0630         .num_parents = 3,
0631     },
0632 };
0633 
0634 static struct clk_regmap meson8b_mpeg_clk_div = {
0635     .data = &(struct clk_regmap_div_data){
0636         .offset = HHI_MPEG_CLK_CNTL,
0637         .shift = 0,
0638         .width = 7,
0639     },
0640     .hw.init = &(struct clk_init_data){
0641         .name = "mpeg_clk_div",
0642         .ops = &clk_regmap_divider_ro_ops,
0643         .parent_hws = (const struct clk_hw *[]) {
0644             &meson8b_mpeg_clk_sel.hw
0645         },
0646         .num_parents = 1,
0647     },
0648 };
0649 
0650 static struct clk_regmap meson8b_clk81 = {
0651     .data = &(struct clk_regmap_gate_data){
0652         .offset = HHI_MPEG_CLK_CNTL,
0653         .bit_idx = 7,
0654     },
0655     .hw.init = &(struct clk_init_data){
0656         .name = "clk81",
0657         .ops = &clk_regmap_gate_ops,
0658         .parent_hws = (const struct clk_hw *[]) {
0659             &meson8b_mpeg_clk_div.hw
0660         },
0661         .num_parents = 1,
0662         .flags = CLK_IS_CRITICAL,
0663     },
0664 };
0665 
0666 static struct clk_regmap meson8b_cpu_in_sel = {
0667     .data = &(struct clk_regmap_mux_data){
0668         .offset = HHI_SYS_CPU_CLK_CNTL0,
0669         .mask = 0x1,
0670         .shift = 0,
0671     },
0672     .hw.init = &(struct clk_init_data){
0673         .name = "cpu_in_sel",
0674         .ops = &clk_regmap_mux_ops,
0675         .parent_data = (const struct clk_parent_data[]) {
0676             { .fw_name = "xtal", .name = "xtal", .index = -1, },
0677             { .hw = &meson8b_sys_pll.hw, },
0678         },
0679         .num_parents = 2,
0680         .flags = (CLK_SET_RATE_PARENT |
0681               CLK_SET_RATE_NO_REPARENT),
0682     },
0683 };
0684 
0685 static struct clk_fixed_factor meson8b_cpu_in_div2 = {
0686     .mult = 1,
0687     .div = 2,
0688     .hw.init = &(struct clk_init_data){
0689         .name = "cpu_in_div2",
0690         .ops = &clk_fixed_factor_ops,
0691         .parent_hws = (const struct clk_hw *[]) {
0692             &meson8b_cpu_in_sel.hw
0693         },
0694         .num_parents = 1,
0695         .flags = CLK_SET_RATE_PARENT,
0696     },
0697 };
0698 
0699 static struct clk_fixed_factor meson8b_cpu_in_div3 = {
0700     .mult = 1,
0701     .div = 3,
0702     .hw.init = &(struct clk_init_data){
0703         .name = "cpu_in_div3",
0704         .ops = &clk_fixed_factor_ops,
0705         .parent_hws = (const struct clk_hw *[]) {
0706             &meson8b_cpu_in_sel.hw
0707         },
0708         .num_parents = 1,
0709         .flags = CLK_SET_RATE_PARENT,
0710     },
0711 };
0712 
0713 static const struct clk_div_table cpu_scale_table[] = {
0714     { .val = 1, .div = 4 },
0715     { .val = 2, .div = 6 },
0716     { .val = 3, .div = 8 },
0717     { .val = 4, .div = 10 },
0718     { .val = 5, .div = 12 },
0719     { .val = 6, .div = 14 },
0720     { .val = 7, .div = 16 },
0721     { .val = 8, .div = 18 },
0722     { /* sentinel */ },
0723 };
0724 
0725 static struct clk_regmap meson8b_cpu_scale_div = {
0726     .data = &(struct clk_regmap_div_data){
0727         .offset =  HHI_SYS_CPU_CLK_CNTL1,
0728         .shift = 20,
0729         .width = 10,
0730         .table = cpu_scale_table,
0731         .flags = CLK_DIVIDER_ALLOW_ZERO,
0732     },
0733     .hw.init = &(struct clk_init_data){
0734         .name = "cpu_scale_div",
0735         .ops = &clk_regmap_divider_ops,
0736         .parent_hws = (const struct clk_hw *[]) {
0737             &meson8b_cpu_in_sel.hw
0738         },
0739         .num_parents = 1,
0740         .flags = CLK_SET_RATE_PARENT,
0741     },
0742 };
0743 
0744 static u32 mux_table_cpu_scale_out_sel[] = { 0, 1, 3 };
0745 static struct clk_regmap meson8b_cpu_scale_out_sel = {
0746     .data = &(struct clk_regmap_mux_data){
0747         .offset = HHI_SYS_CPU_CLK_CNTL0,
0748         .mask = 0x3,
0749         .shift = 2,
0750         .table = mux_table_cpu_scale_out_sel,
0751     },
0752     .hw.init = &(struct clk_init_data){
0753         .name = "cpu_scale_out_sel",
0754         .ops = &clk_regmap_mux_ops,
0755         /*
0756          * NOTE: We are skipping the parent with value 0x2 (which is
0757          * meson8b_cpu_in_div3) because it results in a duty cycle of
0758          * 33% which makes the system unstable and can result in a
0759          * lockup of the whole system.
0760          */
0761         .parent_hws = (const struct clk_hw *[]) {
0762             &meson8b_cpu_in_sel.hw,
0763             &meson8b_cpu_in_div2.hw,
0764             &meson8b_cpu_scale_div.hw,
0765         },
0766         .num_parents = 3,
0767         .flags = CLK_SET_RATE_PARENT,
0768     },
0769 };
0770 
0771 static struct clk_regmap meson8b_cpu_clk = {
0772     .data = &(struct clk_regmap_mux_data){
0773         .offset = HHI_SYS_CPU_CLK_CNTL0,
0774         .mask = 0x1,
0775         .shift = 7,
0776     },
0777     .hw.init = &(struct clk_init_data){
0778         .name = "cpu_clk",
0779         .ops = &clk_regmap_mux_ops,
0780         .parent_data = (const struct clk_parent_data[]) {
0781             { .fw_name = "xtal", .name = "xtal", .index = -1, },
0782             { .hw = &meson8b_cpu_scale_out_sel.hw, },
0783         },
0784         .num_parents = 2,
0785         .flags = (CLK_SET_RATE_PARENT |
0786               CLK_SET_RATE_NO_REPARENT |
0787               CLK_IS_CRITICAL),
0788     },
0789 };
0790 
0791 static struct clk_regmap meson8b_nand_clk_sel = {
0792     .data = &(struct clk_regmap_mux_data){
0793         .offset = HHI_NAND_CLK_CNTL,
0794         .mask = 0x7,
0795         .shift = 9,
0796         .flags = CLK_MUX_ROUND_CLOSEST,
0797     },
0798     .hw.init = &(struct clk_init_data){
0799         .name = "nand_clk_sel",
0800         .ops = &clk_regmap_mux_ops,
0801         /* FIXME all other parents are unknown: */
0802         .parent_data = (const struct clk_parent_data[]) {
0803             { .hw = &meson8b_fclk_div4.hw, },
0804             { .hw = &meson8b_fclk_div3.hw, },
0805             { .hw = &meson8b_fclk_div5.hw, },
0806             { .hw = &meson8b_fclk_div7.hw, },
0807             { .fw_name = "xtal", .name = "xtal", .index = -1, },
0808         },
0809         .num_parents = 5,
0810         .flags = CLK_SET_RATE_PARENT,
0811     },
0812 };
0813 
0814 static struct clk_regmap meson8b_nand_clk_div = {
0815     .data = &(struct clk_regmap_div_data){
0816         .offset =  HHI_NAND_CLK_CNTL,
0817         .shift = 0,
0818         .width = 7,
0819         .flags = CLK_DIVIDER_ROUND_CLOSEST,
0820     },
0821     .hw.init = &(struct clk_init_data){
0822         .name = "nand_clk_div",
0823         .ops = &clk_regmap_divider_ops,
0824         .parent_hws = (const struct clk_hw *[]) {
0825             &meson8b_nand_clk_sel.hw
0826         },
0827         .num_parents = 1,
0828         .flags = CLK_SET_RATE_PARENT,
0829     },
0830 };
0831 
0832 static struct clk_regmap meson8b_nand_clk_gate = {
0833     .data = &(struct clk_regmap_gate_data){
0834         .offset = HHI_NAND_CLK_CNTL,
0835         .bit_idx = 8,
0836     },
0837     .hw.init = &(struct clk_init_data){
0838         .name = "nand_clk_gate",
0839         .ops = &clk_regmap_gate_ops,
0840         .parent_hws = (const struct clk_hw *[]) {
0841             &meson8b_nand_clk_div.hw
0842         },
0843         .num_parents = 1,
0844         .flags = CLK_SET_RATE_PARENT,
0845     },
0846 };
0847 
0848 static struct clk_fixed_factor meson8b_cpu_clk_div2 = {
0849     .mult = 1,
0850     .div = 2,
0851     .hw.init = &(struct clk_init_data){
0852         .name = "cpu_clk_div2",
0853         .ops = &clk_fixed_factor_ops,
0854         .parent_hws = (const struct clk_hw *[]) {
0855             &meson8b_cpu_clk.hw
0856         },
0857         .num_parents = 1,
0858     },
0859 };
0860 
0861 static struct clk_fixed_factor meson8b_cpu_clk_div3 = {
0862     .mult = 1,
0863     .div = 3,
0864     .hw.init = &(struct clk_init_data){
0865         .name = "cpu_clk_div3",
0866         .ops = &clk_fixed_factor_ops,
0867         .parent_hws = (const struct clk_hw *[]) {
0868             &meson8b_cpu_clk.hw
0869         },
0870         .num_parents = 1,
0871     },
0872 };
0873 
0874 static struct clk_fixed_factor meson8b_cpu_clk_div4 = {
0875     .mult = 1,
0876     .div = 4,
0877     .hw.init = &(struct clk_init_data){
0878         .name = "cpu_clk_div4",
0879         .ops = &clk_fixed_factor_ops,
0880         .parent_hws = (const struct clk_hw *[]) {
0881             &meson8b_cpu_clk.hw
0882         },
0883         .num_parents = 1,
0884     },
0885 };
0886 
0887 static struct clk_fixed_factor meson8b_cpu_clk_div5 = {
0888     .mult = 1,
0889     .div = 5,
0890     .hw.init = &(struct clk_init_data){
0891         .name = "cpu_clk_div5",
0892         .ops = &clk_fixed_factor_ops,
0893         .parent_hws = (const struct clk_hw *[]) {
0894             &meson8b_cpu_clk.hw
0895         },
0896         .num_parents = 1,
0897     },
0898 };
0899 
0900 static struct clk_fixed_factor meson8b_cpu_clk_div6 = {
0901     .mult = 1,
0902     .div = 6,
0903     .hw.init = &(struct clk_init_data){
0904         .name = "cpu_clk_div6",
0905         .ops = &clk_fixed_factor_ops,
0906         .parent_hws = (const struct clk_hw *[]) {
0907             &meson8b_cpu_clk.hw
0908         },
0909         .num_parents = 1,
0910     },
0911 };
0912 
0913 static struct clk_fixed_factor meson8b_cpu_clk_div7 = {
0914     .mult = 1,
0915     .div = 7,
0916     .hw.init = &(struct clk_init_data){
0917         .name = "cpu_clk_div7",
0918         .ops = &clk_fixed_factor_ops,
0919         .parent_hws = (const struct clk_hw *[]) {
0920             &meson8b_cpu_clk.hw
0921         },
0922         .num_parents = 1,
0923     },
0924 };
0925 
0926 static struct clk_fixed_factor meson8b_cpu_clk_div8 = {
0927     .mult = 1,
0928     .div = 8,
0929     .hw.init = &(struct clk_init_data){
0930         .name = "cpu_clk_div8",
0931         .ops = &clk_fixed_factor_ops,
0932         .parent_hws = (const struct clk_hw *[]) {
0933             &meson8b_cpu_clk.hw
0934         },
0935         .num_parents = 1,
0936     },
0937 };
0938 
0939 static u32 mux_table_apb[] = { 1, 2, 3, 4, 5, 6, 7 };
0940 static struct clk_regmap meson8b_apb_clk_sel = {
0941     .data = &(struct clk_regmap_mux_data){
0942         .offset = HHI_SYS_CPU_CLK_CNTL1,
0943         .mask = 0x7,
0944         .shift = 3,
0945         .table = mux_table_apb,
0946     },
0947     .hw.init = &(struct clk_init_data){
0948         .name = "apb_clk_sel",
0949         .ops = &clk_regmap_mux_ops,
0950         .parent_hws = (const struct clk_hw *[]) {
0951             &meson8b_cpu_clk_div2.hw,
0952             &meson8b_cpu_clk_div3.hw,
0953             &meson8b_cpu_clk_div4.hw,
0954             &meson8b_cpu_clk_div5.hw,
0955             &meson8b_cpu_clk_div6.hw,
0956             &meson8b_cpu_clk_div7.hw,
0957             &meson8b_cpu_clk_div8.hw,
0958         },
0959         .num_parents = 7,
0960     },
0961 };
0962 
0963 static struct clk_regmap meson8b_apb_clk_gate = {
0964     .data = &(struct clk_regmap_gate_data){
0965         .offset = HHI_SYS_CPU_CLK_CNTL1,
0966         .bit_idx = 16,
0967         .flags = CLK_GATE_SET_TO_DISABLE,
0968     },
0969     .hw.init = &(struct clk_init_data){
0970         .name = "apb_clk_dis",
0971         .ops = &clk_regmap_gate_ro_ops,
0972         .parent_hws = (const struct clk_hw *[]) {
0973             &meson8b_apb_clk_sel.hw
0974         },
0975         .num_parents = 1,
0976         .flags = CLK_SET_RATE_PARENT,
0977     },
0978 };
0979 
0980 static struct clk_regmap meson8b_periph_clk_sel = {
0981     .data = &(struct clk_regmap_mux_data){
0982         .offset = HHI_SYS_CPU_CLK_CNTL1,
0983         .mask = 0x7,
0984         .shift = 6,
0985     },
0986     .hw.init = &(struct clk_init_data){
0987         .name = "periph_clk_sel",
0988         .ops = &clk_regmap_mux_ops,
0989         .parent_hws = (const struct clk_hw *[]) {
0990             &meson8b_cpu_clk_div2.hw,
0991             &meson8b_cpu_clk_div3.hw,
0992             &meson8b_cpu_clk_div4.hw,
0993             &meson8b_cpu_clk_div5.hw,
0994             &meson8b_cpu_clk_div6.hw,
0995             &meson8b_cpu_clk_div7.hw,
0996             &meson8b_cpu_clk_div8.hw,
0997         },
0998         .num_parents = 7,
0999     },
1000 };
1001 
1002 static struct clk_regmap meson8b_periph_clk_gate = {
1003     .data = &(struct clk_regmap_gate_data){
1004         .offset = HHI_SYS_CPU_CLK_CNTL1,
1005         .bit_idx = 17,
1006         .flags = CLK_GATE_SET_TO_DISABLE,
1007     },
1008     .hw.init = &(struct clk_init_data){
1009         .name = "periph_clk_dis",
1010         .ops = &clk_regmap_gate_ro_ops,
1011         .parent_hws = (const struct clk_hw *[]) {
1012             &meson8b_periph_clk_sel.hw
1013         },
1014         .num_parents = 1,
1015         .flags = CLK_SET_RATE_PARENT,
1016     },
1017 };
1018 
1019 static u32 mux_table_axi[] = { 1, 2, 3, 4, 5, 6, 7 };
1020 static struct clk_regmap meson8b_axi_clk_sel = {
1021     .data = &(struct clk_regmap_mux_data){
1022         .offset = HHI_SYS_CPU_CLK_CNTL1,
1023         .mask = 0x7,
1024         .shift = 9,
1025         .table = mux_table_axi,
1026     },
1027     .hw.init = &(struct clk_init_data){
1028         .name = "axi_clk_sel",
1029         .ops = &clk_regmap_mux_ops,
1030         .parent_hws = (const struct clk_hw *[]) {
1031             &meson8b_cpu_clk_div2.hw,
1032             &meson8b_cpu_clk_div3.hw,
1033             &meson8b_cpu_clk_div4.hw,
1034             &meson8b_cpu_clk_div5.hw,
1035             &meson8b_cpu_clk_div6.hw,
1036             &meson8b_cpu_clk_div7.hw,
1037             &meson8b_cpu_clk_div8.hw,
1038         },
1039         .num_parents = 7,
1040     },
1041 };
1042 
1043 static struct clk_regmap meson8b_axi_clk_gate = {
1044     .data = &(struct clk_regmap_gate_data){
1045         .offset = HHI_SYS_CPU_CLK_CNTL1,
1046         .bit_idx = 18,
1047         .flags = CLK_GATE_SET_TO_DISABLE,
1048     },
1049     .hw.init = &(struct clk_init_data){
1050         .name = "axi_clk_dis",
1051         .ops = &clk_regmap_gate_ro_ops,
1052         .parent_hws = (const struct clk_hw *[]) {
1053             &meson8b_axi_clk_sel.hw
1054         },
1055         .num_parents = 1,
1056         .flags = CLK_SET_RATE_PARENT,
1057     },
1058 };
1059 
1060 static struct clk_regmap meson8b_l2_dram_clk_sel = {
1061     .data = &(struct clk_regmap_mux_data){
1062         .offset = HHI_SYS_CPU_CLK_CNTL1,
1063         .mask = 0x7,
1064         .shift = 12,
1065     },
1066     .hw.init = &(struct clk_init_data){
1067         .name = "l2_dram_clk_sel",
1068         .ops = &clk_regmap_mux_ops,
1069         .parent_hws = (const struct clk_hw *[]) {
1070             &meson8b_cpu_clk_div2.hw,
1071             &meson8b_cpu_clk_div3.hw,
1072             &meson8b_cpu_clk_div4.hw,
1073             &meson8b_cpu_clk_div5.hw,
1074             &meson8b_cpu_clk_div6.hw,
1075             &meson8b_cpu_clk_div7.hw,
1076             &meson8b_cpu_clk_div8.hw,
1077         },
1078         .num_parents = 7,
1079     },
1080 };
1081 
1082 static struct clk_regmap meson8b_l2_dram_clk_gate = {
1083     .data = &(struct clk_regmap_gate_data){
1084         .offset = HHI_SYS_CPU_CLK_CNTL1,
1085         .bit_idx = 19,
1086         .flags = CLK_GATE_SET_TO_DISABLE,
1087     },
1088     .hw.init = &(struct clk_init_data){
1089         .name = "l2_dram_clk_dis",
1090         .ops = &clk_regmap_gate_ro_ops,
1091         .parent_hws = (const struct clk_hw *[]) {
1092             &meson8b_l2_dram_clk_sel.hw
1093         },
1094         .num_parents = 1,
1095         .flags = CLK_SET_RATE_PARENT,
1096     },
1097 };
1098 
1099 /* also called LVDS_CLK_EN */
1100 static struct clk_regmap meson8b_vid_pll_lvds_en = {
1101     .data = &(struct clk_regmap_gate_data){
1102         .offset = HHI_VID_DIVIDER_CNTL,
1103         .bit_idx = 11,
1104     },
1105     .hw.init = &(struct clk_init_data){
1106         .name = "vid_pll_lvds_en",
1107         .ops = &clk_regmap_gate_ops,
1108         .parent_hws = (const struct clk_hw *[]) {
1109             &meson8b_hdmi_pll_lvds_out.hw
1110         },
1111         .num_parents = 1,
1112         .flags = CLK_SET_RATE_PARENT,
1113     },
1114 };
1115 
1116 static struct clk_regmap meson8b_vid_pll_in_sel = {
1117     .data = &(struct clk_regmap_mux_data){
1118         .offset = HHI_VID_DIVIDER_CNTL,
1119         .mask = 0x1,
1120         .shift = 15,
1121     },
1122     .hw.init = &(struct clk_init_data){
1123         .name = "vid_pll_in_sel",
1124         .ops = &clk_regmap_mux_ops,
1125         /*
1126          * TODO: depending on the SoC there is also a second parent:
1127          * Meson8: unknown
1128          * Meson8b: hdmi_pll_dco
1129          * Meson8m2: vid2_pll
1130          */
1131         .parent_hws = (const struct clk_hw *[]) {
1132             &meson8b_vid_pll_lvds_en.hw
1133         },
1134         .num_parents = 1,
1135         .flags = CLK_SET_RATE_PARENT,
1136     },
1137 };
1138 
1139 static struct clk_regmap meson8b_vid_pll_in_en = {
1140     .data = &(struct clk_regmap_gate_data){
1141         .offset = HHI_VID_DIVIDER_CNTL,
1142         .bit_idx = 16,
1143     },
1144     .hw.init = &(struct clk_init_data){
1145         .name = "vid_pll_in_en",
1146         .ops = &clk_regmap_gate_ops,
1147         .parent_hws = (const struct clk_hw *[]) {
1148             &meson8b_vid_pll_in_sel.hw
1149         },
1150         .num_parents = 1,
1151         .flags = CLK_SET_RATE_PARENT,
1152     },
1153 };
1154 
1155 static struct clk_regmap meson8b_vid_pll_pre_div = {
1156     .data = &(struct clk_regmap_div_data){
1157         .offset =  HHI_VID_DIVIDER_CNTL,
1158         .shift = 4,
1159         .width = 3,
1160     },
1161     .hw.init = &(struct clk_init_data){
1162         .name = "vid_pll_pre_div",
1163         .ops = &clk_regmap_divider_ops,
1164         .parent_hws = (const struct clk_hw *[]) {
1165             &meson8b_vid_pll_in_en.hw
1166         },
1167         .num_parents = 1,
1168         .flags = CLK_SET_RATE_PARENT,
1169     },
1170 };
1171 
1172 static struct clk_regmap meson8b_vid_pll_post_div = {
1173     .data = &(struct clk_regmap_div_data){
1174         .offset =  HHI_VID_DIVIDER_CNTL,
1175         .shift = 12,
1176         .width = 3,
1177     },
1178     .hw.init = &(struct clk_init_data){
1179         .name = "vid_pll_post_div",
1180         .ops = &clk_regmap_divider_ops,
1181         .parent_hws = (const struct clk_hw *[]) {
1182             &meson8b_vid_pll_pre_div.hw
1183         },
1184         .num_parents = 1,
1185         .flags = CLK_SET_RATE_PARENT,
1186     },
1187 };
1188 
1189 static struct clk_regmap meson8b_vid_pll = {
1190     .data = &(struct clk_regmap_mux_data){
1191         .offset = HHI_VID_DIVIDER_CNTL,
1192         .mask = 0x3,
1193         .shift = 8,
1194     },
1195     .hw.init = &(struct clk_init_data){
1196         .name = "vid_pll",
1197         .ops = &clk_regmap_mux_ops,
1198         /* TODO: parent 0x2 is vid_pll_pre_div_mult7_div2 */
1199         .parent_hws = (const struct clk_hw *[]) {
1200             &meson8b_vid_pll_pre_div.hw,
1201             &meson8b_vid_pll_post_div.hw,
1202         },
1203         .num_parents = 2,
1204         .flags = CLK_SET_RATE_PARENT,
1205     },
1206 };
1207 
1208 static struct clk_regmap meson8b_vid_pll_final_div = {
1209     .data = &(struct clk_regmap_div_data){
1210         .offset =  HHI_VID_CLK_DIV,
1211         .shift = 0,
1212         .width = 8,
1213     },
1214     .hw.init = &(struct clk_init_data){
1215         .name = "vid_pll_final_div",
1216         .ops = &clk_regmap_divider_ops,
1217         .parent_hws = (const struct clk_hw *[]) {
1218             &meson8b_vid_pll.hw
1219         },
1220         .num_parents = 1,
1221         .flags = CLK_SET_RATE_PARENT,
1222     },
1223 };
1224 
1225 static const struct clk_hw *meson8b_vclk_mux_parent_hws[] = {
1226     &meson8b_vid_pll_final_div.hw,
1227     &meson8b_fclk_div4.hw,
1228     &meson8b_fclk_div3.hw,
1229     &meson8b_fclk_div5.hw,
1230     &meson8b_vid_pll_final_div.hw,
1231     &meson8b_fclk_div7.hw,
1232     &meson8b_mpll1.hw,
1233 };
1234 
1235 static struct clk_regmap meson8b_vclk_in_sel = {
1236     .data = &(struct clk_regmap_mux_data){
1237         .offset = HHI_VID_CLK_CNTL,
1238         .mask = 0x7,
1239         .shift = 16,
1240     },
1241     .hw.init = &(struct clk_init_data){
1242         .name = "vclk_in_sel",
1243         .ops = &clk_regmap_mux_ops,
1244         .parent_hws = meson8b_vclk_mux_parent_hws,
1245         .num_parents = ARRAY_SIZE(meson8b_vclk_mux_parent_hws),
1246         .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
1247     },
1248 };
1249 
1250 static struct clk_regmap meson8b_vclk_in_en = {
1251     .data = &(struct clk_regmap_gate_data){
1252         .offset = HHI_VID_CLK_DIV,
1253         .bit_idx = 16,
1254     },
1255     .hw.init = &(struct clk_init_data){
1256         .name = "vclk_in_en",
1257         .ops = &clk_regmap_gate_ops,
1258         .parent_hws = (const struct clk_hw *[]) {
1259             &meson8b_vclk_in_sel.hw
1260         },
1261         .num_parents = 1,
1262         .flags = CLK_SET_RATE_PARENT,
1263     },
1264 };
1265 
1266 static struct clk_regmap meson8b_vclk_en = {
1267     .data = &(struct clk_regmap_gate_data){
1268         .offset = HHI_VID_CLK_CNTL,
1269         .bit_idx = 19,
1270     },
1271     .hw.init = &(struct clk_init_data){
1272         .name = "vclk_en",
1273         .ops = &clk_regmap_gate_ops,
1274         .parent_hws = (const struct clk_hw *[]) {
1275             &meson8b_vclk_in_en.hw
1276         },
1277         .num_parents = 1,
1278         .flags = CLK_SET_RATE_PARENT,
1279     },
1280 };
1281 
1282 static struct clk_regmap meson8b_vclk_div1_gate = {
1283     .data = &(struct clk_regmap_gate_data){
1284         .offset = HHI_VID_CLK_CNTL,
1285         .bit_idx = 0,
1286     },
1287     .hw.init = &(struct clk_init_data){
1288         .name = "vclk_div1_en",
1289         .ops = &clk_regmap_gate_ops,
1290         .parent_hws = (const struct clk_hw *[]) {
1291             &meson8b_vclk_en.hw
1292         },
1293         .num_parents = 1,
1294         .flags = CLK_SET_RATE_PARENT,
1295     },
1296 };
1297 
1298 static struct clk_fixed_factor meson8b_vclk_div2_div = {
1299     .mult = 1,
1300     .div = 2,
1301     .hw.init = &(struct clk_init_data){
1302         .name = "vclk_div2",
1303         .ops = &clk_fixed_factor_ops,
1304         .parent_hws = (const struct clk_hw *[]) {
1305             &meson8b_vclk_en.hw
1306         },
1307         .num_parents = 1,
1308         .flags = CLK_SET_RATE_PARENT,
1309     }
1310 };
1311 
1312 static struct clk_regmap meson8b_vclk_div2_div_gate = {
1313     .data = &(struct clk_regmap_gate_data){
1314         .offset = HHI_VID_CLK_CNTL,
1315         .bit_idx = 1,
1316     },
1317     .hw.init = &(struct clk_init_data){
1318         .name = "vclk_div2_en",
1319         .ops = &clk_regmap_gate_ops,
1320         .parent_hws = (const struct clk_hw *[]) {
1321             &meson8b_vclk_div2_div.hw
1322         },
1323         .num_parents = 1,
1324         .flags = CLK_SET_RATE_PARENT,
1325     },
1326 };
1327 
1328 static struct clk_fixed_factor meson8b_vclk_div4_div = {
1329     .mult = 1,
1330     .div = 4,
1331     .hw.init = &(struct clk_init_data){
1332         .name = "vclk_div4",
1333         .ops = &clk_fixed_factor_ops,
1334         .parent_hws = (const struct clk_hw *[]) {
1335             &meson8b_vclk_en.hw
1336         },
1337         .num_parents = 1,
1338         .flags = CLK_SET_RATE_PARENT,
1339     }
1340 };
1341 
1342 static struct clk_regmap meson8b_vclk_div4_div_gate = {
1343     .data = &(struct clk_regmap_gate_data){
1344         .offset = HHI_VID_CLK_CNTL,
1345         .bit_idx = 2,
1346     },
1347     .hw.init = &(struct clk_init_data){
1348         .name = "vclk_div4_en",
1349         .ops = &clk_regmap_gate_ops,
1350         .parent_hws = (const struct clk_hw *[]) {
1351             &meson8b_vclk_div4_div.hw
1352         },
1353         .num_parents = 1,
1354         .flags = CLK_SET_RATE_PARENT,
1355     },
1356 };
1357 
1358 static struct clk_fixed_factor meson8b_vclk_div6_div = {
1359     .mult = 1,
1360     .div = 6,
1361     .hw.init = &(struct clk_init_data){
1362         .name = "vclk_div6",
1363         .ops = &clk_fixed_factor_ops,
1364         .parent_hws = (const struct clk_hw *[]) {
1365             &meson8b_vclk_en.hw
1366         },
1367         .num_parents = 1,
1368         .flags = CLK_SET_RATE_PARENT,
1369     }
1370 };
1371 
1372 static struct clk_regmap meson8b_vclk_div6_div_gate = {
1373     .data = &(struct clk_regmap_gate_data){
1374         .offset = HHI_VID_CLK_CNTL,
1375         .bit_idx = 3,
1376     },
1377     .hw.init = &(struct clk_init_data){
1378         .name = "vclk_div6_en",
1379         .ops = &clk_regmap_gate_ops,
1380         .parent_hws = (const struct clk_hw *[]) {
1381             &meson8b_vclk_div6_div.hw
1382         },
1383         .num_parents = 1,
1384         .flags = CLK_SET_RATE_PARENT,
1385     },
1386 };
1387 
1388 static struct clk_fixed_factor meson8b_vclk_div12_div = {
1389     .mult = 1,
1390     .div = 12,
1391     .hw.init = &(struct clk_init_data){
1392         .name = "vclk_div12",
1393         .ops = &clk_fixed_factor_ops,
1394         .parent_hws = (const struct clk_hw *[]) {
1395             &meson8b_vclk_en.hw
1396         },
1397         .num_parents = 1,
1398         .flags = CLK_SET_RATE_PARENT,
1399     }
1400 };
1401 
1402 static struct clk_regmap meson8b_vclk_div12_div_gate = {
1403     .data = &(struct clk_regmap_gate_data){
1404         .offset = HHI_VID_CLK_CNTL,
1405         .bit_idx = 4,
1406     },
1407     .hw.init = &(struct clk_init_data){
1408         .name = "vclk_div12_en",
1409         .ops = &clk_regmap_gate_ops,
1410         .parent_hws = (const struct clk_hw *[]) {
1411             &meson8b_vclk_div12_div.hw
1412         },
1413         .num_parents = 1,
1414         .flags = CLK_SET_RATE_PARENT,
1415     },
1416 };
1417 
1418 static struct clk_regmap meson8b_vclk2_in_sel = {
1419     .data = &(struct clk_regmap_mux_data){
1420         .offset = HHI_VIID_CLK_CNTL,
1421         .mask = 0x7,
1422         .shift = 16,
1423     },
1424     .hw.init = &(struct clk_init_data){
1425         .name = "vclk2_in_sel",
1426         .ops = &clk_regmap_mux_ops,
1427         .parent_hws = meson8b_vclk_mux_parent_hws,
1428         .num_parents = ARRAY_SIZE(meson8b_vclk_mux_parent_hws),
1429         .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
1430     },
1431 };
1432 
1433 static struct clk_regmap meson8b_vclk2_clk_in_en = {
1434     .data = &(struct clk_regmap_gate_data){
1435         .offset = HHI_VIID_CLK_DIV,
1436         .bit_idx = 16,
1437     },
1438     .hw.init = &(struct clk_init_data){
1439         .name = "vclk2_in_en",
1440         .ops = &clk_regmap_gate_ops,
1441         .parent_hws = (const struct clk_hw *[]) {
1442             &meson8b_vclk2_in_sel.hw
1443         },
1444         .num_parents = 1,
1445         .flags = CLK_SET_RATE_PARENT,
1446     },
1447 };
1448 
1449 static struct clk_regmap meson8b_vclk2_clk_en = {
1450     .data = &(struct clk_regmap_gate_data){
1451         .offset = HHI_VIID_CLK_DIV,
1452         .bit_idx = 19,
1453     },
1454     .hw.init = &(struct clk_init_data){
1455         .name = "vclk2_en",
1456         .ops = &clk_regmap_gate_ops,
1457         .parent_hws = (const struct clk_hw *[]) {
1458             &meson8b_vclk2_clk_in_en.hw
1459         },
1460         .num_parents = 1,
1461         .flags = CLK_SET_RATE_PARENT,
1462     },
1463 };
1464 
1465 static struct clk_regmap meson8b_vclk2_div1_gate = {
1466     .data = &(struct clk_regmap_gate_data){
1467         .offset = HHI_VIID_CLK_DIV,
1468         .bit_idx = 0,
1469     },
1470     .hw.init = &(struct clk_init_data){
1471         .name = "vclk2_div1_en",
1472         .ops = &clk_regmap_gate_ops,
1473         .parent_hws = (const struct clk_hw *[]) {
1474             &meson8b_vclk2_clk_en.hw
1475         },
1476         .num_parents = 1,
1477         .flags = CLK_SET_RATE_PARENT,
1478     },
1479 };
1480 
1481 static struct clk_fixed_factor meson8b_vclk2_div2_div = {
1482     .mult = 1,
1483     .div = 2,
1484     .hw.init = &(struct clk_init_data){
1485         .name = "vclk2_div2",
1486         .ops = &clk_fixed_factor_ops,
1487         .parent_hws = (const struct clk_hw *[]) {
1488             &meson8b_vclk2_clk_en.hw
1489         },
1490         .num_parents = 1,
1491         .flags = CLK_SET_RATE_PARENT,
1492     }
1493 };
1494 
1495 static struct clk_regmap meson8b_vclk2_div2_div_gate = {
1496     .data = &(struct clk_regmap_gate_data){
1497         .offset = HHI_VIID_CLK_DIV,
1498         .bit_idx = 1,
1499     },
1500     .hw.init = &(struct clk_init_data){
1501         .name = "vclk2_div2_en",
1502         .ops = &clk_regmap_gate_ops,
1503         .parent_hws = (const struct clk_hw *[]) {
1504             &meson8b_vclk2_div2_div.hw
1505         },
1506         .num_parents = 1,
1507         .flags = CLK_SET_RATE_PARENT,
1508     },
1509 };
1510 
1511 static struct clk_fixed_factor meson8b_vclk2_div4_div = {
1512     .mult = 1,
1513     .div = 4,
1514     .hw.init = &(struct clk_init_data){
1515         .name = "vclk2_div4",
1516         .ops = &clk_fixed_factor_ops,
1517         .parent_hws = (const struct clk_hw *[]) {
1518             &meson8b_vclk2_clk_en.hw
1519         },
1520         .num_parents = 1,
1521         .flags = CLK_SET_RATE_PARENT,
1522     }
1523 };
1524 
1525 static struct clk_regmap meson8b_vclk2_div4_div_gate = {
1526     .data = &(struct clk_regmap_gate_data){
1527         .offset = HHI_VIID_CLK_DIV,
1528         .bit_idx = 2,
1529     },
1530     .hw.init = &(struct clk_init_data){
1531         .name = "vclk2_div4_en",
1532         .ops = &clk_regmap_gate_ops,
1533         .parent_hws = (const struct clk_hw *[]) {
1534             &meson8b_vclk2_div4_div.hw
1535         },
1536         .num_parents = 1,
1537         .flags = CLK_SET_RATE_PARENT,
1538     },
1539 };
1540 
1541 static struct clk_fixed_factor meson8b_vclk2_div6_div = {
1542     .mult = 1,
1543     .div = 6,
1544     .hw.init = &(struct clk_init_data){
1545         .name = "vclk2_div6",
1546         .ops = &clk_fixed_factor_ops,
1547         .parent_hws = (const struct clk_hw *[]) {
1548             &meson8b_vclk2_clk_en.hw
1549         },
1550         .num_parents = 1,
1551         .flags = CLK_SET_RATE_PARENT,
1552     }
1553 };
1554 
1555 static struct clk_regmap meson8b_vclk2_div6_div_gate = {
1556     .data = &(struct clk_regmap_gate_data){
1557         .offset = HHI_VIID_CLK_DIV,
1558         .bit_idx = 3,
1559     },
1560     .hw.init = &(struct clk_init_data){
1561         .name = "vclk2_div6_en",
1562         .ops = &clk_regmap_gate_ops,
1563         .parent_hws = (const struct clk_hw *[]) {
1564             &meson8b_vclk2_div6_div.hw
1565         },
1566         .num_parents = 1,
1567         .flags = CLK_SET_RATE_PARENT,
1568     },
1569 };
1570 
1571 static struct clk_fixed_factor meson8b_vclk2_div12_div = {
1572     .mult = 1,
1573     .div = 12,
1574     .hw.init = &(struct clk_init_data){
1575         .name = "vclk2_div12",
1576         .ops = &clk_fixed_factor_ops,
1577         .parent_hws = (const struct clk_hw *[]) {
1578             &meson8b_vclk2_clk_en.hw
1579         },
1580         .num_parents = 1,
1581         .flags = CLK_SET_RATE_PARENT,
1582     }
1583 };
1584 
1585 static struct clk_regmap meson8b_vclk2_div12_div_gate = {
1586     .data = &(struct clk_regmap_gate_data){
1587         .offset = HHI_VIID_CLK_DIV,
1588         .bit_idx = 4,
1589     },
1590     .hw.init = &(struct clk_init_data){
1591         .name = "vclk2_div12_en",
1592         .ops = &clk_regmap_gate_ops,
1593         .parent_hws = (const struct clk_hw *[]) {
1594             &meson8b_vclk2_div12_div.hw
1595         },
1596         .num_parents = 1,
1597         .flags = CLK_SET_RATE_PARENT,
1598     },
1599 };
1600 
1601 static const struct clk_hw *meson8b_vclk_enc_mux_parent_hws[] = {
1602     &meson8b_vclk_div1_gate.hw,
1603     &meson8b_vclk_div2_div_gate.hw,
1604     &meson8b_vclk_div4_div_gate.hw,
1605     &meson8b_vclk_div6_div_gate.hw,
1606     &meson8b_vclk_div12_div_gate.hw,
1607 };
1608 
1609 static struct clk_regmap meson8b_cts_enct_sel = {
1610     .data = &(struct clk_regmap_mux_data){
1611         .offset = HHI_VID_CLK_DIV,
1612         .mask = 0xf,
1613         .shift = 20,
1614     },
1615     .hw.init = &(struct clk_init_data){
1616         .name = "cts_enct_sel",
1617         .ops = &clk_regmap_mux_ops,
1618         .parent_hws = meson8b_vclk_enc_mux_parent_hws,
1619         .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
1620         .flags = CLK_SET_RATE_PARENT,
1621     },
1622 };
1623 
1624 static struct clk_regmap meson8b_cts_enct = {
1625     .data = &(struct clk_regmap_gate_data){
1626         .offset = HHI_VID_CLK_CNTL2,
1627         .bit_idx = 1,
1628     },
1629     .hw.init = &(struct clk_init_data){
1630         .name = "cts_enct",
1631         .ops = &clk_regmap_gate_ops,
1632         .parent_hws = (const struct clk_hw *[]) {
1633             &meson8b_cts_enct_sel.hw
1634         },
1635         .num_parents = 1,
1636         .flags = CLK_SET_RATE_PARENT,
1637     },
1638 };
1639 
1640 static struct clk_regmap meson8b_cts_encp_sel = {
1641     .data = &(struct clk_regmap_mux_data){
1642         .offset = HHI_VID_CLK_DIV,
1643         .mask = 0xf,
1644         .shift = 24,
1645     },
1646     .hw.init = &(struct clk_init_data){
1647         .name = "cts_encp_sel",
1648         .ops = &clk_regmap_mux_ops,
1649         .parent_hws = meson8b_vclk_enc_mux_parent_hws,
1650         .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
1651         .flags = CLK_SET_RATE_PARENT,
1652     },
1653 };
1654 
1655 static struct clk_regmap meson8b_cts_encp = {
1656     .data = &(struct clk_regmap_gate_data){
1657         .offset = HHI_VID_CLK_CNTL2,
1658         .bit_idx = 2,
1659     },
1660     .hw.init = &(struct clk_init_data){
1661         .name = "cts_encp",
1662         .ops = &clk_regmap_gate_ops,
1663         .parent_hws = (const struct clk_hw *[]) {
1664             &meson8b_cts_encp_sel.hw
1665         },
1666         .num_parents = 1,
1667         .flags = CLK_SET_RATE_PARENT,
1668     },
1669 };
1670 
1671 static struct clk_regmap meson8b_cts_enci_sel = {
1672     .data = &(struct clk_regmap_mux_data){
1673         .offset = HHI_VID_CLK_DIV,
1674         .mask = 0xf,
1675         .shift = 28,
1676     },
1677     .hw.init = &(struct clk_init_data){
1678         .name = "cts_enci_sel",
1679         .ops = &clk_regmap_mux_ops,
1680         .parent_hws = meson8b_vclk_enc_mux_parent_hws,
1681         .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
1682         .flags = CLK_SET_RATE_PARENT,
1683     },
1684 };
1685 
1686 static struct clk_regmap meson8b_cts_enci = {
1687     .data = &(struct clk_regmap_gate_data){
1688         .offset = HHI_VID_CLK_CNTL2,
1689         .bit_idx = 0,
1690     },
1691     .hw.init = &(struct clk_init_data){
1692         .name = "cts_enci",
1693         .ops = &clk_regmap_gate_ops,
1694         .parent_hws = (const struct clk_hw *[]) {
1695             &meson8b_cts_enci_sel.hw
1696         },
1697         .num_parents = 1,
1698         .flags = CLK_SET_RATE_PARENT,
1699     },
1700 };
1701 
1702 static struct clk_regmap meson8b_hdmi_tx_pixel_sel = {
1703     .data = &(struct clk_regmap_mux_data){
1704         .offset = HHI_HDMI_CLK_CNTL,
1705         .mask = 0xf,
1706         .shift = 16,
1707     },
1708     .hw.init = &(struct clk_init_data){
1709         .name = "hdmi_tx_pixel_sel",
1710         .ops = &clk_regmap_mux_ops,
1711         .parent_hws = meson8b_vclk_enc_mux_parent_hws,
1712         .num_parents = ARRAY_SIZE(meson8b_vclk_enc_mux_parent_hws),
1713         .flags = CLK_SET_RATE_PARENT,
1714     },
1715 };
1716 
1717 static struct clk_regmap meson8b_hdmi_tx_pixel = {
1718     .data = &(struct clk_regmap_gate_data){
1719         .offset = HHI_VID_CLK_CNTL2,
1720         .bit_idx = 5,
1721     },
1722     .hw.init = &(struct clk_init_data){
1723         .name = "hdmi_tx_pixel",
1724         .ops = &clk_regmap_gate_ops,
1725         .parent_hws = (const struct clk_hw *[]) {
1726             &meson8b_hdmi_tx_pixel_sel.hw
1727         },
1728         .num_parents = 1,
1729         .flags = CLK_SET_RATE_PARENT,
1730     },
1731 };
1732 
1733 static const struct clk_hw *meson8b_vclk2_enc_mux_parent_hws[] = {
1734     &meson8b_vclk2_div1_gate.hw,
1735     &meson8b_vclk2_div2_div_gate.hw,
1736     &meson8b_vclk2_div4_div_gate.hw,
1737     &meson8b_vclk2_div6_div_gate.hw,
1738     &meson8b_vclk2_div12_div_gate.hw,
1739 };
1740 
1741 static struct clk_regmap meson8b_cts_encl_sel = {
1742     .data = &(struct clk_regmap_mux_data){
1743         .offset = HHI_VIID_CLK_DIV,
1744         .mask = 0xf,
1745         .shift = 12,
1746     },
1747     .hw.init = &(struct clk_init_data){
1748         .name = "cts_encl_sel",
1749         .ops = &clk_regmap_mux_ops,
1750         .parent_hws = meson8b_vclk2_enc_mux_parent_hws,
1751         .num_parents = ARRAY_SIZE(meson8b_vclk2_enc_mux_parent_hws),
1752         .flags = CLK_SET_RATE_PARENT,
1753     },
1754 };
1755 
1756 static struct clk_regmap meson8b_cts_encl = {
1757     .data = &(struct clk_regmap_gate_data){
1758         .offset = HHI_VID_CLK_CNTL2,
1759         .bit_idx = 3,
1760     },
1761     .hw.init = &(struct clk_init_data){
1762         .name = "cts_encl",
1763         .ops = &clk_regmap_gate_ops,
1764         .parent_hws = (const struct clk_hw *[]) {
1765             &meson8b_cts_encl_sel.hw
1766         },
1767         .num_parents = 1,
1768         .flags = CLK_SET_RATE_PARENT,
1769     },
1770 };
1771 
1772 static struct clk_regmap meson8b_cts_vdac0_sel = {
1773     .data = &(struct clk_regmap_mux_data){
1774         .offset = HHI_VIID_CLK_DIV,
1775         .mask = 0xf,
1776         .shift = 28,
1777     },
1778     .hw.init = &(struct clk_init_data){
1779         .name = "cts_vdac0_sel",
1780         .ops = &clk_regmap_mux_ops,
1781         .parent_hws = meson8b_vclk2_enc_mux_parent_hws,
1782         .num_parents = ARRAY_SIZE(meson8b_vclk2_enc_mux_parent_hws),
1783         .flags = CLK_SET_RATE_PARENT,
1784     },
1785 };
1786 
1787 static struct clk_regmap meson8b_cts_vdac0 = {
1788     .data = &(struct clk_regmap_gate_data){
1789         .offset = HHI_VID_CLK_CNTL2,
1790         .bit_idx = 4,
1791     },
1792     .hw.init = &(struct clk_init_data){
1793         .name = "cts_vdac0",
1794         .ops = &clk_regmap_gate_ops,
1795         .parent_hws = (const struct clk_hw *[]) {
1796             &meson8b_cts_vdac0_sel.hw
1797         },
1798         .num_parents = 1,
1799         .flags = CLK_SET_RATE_PARENT,
1800     },
1801 };
1802 
1803 static struct clk_regmap meson8b_hdmi_sys_sel = {
1804     .data = &(struct clk_regmap_mux_data){
1805         .offset = HHI_HDMI_CLK_CNTL,
1806         .mask = 0x3,
1807         .shift = 9,
1808         .flags = CLK_MUX_ROUND_CLOSEST,
1809     },
1810     .hw.init = &(struct clk_init_data){
1811         .name = "hdmi_sys_sel",
1812         .ops = &clk_regmap_mux_ops,
1813         /* FIXME: all other parents are unknown */
1814         .parent_data = &(const struct clk_parent_data) {
1815             .fw_name = "xtal",
1816             .name = "xtal",
1817             .index = -1,
1818         },
1819         .num_parents = 1,
1820         .flags = CLK_SET_RATE_NO_REPARENT,
1821     },
1822 };
1823 
1824 static struct clk_regmap meson8b_hdmi_sys_div = {
1825     .data = &(struct clk_regmap_div_data){
1826         .offset = HHI_HDMI_CLK_CNTL,
1827         .shift = 0,
1828         .width = 7,
1829     },
1830     .hw.init = &(struct clk_init_data){
1831         .name = "hdmi_sys_div",
1832         .ops = &clk_regmap_divider_ops,
1833         .parent_hws = (const struct clk_hw *[]) {
1834             &meson8b_hdmi_sys_sel.hw
1835         },
1836         .num_parents = 1,
1837         .flags = CLK_SET_RATE_PARENT,
1838     },
1839 };
1840 
1841 static struct clk_regmap meson8b_hdmi_sys = {
1842     .data = &(struct clk_regmap_gate_data){
1843         .offset = HHI_HDMI_CLK_CNTL,
1844         .bit_idx = 8,
1845     },
1846     .hw.init = &(struct clk_init_data) {
1847         .name = "hdmi_sys",
1848         .ops = &clk_regmap_gate_ops,
1849         .parent_hws = (const struct clk_hw *[]) {
1850             &meson8b_hdmi_sys_div.hw
1851         },
1852         .num_parents = 1,
1853         .flags = CLK_SET_RATE_PARENT,
1854     },
1855 };
1856 
1857 /*
1858  * The MALI IP is clocked by two identical clocks (mali_0 and mali_1)
1859  * muxed by a glitch-free switch on Meson8b and Meson8m2. The CCF can
1860  * actually manage this glitch-free mux because it does top-to-bottom
1861  * updates the each clock tree and switches to the "inactive" one when
1862  * CLK_SET_RATE_GATE is set.
1863  * Meson8 only has mali_0 and no glitch-free mux.
1864  */
1865 static const struct clk_parent_data meson8b_mali_0_1_parent_data[] = {
1866     { .fw_name = "xtal", .name = "xtal", .index = -1, },
1867     { .hw = &meson8b_mpll2.hw, },
1868     { .hw = &meson8b_mpll1.hw, },
1869     { .hw = &meson8b_fclk_div7.hw, },
1870     { .hw = &meson8b_fclk_div4.hw, },
1871     { .hw = &meson8b_fclk_div3.hw, },
1872     { .hw = &meson8b_fclk_div5.hw, },
1873 };
1874 
1875 static u32 meson8b_mali_0_1_mux_table[] = { 0, 2, 3, 4, 5, 6, 7 };
1876 
1877 static struct clk_regmap meson8b_mali_0_sel = {
1878     .data = &(struct clk_regmap_mux_data){
1879         .offset = HHI_MALI_CLK_CNTL,
1880         .mask = 0x7,
1881         .shift = 9,
1882         .table = meson8b_mali_0_1_mux_table,
1883     },
1884     .hw.init = &(struct clk_init_data){
1885         .name = "mali_0_sel",
1886         .ops = &clk_regmap_mux_ops,
1887         .parent_data = meson8b_mali_0_1_parent_data,
1888         .num_parents = ARRAY_SIZE(meson8b_mali_0_1_parent_data),
1889         /*
1890          * Don't propagate rate changes up because the only changeable
1891          * parents are mpll1 and mpll2 but we need those for audio and
1892          * RGMII (Ethernet). We don't want to change the audio or
1893          * Ethernet clocks when setting the GPU frequency.
1894          */
1895         .flags = 0,
1896     },
1897 };
1898 
1899 static struct clk_regmap meson8b_mali_0_div = {
1900     .data = &(struct clk_regmap_div_data){
1901         .offset = HHI_MALI_CLK_CNTL,
1902         .shift = 0,
1903         .width = 7,
1904     },
1905     .hw.init = &(struct clk_init_data){
1906         .name = "mali_0_div",
1907         .ops = &clk_regmap_divider_ops,
1908         .parent_hws = (const struct clk_hw *[]) {
1909             &meson8b_mali_0_sel.hw
1910         },
1911         .num_parents = 1,
1912         .flags = CLK_SET_RATE_PARENT,
1913     },
1914 };
1915 
1916 static struct clk_regmap meson8b_mali_0 = {
1917     .data = &(struct clk_regmap_gate_data){
1918         .offset = HHI_MALI_CLK_CNTL,
1919         .bit_idx = 8,
1920     },
1921     .hw.init = &(struct clk_init_data){
1922         .name = "mali_0",
1923         .ops = &clk_regmap_gate_ops,
1924         .parent_hws = (const struct clk_hw *[]) {
1925             &meson8b_mali_0_div.hw
1926         },
1927         .num_parents = 1,
1928         .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
1929     },
1930 };
1931 
1932 static struct clk_regmap meson8b_mali_1_sel = {
1933     .data = &(struct clk_regmap_mux_data){
1934         .offset = HHI_MALI_CLK_CNTL,
1935         .mask = 0x7,
1936         .shift = 25,
1937         .table = meson8b_mali_0_1_mux_table,
1938     },
1939     .hw.init = &(struct clk_init_data){
1940         .name = "mali_1_sel",
1941         .ops = &clk_regmap_mux_ops,
1942         .parent_data = meson8b_mali_0_1_parent_data,
1943         .num_parents = ARRAY_SIZE(meson8b_mali_0_1_parent_data),
1944         /*
1945          * Don't propagate rate changes up because the only changeable
1946          * parents are mpll1 and mpll2 but we need those for audio and
1947          * RGMII (Ethernet). We don't want to change the audio or
1948          * Ethernet clocks when setting the GPU frequency.
1949          */
1950         .flags = 0,
1951     },
1952 };
1953 
1954 static struct clk_regmap meson8b_mali_1_div = {
1955     .data = &(struct clk_regmap_div_data){
1956         .offset = HHI_MALI_CLK_CNTL,
1957         .shift = 16,
1958         .width = 7,
1959     },
1960     .hw.init = &(struct clk_init_data){
1961         .name = "mali_1_div",
1962         .ops = &clk_regmap_divider_ops,
1963         .parent_hws = (const struct clk_hw *[]) {
1964             &meson8b_mali_1_sel.hw
1965         },
1966         .num_parents = 1,
1967         .flags = CLK_SET_RATE_PARENT,
1968     },
1969 };
1970 
1971 static struct clk_regmap meson8b_mali_1 = {
1972     .data = &(struct clk_regmap_gate_data){
1973         .offset = HHI_MALI_CLK_CNTL,
1974         .bit_idx = 24,
1975     },
1976     .hw.init = &(struct clk_init_data){
1977         .name = "mali_1",
1978         .ops = &clk_regmap_gate_ops,
1979         .parent_hws = (const struct clk_hw *[]) {
1980             &meson8b_mali_1_div.hw
1981         },
1982         .num_parents = 1,
1983         .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
1984     },
1985 };
1986 
1987 static struct clk_regmap meson8b_mali = {
1988     .data = &(struct clk_regmap_mux_data){
1989         .offset = HHI_MALI_CLK_CNTL,
1990         .mask = 1,
1991         .shift = 31,
1992     },
1993     .hw.init = &(struct clk_init_data){
1994         .name = "mali",
1995         .ops = &clk_regmap_mux_ops,
1996         .parent_hws = (const struct clk_hw *[]) {
1997             &meson8b_mali_0.hw,
1998             &meson8b_mali_1.hw,
1999         },
2000         .num_parents = 2,
2001         .flags = CLK_SET_RATE_PARENT,
2002     },
2003 };
2004 
2005 static const struct reg_sequence meson8m2_gp_pll_init_regs[] = {
2006     { .reg = HHI_GP_PLL_CNTL2,  .def = 0x59c88000 },
2007     { .reg = HHI_GP_PLL_CNTL3,  .def = 0xca463823 },
2008     { .reg = HHI_GP_PLL_CNTL4,  .def = 0x0286a027 },
2009     { .reg = HHI_GP_PLL_CNTL5,  .def = 0x00003000 },
2010 };
2011 
2012 static const struct pll_params_table meson8m2_gp_pll_params_table[] = {
2013     PLL_PARAMS(182, 3),
2014     { /* sentinel */ },
2015 };
2016 
2017 static struct clk_regmap meson8m2_gp_pll_dco = {
2018     .data = &(struct meson_clk_pll_data){
2019         .en = {
2020             .reg_off = HHI_GP_PLL_CNTL,
2021             .shift   = 30,
2022             .width   = 1,
2023         },
2024         .m = {
2025             .reg_off = HHI_GP_PLL_CNTL,
2026             .shift   = 0,
2027             .width   = 9,
2028         },
2029         .n = {
2030             .reg_off = HHI_GP_PLL_CNTL,
2031             .shift   = 9,
2032             .width   = 5,
2033         },
2034         .l = {
2035             .reg_off = HHI_GP_PLL_CNTL,
2036             .shift   = 31,
2037             .width   = 1,
2038         },
2039         .rst = {
2040             .reg_off = HHI_GP_PLL_CNTL,
2041             .shift   = 29,
2042             .width   = 1,
2043         },
2044         .table = meson8m2_gp_pll_params_table,
2045         .init_regs = meson8m2_gp_pll_init_regs,
2046         .init_count = ARRAY_SIZE(meson8m2_gp_pll_init_regs),
2047     },
2048     .hw.init = &(struct clk_init_data){
2049         .name = "gp_pll_dco",
2050         .ops = &meson_clk_pll_ops,
2051         .parent_data = &(const struct clk_parent_data) {
2052             .fw_name = "xtal",
2053             .name = "xtal",
2054             .index = -1,
2055         },
2056         .num_parents = 1,
2057     },
2058 };
2059 
2060 static struct clk_regmap meson8m2_gp_pll = {
2061     .data = &(struct clk_regmap_div_data){
2062         .offset = HHI_GP_PLL_CNTL,
2063         .shift = 16,
2064         .width = 2,
2065         .flags = CLK_DIVIDER_POWER_OF_TWO,
2066     },
2067     .hw.init = &(struct clk_init_data){
2068         .name = "gp_pll",
2069         .ops = &clk_regmap_divider_ops,
2070         .parent_hws = (const struct clk_hw *[]) {
2071             &meson8m2_gp_pll_dco.hw
2072         },
2073         .num_parents = 1,
2074         .flags = CLK_SET_RATE_PARENT,
2075     },
2076 };
2077 
2078 static const struct clk_hw *meson8b_vpu_0_1_parent_hws[] = {
2079     &meson8b_fclk_div4.hw,
2080     &meson8b_fclk_div3.hw,
2081     &meson8b_fclk_div5.hw,
2082     &meson8b_fclk_div7.hw,
2083 };
2084 
2085 static const struct clk_hw *mmeson8m2_vpu_0_1_parent_hws[] = {
2086     &meson8b_fclk_div4.hw,
2087     &meson8b_fclk_div3.hw,
2088     &meson8b_fclk_div5.hw,
2089     &meson8m2_gp_pll.hw,
2090 };
2091 
2092 static struct clk_regmap meson8b_vpu_0_sel = {
2093     .data = &(struct clk_regmap_mux_data){
2094         .offset = HHI_VPU_CLK_CNTL,
2095         .mask = 0x3,
2096         .shift = 9,
2097     },
2098     .hw.init = &(struct clk_init_data){
2099         .name = "vpu_0_sel",
2100         .ops = &clk_regmap_mux_ops,
2101         .parent_hws = meson8b_vpu_0_1_parent_hws,
2102         .num_parents = ARRAY_SIZE(meson8b_vpu_0_1_parent_hws),
2103         .flags = CLK_SET_RATE_PARENT,
2104     },
2105 };
2106 
2107 static struct clk_regmap meson8m2_vpu_0_sel = {
2108     .data = &(struct clk_regmap_mux_data){
2109         .offset = HHI_VPU_CLK_CNTL,
2110         .mask = 0x3,
2111         .shift = 9,
2112     },
2113     .hw.init = &(struct clk_init_data){
2114         .name = "vpu_0_sel",
2115         .ops = &clk_regmap_mux_ops,
2116         .parent_hws = mmeson8m2_vpu_0_1_parent_hws,
2117         .num_parents = ARRAY_SIZE(mmeson8m2_vpu_0_1_parent_hws),
2118         .flags = CLK_SET_RATE_PARENT,
2119     },
2120 };
2121 
2122 static struct clk_regmap meson8b_vpu_0_div = {
2123     .data = &(struct clk_regmap_div_data){
2124         .offset = HHI_VPU_CLK_CNTL,
2125         .shift = 0,
2126         .width = 7,
2127     },
2128     .hw.init = &(struct clk_init_data){
2129         .name = "vpu_0_div",
2130         .ops = &clk_regmap_divider_ops,
2131         .parent_data = &(const struct clk_parent_data) {
2132             /*
2133              * Note:
2134              * meson8b and meson8m2 have different vpu_0_sels (with
2135              * different struct clk_hw). We fallback to the global
2136              * naming string mechanism so vpu_0_div picks up the
2137              * appropriate one.
2138              */
2139             .name = "vpu_0_sel",
2140             .index = -1,
2141         },
2142         .num_parents = 1,
2143         .flags = CLK_SET_RATE_PARENT,
2144     },
2145 };
2146 
2147 static struct clk_regmap meson8b_vpu_0 = {
2148     .data = &(struct clk_regmap_gate_data){
2149         .offset = HHI_VPU_CLK_CNTL,
2150         .bit_idx = 8,
2151     },
2152     .hw.init = &(struct clk_init_data) {
2153         .name = "vpu_0",
2154         .ops = &clk_regmap_gate_ops,
2155         .parent_hws = (const struct clk_hw *[]) {
2156             &meson8b_vpu_0_div.hw
2157         },
2158         .num_parents = 1,
2159         .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
2160     },
2161 };
2162 
2163 static struct clk_regmap meson8b_vpu_1_sel = {
2164     .data = &(struct clk_regmap_mux_data){
2165         .offset = HHI_VPU_CLK_CNTL,
2166         .mask = 0x3,
2167         .shift = 25,
2168     },
2169     .hw.init = &(struct clk_init_data){
2170         .name = "vpu_1_sel",
2171         .ops = &clk_regmap_mux_ops,
2172         .parent_hws = meson8b_vpu_0_1_parent_hws,
2173         .num_parents = ARRAY_SIZE(meson8b_vpu_0_1_parent_hws),
2174         .flags = CLK_SET_RATE_PARENT,
2175     },
2176 };
2177 
2178 static struct clk_regmap meson8m2_vpu_1_sel = {
2179     .data = &(struct clk_regmap_mux_data){
2180         .offset = HHI_VPU_CLK_CNTL,
2181         .mask = 0x3,
2182         .shift = 25,
2183     },
2184     .hw.init = &(struct clk_init_data){
2185         .name = "vpu_1_sel",
2186         .ops = &clk_regmap_mux_ops,
2187         .parent_hws = mmeson8m2_vpu_0_1_parent_hws,
2188         .num_parents = ARRAY_SIZE(mmeson8m2_vpu_0_1_parent_hws),
2189         .flags = CLK_SET_RATE_PARENT,
2190     },
2191 };
2192 
2193 static struct clk_regmap meson8b_vpu_1_div = {
2194     .data = &(struct clk_regmap_div_data){
2195         .offset = HHI_VPU_CLK_CNTL,
2196         .shift = 16,
2197         .width = 7,
2198     },
2199     .hw.init = &(struct clk_init_data){
2200         .name = "vpu_1_div",
2201         .ops = &clk_regmap_divider_ops,
2202         .parent_data = &(const struct clk_parent_data) {
2203             /*
2204              * Note:
2205              * meson8b and meson8m2 have different vpu_1_sels (with
2206              * different struct clk_hw). We fallback to the global
2207              * naming string mechanism so vpu_1_div picks up the
2208              * appropriate one.
2209              */
2210             .name = "vpu_1_sel",
2211             .index = -1,
2212         },
2213         .num_parents = 1,
2214         .flags = CLK_SET_RATE_PARENT,
2215     },
2216 };
2217 
2218 static struct clk_regmap meson8b_vpu_1 = {
2219     .data = &(struct clk_regmap_gate_data){
2220         .offset = HHI_VPU_CLK_CNTL,
2221         .bit_idx = 24,
2222     },
2223     .hw.init = &(struct clk_init_data) {
2224         .name = "vpu_1",
2225         .ops = &clk_regmap_gate_ops,
2226         .parent_hws = (const struct clk_hw *[]) {
2227             &meson8b_vpu_1_div.hw
2228         },
2229         .num_parents = 1,
2230         .flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT,
2231     },
2232 };
2233 
2234 /*
2235  * The VPU clock has two identical clock trees (vpu_0 and vpu_1)
2236  * muxed by a glitch-free switch on Meson8b and Meson8m2. The CCF can
2237  * actually manage this glitch-free mux because it does top-to-bottom
2238  * updates the each clock tree and switches to the "inactive" one when
2239  * CLK_SET_RATE_GATE is set.
2240  * Meson8 only has vpu_0 and no glitch-free mux.
2241  */
2242 static struct clk_regmap meson8b_vpu = {
2243     .data = &(struct clk_regmap_mux_data){
2244         .offset = HHI_VPU_CLK_CNTL,
2245         .mask = 1,
2246         .shift = 31,
2247     },
2248     .hw.init = &(struct clk_init_data){
2249         .name = "vpu",
2250         .ops = &clk_regmap_mux_ops,
2251         .parent_hws = (const struct clk_hw *[]) {
2252             &meson8b_vpu_0.hw,
2253             &meson8b_vpu_1.hw,
2254         },
2255         .num_parents = 2,
2256         .flags = CLK_SET_RATE_PARENT,
2257     },
2258 };
2259 
2260 static const struct clk_hw *meson8b_vdec_parent_hws[] = {
2261     &meson8b_fclk_div4.hw,
2262     &meson8b_fclk_div3.hw,
2263     &meson8b_fclk_div5.hw,
2264     &meson8b_fclk_div7.hw,
2265     &meson8b_mpll2.hw,
2266     &meson8b_mpll1.hw,
2267 };
2268 
2269 static struct clk_regmap meson8b_vdec_1_sel = {
2270     .data = &(struct clk_regmap_mux_data){
2271         .offset = HHI_VDEC_CLK_CNTL,
2272         .mask = 0x3,
2273         .shift = 9,
2274         .flags = CLK_MUX_ROUND_CLOSEST,
2275     },
2276     .hw.init = &(struct clk_init_data){
2277         .name = "vdec_1_sel",
2278         .ops = &clk_regmap_mux_ops,
2279         .parent_hws = meson8b_vdec_parent_hws,
2280         .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
2281         .flags = CLK_SET_RATE_PARENT,
2282     },
2283 };
2284 
2285 static struct clk_regmap meson8b_vdec_1_1_div = {
2286     .data = &(struct clk_regmap_div_data){
2287         .offset = HHI_VDEC_CLK_CNTL,
2288         .shift = 0,
2289         .width = 7,
2290         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2291     },
2292     .hw.init = &(struct clk_init_data){
2293         .name = "vdec_1_1_div",
2294         .ops = &clk_regmap_divider_ops,
2295         .parent_hws = (const struct clk_hw *[]) {
2296             &meson8b_vdec_1_sel.hw
2297         },
2298         .num_parents = 1,
2299         .flags = CLK_SET_RATE_PARENT,
2300     },
2301 };
2302 
2303 static struct clk_regmap meson8b_vdec_1_1 = {
2304     .data = &(struct clk_regmap_gate_data){
2305         .offset = HHI_VDEC_CLK_CNTL,
2306         .bit_idx = 8,
2307     },
2308     .hw.init = &(struct clk_init_data) {
2309         .name = "vdec_1_1",
2310         .ops = &clk_regmap_gate_ops,
2311         .parent_hws = (const struct clk_hw *[]) {
2312             &meson8b_vdec_1_1_div.hw
2313         },
2314         .num_parents = 1,
2315         .flags = CLK_SET_RATE_PARENT,
2316     },
2317 };
2318 
2319 static struct clk_regmap meson8b_vdec_1_2_div = {
2320     .data = &(struct clk_regmap_div_data){
2321         .offset = HHI_VDEC3_CLK_CNTL,
2322         .shift = 0,
2323         .width = 7,
2324         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2325     },
2326     .hw.init = &(struct clk_init_data){
2327         .name = "vdec_1_2_div",
2328         .ops = &clk_regmap_divider_ops,
2329         .parent_hws = (const struct clk_hw *[]) {
2330             &meson8b_vdec_1_sel.hw
2331         },
2332         .num_parents = 1,
2333         .flags = CLK_SET_RATE_PARENT,
2334     },
2335 };
2336 
2337 static struct clk_regmap meson8b_vdec_1_2 = {
2338     .data = &(struct clk_regmap_gate_data){
2339         .offset = HHI_VDEC3_CLK_CNTL,
2340         .bit_idx = 8,
2341     },
2342     .hw.init = &(struct clk_init_data) {
2343         .name = "vdec_1_2",
2344         .ops = &clk_regmap_gate_ops,
2345         .parent_hws = (const struct clk_hw *[]) {
2346             &meson8b_vdec_1_2_div.hw
2347         },
2348         .num_parents = 1,
2349         .flags = CLK_SET_RATE_PARENT,
2350     },
2351 };
2352 
2353 static struct clk_regmap meson8b_vdec_1 = {
2354     .data = &(struct clk_regmap_mux_data){
2355         .offset = HHI_VDEC3_CLK_CNTL,
2356         .mask = 0x1,
2357         .shift = 15,
2358         .flags = CLK_MUX_ROUND_CLOSEST,
2359     },
2360     .hw.init = &(struct clk_init_data){
2361         .name = "vdec_1",
2362         .ops = &clk_regmap_mux_ops,
2363         .parent_hws = (const struct clk_hw *[]) {
2364             &meson8b_vdec_1_1.hw,
2365             &meson8b_vdec_1_2.hw,
2366         },
2367         .num_parents = 2,
2368         .flags = CLK_SET_RATE_PARENT,
2369     },
2370 };
2371 
2372 static struct clk_regmap meson8b_vdec_hcodec_sel = {
2373     .data = &(struct clk_regmap_mux_data){
2374         .offset = HHI_VDEC_CLK_CNTL,
2375         .mask = 0x3,
2376         .shift = 25,
2377         .flags = CLK_MUX_ROUND_CLOSEST,
2378     },
2379     .hw.init = &(struct clk_init_data){
2380         .name = "vdec_hcodec_sel",
2381         .ops = &clk_regmap_mux_ops,
2382         .parent_hws = meson8b_vdec_parent_hws,
2383         .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
2384         .flags = CLK_SET_RATE_PARENT,
2385     },
2386 };
2387 
2388 static struct clk_regmap meson8b_vdec_hcodec_div = {
2389     .data = &(struct clk_regmap_div_data){
2390         .offset = HHI_VDEC_CLK_CNTL,
2391         .shift = 16,
2392         .width = 7,
2393         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2394     },
2395     .hw.init = &(struct clk_init_data){
2396         .name = "vdec_hcodec_div",
2397         .ops = &clk_regmap_divider_ops,
2398         .parent_hws = (const struct clk_hw *[]) {
2399             &meson8b_vdec_hcodec_sel.hw
2400         },
2401         .num_parents = 1,
2402         .flags = CLK_SET_RATE_PARENT,
2403     },
2404 };
2405 
2406 static struct clk_regmap meson8b_vdec_hcodec = {
2407     .data = &(struct clk_regmap_gate_data){
2408         .offset = HHI_VDEC_CLK_CNTL,
2409         .bit_idx = 24,
2410     },
2411     .hw.init = &(struct clk_init_data) {
2412         .name = "vdec_hcodec",
2413         .ops = &clk_regmap_gate_ops,
2414         .parent_hws = (const struct clk_hw *[]) {
2415             &meson8b_vdec_hcodec_div.hw
2416         },
2417         .num_parents = 1,
2418         .flags = CLK_SET_RATE_PARENT,
2419     },
2420 };
2421 
2422 static struct clk_regmap meson8b_vdec_2_sel = {
2423     .data = &(struct clk_regmap_mux_data){
2424         .offset = HHI_VDEC2_CLK_CNTL,
2425         .mask = 0x3,
2426         .shift = 9,
2427         .flags = CLK_MUX_ROUND_CLOSEST,
2428     },
2429     .hw.init = &(struct clk_init_data){
2430         .name = "vdec_2_sel",
2431         .ops = &clk_regmap_mux_ops,
2432         .parent_hws = meson8b_vdec_parent_hws,
2433         .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
2434         .flags = CLK_SET_RATE_PARENT,
2435     },
2436 };
2437 
2438 static struct clk_regmap meson8b_vdec_2_div = {
2439     .data = &(struct clk_regmap_div_data){
2440         .offset = HHI_VDEC2_CLK_CNTL,
2441         .shift = 0,
2442         .width = 7,
2443         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2444     },
2445     .hw.init = &(struct clk_init_data){
2446         .name = "vdec_2_div",
2447         .ops = &clk_regmap_divider_ops,
2448         .parent_hws = (const struct clk_hw *[]) {
2449             &meson8b_vdec_2_sel.hw
2450         },
2451         .num_parents = 1,
2452         .flags = CLK_SET_RATE_PARENT,
2453     },
2454 };
2455 
2456 static struct clk_regmap meson8b_vdec_2 = {
2457     .data = &(struct clk_regmap_gate_data){
2458         .offset = HHI_VDEC2_CLK_CNTL,
2459         .bit_idx = 8,
2460     },
2461     .hw.init = &(struct clk_init_data) {
2462         .name = "vdec_2",
2463         .ops = &clk_regmap_gate_ops,
2464         .parent_hws = (const struct clk_hw *[]) {
2465             &meson8b_vdec_2_div.hw
2466         },
2467         .num_parents = 1,
2468         .flags = CLK_SET_RATE_PARENT,
2469     },
2470 };
2471 
2472 static struct clk_regmap meson8b_vdec_hevc_sel = {
2473     .data = &(struct clk_regmap_mux_data){
2474         .offset = HHI_VDEC2_CLK_CNTL,
2475         .mask = 0x3,
2476         .shift = 25,
2477         .flags = CLK_MUX_ROUND_CLOSEST,
2478     },
2479     .hw.init = &(struct clk_init_data){
2480         .name = "vdec_hevc_sel",
2481         .ops = &clk_regmap_mux_ops,
2482         .parent_hws = meson8b_vdec_parent_hws,
2483         .num_parents = ARRAY_SIZE(meson8b_vdec_parent_hws),
2484         .flags = CLK_SET_RATE_PARENT,
2485     },
2486 };
2487 
2488 static struct clk_regmap meson8b_vdec_hevc_div = {
2489     .data = &(struct clk_regmap_div_data){
2490         .offset = HHI_VDEC2_CLK_CNTL,
2491         .shift = 16,
2492         .width = 7,
2493         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2494     },
2495     .hw.init = &(struct clk_init_data){
2496         .name = "vdec_hevc_div",
2497         .ops = &clk_regmap_divider_ops,
2498         .parent_hws = (const struct clk_hw *[]) {
2499             &meson8b_vdec_hevc_sel.hw
2500         },
2501         .num_parents = 1,
2502         .flags = CLK_SET_RATE_PARENT,
2503     },
2504 };
2505 
2506 static struct clk_regmap meson8b_vdec_hevc_en = {
2507     .data = &(struct clk_regmap_gate_data){
2508         .offset = HHI_VDEC2_CLK_CNTL,
2509         .bit_idx = 24,
2510     },
2511     .hw.init = &(struct clk_init_data) {
2512         .name = "vdec_hevc_en",
2513         .ops = &clk_regmap_gate_ops,
2514         .parent_hws = (const struct clk_hw *[]) {
2515             &meson8b_vdec_hevc_div.hw
2516         },
2517         .num_parents = 1,
2518         .flags = CLK_SET_RATE_PARENT,
2519     },
2520 };
2521 
2522 static struct clk_regmap meson8b_vdec_hevc = {
2523     .data = &(struct clk_regmap_mux_data){
2524         .offset = HHI_VDEC2_CLK_CNTL,
2525         .mask = 0x1,
2526         .shift = 31,
2527         .flags = CLK_MUX_ROUND_CLOSEST,
2528     },
2529     .hw.init = &(struct clk_init_data){
2530         .name = "vdec_hevc",
2531         .ops = &clk_regmap_mux_ops,
2532         /* TODO: The second parent is currently unknown */
2533         .parent_hws = (const struct clk_hw *[]) {
2534             &meson8b_vdec_hevc_en.hw
2535         },
2536         .num_parents = 1,
2537         .flags = CLK_SET_RATE_PARENT,
2538     },
2539 };
2540 
2541 /* TODO: the clock at index 0 is "DDR_PLL" which we don't support yet */
2542 static const struct clk_hw *meson8b_cts_amclk_parent_hws[] = {
2543     &meson8b_mpll0.hw,
2544     &meson8b_mpll1.hw,
2545     &meson8b_mpll2.hw
2546 };
2547 
2548 static u32 meson8b_cts_amclk_mux_table[] = { 1, 2, 3 };
2549 
2550 static struct clk_regmap meson8b_cts_amclk_sel = {
2551     .data = &(struct clk_regmap_mux_data){
2552         .offset = HHI_AUD_CLK_CNTL,
2553         .mask = 0x3,
2554         .shift = 9,
2555         .table = meson8b_cts_amclk_mux_table,
2556         .flags = CLK_MUX_ROUND_CLOSEST,
2557     },
2558     .hw.init = &(struct clk_init_data){
2559         .name = "cts_amclk_sel",
2560         .ops = &clk_regmap_mux_ops,
2561         .parent_hws = meson8b_cts_amclk_parent_hws,
2562         .num_parents = ARRAY_SIZE(meson8b_cts_amclk_parent_hws),
2563     },
2564 };
2565 
2566 static struct clk_regmap meson8b_cts_amclk_div = {
2567     .data = &(struct clk_regmap_div_data) {
2568         .offset = HHI_AUD_CLK_CNTL,
2569         .shift = 0,
2570         .width = 8,
2571         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2572     },
2573     .hw.init = &(struct clk_init_data){
2574         .name = "cts_amclk_div",
2575         .ops = &clk_regmap_divider_ops,
2576         .parent_hws = (const struct clk_hw *[]) {
2577             &meson8b_cts_amclk_sel.hw
2578         },
2579         .num_parents = 1,
2580         .flags = CLK_SET_RATE_PARENT,
2581     },
2582 };
2583 
2584 static struct clk_regmap meson8b_cts_amclk = {
2585     .data = &(struct clk_regmap_gate_data){
2586         .offset = HHI_AUD_CLK_CNTL,
2587         .bit_idx = 8,
2588     },
2589     .hw.init = &(struct clk_init_data){
2590         .name = "cts_amclk",
2591         .ops = &clk_regmap_gate_ops,
2592         .parent_hws = (const struct clk_hw *[]) {
2593             &meson8b_cts_amclk_div.hw
2594         },
2595         .num_parents = 1,
2596         .flags = CLK_SET_RATE_PARENT,
2597     },
2598 };
2599 
2600 /* TODO: the clock at index 0 is "DDR_PLL" which we don't support yet */
2601 static const struct clk_hw *meson8b_cts_mclk_i958_parent_hws[] = {
2602     &meson8b_mpll0.hw,
2603     &meson8b_mpll1.hw,
2604     &meson8b_mpll2.hw
2605 };
2606 
2607 static u32 meson8b_cts_mclk_i958_mux_table[] = { 1, 2, 3 };
2608 
2609 static struct clk_regmap meson8b_cts_mclk_i958_sel = {
2610     .data = &(struct clk_regmap_mux_data){
2611         .offset = HHI_AUD_CLK_CNTL2,
2612         .mask = 0x3,
2613         .shift = 25,
2614         .table = meson8b_cts_mclk_i958_mux_table,
2615         .flags = CLK_MUX_ROUND_CLOSEST,
2616     },
2617     .hw.init = &(struct clk_init_data) {
2618         .name = "cts_mclk_i958_sel",
2619         .ops = &clk_regmap_mux_ops,
2620         .parent_hws = meson8b_cts_mclk_i958_parent_hws,
2621         .num_parents = ARRAY_SIZE(meson8b_cts_mclk_i958_parent_hws),
2622     },
2623 };
2624 
2625 static struct clk_regmap meson8b_cts_mclk_i958_div = {
2626     .data = &(struct clk_regmap_div_data){
2627         .offset = HHI_AUD_CLK_CNTL2,
2628         .shift = 16,
2629         .width = 8,
2630         .flags = CLK_DIVIDER_ROUND_CLOSEST,
2631     },
2632     .hw.init = &(struct clk_init_data) {
2633         .name = "cts_mclk_i958_div",
2634         .ops = &clk_regmap_divider_ops,
2635         .parent_hws = (const struct clk_hw *[]) {
2636             &meson8b_cts_mclk_i958_sel.hw
2637         },
2638         .num_parents = 1,
2639         .flags = CLK_SET_RATE_PARENT,
2640     },
2641 };
2642 
2643 static struct clk_regmap meson8b_cts_mclk_i958 = {
2644     .data = &(struct clk_regmap_gate_data){
2645         .offset = HHI_AUD_CLK_CNTL2,
2646         .bit_idx = 24,
2647     },
2648     .hw.init = &(struct clk_init_data){
2649         .name = "cts_mclk_i958",
2650         .ops = &clk_regmap_gate_ops,
2651         .parent_hws = (const struct clk_hw *[]) {
2652             &meson8b_cts_mclk_i958_div.hw
2653         },
2654         .num_parents = 1,
2655         .flags = CLK_SET_RATE_PARENT,
2656     },
2657 };
2658 
2659 static struct clk_regmap meson8b_cts_i958 = {
2660     .data = &(struct clk_regmap_mux_data){
2661         .offset = HHI_AUD_CLK_CNTL2,
2662         .mask = 0x1,
2663         .shift = 27,
2664         },
2665     .hw.init = &(struct clk_init_data){
2666         .name = "cts_i958",
2667         .ops = &clk_regmap_mux_ops,
2668         .parent_hws = (const struct clk_hw *[]) {
2669             &meson8b_cts_amclk.hw,
2670             &meson8b_cts_mclk_i958.hw
2671         },
2672         .num_parents = 2,
2673         /*
2674          * The parent is specific to origin of the audio data. Let the
2675          * consumer choose the appropriate parent.
2676          */
2677         .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
2678     },
2679 };
2680 
2681 #define MESON_GATE(_name, _reg, _bit) \
2682     MESON_PCLK(_name, _reg, _bit, &meson8b_clk81.hw)
2683 
2684 /* Everything Else (EE) domain gates */
2685 
2686 static MESON_GATE(meson8b_ddr, HHI_GCLK_MPEG0, 0);
2687 static MESON_GATE(meson8b_dos, HHI_GCLK_MPEG0, 1);
2688 static MESON_GATE(meson8b_isa, HHI_GCLK_MPEG0, 5);
2689 static MESON_GATE(meson8b_pl301, HHI_GCLK_MPEG0, 6);
2690 static MESON_GATE(meson8b_periphs, HHI_GCLK_MPEG0, 7);
2691 static MESON_GATE(meson8b_spicc, HHI_GCLK_MPEG0, 8);
2692 static MESON_GATE(meson8b_i2c, HHI_GCLK_MPEG0, 9);
2693 static MESON_GATE(meson8b_sar_adc, HHI_GCLK_MPEG0, 10);
2694 static MESON_GATE(meson8b_smart_card, HHI_GCLK_MPEG0, 11);
2695 static MESON_GATE(meson8b_rng0, HHI_GCLK_MPEG0, 12);
2696 static MESON_GATE(meson8b_uart0, HHI_GCLK_MPEG0, 13);
2697 static MESON_GATE(meson8b_sdhc, HHI_GCLK_MPEG0, 14);
2698 static MESON_GATE(meson8b_stream, HHI_GCLK_MPEG0, 15);
2699 static MESON_GATE(meson8b_async_fifo, HHI_GCLK_MPEG0, 16);
2700 static MESON_GATE(meson8b_sdio, HHI_GCLK_MPEG0, 17);
2701 static MESON_GATE(meson8b_abuf, HHI_GCLK_MPEG0, 18);
2702 static MESON_GATE(meson8b_hiu_iface, HHI_GCLK_MPEG0, 19);
2703 static MESON_GATE(meson8b_assist_misc, HHI_GCLK_MPEG0, 23);
2704 static MESON_GATE(meson8b_spi, HHI_GCLK_MPEG0, 30);
2705 
2706 static MESON_GATE(meson8b_i2s_spdif, HHI_GCLK_MPEG1, 2);
2707 static MESON_GATE(meson8b_eth, HHI_GCLK_MPEG1, 3);
2708 static MESON_GATE(meson8b_demux, HHI_GCLK_MPEG1, 4);
2709 static MESON_GATE(meson8b_blkmv, HHI_GCLK_MPEG1, 14);
2710 static MESON_GATE(meson8b_aiu, HHI_GCLK_MPEG1, 15);
2711 static MESON_GATE(meson8b_uart1, HHI_GCLK_MPEG1, 16);
2712 static MESON_GATE(meson8b_g2d, HHI_GCLK_MPEG1, 20);
2713 static MESON_GATE(meson8b_usb0, HHI_GCLK_MPEG1, 21);
2714 static MESON_GATE(meson8b_usb1, HHI_GCLK_MPEG1, 22);
2715 static MESON_GATE(meson8b_reset, HHI_GCLK_MPEG1, 23);
2716 static MESON_GATE(meson8b_nand, HHI_GCLK_MPEG1, 24);
2717 static MESON_GATE(meson8b_dos_parser, HHI_GCLK_MPEG1, 25);
2718 static MESON_GATE(meson8b_usb, HHI_GCLK_MPEG1, 26);
2719 static MESON_GATE(meson8b_vdin1, HHI_GCLK_MPEG1, 28);
2720 static MESON_GATE(meson8b_ahb_arb0, HHI_GCLK_MPEG1, 29);
2721 static MESON_GATE(meson8b_efuse, HHI_GCLK_MPEG1, 30);
2722 static MESON_GATE(meson8b_boot_rom, HHI_GCLK_MPEG1, 31);
2723 
2724 static MESON_GATE(meson8b_ahb_data_bus, HHI_GCLK_MPEG2, 1);
2725 static MESON_GATE(meson8b_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
2726 static MESON_GATE(meson8b_hdmi_intr_sync, HHI_GCLK_MPEG2, 3);
2727 static MESON_GATE(meson8b_hdmi_pclk, HHI_GCLK_MPEG2, 4);
2728 static MESON_GATE(meson8b_usb1_ddr_bridge, HHI_GCLK_MPEG2, 8);
2729 static MESON_GATE(meson8b_usb0_ddr_bridge, HHI_GCLK_MPEG2, 9);
2730 static MESON_GATE(meson8b_mmc_pclk, HHI_GCLK_MPEG2, 11);
2731 static MESON_GATE(meson8b_dvin, HHI_GCLK_MPEG2, 12);
2732 static MESON_GATE(meson8b_uart2, HHI_GCLK_MPEG2, 15);
2733 static MESON_GATE(meson8b_sana, HHI_GCLK_MPEG2, 22);
2734 static MESON_GATE(meson8b_vpu_intr, HHI_GCLK_MPEG2, 25);
2735 static MESON_GATE(meson8b_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
2736 static MESON_GATE(meson8b_clk81_a9, HHI_GCLK_MPEG2, 29);
2737 
2738 static MESON_GATE(meson8b_vclk2_venci0, HHI_GCLK_OTHER, 1);
2739 static MESON_GATE(meson8b_vclk2_venci1, HHI_GCLK_OTHER, 2);
2740 static MESON_GATE(meson8b_vclk2_vencp0, HHI_GCLK_OTHER, 3);
2741 static MESON_GATE(meson8b_vclk2_vencp1, HHI_GCLK_OTHER, 4);
2742 static MESON_GATE(meson8b_gclk_venci_int, HHI_GCLK_OTHER, 8);
2743 static MESON_GATE(meson8b_gclk_vencp_int, HHI_GCLK_OTHER, 9);
2744 static MESON_GATE(meson8b_dac_clk, HHI_GCLK_OTHER, 10);
2745 static MESON_GATE(meson8b_aoclk_gate, HHI_GCLK_OTHER, 14);
2746 static MESON_GATE(meson8b_iec958_gate, HHI_GCLK_OTHER, 16);
2747 static MESON_GATE(meson8b_enc480p, HHI_GCLK_OTHER, 20);
2748 static MESON_GATE(meson8b_rng1, HHI_GCLK_OTHER, 21);
2749 static MESON_GATE(meson8b_gclk_vencl_int, HHI_GCLK_OTHER, 22);
2750 static MESON_GATE(meson8b_vclk2_venclmcc, HHI_GCLK_OTHER, 24);
2751 static MESON_GATE(meson8b_vclk2_vencl, HHI_GCLK_OTHER, 25);
2752 static MESON_GATE(meson8b_vclk2_other, HHI_GCLK_OTHER, 26);
2753 static MESON_GATE(meson8b_edp, HHI_GCLK_OTHER, 31);
2754 
2755 /* AIU gates */
2756 #define MESON_AIU_GLUE_GATE(_name, _reg, _bit) \
2757     MESON_PCLK(_name, _reg, _bit, &meson8b_aiu_glue.hw)
2758 
2759 static MESON_PCLK(meson8b_aiu_glue, HHI_GCLK_MPEG1, 6, &meson8b_aiu.hw);
2760 static MESON_AIU_GLUE_GATE(meson8b_iec958, HHI_GCLK_MPEG1, 7);
2761 static MESON_AIU_GLUE_GATE(meson8b_i2s_out, HHI_GCLK_MPEG1, 8);
2762 static MESON_AIU_GLUE_GATE(meson8b_amclk, HHI_GCLK_MPEG1, 9);
2763 static MESON_AIU_GLUE_GATE(meson8b_aififo2, HHI_GCLK_MPEG1, 10);
2764 static MESON_AIU_GLUE_GATE(meson8b_mixer, HHI_GCLK_MPEG1, 11);
2765 static MESON_AIU_GLUE_GATE(meson8b_mixer_iface, HHI_GCLK_MPEG1, 12);
2766 static MESON_AIU_GLUE_GATE(meson8b_adc, HHI_GCLK_MPEG1, 13);
2767 
2768 /* Always On (AO) domain gates */
2769 
2770 static MESON_GATE(meson8b_ao_media_cpu, HHI_GCLK_AO, 0);
2771 static MESON_GATE(meson8b_ao_ahb_sram, HHI_GCLK_AO, 1);
2772 static MESON_GATE(meson8b_ao_ahb_bus, HHI_GCLK_AO, 2);
2773 static MESON_GATE(meson8b_ao_iface, HHI_GCLK_AO, 3);
2774 
2775 static struct clk_hw_onecell_data meson8_hw_onecell_data = {
2776     .hws = {
2777         [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
2778         [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
2779         [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
2780         [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
2781         [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
2782         [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
2783         [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
2784         [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
2785         [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
2786         [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
2787         [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
2788         [CLKID_CLK81] = &meson8b_clk81.hw,
2789         [CLKID_DDR]         = &meson8b_ddr.hw,
2790         [CLKID_DOS]         = &meson8b_dos.hw,
2791         [CLKID_ISA]         = &meson8b_isa.hw,
2792         [CLKID_PL301]           = &meson8b_pl301.hw,
2793         [CLKID_PERIPHS]         = &meson8b_periphs.hw,
2794         [CLKID_SPICC]           = &meson8b_spicc.hw,
2795         [CLKID_I2C]         = &meson8b_i2c.hw,
2796         [CLKID_SAR_ADC]         = &meson8b_sar_adc.hw,
2797         [CLKID_SMART_CARD]      = &meson8b_smart_card.hw,
2798         [CLKID_RNG0]            = &meson8b_rng0.hw,
2799         [CLKID_UART0]           = &meson8b_uart0.hw,
2800         [CLKID_SDHC]            = &meson8b_sdhc.hw,
2801         [CLKID_STREAM]          = &meson8b_stream.hw,
2802         [CLKID_ASYNC_FIFO]      = &meson8b_async_fifo.hw,
2803         [CLKID_SDIO]            = &meson8b_sdio.hw,
2804         [CLKID_ABUF]            = &meson8b_abuf.hw,
2805         [CLKID_HIU_IFACE]       = &meson8b_hiu_iface.hw,
2806         [CLKID_ASSIST_MISC]     = &meson8b_assist_misc.hw,
2807         [CLKID_SPI]         = &meson8b_spi.hw,
2808         [CLKID_I2S_SPDIF]       = &meson8b_i2s_spdif.hw,
2809         [CLKID_ETH]         = &meson8b_eth.hw,
2810         [CLKID_DEMUX]           = &meson8b_demux.hw,
2811         [CLKID_AIU_GLUE]        = &meson8b_aiu_glue.hw,
2812         [CLKID_IEC958]          = &meson8b_iec958.hw,
2813         [CLKID_I2S_OUT]         = &meson8b_i2s_out.hw,
2814         [CLKID_AMCLK]           = &meson8b_amclk.hw,
2815         [CLKID_AIFIFO2]         = &meson8b_aififo2.hw,
2816         [CLKID_MIXER]           = &meson8b_mixer.hw,
2817         [CLKID_MIXER_IFACE]     = &meson8b_mixer_iface.hw,
2818         [CLKID_ADC]         = &meson8b_adc.hw,
2819         [CLKID_BLKMV]           = &meson8b_blkmv.hw,
2820         [CLKID_AIU]         = &meson8b_aiu.hw,
2821         [CLKID_UART1]           = &meson8b_uart1.hw,
2822         [CLKID_G2D]         = &meson8b_g2d.hw,
2823         [CLKID_USB0]            = &meson8b_usb0.hw,
2824         [CLKID_USB1]            = &meson8b_usb1.hw,
2825         [CLKID_RESET]           = &meson8b_reset.hw,
2826         [CLKID_NAND]            = &meson8b_nand.hw,
2827         [CLKID_DOS_PARSER]      = &meson8b_dos_parser.hw,
2828         [CLKID_USB]         = &meson8b_usb.hw,
2829         [CLKID_VDIN1]           = &meson8b_vdin1.hw,
2830         [CLKID_AHB_ARB0]        = &meson8b_ahb_arb0.hw,
2831         [CLKID_EFUSE]           = &meson8b_efuse.hw,
2832         [CLKID_BOOT_ROM]        = &meson8b_boot_rom.hw,
2833         [CLKID_AHB_DATA_BUS]        = &meson8b_ahb_data_bus.hw,
2834         [CLKID_AHB_CTRL_BUS]        = &meson8b_ahb_ctrl_bus.hw,
2835         [CLKID_HDMI_INTR_SYNC]      = &meson8b_hdmi_intr_sync.hw,
2836         [CLKID_HDMI_PCLK]       = &meson8b_hdmi_pclk.hw,
2837         [CLKID_USB1_DDR_BRIDGE]     = &meson8b_usb1_ddr_bridge.hw,
2838         [CLKID_USB0_DDR_BRIDGE]     = &meson8b_usb0_ddr_bridge.hw,
2839         [CLKID_MMC_PCLK]        = &meson8b_mmc_pclk.hw,
2840         [CLKID_DVIN]            = &meson8b_dvin.hw,
2841         [CLKID_UART2]           = &meson8b_uart2.hw,
2842         [CLKID_SANA]            = &meson8b_sana.hw,
2843         [CLKID_VPU_INTR]        = &meson8b_vpu_intr.hw,
2844         [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
2845         [CLKID_CLK81_A9]        = &meson8b_clk81_a9.hw,
2846         [CLKID_VCLK2_VENCI0]        = &meson8b_vclk2_venci0.hw,
2847         [CLKID_VCLK2_VENCI1]        = &meson8b_vclk2_venci1.hw,
2848         [CLKID_VCLK2_VENCP0]        = &meson8b_vclk2_vencp0.hw,
2849         [CLKID_VCLK2_VENCP1]        = &meson8b_vclk2_vencp1.hw,
2850         [CLKID_GCLK_VENCI_INT]      = &meson8b_gclk_venci_int.hw,
2851         [CLKID_GCLK_VENCP_INT]      = &meson8b_gclk_vencp_int.hw,
2852         [CLKID_DAC_CLK]         = &meson8b_dac_clk.hw,
2853         [CLKID_AOCLK_GATE]      = &meson8b_aoclk_gate.hw,
2854         [CLKID_IEC958_GATE]     = &meson8b_iec958_gate.hw,
2855         [CLKID_ENC480P]         = &meson8b_enc480p.hw,
2856         [CLKID_RNG1]            = &meson8b_rng1.hw,
2857         [CLKID_GCLK_VENCL_INT]      = &meson8b_gclk_vencl_int.hw,
2858         [CLKID_VCLK2_VENCLMCC]      = &meson8b_vclk2_venclmcc.hw,
2859         [CLKID_VCLK2_VENCL]     = &meson8b_vclk2_vencl.hw,
2860         [CLKID_VCLK2_OTHER]     = &meson8b_vclk2_other.hw,
2861         [CLKID_EDP]         = &meson8b_edp.hw,
2862         [CLKID_AO_MEDIA_CPU]        = &meson8b_ao_media_cpu.hw,
2863         [CLKID_AO_AHB_SRAM]     = &meson8b_ao_ahb_sram.hw,
2864         [CLKID_AO_AHB_BUS]      = &meson8b_ao_ahb_bus.hw,
2865         [CLKID_AO_IFACE]        = &meson8b_ao_iface.hw,
2866         [CLKID_MPLL0]           = &meson8b_mpll0.hw,
2867         [CLKID_MPLL1]           = &meson8b_mpll1.hw,
2868         [CLKID_MPLL2]           = &meson8b_mpll2.hw,
2869         [CLKID_MPLL0_DIV]       = &meson8b_mpll0_div.hw,
2870         [CLKID_MPLL1_DIV]       = &meson8b_mpll1_div.hw,
2871         [CLKID_MPLL2_DIV]       = &meson8b_mpll2_div.hw,
2872         [CLKID_CPU_IN_SEL]      = &meson8b_cpu_in_sel.hw,
2873         [CLKID_CPU_IN_DIV2]     = &meson8b_cpu_in_div2.hw,
2874         [CLKID_CPU_IN_DIV3]     = &meson8b_cpu_in_div3.hw,
2875         [CLKID_CPU_SCALE_DIV]       = &meson8b_cpu_scale_div.hw,
2876         [CLKID_CPU_SCALE_OUT_SEL]   = &meson8b_cpu_scale_out_sel.hw,
2877         [CLKID_MPLL_PREDIV]     = &meson8b_mpll_prediv.hw,
2878         [CLKID_FCLK_DIV2_DIV]       = &meson8b_fclk_div2_div.hw,
2879         [CLKID_FCLK_DIV3_DIV]       = &meson8b_fclk_div3_div.hw,
2880         [CLKID_FCLK_DIV4_DIV]       = &meson8b_fclk_div4_div.hw,
2881         [CLKID_FCLK_DIV5_DIV]       = &meson8b_fclk_div5_div.hw,
2882         [CLKID_FCLK_DIV7_DIV]       = &meson8b_fclk_div7_div.hw,
2883         [CLKID_NAND_SEL]        = &meson8b_nand_clk_sel.hw,
2884         [CLKID_NAND_DIV]        = &meson8b_nand_clk_div.hw,
2885         [CLKID_NAND_CLK]        = &meson8b_nand_clk_gate.hw,
2886         [CLKID_PLL_FIXED_DCO]       = &meson8b_fixed_pll_dco.hw,
2887         [CLKID_HDMI_PLL_DCO]        = &meson8b_hdmi_pll_dco.hw,
2888         [CLKID_PLL_SYS_DCO]     = &meson8b_sys_pll_dco.hw,
2889         [CLKID_CPU_CLK_DIV2]        = &meson8b_cpu_clk_div2.hw,
2890         [CLKID_CPU_CLK_DIV3]        = &meson8b_cpu_clk_div3.hw,
2891         [CLKID_CPU_CLK_DIV4]        = &meson8b_cpu_clk_div4.hw,
2892         [CLKID_CPU_CLK_DIV5]        = &meson8b_cpu_clk_div5.hw,
2893         [CLKID_CPU_CLK_DIV6]        = &meson8b_cpu_clk_div6.hw,
2894         [CLKID_CPU_CLK_DIV7]        = &meson8b_cpu_clk_div7.hw,
2895         [CLKID_CPU_CLK_DIV8]        = &meson8b_cpu_clk_div8.hw,
2896         [CLKID_APB_SEL]         = &meson8b_apb_clk_sel.hw,
2897         [CLKID_APB]         = &meson8b_apb_clk_gate.hw,
2898         [CLKID_PERIPH_SEL]      = &meson8b_periph_clk_sel.hw,
2899         [CLKID_PERIPH]          = &meson8b_periph_clk_gate.hw,
2900         [CLKID_AXI_SEL]         = &meson8b_axi_clk_sel.hw,
2901         [CLKID_AXI]         = &meson8b_axi_clk_gate.hw,
2902         [CLKID_L2_DRAM_SEL]     = &meson8b_l2_dram_clk_sel.hw,
2903         [CLKID_L2_DRAM]         = &meson8b_l2_dram_clk_gate.hw,
2904         [CLKID_HDMI_PLL_LVDS_OUT]   = &meson8b_hdmi_pll_lvds_out.hw,
2905         [CLKID_HDMI_PLL_HDMI_OUT]   = &meson8b_hdmi_pll_hdmi_out.hw,
2906         [CLKID_VID_PLL_IN_SEL]      = &meson8b_vid_pll_in_sel.hw,
2907         [CLKID_VID_PLL_IN_EN]       = &meson8b_vid_pll_in_en.hw,
2908         [CLKID_VID_PLL_PRE_DIV]     = &meson8b_vid_pll_pre_div.hw,
2909         [CLKID_VID_PLL_POST_DIV]    = &meson8b_vid_pll_post_div.hw,
2910         [CLKID_VID_PLL_FINAL_DIV]   = &meson8b_vid_pll_final_div.hw,
2911         [CLKID_VCLK_IN_SEL]     = &meson8b_vclk_in_sel.hw,
2912         [CLKID_VCLK_IN_EN]      = &meson8b_vclk_in_en.hw,
2913         [CLKID_VCLK_EN]         = &meson8b_vclk_en.hw,
2914         [CLKID_VCLK_DIV1]       = &meson8b_vclk_div1_gate.hw,
2915         [CLKID_VCLK_DIV2_DIV]       = &meson8b_vclk_div2_div.hw,
2916         [CLKID_VCLK_DIV2]       = &meson8b_vclk_div2_div_gate.hw,
2917         [CLKID_VCLK_DIV4_DIV]       = &meson8b_vclk_div4_div.hw,
2918         [CLKID_VCLK_DIV4]       = &meson8b_vclk_div4_div_gate.hw,
2919         [CLKID_VCLK_DIV6_DIV]       = &meson8b_vclk_div6_div.hw,
2920         [CLKID_VCLK_DIV6]       = &meson8b_vclk_div6_div_gate.hw,
2921         [CLKID_VCLK_DIV12_DIV]      = &meson8b_vclk_div12_div.hw,
2922         [CLKID_VCLK_DIV12]      = &meson8b_vclk_div12_div_gate.hw,
2923         [CLKID_VCLK2_IN_SEL]        = &meson8b_vclk2_in_sel.hw,
2924         [CLKID_VCLK2_IN_EN]     = &meson8b_vclk2_clk_in_en.hw,
2925         [CLKID_VCLK2_EN]        = &meson8b_vclk2_clk_en.hw,
2926         [CLKID_VCLK2_DIV1]      = &meson8b_vclk2_div1_gate.hw,
2927         [CLKID_VCLK2_DIV2_DIV]      = &meson8b_vclk2_div2_div.hw,
2928         [CLKID_VCLK2_DIV2]      = &meson8b_vclk2_div2_div_gate.hw,
2929         [CLKID_VCLK2_DIV4_DIV]      = &meson8b_vclk2_div4_div.hw,
2930         [CLKID_VCLK2_DIV4]      = &meson8b_vclk2_div4_div_gate.hw,
2931         [CLKID_VCLK2_DIV6_DIV]      = &meson8b_vclk2_div6_div.hw,
2932         [CLKID_VCLK2_DIV6]      = &meson8b_vclk2_div6_div_gate.hw,
2933         [CLKID_VCLK2_DIV12_DIV]     = &meson8b_vclk2_div12_div.hw,
2934         [CLKID_VCLK2_DIV12]     = &meson8b_vclk2_div12_div_gate.hw,
2935         [CLKID_CTS_ENCT_SEL]        = &meson8b_cts_enct_sel.hw,
2936         [CLKID_CTS_ENCT]        = &meson8b_cts_enct.hw,
2937         [CLKID_CTS_ENCP_SEL]        = &meson8b_cts_encp_sel.hw,
2938         [CLKID_CTS_ENCP]        = &meson8b_cts_encp.hw,
2939         [CLKID_CTS_ENCI_SEL]        = &meson8b_cts_enci_sel.hw,
2940         [CLKID_CTS_ENCI]        = &meson8b_cts_enci.hw,
2941         [CLKID_HDMI_TX_PIXEL_SEL]   = &meson8b_hdmi_tx_pixel_sel.hw,
2942         [CLKID_HDMI_TX_PIXEL]       = &meson8b_hdmi_tx_pixel.hw,
2943         [CLKID_CTS_ENCL_SEL]        = &meson8b_cts_encl_sel.hw,
2944         [CLKID_CTS_ENCL]        = &meson8b_cts_encl.hw,
2945         [CLKID_CTS_VDAC0_SEL]       = &meson8b_cts_vdac0_sel.hw,
2946         [CLKID_CTS_VDAC0]       = &meson8b_cts_vdac0.hw,
2947         [CLKID_HDMI_SYS_SEL]        = &meson8b_hdmi_sys_sel.hw,
2948         [CLKID_HDMI_SYS_DIV]        = &meson8b_hdmi_sys_div.hw,
2949         [CLKID_HDMI_SYS]        = &meson8b_hdmi_sys.hw,
2950         [CLKID_MALI_0_SEL]      = &meson8b_mali_0_sel.hw,
2951         [CLKID_MALI_0_DIV]      = &meson8b_mali_0_div.hw,
2952         [CLKID_MALI]            = &meson8b_mali_0.hw,
2953         [CLKID_VPU_0_SEL]       = &meson8b_vpu_0_sel.hw,
2954         [CLKID_VPU_0_DIV]       = &meson8b_vpu_0_div.hw,
2955         [CLKID_VPU]         = &meson8b_vpu_0.hw,
2956         [CLKID_VDEC_1_SEL]      = &meson8b_vdec_1_sel.hw,
2957         [CLKID_VDEC_1_1_DIV]        = &meson8b_vdec_1_1_div.hw,
2958         [CLKID_VDEC_1]          = &meson8b_vdec_1_1.hw,
2959         [CLKID_VDEC_HCODEC_SEL]     = &meson8b_vdec_hcodec_sel.hw,
2960         [CLKID_VDEC_HCODEC_DIV]     = &meson8b_vdec_hcodec_div.hw,
2961         [CLKID_VDEC_HCODEC]     = &meson8b_vdec_hcodec.hw,
2962         [CLKID_VDEC_2_SEL]      = &meson8b_vdec_2_sel.hw,
2963         [CLKID_VDEC_2_DIV]      = &meson8b_vdec_2_div.hw,
2964         [CLKID_VDEC_2]              = &meson8b_vdec_2.hw,
2965         [CLKID_VDEC_HEVC_SEL]       = &meson8b_vdec_hevc_sel.hw,
2966         [CLKID_VDEC_HEVC_DIV]       = &meson8b_vdec_hevc_div.hw,
2967         [CLKID_VDEC_HEVC_EN]        = &meson8b_vdec_hevc_en.hw,
2968         [CLKID_VDEC_HEVC]       = &meson8b_vdec_hevc.hw,
2969         [CLKID_CTS_AMCLK_SEL]       = &meson8b_cts_amclk_sel.hw,
2970         [CLKID_CTS_AMCLK_DIV]       = &meson8b_cts_amclk_div.hw,
2971         [CLKID_CTS_AMCLK]       = &meson8b_cts_amclk.hw,
2972         [CLKID_CTS_MCLK_I958_SEL]   = &meson8b_cts_mclk_i958_sel.hw,
2973         [CLKID_CTS_MCLK_I958_DIV]   = &meson8b_cts_mclk_i958_div.hw,
2974         [CLKID_CTS_MCLK_I958]       = &meson8b_cts_mclk_i958.hw,
2975         [CLKID_CTS_I958]        = &meson8b_cts_i958.hw,
2976         [CLKID_VID_PLL_LVDS_EN]     = &meson8b_vid_pll_lvds_en.hw,
2977         [CLKID_HDMI_PLL_DCO_IN]     = &hdmi_pll_dco_in.hw,
2978         [CLK_NR_CLKS]           = NULL,
2979     },
2980     .num = CLK_NR_CLKS,
2981 };
2982 
2983 static struct clk_hw_onecell_data meson8b_hw_onecell_data = {
2984     .hws = {
2985         [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
2986         [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
2987         [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
2988         [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
2989         [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
2990         [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
2991         [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
2992         [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
2993         [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
2994         [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
2995         [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
2996         [CLKID_CLK81] = &meson8b_clk81.hw,
2997         [CLKID_DDR]         = &meson8b_ddr.hw,
2998         [CLKID_DOS]         = &meson8b_dos.hw,
2999         [CLKID_ISA]         = &meson8b_isa.hw,
3000         [CLKID_PL301]           = &meson8b_pl301.hw,
3001         [CLKID_PERIPHS]         = &meson8b_periphs.hw,
3002         [CLKID_SPICC]           = &meson8b_spicc.hw,
3003         [CLKID_I2C]         = &meson8b_i2c.hw,
3004         [CLKID_SAR_ADC]         = &meson8b_sar_adc.hw,
3005         [CLKID_SMART_CARD]      = &meson8b_smart_card.hw,
3006         [CLKID_RNG0]            = &meson8b_rng0.hw,
3007         [CLKID_UART0]           = &meson8b_uart0.hw,
3008         [CLKID_SDHC]            = &meson8b_sdhc.hw,
3009         [CLKID_STREAM]          = &meson8b_stream.hw,
3010         [CLKID_ASYNC_FIFO]      = &meson8b_async_fifo.hw,
3011         [CLKID_SDIO]            = &meson8b_sdio.hw,
3012         [CLKID_ABUF]            = &meson8b_abuf.hw,
3013         [CLKID_HIU_IFACE]       = &meson8b_hiu_iface.hw,
3014         [CLKID_ASSIST_MISC]     = &meson8b_assist_misc.hw,
3015         [CLKID_SPI]         = &meson8b_spi.hw,
3016         [CLKID_I2S_SPDIF]       = &meson8b_i2s_spdif.hw,
3017         [CLKID_ETH]         = &meson8b_eth.hw,
3018         [CLKID_DEMUX]           = &meson8b_demux.hw,
3019         [CLKID_AIU_GLUE]        = &meson8b_aiu_glue.hw,
3020         [CLKID_IEC958]          = &meson8b_iec958.hw,
3021         [CLKID_I2S_OUT]         = &meson8b_i2s_out.hw,
3022         [CLKID_AMCLK]           = &meson8b_amclk.hw,
3023         [CLKID_AIFIFO2]         = &meson8b_aififo2.hw,
3024         [CLKID_MIXER]           = &meson8b_mixer.hw,
3025         [CLKID_MIXER_IFACE]     = &meson8b_mixer_iface.hw,
3026         [CLKID_ADC]         = &meson8b_adc.hw,
3027         [CLKID_BLKMV]           = &meson8b_blkmv.hw,
3028         [CLKID_AIU]         = &meson8b_aiu.hw,
3029         [CLKID_UART1]           = &meson8b_uart1.hw,
3030         [CLKID_G2D]         = &meson8b_g2d.hw,
3031         [CLKID_USB0]            = &meson8b_usb0.hw,
3032         [CLKID_USB1]            = &meson8b_usb1.hw,
3033         [CLKID_RESET]           = &meson8b_reset.hw,
3034         [CLKID_NAND]            = &meson8b_nand.hw,
3035         [CLKID_DOS_PARSER]      = &meson8b_dos_parser.hw,
3036         [CLKID_USB]         = &meson8b_usb.hw,
3037         [CLKID_VDIN1]           = &meson8b_vdin1.hw,
3038         [CLKID_AHB_ARB0]        = &meson8b_ahb_arb0.hw,
3039         [CLKID_EFUSE]           = &meson8b_efuse.hw,
3040         [CLKID_BOOT_ROM]        = &meson8b_boot_rom.hw,
3041         [CLKID_AHB_DATA_BUS]        = &meson8b_ahb_data_bus.hw,
3042         [CLKID_AHB_CTRL_BUS]        = &meson8b_ahb_ctrl_bus.hw,
3043         [CLKID_HDMI_INTR_SYNC]      = &meson8b_hdmi_intr_sync.hw,
3044         [CLKID_HDMI_PCLK]       = &meson8b_hdmi_pclk.hw,
3045         [CLKID_USB1_DDR_BRIDGE]     = &meson8b_usb1_ddr_bridge.hw,
3046         [CLKID_USB0_DDR_BRIDGE]     = &meson8b_usb0_ddr_bridge.hw,
3047         [CLKID_MMC_PCLK]        = &meson8b_mmc_pclk.hw,
3048         [CLKID_DVIN]            = &meson8b_dvin.hw,
3049         [CLKID_UART2]           = &meson8b_uart2.hw,
3050         [CLKID_SANA]            = &meson8b_sana.hw,
3051         [CLKID_VPU_INTR]        = &meson8b_vpu_intr.hw,
3052         [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
3053         [CLKID_CLK81_A9]        = &meson8b_clk81_a9.hw,
3054         [CLKID_VCLK2_VENCI0]        = &meson8b_vclk2_venci0.hw,
3055         [CLKID_VCLK2_VENCI1]        = &meson8b_vclk2_venci1.hw,
3056         [CLKID_VCLK2_VENCP0]        = &meson8b_vclk2_vencp0.hw,
3057         [CLKID_VCLK2_VENCP1]        = &meson8b_vclk2_vencp1.hw,
3058         [CLKID_GCLK_VENCI_INT]      = &meson8b_gclk_venci_int.hw,
3059         [CLKID_GCLK_VENCP_INT]      = &meson8b_gclk_vencp_int.hw,
3060         [CLKID_DAC_CLK]         = &meson8b_dac_clk.hw,
3061         [CLKID_AOCLK_GATE]      = &meson8b_aoclk_gate.hw,
3062         [CLKID_IEC958_GATE]     = &meson8b_iec958_gate.hw,
3063         [CLKID_ENC480P]         = &meson8b_enc480p.hw,
3064         [CLKID_RNG1]            = &meson8b_rng1.hw,
3065         [CLKID_GCLK_VENCL_INT]      = &meson8b_gclk_vencl_int.hw,
3066         [CLKID_VCLK2_VENCLMCC]      = &meson8b_vclk2_venclmcc.hw,
3067         [CLKID_VCLK2_VENCL]     = &meson8b_vclk2_vencl.hw,
3068         [CLKID_VCLK2_OTHER]     = &meson8b_vclk2_other.hw,
3069         [CLKID_EDP]         = &meson8b_edp.hw,
3070         [CLKID_AO_MEDIA_CPU]        = &meson8b_ao_media_cpu.hw,
3071         [CLKID_AO_AHB_SRAM]     = &meson8b_ao_ahb_sram.hw,
3072         [CLKID_AO_AHB_BUS]      = &meson8b_ao_ahb_bus.hw,
3073         [CLKID_AO_IFACE]        = &meson8b_ao_iface.hw,
3074         [CLKID_MPLL0]           = &meson8b_mpll0.hw,
3075         [CLKID_MPLL1]           = &meson8b_mpll1.hw,
3076         [CLKID_MPLL2]           = &meson8b_mpll2.hw,
3077         [CLKID_MPLL0_DIV]       = &meson8b_mpll0_div.hw,
3078         [CLKID_MPLL1_DIV]       = &meson8b_mpll1_div.hw,
3079         [CLKID_MPLL2_DIV]       = &meson8b_mpll2_div.hw,
3080         [CLKID_CPU_IN_SEL]      = &meson8b_cpu_in_sel.hw,
3081         [CLKID_CPU_IN_DIV2]     = &meson8b_cpu_in_div2.hw,
3082         [CLKID_CPU_IN_DIV3]     = &meson8b_cpu_in_div3.hw,
3083         [CLKID_CPU_SCALE_DIV]       = &meson8b_cpu_scale_div.hw,
3084         [CLKID_CPU_SCALE_OUT_SEL]   = &meson8b_cpu_scale_out_sel.hw,
3085         [CLKID_MPLL_PREDIV]     = &meson8b_mpll_prediv.hw,
3086         [CLKID_FCLK_DIV2_DIV]       = &meson8b_fclk_div2_div.hw,
3087         [CLKID_FCLK_DIV3_DIV]       = &meson8b_fclk_div3_div.hw,
3088         [CLKID_FCLK_DIV4_DIV]       = &meson8b_fclk_div4_div.hw,
3089         [CLKID_FCLK_DIV5_DIV]       = &meson8b_fclk_div5_div.hw,
3090         [CLKID_FCLK_DIV7_DIV]       = &meson8b_fclk_div7_div.hw,
3091         [CLKID_NAND_SEL]        = &meson8b_nand_clk_sel.hw,
3092         [CLKID_NAND_DIV]        = &meson8b_nand_clk_div.hw,
3093         [CLKID_NAND_CLK]        = &meson8b_nand_clk_gate.hw,
3094         [CLKID_PLL_FIXED_DCO]       = &meson8b_fixed_pll_dco.hw,
3095         [CLKID_HDMI_PLL_DCO]        = &meson8b_hdmi_pll_dco.hw,
3096         [CLKID_PLL_SYS_DCO]     = &meson8b_sys_pll_dco.hw,
3097         [CLKID_CPU_CLK_DIV2]        = &meson8b_cpu_clk_div2.hw,
3098         [CLKID_CPU_CLK_DIV3]        = &meson8b_cpu_clk_div3.hw,
3099         [CLKID_CPU_CLK_DIV4]        = &meson8b_cpu_clk_div4.hw,
3100         [CLKID_CPU_CLK_DIV5]        = &meson8b_cpu_clk_div5.hw,
3101         [CLKID_CPU_CLK_DIV6]        = &meson8b_cpu_clk_div6.hw,
3102         [CLKID_CPU_CLK_DIV7]        = &meson8b_cpu_clk_div7.hw,
3103         [CLKID_CPU_CLK_DIV8]        = &meson8b_cpu_clk_div8.hw,
3104         [CLKID_APB_SEL]         = &meson8b_apb_clk_sel.hw,
3105         [CLKID_APB]         = &meson8b_apb_clk_gate.hw,
3106         [CLKID_PERIPH_SEL]      = &meson8b_periph_clk_sel.hw,
3107         [CLKID_PERIPH]          = &meson8b_periph_clk_gate.hw,
3108         [CLKID_AXI_SEL]         = &meson8b_axi_clk_sel.hw,
3109         [CLKID_AXI]         = &meson8b_axi_clk_gate.hw,
3110         [CLKID_L2_DRAM_SEL]     = &meson8b_l2_dram_clk_sel.hw,
3111         [CLKID_L2_DRAM]         = &meson8b_l2_dram_clk_gate.hw,
3112         [CLKID_HDMI_PLL_LVDS_OUT]   = &meson8b_hdmi_pll_lvds_out.hw,
3113         [CLKID_HDMI_PLL_HDMI_OUT]   = &meson8b_hdmi_pll_hdmi_out.hw,
3114         [CLKID_VID_PLL_IN_SEL]      = &meson8b_vid_pll_in_sel.hw,
3115         [CLKID_VID_PLL_IN_EN]       = &meson8b_vid_pll_in_en.hw,
3116         [CLKID_VID_PLL_PRE_DIV]     = &meson8b_vid_pll_pre_div.hw,
3117         [CLKID_VID_PLL_POST_DIV]    = &meson8b_vid_pll_post_div.hw,
3118         [CLKID_VID_PLL_FINAL_DIV]   = &meson8b_vid_pll_final_div.hw,
3119         [CLKID_VCLK_IN_SEL]     = &meson8b_vclk_in_sel.hw,
3120         [CLKID_VCLK_IN_EN]      = &meson8b_vclk_in_en.hw,
3121         [CLKID_VCLK_EN]         = &meson8b_vclk_en.hw,
3122         [CLKID_VCLK_DIV1]       = &meson8b_vclk_div1_gate.hw,
3123         [CLKID_VCLK_DIV2_DIV]       = &meson8b_vclk_div2_div.hw,
3124         [CLKID_VCLK_DIV2]       = &meson8b_vclk_div2_div_gate.hw,
3125         [CLKID_VCLK_DIV4_DIV]       = &meson8b_vclk_div4_div.hw,
3126         [CLKID_VCLK_DIV4]       = &meson8b_vclk_div4_div_gate.hw,
3127         [CLKID_VCLK_DIV6_DIV]       = &meson8b_vclk_div6_div.hw,
3128         [CLKID_VCLK_DIV6]       = &meson8b_vclk_div6_div_gate.hw,
3129         [CLKID_VCLK_DIV12_DIV]      = &meson8b_vclk_div12_div.hw,
3130         [CLKID_VCLK_DIV12]      = &meson8b_vclk_div12_div_gate.hw,
3131         [CLKID_VCLK2_IN_SEL]        = &meson8b_vclk2_in_sel.hw,
3132         [CLKID_VCLK2_IN_EN]     = &meson8b_vclk2_clk_in_en.hw,
3133         [CLKID_VCLK2_EN]        = &meson8b_vclk2_clk_en.hw,
3134         [CLKID_VCLK2_DIV1]      = &meson8b_vclk2_div1_gate.hw,
3135         [CLKID_VCLK2_DIV2_DIV]      = &meson8b_vclk2_div2_div.hw,
3136         [CLKID_VCLK2_DIV2]      = &meson8b_vclk2_div2_div_gate.hw,
3137         [CLKID_VCLK2_DIV4_DIV]      = &meson8b_vclk2_div4_div.hw,
3138         [CLKID_VCLK2_DIV4]      = &meson8b_vclk2_div4_div_gate.hw,
3139         [CLKID_VCLK2_DIV6_DIV]      = &meson8b_vclk2_div6_div.hw,
3140         [CLKID_VCLK2_DIV6]      = &meson8b_vclk2_div6_div_gate.hw,
3141         [CLKID_VCLK2_DIV12_DIV]     = &meson8b_vclk2_div12_div.hw,
3142         [CLKID_VCLK2_DIV12]     = &meson8b_vclk2_div12_div_gate.hw,
3143         [CLKID_CTS_ENCT_SEL]        = &meson8b_cts_enct_sel.hw,
3144         [CLKID_CTS_ENCT]        = &meson8b_cts_enct.hw,
3145         [CLKID_CTS_ENCP_SEL]        = &meson8b_cts_encp_sel.hw,
3146         [CLKID_CTS_ENCP]        = &meson8b_cts_encp.hw,
3147         [CLKID_CTS_ENCI_SEL]        = &meson8b_cts_enci_sel.hw,
3148         [CLKID_CTS_ENCI]        = &meson8b_cts_enci.hw,
3149         [CLKID_HDMI_TX_PIXEL_SEL]   = &meson8b_hdmi_tx_pixel_sel.hw,
3150         [CLKID_HDMI_TX_PIXEL]       = &meson8b_hdmi_tx_pixel.hw,
3151         [CLKID_CTS_ENCL_SEL]        = &meson8b_cts_encl_sel.hw,
3152         [CLKID_CTS_ENCL]        = &meson8b_cts_encl.hw,
3153         [CLKID_CTS_VDAC0_SEL]       = &meson8b_cts_vdac0_sel.hw,
3154         [CLKID_CTS_VDAC0]       = &meson8b_cts_vdac0.hw,
3155         [CLKID_HDMI_SYS_SEL]        = &meson8b_hdmi_sys_sel.hw,
3156         [CLKID_HDMI_SYS_DIV]        = &meson8b_hdmi_sys_div.hw,
3157         [CLKID_HDMI_SYS]        = &meson8b_hdmi_sys.hw,
3158         [CLKID_MALI_0_SEL]      = &meson8b_mali_0_sel.hw,
3159         [CLKID_MALI_0_DIV]      = &meson8b_mali_0_div.hw,
3160         [CLKID_MALI_0]          = &meson8b_mali_0.hw,
3161         [CLKID_MALI_1_SEL]      = &meson8b_mali_1_sel.hw,
3162         [CLKID_MALI_1_DIV]      = &meson8b_mali_1_div.hw,
3163         [CLKID_MALI_1]          = &meson8b_mali_1.hw,
3164         [CLKID_MALI]            = &meson8b_mali.hw,
3165         [CLKID_VPU_0_SEL]       = &meson8b_vpu_0_sel.hw,
3166         [CLKID_VPU_0_DIV]       = &meson8b_vpu_0_div.hw,
3167         [CLKID_VPU_0]           = &meson8b_vpu_0.hw,
3168         [CLKID_VPU_1_SEL]       = &meson8b_vpu_1_sel.hw,
3169         [CLKID_VPU_1_DIV]       = &meson8b_vpu_1_div.hw,
3170         [CLKID_VPU_1]           = &meson8b_vpu_1.hw,
3171         [CLKID_VPU]         = &meson8b_vpu.hw,
3172         [CLKID_VDEC_1_SEL]      = &meson8b_vdec_1_sel.hw,
3173         [CLKID_VDEC_1_1_DIV]        = &meson8b_vdec_1_1_div.hw,
3174         [CLKID_VDEC_1_1]        = &meson8b_vdec_1_1.hw,
3175         [CLKID_VDEC_1_2_DIV]        = &meson8b_vdec_1_2_div.hw,
3176         [CLKID_VDEC_1_2]        = &meson8b_vdec_1_2.hw,
3177         [CLKID_VDEC_1]              = &meson8b_vdec_1.hw,
3178         [CLKID_VDEC_HCODEC_SEL]     = &meson8b_vdec_hcodec_sel.hw,
3179         [CLKID_VDEC_HCODEC_DIV]     = &meson8b_vdec_hcodec_div.hw,
3180         [CLKID_VDEC_HCODEC]     = &meson8b_vdec_hcodec.hw,
3181         [CLKID_VDEC_2_SEL]      = &meson8b_vdec_2_sel.hw,
3182         [CLKID_VDEC_2_DIV]      = &meson8b_vdec_2_div.hw,
3183         [CLKID_VDEC_2]              = &meson8b_vdec_2.hw,
3184         [CLKID_VDEC_HEVC_SEL]       = &meson8b_vdec_hevc_sel.hw,
3185         [CLKID_VDEC_HEVC_DIV]       = &meson8b_vdec_hevc_div.hw,
3186         [CLKID_VDEC_HEVC_EN]        = &meson8b_vdec_hevc_en.hw,
3187         [CLKID_VDEC_HEVC]       = &meson8b_vdec_hevc.hw,
3188         [CLKID_CTS_AMCLK_SEL]       = &meson8b_cts_amclk_sel.hw,
3189         [CLKID_CTS_AMCLK_DIV]       = &meson8b_cts_amclk_div.hw,
3190         [CLKID_CTS_AMCLK]       = &meson8b_cts_amclk.hw,
3191         [CLKID_CTS_MCLK_I958_SEL]   = &meson8b_cts_mclk_i958_sel.hw,
3192         [CLKID_CTS_MCLK_I958_DIV]   = &meson8b_cts_mclk_i958_div.hw,
3193         [CLKID_CTS_MCLK_I958]       = &meson8b_cts_mclk_i958.hw,
3194         [CLKID_CTS_I958]        = &meson8b_cts_i958.hw,
3195         [CLKID_VID_PLL_LVDS_EN]     = &meson8b_vid_pll_lvds_en.hw,
3196         [CLKID_HDMI_PLL_DCO_IN]     = &hdmi_pll_dco_in.hw,
3197         [CLK_NR_CLKS]           = NULL,
3198     },
3199     .num = CLK_NR_CLKS,
3200 };
3201 
3202 static struct clk_hw_onecell_data meson8m2_hw_onecell_data = {
3203     .hws = {
3204         [CLKID_PLL_FIXED] = &meson8b_fixed_pll.hw,
3205         [CLKID_PLL_VID] = &meson8b_vid_pll.hw,
3206         [CLKID_PLL_SYS] = &meson8b_sys_pll.hw,
3207         [CLKID_FCLK_DIV2] = &meson8b_fclk_div2.hw,
3208         [CLKID_FCLK_DIV3] = &meson8b_fclk_div3.hw,
3209         [CLKID_FCLK_DIV4] = &meson8b_fclk_div4.hw,
3210         [CLKID_FCLK_DIV5] = &meson8b_fclk_div5.hw,
3211         [CLKID_FCLK_DIV7] = &meson8b_fclk_div7.hw,
3212         [CLKID_CPUCLK] = &meson8b_cpu_clk.hw,
3213         [CLKID_MPEG_SEL] = &meson8b_mpeg_clk_sel.hw,
3214         [CLKID_MPEG_DIV] = &meson8b_mpeg_clk_div.hw,
3215         [CLKID_CLK81] = &meson8b_clk81.hw,
3216         [CLKID_DDR]         = &meson8b_ddr.hw,
3217         [CLKID_DOS]         = &meson8b_dos.hw,
3218         [CLKID_ISA]         = &meson8b_isa.hw,
3219         [CLKID_PL301]           = &meson8b_pl301.hw,
3220         [CLKID_PERIPHS]         = &meson8b_periphs.hw,
3221         [CLKID_SPICC]           = &meson8b_spicc.hw,
3222         [CLKID_I2C]         = &meson8b_i2c.hw,
3223         [CLKID_SAR_ADC]         = &meson8b_sar_adc.hw,
3224         [CLKID_SMART_CARD]      = &meson8b_smart_card.hw,
3225         [CLKID_RNG0]            = &meson8b_rng0.hw,
3226         [CLKID_UART0]           = &meson8b_uart0.hw,
3227         [CLKID_SDHC]            = &meson8b_sdhc.hw,
3228         [CLKID_STREAM]          = &meson8b_stream.hw,
3229         [CLKID_ASYNC_FIFO]      = &meson8b_async_fifo.hw,
3230         [CLKID_SDIO]            = &meson8b_sdio.hw,
3231         [CLKID_ABUF]            = &meson8b_abuf.hw,
3232         [CLKID_HIU_IFACE]       = &meson8b_hiu_iface.hw,
3233         [CLKID_ASSIST_MISC]     = &meson8b_assist_misc.hw,
3234         [CLKID_SPI]         = &meson8b_spi.hw,
3235         [CLKID_I2S_SPDIF]       = &meson8b_i2s_spdif.hw,
3236         [CLKID_ETH]         = &meson8b_eth.hw,
3237         [CLKID_DEMUX]           = &meson8b_demux.hw,
3238         [CLKID_AIU_GLUE]        = &meson8b_aiu_glue.hw,
3239         [CLKID_IEC958]          = &meson8b_iec958.hw,
3240         [CLKID_I2S_OUT]         = &meson8b_i2s_out.hw,
3241         [CLKID_AMCLK]           = &meson8b_amclk.hw,
3242         [CLKID_AIFIFO2]         = &meson8b_aififo2.hw,
3243         [CLKID_MIXER]           = &meson8b_mixer.hw,
3244         [CLKID_MIXER_IFACE]     = &meson8b_mixer_iface.hw,
3245         [CLKID_ADC]         = &meson8b_adc.hw,
3246         [CLKID_BLKMV]           = &meson8b_blkmv.hw,
3247         [CLKID_AIU]         = &meson8b_aiu.hw,
3248         [CLKID_UART1]           = &meson8b_uart1.hw,
3249         [CLKID_G2D]         = &meson8b_g2d.hw,
3250         [CLKID_USB0]            = &meson8b_usb0.hw,
3251         [CLKID_USB1]            = &meson8b_usb1.hw,
3252         [CLKID_RESET]           = &meson8b_reset.hw,
3253         [CLKID_NAND]            = &meson8b_nand.hw,
3254         [CLKID_DOS_PARSER]      = &meson8b_dos_parser.hw,
3255         [CLKID_USB]         = &meson8b_usb.hw,
3256         [CLKID_VDIN1]           = &meson8b_vdin1.hw,
3257         [CLKID_AHB_ARB0]        = &meson8b_ahb_arb0.hw,
3258         [CLKID_EFUSE]           = &meson8b_efuse.hw,
3259         [CLKID_BOOT_ROM]        = &meson8b_boot_rom.hw,
3260         [CLKID_AHB_DATA_BUS]        = &meson8b_ahb_data_bus.hw,
3261         [CLKID_AHB_CTRL_BUS]        = &meson8b_ahb_ctrl_bus.hw,
3262         [CLKID_HDMI_INTR_SYNC]      = &meson8b_hdmi_intr_sync.hw,
3263         [CLKID_HDMI_PCLK]       = &meson8b_hdmi_pclk.hw,
3264         [CLKID_USB1_DDR_BRIDGE]     = &meson8b_usb1_ddr_bridge.hw,
3265         [CLKID_USB0_DDR_BRIDGE]     = &meson8b_usb0_ddr_bridge.hw,
3266         [CLKID_MMC_PCLK]        = &meson8b_mmc_pclk.hw,
3267         [CLKID_DVIN]            = &meson8b_dvin.hw,
3268         [CLKID_UART2]           = &meson8b_uart2.hw,
3269         [CLKID_SANA]            = &meson8b_sana.hw,
3270         [CLKID_VPU_INTR]        = &meson8b_vpu_intr.hw,
3271         [CLKID_SEC_AHB_AHB3_BRIDGE] = &meson8b_sec_ahb_ahb3_bridge.hw,
3272         [CLKID_CLK81_A9]        = &meson8b_clk81_a9.hw,
3273         [CLKID_VCLK2_VENCI0]        = &meson8b_vclk2_venci0.hw,
3274         [CLKID_VCLK2_VENCI1]        = &meson8b_vclk2_venci1.hw,
3275         [CLKID_VCLK2_VENCP0]        = &meson8b_vclk2_vencp0.hw,
3276         [CLKID_VCLK2_VENCP1]        = &meson8b_vclk2_vencp1.hw,
3277         [CLKID_GCLK_VENCI_INT]      = &meson8b_gclk_venci_int.hw,
3278         [CLKID_GCLK_VENCP_INT]      = &meson8b_gclk_vencp_int.hw,
3279         [CLKID_DAC_CLK]         = &meson8b_dac_clk.hw,
3280         [CLKID_AOCLK_GATE]      = &meson8b_aoclk_gate.hw,
3281         [CLKID_IEC958_GATE]     = &meson8b_iec958_gate.hw,
3282         [CLKID_ENC480P]         = &meson8b_enc480p.hw,
3283         [CLKID_RNG1]            = &meson8b_rng1.hw,
3284         [CLKID_GCLK_VENCL_INT]      = &meson8b_gclk_vencl_int.hw,
3285         [CLKID_VCLK2_VENCLMCC]      = &meson8b_vclk2_venclmcc.hw,
3286         [CLKID_VCLK2_VENCL]     = &meson8b_vclk2_vencl.hw,
3287         [CLKID_VCLK2_OTHER]     = &meson8b_vclk2_other.hw,
3288         [CLKID_EDP]         = &meson8b_edp.hw,
3289         [CLKID_AO_MEDIA_CPU]        = &meson8b_ao_media_cpu.hw,
3290         [CLKID_AO_AHB_SRAM]     = &meson8b_ao_ahb_sram.hw,
3291         [CLKID_AO_AHB_BUS]      = &meson8b_ao_ahb_bus.hw,
3292         [CLKID_AO_IFACE]        = &meson8b_ao_iface.hw,
3293         [CLKID_MPLL0]           = &meson8b_mpll0.hw,
3294         [CLKID_MPLL1]           = &meson8b_mpll1.hw,
3295         [CLKID_MPLL2]           = &meson8b_mpll2.hw,
3296         [CLKID_MPLL0_DIV]       = &meson8b_mpll0_div.hw,
3297         [CLKID_MPLL1_DIV]       = &meson8b_mpll1_div.hw,
3298         [CLKID_MPLL2_DIV]       = &meson8b_mpll2_div.hw,
3299         [CLKID_CPU_IN_SEL]      = &meson8b_cpu_in_sel.hw,
3300         [CLKID_CPU_IN_DIV2]     = &meson8b_cpu_in_div2.hw,
3301         [CLKID_CPU_IN_DIV3]     = &meson8b_cpu_in_div3.hw,
3302         [CLKID_CPU_SCALE_DIV]       = &meson8b_cpu_scale_div.hw,
3303         [CLKID_CPU_SCALE_OUT_SEL]   = &meson8b_cpu_scale_out_sel.hw,
3304         [CLKID_MPLL_PREDIV]     = &meson8b_mpll_prediv.hw,
3305         [CLKID_FCLK_DIV2_DIV]       = &meson8b_fclk_div2_div.hw,
3306         [CLKID_FCLK_DIV3_DIV]       = &meson8b_fclk_div3_div.hw,
3307         [CLKID_FCLK_DIV4_DIV]       = &meson8b_fclk_div4_div.hw,
3308         [CLKID_FCLK_DIV5_DIV]       = &meson8b_fclk_div5_div.hw,
3309         [CLKID_FCLK_DIV7_DIV]       = &meson8b_fclk_div7_div.hw,
3310         [CLKID_NAND_SEL]        = &meson8b_nand_clk_sel.hw,
3311         [CLKID_NAND_DIV]        = &meson8b_nand_clk_div.hw,
3312         [CLKID_NAND_CLK]        = &meson8b_nand_clk_gate.hw,
3313         [CLKID_PLL_FIXED_DCO]       = &meson8b_fixed_pll_dco.hw,
3314         [CLKID_HDMI_PLL_DCO]        = &meson8b_hdmi_pll_dco.hw,
3315         [CLKID_PLL_SYS_DCO]     = &meson8b_sys_pll_dco.hw,
3316         [CLKID_CPU_CLK_DIV2]        = &meson8b_cpu_clk_div2.hw,
3317         [CLKID_CPU_CLK_DIV3]        = &meson8b_cpu_clk_div3.hw,
3318         [CLKID_CPU_CLK_DIV4]        = &meson8b_cpu_clk_div4.hw,
3319         [CLKID_CPU_CLK_DIV5]        = &meson8b_cpu_clk_div5.hw,
3320         [CLKID_CPU_CLK_DIV6]        = &meson8b_cpu_clk_div6.hw,
3321         [CLKID_CPU_CLK_DIV7]        = &meson8b_cpu_clk_div7.hw,
3322         [CLKID_CPU_CLK_DIV8]        = &meson8b_cpu_clk_div8.hw,
3323         [CLKID_APB_SEL]         = &meson8b_apb_clk_sel.hw,
3324         [CLKID_APB]         = &meson8b_apb_clk_gate.hw,
3325         [CLKID_PERIPH_SEL]      = &meson8b_periph_clk_sel.hw,
3326         [CLKID_PERIPH]          = &meson8b_periph_clk_gate.hw,
3327         [CLKID_AXI_SEL]         = &meson8b_axi_clk_sel.hw,
3328         [CLKID_AXI]         = &meson8b_axi_clk_gate.hw,
3329         [CLKID_L2_DRAM_SEL]     = &meson8b_l2_dram_clk_sel.hw,
3330         [CLKID_L2_DRAM]         = &meson8b_l2_dram_clk_gate.hw,
3331         [CLKID_HDMI_PLL_LVDS_OUT]   = &meson8b_hdmi_pll_lvds_out.hw,
3332         [CLKID_HDMI_PLL_HDMI_OUT]   = &meson8b_hdmi_pll_hdmi_out.hw,
3333         [CLKID_VID_PLL_IN_SEL]      = &meson8b_vid_pll_in_sel.hw,
3334         [CLKID_VID_PLL_IN_EN]       = &meson8b_vid_pll_in_en.hw,
3335         [CLKID_VID_PLL_PRE_DIV]     = &meson8b_vid_pll_pre_div.hw,
3336         [CLKID_VID_PLL_POST_DIV]    = &meson8b_vid_pll_post_div.hw,
3337         [CLKID_VID_PLL_FINAL_DIV]   = &meson8b_vid_pll_final_div.hw,
3338         [CLKID_VCLK_IN_SEL]     = &meson8b_vclk_in_sel.hw,
3339         [CLKID_VCLK_IN_EN]      = &meson8b_vclk_in_en.hw,
3340         [CLKID_VCLK_EN]         = &meson8b_vclk_en.hw,
3341         [CLKID_VCLK_DIV1]       = &meson8b_vclk_div1_gate.hw,
3342         [CLKID_VCLK_DIV2_DIV]       = &meson8b_vclk_div2_div.hw,
3343         [CLKID_VCLK_DIV2]       = &meson8b_vclk_div2_div_gate.hw,
3344         [CLKID_VCLK_DIV4_DIV]       = &meson8b_vclk_div4_div.hw,
3345         [CLKID_VCLK_DIV4]       = &meson8b_vclk_div4_div_gate.hw,
3346         [CLKID_VCLK_DIV6_DIV]       = &meson8b_vclk_div6_div.hw,
3347         [CLKID_VCLK_DIV6]       = &meson8b_vclk_div6_div_gate.hw,
3348         [CLKID_VCLK_DIV12_DIV]      = &meson8b_vclk_div12_div.hw,
3349         [CLKID_VCLK_DIV12]      = &meson8b_vclk_div12_div_gate.hw,
3350         [CLKID_VCLK2_IN_SEL]        = &meson8b_vclk2_in_sel.hw,
3351         [CLKID_VCLK2_IN_EN]     = &meson8b_vclk2_clk_in_en.hw,
3352         [CLKID_VCLK2_EN]        = &meson8b_vclk2_clk_en.hw,
3353         [CLKID_VCLK2_DIV1]      = &meson8b_vclk2_div1_gate.hw,
3354         [CLKID_VCLK2_DIV2_DIV]      = &meson8b_vclk2_div2_div.hw,
3355         [CLKID_VCLK2_DIV2]      = &meson8b_vclk2_div2_div_gate.hw,
3356         [CLKID_VCLK2_DIV4_DIV]      = &meson8b_vclk2_div4_div.hw,
3357         [CLKID_VCLK2_DIV4]      = &meson8b_vclk2_div4_div_gate.hw,
3358         [CLKID_VCLK2_DIV6_DIV]      = &meson8b_vclk2_div6_div.hw,
3359         [CLKID_VCLK2_DIV6]      = &meson8b_vclk2_div6_div_gate.hw,
3360         [CLKID_VCLK2_DIV12_DIV]     = &meson8b_vclk2_div12_div.hw,
3361         [CLKID_VCLK2_DIV12]     = &meson8b_vclk2_div12_div_gate.hw,
3362         [CLKID_CTS_ENCT_SEL]        = &meson8b_cts_enct_sel.hw,
3363         [CLKID_CTS_ENCT]        = &meson8b_cts_enct.hw,
3364         [CLKID_CTS_ENCP_SEL]        = &meson8b_cts_encp_sel.hw,
3365         [CLKID_CTS_ENCP]        = &meson8b_cts_encp.hw,
3366         [CLKID_CTS_ENCI_SEL]        = &meson8b_cts_enci_sel.hw,
3367         [CLKID_CTS_ENCI]        = &meson8b_cts_enci.hw,
3368         [CLKID_HDMI_TX_PIXEL_SEL]   = &meson8b_hdmi_tx_pixel_sel.hw,
3369         [CLKID_HDMI_TX_PIXEL]       = &meson8b_hdmi_tx_pixel.hw,
3370         [CLKID_CTS_ENCL_SEL]        = &meson8b_cts_encl_sel.hw,
3371         [CLKID_CTS_ENCL]        = &meson8b_cts_encl.hw,
3372         [CLKID_CTS_VDAC0_SEL]       = &meson8b_cts_vdac0_sel.hw,
3373         [CLKID_CTS_VDAC0]       = &meson8b_cts_vdac0.hw,
3374         [CLKID_HDMI_SYS_SEL]        = &meson8b_hdmi_sys_sel.hw,
3375         [CLKID_HDMI_SYS_DIV]        = &meson8b_hdmi_sys_div.hw,
3376         [CLKID_HDMI_SYS]        = &meson8b_hdmi_sys.hw,
3377         [CLKID_MALI_0_SEL]      = &meson8b_mali_0_sel.hw,
3378         [CLKID_MALI_0_DIV]      = &meson8b_mali_0_div.hw,
3379         [CLKID_MALI_0]          = &meson8b_mali_0.hw,
3380         [CLKID_MALI_1_SEL]      = &meson8b_mali_1_sel.hw,
3381         [CLKID_MALI_1_DIV]      = &meson8b_mali_1_div.hw,
3382         [CLKID_MALI_1]          = &meson8b_mali_1.hw,
3383         [CLKID_MALI]            = &meson8b_mali.hw,
3384         [CLKID_GP_PLL_DCO]      = &meson8m2_gp_pll_dco.hw,
3385         [CLKID_GP_PLL]          = &meson8m2_gp_pll.hw,
3386         [CLKID_VPU_0_SEL]       = &meson8m2_vpu_0_sel.hw,
3387         [CLKID_VPU_0_DIV]       = &meson8b_vpu_0_div.hw,
3388         [CLKID_VPU_0]           = &meson8b_vpu_0.hw,
3389         [CLKID_VPU_1_SEL]       = &meson8m2_vpu_1_sel.hw,
3390         [CLKID_VPU_1_DIV]       = &meson8b_vpu_1_div.hw,
3391         [CLKID_VPU_1]           = &meson8b_vpu_1.hw,
3392         [CLKID_VPU]         = &meson8b_vpu.hw,
3393         [CLKID_VDEC_1_SEL]      = &meson8b_vdec_1_sel.hw,
3394         [CLKID_VDEC_1_1_DIV]        = &meson8b_vdec_1_1_div.hw,
3395         [CLKID_VDEC_1_1]        = &meson8b_vdec_1_1.hw,
3396         [CLKID_VDEC_1_2_DIV]        = &meson8b_vdec_1_2_div.hw,
3397         [CLKID_VDEC_1_2]        = &meson8b_vdec_1_2.hw,
3398         [CLKID_VDEC_1]              = &meson8b_vdec_1.hw,
3399         [CLKID_VDEC_HCODEC_SEL]     = &meson8b_vdec_hcodec_sel.hw,
3400         [CLKID_VDEC_HCODEC_DIV]     = &meson8b_vdec_hcodec_div.hw,
3401         [CLKID_VDEC_HCODEC]     = &meson8b_vdec_hcodec.hw,
3402         [CLKID_VDEC_2_SEL]      = &meson8b_vdec_2_sel.hw,
3403         [CLKID_VDEC_2_DIV]      = &meson8b_vdec_2_div.hw,
3404         [CLKID_VDEC_2]              = &meson8b_vdec_2.hw,
3405         [CLKID_VDEC_HEVC_SEL]       = &meson8b_vdec_hevc_sel.hw,
3406         [CLKID_VDEC_HEVC_DIV]       = &meson8b_vdec_hevc_div.hw,
3407         [CLKID_VDEC_HEVC_EN]        = &meson8b_vdec_hevc_en.hw,
3408         [CLKID_VDEC_HEVC]       = &meson8b_vdec_hevc.hw,
3409         [CLKID_CTS_AMCLK_SEL]       = &meson8b_cts_amclk_sel.hw,
3410         [CLKID_CTS_AMCLK_DIV]       = &meson8b_cts_amclk_div.hw,
3411         [CLKID_CTS_AMCLK]       = &meson8b_cts_amclk.hw,
3412         [CLKID_CTS_MCLK_I958_SEL]   = &meson8b_cts_mclk_i958_sel.hw,
3413         [CLKID_CTS_MCLK_I958_DIV]   = &meson8b_cts_mclk_i958_div.hw,
3414         [CLKID_CTS_MCLK_I958]       = &meson8b_cts_mclk_i958.hw,
3415         [CLKID_CTS_I958]        = &meson8b_cts_i958.hw,
3416         [CLKID_VID_PLL_LVDS_EN]     = &meson8b_vid_pll_lvds_en.hw,
3417         [CLKID_HDMI_PLL_DCO_IN]     = &hdmi_pll_dco_in.hw,
3418         [CLK_NR_CLKS]           = NULL,
3419     },
3420     .num = CLK_NR_CLKS,
3421 };
3422 
3423 static struct clk_regmap *const meson8b_clk_regmaps[] = {
3424     &meson8b_clk81,
3425     &meson8b_ddr,
3426     &meson8b_dos,
3427     &meson8b_isa,
3428     &meson8b_pl301,
3429     &meson8b_periphs,
3430     &meson8b_spicc,
3431     &meson8b_i2c,
3432     &meson8b_sar_adc,
3433     &meson8b_smart_card,
3434     &meson8b_rng0,
3435     &meson8b_uart0,
3436     &meson8b_sdhc,
3437     &meson8b_stream,
3438     &meson8b_async_fifo,
3439     &meson8b_sdio,
3440     &meson8b_abuf,
3441     &meson8b_hiu_iface,
3442     &meson8b_assist_misc,
3443     &meson8b_spi,
3444     &meson8b_i2s_spdif,
3445     &meson8b_eth,
3446     &meson8b_demux,
3447     &meson8b_aiu_glue,
3448     &meson8b_iec958,
3449     &meson8b_i2s_out,
3450     &meson8b_amclk,
3451     &meson8b_aififo2,
3452     &meson8b_mixer,
3453     &meson8b_mixer_iface,
3454     &meson8b_adc,
3455     &meson8b_blkmv,
3456     &meson8b_aiu,
3457     &meson8b_uart1,
3458     &meson8b_g2d,
3459     &meson8b_usb0,
3460     &meson8b_usb1,
3461     &meson8b_reset,
3462     &meson8b_nand,
3463     &meson8b_dos_parser,
3464     &meson8b_usb,
3465     &meson8b_vdin1,
3466     &meson8b_ahb_arb0,
3467     &meson8b_efuse,
3468     &meson8b_boot_rom,
3469     &meson8b_ahb_data_bus,
3470     &meson8b_ahb_ctrl_bus,
3471     &meson8b_hdmi_intr_sync,
3472     &meson8b_hdmi_pclk,
3473     &meson8b_usb1_ddr_bridge,
3474     &meson8b_usb0_ddr_bridge,
3475     &meson8b_mmc_pclk,
3476     &meson8b_dvin,
3477     &meson8b_uart2,
3478     &meson8b_sana,
3479     &meson8b_vpu_intr,
3480     &meson8b_sec_ahb_ahb3_bridge,
3481     &meson8b_clk81_a9,
3482     &meson8b_vclk2_venci0,
3483     &meson8b_vclk2_venci1,
3484     &meson8b_vclk2_vencp0,
3485     &meson8b_vclk2_vencp1,
3486     &meson8b_gclk_venci_int,
3487     &meson8b_gclk_vencp_int,
3488     &meson8b_dac_clk,
3489     &meson8b_aoclk_gate,
3490     &meson8b_iec958_gate,
3491     &meson8b_enc480p,
3492     &meson8b_rng1,
3493     &meson8b_gclk_vencl_int,
3494     &meson8b_vclk2_venclmcc,
3495     &meson8b_vclk2_vencl,
3496     &meson8b_vclk2_other,
3497     &meson8b_edp,
3498     &meson8b_ao_media_cpu,
3499     &meson8b_ao_ahb_sram,
3500     &meson8b_ao_ahb_bus,
3501     &meson8b_ao_iface,
3502     &meson8b_mpeg_clk_div,
3503     &meson8b_mpeg_clk_sel,
3504     &meson8b_mpll0,
3505     &meson8b_mpll1,
3506     &meson8b_mpll2,
3507     &meson8b_mpll0_div,
3508     &meson8b_mpll1_div,
3509     &meson8b_mpll2_div,
3510     &meson8b_fixed_pll,
3511     &meson8b_sys_pll,
3512     &meson8b_cpu_in_sel,
3513     &meson8b_cpu_scale_div,
3514     &meson8b_cpu_scale_out_sel,
3515     &meson8b_cpu_clk,
3516     &meson8b_mpll_prediv,
3517     &meson8b_fclk_div2,
3518     &meson8b_fclk_div3,
3519     &meson8b_fclk_div4,
3520     &meson8b_fclk_div5,
3521     &meson8b_fclk_div7,
3522     &meson8b_nand_clk_sel,
3523     &meson8b_nand_clk_div,
3524     &meson8b_nand_clk_gate,
3525     &meson8b_fixed_pll_dco,
3526     &meson8b_hdmi_pll_dco,
3527     &meson8b_sys_pll_dco,
3528     &meson8b_apb_clk_sel,
3529     &meson8b_apb_clk_gate,
3530     &meson8b_periph_clk_sel,
3531     &meson8b_periph_clk_gate,
3532     &meson8b_axi_clk_sel,
3533     &meson8b_axi_clk_gate,
3534     &meson8b_l2_dram_clk_sel,
3535     &meson8b_l2_dram_clk_gate,
3536     &meson8b_hdmi_pll_lvds_out,
3537     &meson8b_hdmi_pll_hdmi_out,
3538     &meson8b_vid_pll_in_sel,
3539     &meson8b_vid_pll_in_en,
3540     &meson8b_vid_pll_pre_div,
3541     &meson8b_vid_pll_post_div,
3542     &meson8b_vid_pll,
3543     &meson8b_vid_pll_final_div,
3544     &meson8b_vclk_in_sel,
3545     &meson8b_vclk_in_en,
3546     &meson8b_vclk_en,
3547     &meson8b_vclk_div1_gate,
3548     &meson8b_vclk_div2_div_gate,
3549     &meson8b_vclk_div4_div_gate,
3550     &meson8b_vclk_div6_div_gate,
3551     &meson8b_vclk_div12_div_gate,
3552     &meson8b_vclk2_in_sel,
3553     &meson8b_vclk2_clk_in_en,
3554     &meson8b_vclk2_clk_en,
3555     &meson8b_vclk2_div1_gate,
3556     &meson8b_vclk2_div2_div_gate,
3557     &meson8b_vclk2_div4_div_gate,
3558     &meson8b_vclk2_div6_div_gate,
3559     &meson8b_vclk2_div12_div_gate,
3560     &meson8b_cts_enct_sel,
3561     &meson8b_cts_enct,
3562     &meson8b_cts_encp_sel,
3563     &meson8b_cts_encp,
3564     &meson8b_cts_enci_sel,
3565     &meson8b_cts_enci,
3566     &meson8b_hdmi_tx_pixel_sel,
3567     &meson8b_hdmi_tx_pixel,
3568     &meson8b_cts_encl_sel,
3569     &meson8b_cts_encl,
3570     &meson8b_cts_vdac0_sel,
3571     &meson8b_cts_vdac0,
3572     &meson8b_hdmi_sys_sel,
3573     &meson8b_hdmi_sys_div,
3574     &meson8b_hdmi_sys,
3575     &meson8b_mali_0_sel,
3576     &meson8b_mali_0_div,
3577     &meson8b_mali_0,
3578     &meson8b_mali_1_sel,
3579     &meson8b_mali_1_div,
3580     &meson8b_mali_1,
3581     &meson8b_mali,
3582     &meson8m2_gp_pll_dco,
3583     &meson8m2_gp_pll,
3584     &meson8b_vpu_0_sel,
3585     &meson8m2_vpu_0_sel,
3586     &meson8b_vpu_0_div,
3587     &meson8b_vpu_0,
3588     &meson8b_vpu_1_sel,
3589     &meson8m2_vpu_1_sel,
3590     &meson8b_vpu_1_div,
3591     &meson8b_vpu_1,
3592     &meson8b_vpu,
3593     &meson8b_vdec_1_sel,
3594     &meson8b_vdec_1_1_div,
3595     &meson8b_vdec_1_1,
3596     &meson8b_vdec_1_2_div,
3597     &meson8b_vdec_1_2,
3598     &meson8b_vdec_1,
3599     &meson8b_vdec_hcodec_sel,
3600     &meson8b_vdec_hcodec_div,
3601     &meson8b_vdec_hcodec,
3602     &meson8b_vdec_2_sel,
3603     &meson8b_vdec_2_div,
3604     &meson8b_vdec_2,
3605     &meson8b_vdec_hevc_sel,
3606     &meson8b_vdec_hevc_div,
3607     &meson8b_vdec_hevc_en,
3608     &meson8b_vdec_hevc,
3609     &meson8b_cts_amclk,
3610     &meson8b_cts_amclk_sel,
3611     &meson8b_cts_amclk_div,
3612     &meson8b_cts_mclk_i958_sel,
3613     &meson8b_cts_mclk_i958_div,
3614     &meson8b_cts_mclk_i958,
3615     &meson8b_cts_i958,
3616     &meson8b_vid_pll_lvds_en,
3617 };
3618 
3619 static const struct meson8b_clk_reset_line {
3620     u32 reg;
3621     u8 bit_idx;
3622     bool active_low;
3623 } meson8b_clk_reset_bits[] = {
3624     [CLKC_RESET_L2_CACHE_SOFT_RESET] = {
3625         .reg = HHI_SYS_CPU_CLK_CNTL0,
3626         .bit_idx = 30,
3627         .active_low = false,
3628     },
3629     [CLKC_RESET_AXI_64_TO_128_BRIDGE_A5_SOFT_RESET] = {
3630         .reg = HHI_SYS_CPU_CLK_CNTL0,
3631         .bit_idx = 29,
3632         .active_low = false,
3633     },
3634     [CLKC_RESET_SCU_SOFT_RESET] = {
3635         .reg = HHI_SYS_CPU_CLK_CNTL0,
3636         .bit_idx = 28,
3637         .active_low = false,
3638     },
3639     [CLKC_RESET_CPU3_SOFT_RESET] = {
3640         .reg = HHI_SYS_CPU_CLK_CNTL0,
3641         .bit_idx = 27,
3642         .active_low = false,
3643     },
3644     [CLKC_RESET_CPU2_SOFT_RESET] = {
3645         .reg = HHI_SYS_CPU_CLK_CNTL0,
3646         .bit_idx = 26,
3647         .active_low = false,
3648     },
3649     [CLKC_RESET_CPU1_SOFT_RESET] = {
3650         .reg = HHI_SYS_CPU_CLK_CNTL0,
3651         .bit_idx = 25,
3652         .active_low = false,
3653     },
3654     [CLKC_RESET_CPU0_SOFT_RESET] = {
3655         .reg = HHI_SYS_CPU_CLK_CNTL0,
3656         .bit_idx = 24,
3657         .active_low = false,
3658     },
3659     [CLKC_RESET_A5_GLOBAL_RESET] = {
3660         .reg = HHI_SYS_CPU_CLK_CNTL0,
3661         .bit_idx = 18,
3662         .active_low = false,
3663     },
3664     [CLKC_RESET_A5_AXI_SOFT_RESET] = {
3665         .reg = HHI_SYS_CPU_CLK_CNTL0,
3666         .bit_idx = 17,
3667         .active_low = false,
3668     },
3669     [CLKC_RESET_A5_ABP_SOFT_RESET] = {
3670         .reg = HHI_SYS_CPU_CLK_CNTL0,
3671         .bit_idx = 16,
3672         .active_low = false,
3673     },
3674     [CLKC_RESET_AXI_64_TO_128_BRIDGE_MMC_SOFT_RESET] = {
3675         .reg = HHI_SYS_CPU_CLK_CNTL1,
3676         .bit_idx = 30,
3677         .active_low = false,
3678     },
3679     [CLKC_RESET_VID_CLK_CNTL_SOFT_RESET] = {
3680         .reg = HHI_VID_CLK_CNTL,
3681         .bit_idx = 15,
3682         .active_low = false,
3683     },
3684     [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_POST] = {
3685         .reg = HHI_VID_DIVIDER_CNTL,
3686         .bit_idx = 7,
3687         .active_low = false,
3688     },
3689     [CLKC_RESET_VID_DIVIDER_CNTL_SOFT_RESET_PRE] = {
3690         .reg = HHI_VID_DIVIDER_CNTL,
3691         .bit_idx = 3,
3692         .active_low = false,
3693     },
3694     [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_POST] = {
3695         .reg = HHI_VID_DIVIDER_CNTL,
3696         .bit_idx = 1,
3697         .active_low = true,
3698     },
3699     [CLKC_RESET_VID_DIVIDER_CNTL_RESET_N_PRE] = {
3700         .reg = HHI_VID_DIVIDER_CNTL,
3701         .bit_idx = 0,
3702         .active_low = true,
3703     },
3704 };
3705 
3706 static int meson8b_clk_reset_update(struct reset_controller_dev *rcdev,
3707                     unsigned long id, bool assert)
3708 {
3709     struct meson8b_clk_reset *meson8b_clk_reset =
3710         container_of(rcdev, struct meson8b_clk_reset, reset);
3711     const struct meson8b_clk_reset_line *reset;
3712     unsigned int value = 0;
3713     unsigned long flags;
3714 
3715     if (id >= ARRAY_SIZE(meson8b_clk_reset_bits))
3716         return -EINVAL;
3717 
3718     reset = &meson8b_clk_reset_bits[id];
3719 
3720     if (assert != reset->active_low)
3721         value = BIT(reset->bit_idx);
3722 
3723     spin_lock_irqsave(&meson_clk_lock, flags);
3724 
3725     regmap_update_bits(meson8b_clk_reset->regmap, reset->reg,
3726                BIT(reset->bit_idx), value);
3727 
3728     spin_unlock_irqrestore(&meson_clk_lock, flags);
3729 
3730     return 0;
3731 }
3732 
3733 static int meson8b_clk_reset_assert(struct reset_controller_dev *rcdev,
3734                      unsigned long id)
3735 {
3736     return meson8b_clk_reset_update(rcdev, id, true);
3737 }
3738 
3739 static int meson8b_clk_reset_deassert(struct reset_controller_dev *rcdev,
3740                        unsigned long id)
3741 {
3742     return meson8b_clk_reset_update(rcdev, id, false);
3743 }
3744 
3745 static const struct reset_control_ops meson8b_clk_reset_ops = {
3746     .assert = meson8b_clk_reset_assert,
3747     .deassert = meson8b_clk_reset_deassert,
3748 };
3749 
3750 struct meson8b_nb_data {
3751     struct notifier_block nb;
3752     struct clk_hw *cpu_clk;
3753 };
3754 
3755 static int meson8b_cpu_clk_notifier_cb(struct notifier_block *nb,
3756                        unsigned long event, void *data)
3757 {
3758     struct meson8b_nb_data *nb_data =
3759         container_of(nb, struct meson8b_nb_data, nb);
3760     struct clk_hw *parent_clk;
3761     int ret;
3762 
3763     switch (event) {
3764     case PRE_RATE_CHANGE:
3765         /* xtal */
3766         parent_clk = clk_hw_get_parent_by_index(nb_data->cpu_clk, 0);
3767         break;
3768 
3769     case POST_RATE_CHANGE:
3770         /* cpu_scale_out_sel */
3771         parent_clk = clk_hw_get_parent_by_index(nb_data->cpu_clk, 1);
3772         break;
3773 
3774     default:
3775         return NOTIFY_DONE;
3776     }
3777 
3778     ret = clk_hw_set_parent(nb_data->cpu_clk, parent_clk);
3779     if (ret)
3780         return notifier_from_errno(ret);
3781 
3782     udelay(100);
3783 
3784     return NOTIFY_OK;
3785 }
3786 
3787 static struct meson8b_nb_data meson8b_cpu_nb_data = {
3788     .nb.notifier_call = meson8b_cpu_clk_notifier_cb,
3789 };
3790 
3791 static void __init meson8b_clkc_init_common(struct device_node *np,
3792             struct clk_hw_onecell_data *clk_hw_onecell_data)
3793 {
3794     struct meson8b_clk_reset *rstc;
3795     const char *notifier_clk_name;
3796     struct clk *notifier_clk;
3797     struct regmap *map;
3798     int i, ret;
3799 
3800     map = syscon_node_to_regmap(of_get_parent(np));
3801     if (IS_ERR(map)) {
3802         pr_err("failed to get HHI regmap - Trying obsolete regs\n");
3803         return;
3804     }
3805 
3806     rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
3807     if (!rstc)
3808         return;
3809 
3810     /* Reset Controller */
3811     rstc->regmap = map;
3812     rstc->reset.ops = &meson8b_clk_reset_ops;
3813     rstc->reset.nr_resets = ARRAY_SIZE(meson8b_clk_reset_bits);
3814     rstc->reset.of_node = np;
3815     ret = reset_controller_register(&rstc->reset);
3816     if (ret) {
3817         pr_err("%s: Failed to register clkc reset controller: %d\n",
3818                __func__, ret);
3819         return;
3820     }
3821 
3822     /* Populate regmap for the regmap backed clocks */
3823     for (i = 0; i < ARRAY_SIZE(meson8b_clk_regmaps); i++)
3824         meson8b_clk_regmaps[i]->map = map;
3825 
3826     /*
3827      * register all clks and start with the first used ID (which is
3828      * CLKID_PLL_FIXED)
3829      */
3830     for (i = CLKID_PLL_FIXED; i < CLK_NR_CLKS; i++) {
3831         /* array might be sparse */
3832         if (!clk_hw_onecell_data->hws[i])
3833             continue;
3834 
3835         ret = of_clk_hw_register(np, clk_hw_onecell_data->hws[i]);
3836         if (ret)
3837             return;
3838     }
3839 
3840     meson8b_cpu_nb_data.cpu_clk = clk_hw_onecell_data->hws[CLKID_CPUCLK];
3841 
3842     /*
3843      * FIXME we shouldn't program the muxes in notifier handlers. The
3844      * tricky programming sequence will be handled by the forthcoming
3845      * coordinated clock rates mechanism once that feature is released.
3846      */
3847     notifier_clk_name = clk_hw_get_name(&meson8b_cpu_scale_out_sel.hw);
3848     notifier_clk = __clk_lookup(notifier_clk_name);
3849     ret = clk_notifier_register(notifier_clk, &meson8b_cpu_nb_data.nb);
3850     if (ret) {
3851         pr_err("%s: failed to register the CPU clock notifier\n",
3852                __func__);
3853         return;
3854     }
3855 
3856     ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
3857                      clk_hw_onecell_data);
3858     if (ret)
3859         pr_err("%s: failed to register clock provider\n", __func__);
3860 }
3861 
3862 static void __init meson8_clkc_init(struct device_node *np)
3863 {
3864     return meson8b_clkc_init_common(np, &meson8_hw_onecell_data);
3865 }
3866 
3867 static void __init meson8b_clkc_init(struct device_node *np)
3868 {
3869     return meson8b_clkc_init_common(np, &meson8b_hw_onecell_data);
3870 }
3871 
3872 static void __init meson8m2_clkc_init(struct device_node *np)
3873 {
3874     return meson8b_clkc_init_common(np, &meson8m2_hw_onecell_data);
3875 }
3876 
3877 CLK_OF_DECLARE_DRIVER(meson8_clkc, "amlogic,meson8-clkc",
3878               meson8_clkc_init);
3879 CLK_OF_DECLARE_DRIVER(meson8b_clkc, "amlogic,meson8b-clkc",
3880               meson8b_clkc_init);
3881 CLK_OF_DECLARE_DRIVER(meson8m2_clkc, "amlogic,meson8m2-clkc",
3882               meson8m2_clkc_init);