Linux Audio

Check our new training course

Loading...
v6.8
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * AmLogic Meson-AXG Clock Controller Driver
   4 *
   5 * Copyright (c) 2016 Baylibre SAS.
   6 * Author: Michael Turquette <mturquette@baylibre.com>
   7 *
   8 * Copyright (c) 2017 Amlogic, inc.
   9 * Author: Qiufang Dai <qiufang.dai@amlogic.com>
  10 */
  11
  12#include <linux/clk-provider.h>
  13#include <linux/init.h>
  14#include <linux/mod_devicetable.h>
  15#include <linux/platform_device.h>
  16#include <linux/module.h>
  17
  18#include "clk-regmap.h"
  19#include "clk-pll.h"
  20#include "clk-mpll.h"
  21#include "axg.h"
  22#include "meson-eeclk.h"
  23
  24#include <dt-bindings/clock/axg-clkc.h>
  25
  26static DEFINE_SPINLOCK(meson_clk_lock);
  27
  28static struct clk_regmap axg_fixed_pll_dco = {
  29	.data = &(struct meson_clk_pll_data){
  30		.en = {
  31			.reg_off = HHI_MPLL_CNTL,
  32			.shift   = 30,
  33			.width   = 1,
  34		},
  35		.m = {
  36			.reg_off = HHI_MPLL_CNTL,
  37			.shift   = 0,
  38			.width   = 9,
  39		},
  40		.n = {
  41			.reg_off = HHI_MPLL_CNTL,
  42			.shift   = 9,
  43			.width   = 5,
  44		},
  45		.frac = {
  46			.reg_off = HHI_MPLL_CNTL2,
  47			.shift   = 0,
  48			.width   = 12,
  49		},
  50		.l = {
  51			.reg_off = HHI_MPLL_CNTL,
  52			.shift   = 31,
  53			.width   = 1,
  54		},
  55		.rst = {
  56			.reg_off = HHI_MPLL_CNTL,
  57			.shift   = 29,
  58			.width   = 1,
  59		},
  60	},
  61	.hw.init = &(struct clk_init_data){
  62		.name = "fixed_pll_dco",
  63		.ops = &meson_clk_pll_ro_ops,
  64		.parent_data = &(const struct clk_parent_data) {
  65			.fw_name = "xtal",
  66		},
  67		.num_parents = 1,
  68	},
  69};
  70
  71static struct clk_regmap axg_fixed_pll = {
  72	.data = &(struct clk_regmap_div_data){
  73		.offset = HHI_MPLL_CNTL,
  74		.shift = 16,
  75		.width = 2,
  76		.flags = CLK_DIVIDER_POWER_OF_TWO,
  77	},
  78	.hw.init = &(struct clk_init_data){
  79		.name = "fixed_pll",
  80		.ops = &clk_regmap_divider_ro_ops,
  81		.parent_hws = (const struct clk_hw *[]) {
  82			&axg_fixed_pll_dco.hw
  83		},
  84		.num_parents = 1,
  85		/*
  86		 * This clock won't ever change at runtime so
  87		 * CLK_SET_RATE_PARENT is not required
  88		 */
  89	},
  90};
  91
  92static struct clk_regmap axg_sys_pll_dco = {
  93	.data = &(struct meson_clk_pll_data){
  94		.en = {
  95			.reg_off = HHI_SYS_PLL_CNTL,
  96			.shift   = 30,
  97			.width   = 1,
  98		},
  99		.m = {
 100			.reg_off = HHI_SYS_PLL_CNTL,
 101			.shift   = 0,
 102			.width   = 9,
 103		},
 104		.n = {
 105			.reg_off = HHI_SYS_PLL_CNTL,
 106			.shift   = 9,
 107			.width   = 5,
 108		},
 109		.l = {
 110			.reg_off = HHI_SYS_PLL_CNTL,
 111			.shift   = 31,
 112			.width   = 1,
 113		},
 114		.rst = {
 115			.reg_off = HHI_SYS_PLL_CNTL,
 116			.shift   = 29,
 117			.width   = 1,
 118		},
 119	},
 120	.hw.init = &(struct clk_init_data){
 121		.name = "sys_pll_dco",
 122		.ops = &meson_clk_pll_ro_ops,
 123		.parent_data = &(const struct clk_parent_data) {
 124			.fw_name = "xtal",
 125		},
 126		.num_parents = 1,
 127	},
 128};
 129
 130static struct clk_regmap axg_sys_pll = {
 131	.data = &(struct clk_regmap_div_data){
 132		.offset = HHI_SYS_PLL_CNTL,
 133		.shift = 16,
 134		.width = 2,
 135		.flags = CLK_DIVIDER_POWER_OF_TWO,
 136	},
 137	.hw.init = &(struct clk_init_data){
 138		.name = "sys_pll",
 139		.ops = &clk_regmap_divider_ro_ops,
 140		.parent_hws = (const struct clk_hw *[]) {
 141			&axg_sys_pll_dco.hw
 142		},
 143		.num_parents = 1,
 144		.flags = CLK_SET_RATE_PARENT,
 145	},
 146};
 147
 148static const struct pll_params_table axg_gp0_pll_params_table[] = {
 149	PLL_PARAMS(40, 1),
 150	PLL_PARAMS(41, 1),
 151	PLL_PARAMS(42, 1),
 152	PLL_PARAMS(43, 1),
 153	PLL_PARAMS(44, 1),
 154	PLL_PARAMS(45, 1),
 155	PLL_PARAMS(46, 1),
 156	PLL_PARAMS(47, 1),
 157	PLL_PARAMS(48, 1),
 158	PLL_PARAMS(49, 1),
 159	PLL_PARAMS(50, 1),
 160	PLL_PARAMS(51, 1),
 161	PLL_PARAMS(52, 1),
 162	PLL_PARAMS(53, 1),
 163	PLL_PARAMS(54, 1),
 164	PLL_PARAMS(55, 1),
 165	PLL_PARAMS(56, 1),
 166	PLL_PARAMS(57, 1),
 167	PLL_PARAMS(58, 1),
 168	PLL_PARAMS(59, 1),
 169	PLL_PARAMS(60, 1),
 170	PLL_PARAMS(61, 1),
 171	PLL_PARAMS(62, 1),
 172	PLL_PARAMS(63, 1),
 173	PLL_PARAMS(64, 1),
 174	PLL_PARAMS(65, 1),
 175	PLL_PARAMS(66, 1),
 176	PLL_PARAMS(67, 1),
 177	PLL_PARAMS(68, 1),
 178	{ /* sentinel */ },
 179};
 180
 181static const struct reg_sequence axg_gp0_init_regs[] = {
 182	{ .reg = HHI_GP0_PLL_CNTL1,	.def = 0xc084b000 },
 183	{ .reg = HHI_GP0_PLL_CNTL2,	.def = 0xb75020be },
 184	{ .reg = HHI_GP0_PLL_CNTL3,	.def = 0x0a59a288 },
 185	{ .reg = HHI_GP0_PLL_CNTL4,	.def = 0xc000004d },
 186	{ .reg = HHI_GP0_PLL_CNTL5,	.def = 0x00078000 },
 187};
 188
 189static struct clk_regmap axg_gp0_pll_dco = {
 190	.data = &(struct meson_clk_pll_data){
 191		.en = {
 192			.reg_off = HHI_GP0_PLL_CNTL,
 193			.shift   = 30,
 194			.width   = 1,
 195		},
 196		.m = {
 197			.reg_off = HHI_GP0_PLL_CNTL,
 198			.shift   = 0,
 199			.width   = 9,
 200		},
 201		.n = {
 202			.reg_off = HHI_GP0_PLL_CNTL,
 203			.shift   = 9,
 204			.width   = 5,
 205		},
 206		.frac = {
 207			.reg_off = HHI_GP0_PLL_CNTL1,
 208			.shift   = 0,
 209			.width   = 10,
 210		},
 211		.l = {
 212			.reg_off = HHI_GP0_PLL_CNTL,
 213			.shift   = 31,
 214			.width   = 1,
 215		},
 216		.rst = {
 217			.reg_off = HHI_GP0_PLL_CNTL,
 218			.shift   = 29,
 219			.width   = 1,
 220		},
 221		.table = axg_gp0_pll_params_table,
 222		.init_regs = axg_gp0_init_regs,
 223		.init_count = ARRAY_SIZE(axg_gp0_init_regs),
 224	},
 225	.hw.init = &(struct clk_init_data){
 226		.name = "gp0_pll_dco",
 227		.ops = &meson_clk_pll_ops,
 228		.parent_data = &(const struct clk_parent_data) {
 229			.fw_name = "xtal",
 230		},
 231		.num_parents = 1,
 232	},
 233};
 234
 235static struct clk_regmap axg_gp0_pll = {
 236	.data = &(struct clk_regmap_div_data){
 237		.offset = HHI_GP0_PLL_CNTL,
 238		.shift = 16,
 239		.width = 2,
 240		.flags = CLK_DIVIDER_POWER_OF_TWO,
 241	},
 242	.hw.init = &(struct clk_init_data){
 243		.name = "gp0_pll",
 244		.ops = &clk_regmap_divider_ops,
 245		.parent_hws = (const struct clk_hw *[]) {
 246			&axg_gp0_pll_dco.hw
 247		},
 248		.num_parents = 1,
 249		.flags = CLK_SET_RATE_PARENT,
 250	},
 251};
 252
 253static const struct reg_sequence axg_hifi_init_regs[] = {
 254	{ .reg = HHI_HIFI_PLL_CNTL1,	.def = 0xc084b000 },
 255	{ .reg = HHI_HIFI_PLL_CNTL2,	.def = 0xb75020be },
 256	{ .reg = HHI_HIFI_PLL_CNTL3,	.def = 0x0a6a3a88 },
 257	{ .reg = HHI_HIFI_PLL_CNTL4,	.def = 0xc000004d },
 258	{ .reg = HHI_HIFI_PLL_CNTL5,	.def = 0x00058000 },
 259};
 260
 261static struct clk_regmap axg_hifi_pll_dco = {
 262	.data = &(struct meson_clk_pll_data){
 263		.en = {
 264			.reg_off = HHI_HIFI_PLL_CNTL,
 265			.shift   = 30,
 266			.width   = 1,
 267		},
 268		.m = {
 269			.reg_off = HHI_HIFI_PLL_CNTL,
 270			.shift   = 0,
 271			.width   = 9,
 272		},
 273		.n = {
 274			.reg_off = HHI_HIFI_PLL_CNTL,
 275			.shift   = 9,
 276			.width   = 5,
 277		},
 278		.frac = {
 279			.reg_off = HHI_HIFI_PLL_CNTL5,
 280			.shift   = 0,
 281			.width   = 13,
 282		},
 283		.l = {
 284			.reg_off = HHI_HIFI_PLL_CNTL,
 285			.shift   = 31,
 286			.width   = 1,
 287		},
 288		.rst = {
 289			.reg_off = HHI_HIFI_PLL_CNTL,
 290			.shift   = 29,
 291			.width   = 1,
 292		},
 293		.table = axg_gp0_pll_params_table,
 294		.init_regs = axg_hifi_init_regs,
 295		.init_count = ARRAY_SIZE(axg_hifi_init_regs),
 296		.flags = CLK_MESON_PLL_ROUND_CLOSEST,
 297	},
 298	.hw.init = &(struct clk_init_data){
 299		.name = "hifi_pll_dco",
 300		.ops = &meson_clk_pll_ops,
 301		.parent_data = &(const struct clk_parent_data) {
 302			.fw_name = "xtal",
 303		},
 304		.num_parents = 1,
 305	},
 306};
 307
 308static struct clk_regmap axg_hifi_pll = {
 309	.data = &(struct clk_regmap_div_data){
 310		.offset = HHI_HIFI_PLL_CNTL,
 311		.shift = 16,
 312		.width = 2,
 313		.flags = CLK_DIVIDER_POWER_OF_TWO,
 314	},
 315	.hw.init = &(struct clk_init_data){
 316		.name = "hifi_pll",
 317		.ops = &clk_regmap_divider_ops,
 318		.parent_hws = (const struct clk_hw *[]) {
 319			&axg_hifi_pll_dco.hw
 320		},
 321		.num_parents = 1,
 322		.flags = CLK_SET_RATE_PARENT,
 323	},
 324};
 325
 326static struct clk_fixed_factor axg_fclk_div2_div = {
 327	.mult = 1,
 328	.div = 2,
 329	.hw.init = &(struct clk_init_data){
 330		.name = "fclk_div2_div",
 331		.ops = &clk_fixed_factor_ops,
 332		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 333		.num_parents = 1,
 334	},
 335};
 336
 337static struct clk_regmap axg_fclk_div2 = {
 338	.data = &(struct clk_regmap_gate_data){
 339		.offset = HHI_MPLL_CNTL6,
 340		.bit_idx = 27,
 341	},
 342	.hw.init = &(struct clk_init_data){
 343		.name = "fclk_div2",
 344		.ops = &clk_regmap_gate_ops,
 345		.parent_hws = (const struct clk_hw *[]) {
 346			&axg_fclk_div2_div.hw
 347		},
 348		.num_parents = 1,
 349		.flags = CLK_IS_CRITICAL,
 350	},
 351};
 352
 353static struct clk_fixed_factor axg_fclk_div3_div = {
 354	.mult = 1,
 355	.div = 3,
 356	.hw.init = &(struct clk_init_data){
 357		.name = "fclk_div3_div",
 358		.ops = &clk_fixed_factor_ops,
 359		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 360		.num_parents = 1,
 361	},
 362};
 363
 364static struct clk_regmap axg_fclk_div3 = {
 365	.data = &(struct clk_regmap_gate_data){
 366		.offset = HHI_MPLL_CNTL6,
 367		.bit_idx = 28,
 368	},
 369	.hw.init = &(struct clk_init_data){
 370		.name = "fclk_div3",
 371		.ops = &clk_regmap_gate_ops,
 372		.parent_hws = (const struct clk_hw *[]) {
 373			&axg_fclk_div3_div.hw
 374		},
 375		.num_parents = 1,
 376		/*
 377		 * FIXME:
 378		 * This clock, as fdiv2, is used by the SCPI FW and is required
 379		 * by the platform to operate correctly.
 380		 * Until the following condition are met, we need this clock to
 381		 * be marked as critical:
 382		 * a) The SCPI generic driver claims and enable all the clocks
 383		 *    it needs
 384		 * b) CCF has a clock hand-off mechanism to make the sure the
 385		 *    clock stays on until the proper driver comes along
 386		 */
 387		.flags = CLK_IS_CRITICAL,
 388	},
 389};
 390
 391static struct clk_fixed_factor axg_fclk_div4_div = {
 392	.mult = 1,
 393	.div = 4,
 394	.hw.init = &(struct clk_init_data){
 395		.name = "fclk_div4_div",
 396		.ops = &clk_fixed_factor_ops,
 397		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 398		.num_parents = 1,
 399	},
 400};
 401
 402static struct clk_regmap axg_fclk_div4 = {
 403	.data = &(struct clk_regmap_gate_data){
 404		.offset = HHI_MPLL_CNTL6,
 405		.bit_idx = 29,
 406	},
 407	.hw.init = &(struct clk_init_data){
 408		.name = "fclk_div4",
 409		.ops = &clk_regmap_gate_ops,
 410		.parent_hws = (const struct clk_hw *[]) {
 411			&axg_fclk_div4_div.hw
 412		},
 413		.num_parents = 1,
 414	},
 415};
 416
 417static struct clk_fixed_factor axg_fclk_div5_div = {
 418	.mult = 1,
 419	.div = 5,
 420	.hw.init = &(struct clk_init_data){
 421		.name = "fclk_div5_div",
 422		.ops = &clk_fixed_factor_ops,
 423		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 424		.num_parents = 1,
 425	},
 426};
 427
 428static struct clk_regmap axg_fclk_div5 = {
 429	.data = &(struct clk_regmap_gate_data){
 430		.offset = HHI_MPLL_CNTL6,
 431		.bit_idx = 30,
 432	},
 433	.hw.init = &(struct clk_init_data){
 434		.name = "fclk_div5",
 435		.ops = &clk_regmap_gate_ops,
 436		.parent_hws = (const struct clk_hw *[]) {
 437			&axg_fclk_div5_div.hw
 438		},
 439		.num_parents = 1,
 440	},
 441};
 442
 443static struct clk_fixed_factor axg_fclk_div7_div = {
 444	.mult = 1,
 445	.div = 7,
 446	.hw.init = &(struct clk_init_data){
 447		.name = "fclk_div7_div",
 448		.ops = &clk_fixed_factor_ops,
 449		.parent_hws = (const struct clk_hw *[]) {
 450			&axg_fixed_pll.hw
 451		},
 452		.num_parents = 1,
 453	},
 454};
 455
 456static struct clk_regmap axg_fclk_div7 = {
 457	.data = &(struct clk_regmap_gate_data){
 458		.offset = HHI_MPLL_CNTL6,
 459		.bit_idx = 31,
 460	},
 461	.hw.init = &(struct clk_init_data){
 462		.name = "fclk_div7",
 463		.ops = &clk_regmap_gate_ops,
 464		.parent_hws = (const struct clk_hw *[]) {
 465			&axg_fclk_div7_div.hw
 466		},
 467		.num_parents = 1,
 468	},
 469};
 470
 471static struct clk_regmap axg_mpll_prediv = {
 472	.data = &(struct clk_regmap_div_data){
 473		.offset = HHI_MPLL_CNTL5,
 474		.shift = 12,
 475		.width = 1,
 476	},
 477	.hw.init = &(struct clk_init_data){
 478		.name = "mpll_prediv",
 479		.ops = &clk_regmap_divider_ro_ops,
 480		.parent_hws = (const struct clk_hw *[]) {
 481			&axg_fixed_pll.hw
 482		},
 483		.num_parents = 1,
 484	},
 485};
 486
 487static struct clk_regmap axg_mpll0_div = {
 488	.data = &(struct meson_clk_mpll_data){
 489		.sdm = {
 490			.reg_off = HHI_MPLL_CNTL7,
 491			.shift   = 0,
 492			.width   = 14,
 493		},
 494		.sdm_en = {
 495			.reg_off = HHI_MPLL_CNTL7,
 496			.shift   = 15,
 497			.width	 = 1,
 498		},
 499		.n2 = {
 500			.reg_off = HHI_MPLL_CNTL7,
 501			.shift   = 16,
 502			.width   = 9,
 503		},
 504		.misc = {
 505			.reg_off = HHI_PLL_TOP_MISC,
 506			.shift   = 0,
 507			.width	 = 1,
 508		},
 509		.lock = &meson_clk_lock,
 510		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 511	},
 512	.hw.init = &(struct clk_init_data){
 513		.name = "mpll0_div",
 514		.ops = &meson_clk_mpll_ops,
 515		.parent_hws = (const struct clk_hw *[]) {
 516			&axg_mpll_prediv.hw
 517		},
 518		.num_parents = 1,
 519	},
 520};
 521
 522static struct clk_regmap axg_mpll0 = {
 523	.data = &(struct clk_regmap_gate_data){
 524		.offset = HHI_MPLL_CNTL7,
 525		.bit_idx = 14,
 526	},
 527	.hw.init = &(struct clk_init_data){
 528		.name = "mpll0",
 529		.ops = &clk_regmap_gate_ops,
 530		.parent_hws = (const struct clk_hw *[]) {
 531			&axg_mpll0_div.hw
 532		},
 533		.num_parents = 1,
 534		.flags = CLK_SET_RATE_PARENT,
 535	},
 536};
 537
 538static struct clk_regmap axg_mpll1_div = {
 539	.data = &(struct meson_clk_mpll_data){
 540		.sdm = {
 541			.reg_off = HHI_MPLL_CNTL8,
 542			.shift   = 0,
 543			.width   = 14,
 544		},
 545		.sdm_en = {
 546			.reg_off = HHI_MPLL_CNTL8,
 547			.shift   = 15,
 548			.width	 = 1,
 549		},
 550		.n2 = {
 551			.reg_off = HHI_MPLL_CNTL8,
 552			.shift   = 16,
 553			.width   = 9,
 554		},
 555		.misc = {
 556			.reg_off = HHI_PLL_TOP_MISC,
 557			.shift   = 1,
 558			.width	 = 1,
 559		},
 560		.lock = &meson_clk_lock,
 561		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 562	},
 563	.hw.init = &(struct clk_init_data){
 564		.name = "mpll1_div",
 565		.ops = &meson_clk_mpll_ops,
 566		.parent_hws = (const struct clk_hw *[]) {
 567			&axg_mpll_prediv.hw
 568		},
 569		.num_parents = 1,
 570	},
 571};
 572
 573static struct clk_regmap axg_mpll1 = {
 574	.data = &(struct clk_regmap_gate_data){
 575		.offset = HHI_MPLL_CNTL8,
 576		.bit_idx = 14,
 577	},
 578	.hw.init = &(struct clk_init_data){
 579		.name = "mpll1",
 580		.ops = &clk_regmap_gate_ops,
 581		.parent_hws = (const struct clk_hw *[]) {
 582			&axg_mpll1_div.hw
 583		},
 584		.num_parents = 1,
 585		.flags = CLK_SET_RATE_PARENT,
 586	},
 587};
 588
 589static struct clk_regmap axg_mpll2_div = {
 590	.data = &(struct meson_clk_mpll_data){
 591		.sdm = {
 592			.reg_off = HHI_MPLL_CNTL9,
 593			.shift   = 0,
 594			.width   = 14,
 595		},
 596		.sdm_en = {
 597			.reg_off = HHI_MPLL_CNTL9,
 598			.shift   = 15,
 599			.width	 = 1,
 600		},
 601		.n2 = {
 602			.reg_off = HHI_MPLL_CNTL9,
 603			.shift   = 16,
 604			.width   = 9,
 605		},
 606		.ssen = {
 607			.reg_off = HHI_MPLL_CNTL,
 608			.shift   = 25,
 609			.width	 = 1,
 610		},
 611		.misc = {
 612			.reg_off = HHI_PLL_TOP_MISC,
 613			.shift   = 2,
 614			.width	 = 1,
 615		},
 616		.lock = &meson_clk_lock,
 617		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 618	},
 619	.hw.init = &(struct clk_init_data){
 620		.name = "mpll2_div",
 621		.ops = &meson_clk_mpll_ops,
 622		.parent_hws = (const struct clk_hw *[]) {
 623			&axg_mpll_prediv.hw
 624		},
 625		.num_parents = 1,
 626	},
 627};
 628
 629static struct clk_regmap axg_mpll2 = {
 630	.data = &(struct clk_regmap_gate_data){
 631		.offset = HHI_MPLL_CNTL9,
 632		.bit_idx = 14,
 633	},
 634	.hw.init = &(struct clk_init_data){
 635		.name = "mpll2",
 636		.ops = &clk_regmap_gate_ops,
 637		.parent_hws = (const struct clk_hw *[]) {
 638			&axg_mpll2_div.hw
 639		},
 640		.num_parents = 1,
 641		.flags = CLK_SET_RATE_PARENT,
 642	},
 643};
 644
 645static struct clk_regmap axg_mpll3_div = {
 646	.data = &(struct meson_clk_mpll_data){
 647		.sdm = {
 648			.reg_off = HHI_MPLL3_CNTL0,
 649			.shift   = 12,
 650			.width   = 14,
 651		},
 652		.sdm_en = {
 653			.reg_off = HHI_MPLL3_CNTL0,
 654			.shift   = 11,
 655			.width	 = 1,
 656		},
 657		.n2 = {
 658			.reg_off = HHI_MPLL3_CNTL0,
 659			.shift   = 2,
 660			.width   = 9,
 661		},
 662		.misc = {
 663			.reg_off = HHI_PLL_TOP_MISC,
 664			.shift   = 3,
 665			.width	 = 1,
 666		},
 667		.lock = &meson_clk_lock,
 668		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 669	},
 670	.hw.init = &(struct clk_init_data){
 671		.name = "mpll3_div",
 672		.ops = &meson_clk_mpll_ops,
 673		.parent_hws = (const struct clk_hw *[]) {
 674			&axg_mpll_prediv.hw
 675		},
 676		.num_parents = 1,
 677	},
 678};
 679
 680static struct clk_regmap axg_mpll3 = {
 681	.data = &(struct clk_regmap_gate_data){
 682		.offset = HHI_MPLL3_CNTL0,
 683		.bit_idx = 0,
 684	},
 685	.hw.init = &(struct clk_init_data){
 686		.name = "mpll3",
 687		.ops = &clk_regmap_gate_ops,
 688		.parent_hws = (const struct clk_hw *[]) {
 689			&axg_mpll3_div.hw
 690		},
 691		.num_parents = 1,
 692		.flags = CLK_SET_RATE_PARENT,
 693	},
 694};
 695
 696static const struct pll_params_table axg_pcie_pll_params_table[] = {
 697	{
 698		.m = 200,
 699		.n = 3,
 700	},
 701	{ /* sentinel */ },
 702};
 703
 704static const struct reg_sequence axg_pcie_init_regs[] = {
 705	{ .reg = HHI_PCIE_PLL_CNTL1,	.def = 0x0084a2aa },
 706	{ .reg = HHI_PCIE_PLL_CNTL2,	.def = 0xb75020be },
 707	{ .reg = HHI_PCIE_PLL_CNTL3,	.def = 0x0a47488e },
 708	{ .reg = HHI_PCIE_PLL_CNTL4,	.def = 0xc000004d },
 709	{ .reg = HHI_PCIE_PLL_CNTL5,	.def = 0x00078000 },
 710	{ .reg = HHI_PCIE_PLL_CNTL6,	.def = 0x002323c6 },
 711	{ .reg = HHI_PCIE_PLL_CNTL,     .def = 0x400106c8 },
 712};
 713
 714static struct clk_regmap axg_pcie_pll_dco = {
 715	.data = &(struct meson_clk_pll_data){
 716		.en = {
 717			.reg_off = HHI_PCIE_PLL_CNTL,
 718			.shift   = 30,
 719			.width   = 1,
 720		},
 721		.m = {
 722			.reg_off = HHI_PCIE_PLL_CNTL,
 723			.shift   = 0,
 724			.width   = 9,
 725		},
 726		.n = {
 727			.reg_off = HHI_PCIE_PLL_CNTL,
 728			.shift   = 9,
 729			.width   = 5,
 730		},
 731		.frac = {
 732			.reg_off = HHI_PCIE_PLL_CNTL1,
 733			.shift   = 0,
 734			.width   = 12,
 735		},
 736		.l = {
 737			.reg_off = HHI_PCIE_PLL_CNTL,
 738			.shift   = 31,
 739			.width   = 1,
 740		},
 741		.rst = {
 742			.reg_off = HHI_PCIE_PLL_CNTL,
 743			.shift   = 29,
 744			.width   = 1,
 745		},
 746		.table = axg_pcie_pll_params_table,
 747		.init_regs = axg_pcie_init_regs,
 748		.init_count = ARRAY_SIZE(axg_pcie_init_regs),
 749	},
 750	.hw.init = &(struct clk_init_data){
 751		.name = "pcie_pll_dco",
 752		.ops = &meson_clk_pll_ops,
 753		.parent_data = &(const struct clk_parent_data) {
 754			.fw_name = "xtal",
 755		},
 756		.num_parents = 1,
 757	},
 758};
 759
 760static struct clk_regmap axg_pcie_pll_od = {
 761	.data = &(struct clk_regmap_div_data){
 762		.offset = HHI_PCIE_PLL_CNTL,
 763		.shift = 16,
 764		.width = 2,
 765		.flags = CLK_DIVIDER_POWER_OF_TWO,
 766	},
 767	.hw.init = &(struct clk_init_data){
 768		.name = "pcie_pll_od",
 769		.ops = &clk_regmap_divider_ops,
 770		.parent_hws = (const struct clk_hw *[]) {
 771			&axg_pcie_pll_dco.hw
 772		},
 773		.num_parents = 1,
 774		.flags = CLK_SET_RATE_PARENT,
 775	},
 776};
 777
 778static struct clk_regmap axg_pcie_pll = {
 779	.data = &(struct clk_regmap_div_data){
 780		.offset = HHI_PCIE_PLL_CNTL6,
 781		.shift = 6,
 782		.width = 2,
 783		.flags = CLK_DIVIDER_POWER_OF_TWO,
 784	},
 785	.hw.init = &(struct clk_init_data){
 786		.name = "pcie_pll",
 787		.ops = &clk_regmap_divider_ops,
 788		.parent_hws = (const struct clk_hw *[]) {
 789			&axg_pcie_pll_od.hw
 790		},
 791		.num_parents = 1,
 792		.flags = CLK_SET_RATE_PARENT,
 793	},
 794};
 795
 796static struct clk_regmap axg_pcie_mux = {
 797	.data = &(struct clk_regmap_mux_data){
 798		.offset = HHI_PCIE_PLL_CNTL6,
 799		.mask = 0x1,
 800		.shift = 2,
 801		/* skip the parent mpll3, reserved for debug */
 802		.table = (u32[]){ 1 },
 803	},
 804	.hw.init = &(struct clk_init_data){
 805		.name = "pcie_mux",
 806		.ops = &clk_regmap_mux_ops,
 807		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_pll.hw },
 808		.num_parents = 1,
 809		.flags = CLK_SET_RATE_PARENT,
 810	},
 811};
 812
 813static struct clk_regmap axg_pcie_ref = {
 814	.data = &(struct clk_regmap_mux_data){
 815		.offset = HHI_PCIE_PLL_CNTL6,
 816		.mask = 0x1,
 817		.shift = 1,
 818		/* skip the parent 0, reserved for debug */
 819		.table = (u32[]){ 1 },
 820	},
 821	.hw.init = &(struct clk_init_data){
 822		.name = "pcie_ref",
 823		.ops = &clk_regmap_mux_ops,
 824		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_mux.hw },
 825		.num_parents = 1,
 826		.flags = CLK_SET_RATE_PARENT,
 827	},
 828};
 829
 830static struct clk_regmap axg_pcie_cml_en0 = {
 831	.data = &(struct clk_regmap_gate_data){
 832		.offset = HHI_PCIE_PLL_CNTL6,
 833		.bit_idx = 4,
 834	},
 835	.hw.init = &(struct clk_init_data) {
 836		.name = "pcie_cml_en0",
 837		.ops = &clk_regmap_gate_ops,
 838		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_ref.hw },
 839		.num_parents = 1,
 840		.flags = CLK_SET_RATE_PARENT,
 841
 842	},
 843};
 844
 845static struct clk_regmap axg_pcie_cml_en1 = {
 846	.data = &(struct clk_regmap_gate_data){
 847		.offset = HHI_PCIE_PLL_CNTL6,
 848		.bit_idx = 3,
 849	},
 850	.hw.init = &(struct clk_init_data) {
 851		.name = "pcie_cml_en1",
 852		.ops = &clk_regmap_gate_ops,
 853		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_ref.hw },
 854		.num_parents = 1,
 855		.flags = CLK_SET_RATE_PARENT,
 856	},
 857};
 858
 859static u32 mux_table_clk81[]	= { 0, 2, 3, 4, 5, 6, 7 };
 860static const struct clk_parent_data clk81_parent_data[] = {
 861	{ .fw_name = "xtal", },
 862	{ .hw = &axg_fclk_div7.hw },
 863	{ .hw = &axg_mpll1.hw },
 864	{ .hw = &axg_mpll2.hw },
 865	{ .hw = &axg_fclk_div4.hw },
 866	{ .hw = &axg_fclk_div3.hw },
 867	{ .hw = &axg_fclk_div5.hw },
 868};
 869
 870static struct clk_regmap axg_mpeg_clk_sel = {
 871	.data = &(struct clk_regmap_mux_data){
 872		.offset = HHI_MPEG_CLK_CNTL,
 873		.mask = 0x7,
 874		.shift = 12,
 875		.table = mux_table_clk81,
 876	},
 877	.hw.init = &(struct clk_init_data){
 878		.name = "mpeg_clk_sel",
 879		.ops = &clk_regmap_mux_ro_ops,
 880		.parent_data = clk81_parent_data,
 881		.num_parents = ARRAY_SIZE(clk81_parent_data),
 882	},
 883};
 884
 885static struct clk_regmap axg_mpeg_clk_div = {
 886	.data = &(struct clk_regmap_div_data){
 887		.offset = HHI_MPEG_CLK_CNTL,
 888		.shift = 0,
 889		.width = 7,
 890	},
 891	.hw.init = &(struct clk_init_data){
 892		.name = "mpeg_clk_div",
 893		.ops = &clk_regmap_divider_ops,
 894		.parent_hws = (const struct clk_hw *[]) {
 895			&axg_mpeg_clk_sel.hw
 896		},
 897		.num_parents = 1,
 898		.flags = CLK_SET_RATE_PARENT,
 899	},
 900};
 901
 902static struct clk_regmap axg_clk81 = {
 903	.data = &(struct clk_regmap_gate_data){
 904		.offset = HHI_MPEG_CLK_CNTL,
 905		.bit_idx = 7,
 906	},
 907	.hw.init = &(struct clk_init_data){
 908		.name = "clk81",
 909		.ops = &clk_regmap_gate_ops,
 910		.parent_hws = (const struct clk_hw *[]) {
 911			&axg_mpeg_clk_div.hw
 912		},
 913		.num_parents = 1,
 914		.flags = (CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
 915	},
 916};
 917
 918static const struct clk_parent_data axg_sd_emmc_clk0_parent_data[] = {
 919	{ .fw_name = "xtal", },
 920	{ .hw = &axg_fclk_div2.hw },
 921	{ .hw = &axg_fclk_div3.hw },
 922	{ .hw = &axg_fclk_div5.hw },
 923	{ .hw = &axg_fclk_div7.hw },
 924	/*
 925	 * Following these parent clocks, we should also have had mpll2, mpll3
 926	 * and gp0_pll but these clocks are too precious to be used here. All
 927	 * the necessary rates for MMC and NAND operation can be acheived using
 928	 * xtal or fclk_div clocks
 929	 */
 930};
 931
 932/* SDcard clock */
 933static struct clk_regmap axg_sd_emmc_b_clk0_sel = {
 934	.data = &(struct clk_regmap_mux_data){
 935		.offset = HHI_SD_EMMC_CLK_CNTL,
 936		.mask = 0x7,
 937		.shift = 25,
 938	},
 939	.hw.init = &(struct clk_init_data) {
 940		.name = "sd_emmc_b_clk0_sel",
 941		.ops = &clk_regmap_mux_ops,
 942		.parent_data = axg_sd_emmc_clk0_parent_data,
 943		.num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_data),
 944		.flags = CLK_SET_RATE_PARENT,
 945	},
 946};
 947
 948static struct clk_regmap axg_sd_emmc_b_clk0_div = {
 949	.data = &(struct clk_regmap_div_data){
 950		.offset = HHI_SD_EMMC_CLK_CNTL,
 951		.shift = 16,
 952		.width = 7,
 953		.flags = CLK_DIVIDER_ROUND_CLOSEST,
 954	},
 955	.hw.init = &(struct clk_init_data) {
 956		.name = "sd_emmc_b_clk0_div",
 957		.ops = &clk_regmap_divider_ops,
 958		.parent_hws = (const struct clk_hw *[]) {
 959			&axg_sd_emmc_b_clk0_sel.hw
 960		},
 961		.num_parents = 1,
 962		.flags = CLK_SET_RATE_PARENT,
 963	},
 964};
 965
 966static struct clk_regmap axg_sd_emmc_b_clk0 = {
 967	.data = &(struct clk_regmap_gate_data){
 968		.offset = HHI_SD_EMMC_CLK_CNTL,
 969		.bit_idx = 23,
 970	},
 971	.hw.init = &(struct clk_init_data){
 972		.name = "sd_emmc_b_clk0",
 973		.ops = &clk_regmap_gate_ops,
 974		.parent_hws = (const struct clk_hw *[]) {
 975			&axg_sd_emmc_b_clk0_div.hw
 976		},
 977		.num_parents = 1,
 978		.flags = CLK_SET_RATE_PARENT,
 979	},
 980};
 981
 982/* EMMC/NAND clock */
 983static struct clk_regmap axg_sd_emmc_c_clk0_sel = {
 984	.data = &(struct clk_regmap_mux_data){
 985		.offset = HHI_NAND_CLK_CNTL,
 986		.mask = 0x7,
 987		.shift = 9,
 988	},
 989	.hw.init = &(struct clk_init_data) {
 990		.name = "sd_emmc_c_clk0_sel",
 991		.ops = &clk_regmap_mux_ops,
 992		.parent_data = axg_sd_emmc_clk0_parent_data,
 993		.num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_data),
 994		.flags = CLK_SET_RATE_PARENT,
 995	},
 996};
 997
 998static struct clk_regmap axg_sd_emmc_c_clk0_div = {
 999	.data = &(struct clk_regmap_div_data){
1000		.offset = HHI_NAND_CLK_CNTL,
1001		.shift = 0,
1002		.width = 7,
1003		.flags = CLK_DIVIDER_ROUND_CLOSEST,
1004	},
1005	.hw.init = &(struct clk_init_data) {
1006		.name = "sd_emmc_c_clk0_div",
1007		.ops = &clk_regmap_divider_ops,
1008		.parent_hws = (const struct clk_hw *[]) {
1009			&axg_sd_emmc_c_clk0_sel.hw
1010		},
1011		.num_parents = 1,
1012		.flags = CLK_SET_RATE_PARENT,
1013	},
1014};
1015
1016static struct clk_regmap axg_sd_emmc_c_clk0 = {
1017	.data = &(struct clk_regmap_gate_data){
1018		.offset = HHI_NAND_CLK_CNTL,
1019		.bit_idx = 7,
1020	},
1021	.hw.init = &(struct clk_init_data){
1022		.name = "sd_emmc_c_clk0",
1023		.ops = &clk_regmap_gate_ops,
1024		.parent_hws = (const struct clk_hw *[]) {
1025			&axg_sd_emmc_c_clk0_div.hw
1026		},
1027		.num_parents = 1,
1028		.flags = CLK_SET_RATE_PARENT,
1029	},
1030};
1031
1032/* VPU Clock */
1033
1034static const struct clk_hw *axg_vpu_parent_hws[] = {
1035	&axg_fclk_div4.hw,
1036	&axg_fclk_div3.hw,
1037	&axg_fclk_div5.hw,
1038	&axg_fclk_div7.hw,
1039};
1040
1041static struct clk_regmap axg_vpu_0_sel = {
1042	.data = &(struct clk_regmap_mux_data){
1043		.offset = HHI_VPU_CLK_CNTL,
1044		.mask = 0x3,
1045		.shift = 9,
1046	},
1047	.hw.init = &(struct clk_init_data){
1048		.name = "vpu_0_sel",
1049		.ops = &clk_regmap_mux_ops,
1050		.parent_hws = axg_vpu_parent_hws,
1051		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1052		/* We need a specific parent for VPU clock source, let it be set in DT */
1053		.flags = CLK_SET_RATE_NO_REPARENT,
1054	},
1055};
1056
1057static struct clk_regmap axg_vpu_0_div = {
1058	.data = &(struct clk_regmap_div_data){
1059		.offset = HHI_VPU_CLK_CNTL,
1060		.shift = 0,
1061		.width = 7,
1062	},
1063	.hw.init = &(struct clk_init_data){
1064		.name = "vpu_0_div",
1065		.ops = &clk_regmap_divider_ops,
1066		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_0_sel.hw },
1067		.num_parents = 1,
1068		.flags = CLK_SET_RATE_PARENT,
1069	},
1070};
1071
1072static struct clk_regmap axg_vpu_0 = {
1073	.data = &(struct clk_regmap_gate_data){
1074		.offset = HHI_VPU_CLK_CNTL,
1075		.bit_idx = 8,
1076	},
1077	.hw.init = &(struct clk_init_data) {
1078		.name = "vpu_0",
1079		.ops = &clk_regmap_gate_ops,
1080		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_0_div.hw },
1081		.num_parents = 1,
1082		/*
1083		 * We want to avoid CCF to disable the VPU clock if
1084		 * display has been set by Bootloader
1085		 */
1086		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1087	},
1088};
1089
1090static struct clk_regmap axg_vpu_1_sel = {
1091	.data = &(struct clk_regmap_mux_data){
1092		.offset = HHI_VPU_CLK_CNTL,
1093		.mask = 0x3,
1094		.shift = 25,
1095	},
1096	.hw.init = &(struct clk_init_data){
1097		.name = "vpu_1_sel",
1098		.ops = &clk_regmap_mux_ops,
1099		.parent_hws = axg_vpu_parent_hws,
1100		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1101		/* We need a specific parent for VPU clock source, let it be set in DT */
1102		.flags = CLK_SET_RATE_NO_REPARENT,
1103	},
1104};
1105
1106static struct clk_regmap axg_vpu_1_div = {
1107	.data = &(struct clk_regmap_div_data){
1108		.offset = HHI_VPU_CLK_CNTL,
1109		.shift = 16,
1110		.width = 7,
1111	},
1112	.hw.init = &(struct clk_init_data){
1113		.name = "vpu_1_div",
1114		.ops = &clk_regmap_divider_ops,
1115		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_1_sel.hw },
1116		.num_parents = 1,
1117		.flags = CLK_SET_RATE_PARENT,
1118	},
1119};
1120
1121static struct clk_regmap axg_vpu_1 = {
1122	.data = &(struct clk_regmap_gate_data){
1123		.offset = HHI_VPU_CLK_CNTL,
1124		.bit_idx = 24,
1125	},
1126	.hw.init = &(struct clk_init_data) {
1127		.name = "vpu_1",
1128		.ops = &clk_regmap_gate_ops,
1129		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_1_div.hw },
1130		.num_parents = 1,
1131		/*
1132		 * We want to avoid CCF to disable the VPU clock if
1133		 * display has been set by Bootloader
1134		 */
1135		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1136	},
1137};
1138
1139static struct clk_regmap axg_vpu = {
1140	.data = &(struct clk_regmap_mux_data){
1141		.offset = HHI_VPU_CLK_CNTL,
1142		.mask = 1,
1143		.shift = 31,
1144	},
1145	.hw.init = &(struct clk_init_data){
1146		.name = "vpu",
1147		.ops = &clk_regmap_mux_ops,
1148		.parent_hws = (const struct clk_hw *[]) {
1149			&axg_vpu_0.hw,
1150			&axg_vpu_1.hw
1151		},
1152		.num_parents = 2,
1153		.flags = CLK_SET_RATE_NO_REPARENT,
1154	},
1155};
1156
1157/* VAPB Clock */
1158
1159static struct clk_regmap axg_vapb_0_sel = {
1160	.data = &(struct clk_regmap_mux_data){
1161		.offset = HHI_VAPBCLK_CNTL,
1162		.mask = 0x3,
1163		.shift = 9,
1164	},
1165	.hw.init = &(struct clk_init_data){
1166		.name = "vapb_0_sel",
1167		.ops = &clk_regmap_mux_ops,
1168		.parent_hws = axg_vpu_parent_hws,
1169		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1170		.flags = CLK_SET_RATE_NO_REPARENT,
1171	},
1172};
1173
1174static struct clk_regmap axg_vapb_0_div = {
1175	.data = &(struct clk_regmap_div_data){
1176		.offset = HHI_VAPBCLK_CNTL,
1177		.shift = 0,
1178		.width = 7,
1179	},
1180	.hw.init = &(struct clk_init_data){
1181		.name = "vapb_0_div",
1182		.ops = &clk_regmap_divider_ops,
1183		.parent_hws = (const struct clk_hw *[]) {
1184			&axg_vapb_0_sel.hw
1185		},
1186		.num_parents = 1,
1187		.flags = CLK_SET_RATE_PARENT,
1188	},
1189};
1190
1191static struct clk_regmap axg_vapb_0 = {
1192	.data = &(struct clk_regmap_gate_data){
1193		.offset = HHI_VAPBCLK_CNTL,
1194		.bit_idx = 8,
1195	},
1196	.hw.init = &(struct clk_init_data) {
1197		.name = "vapb_0",
1198		.ops = &clk_regmap_gate_ops,
1199		.parent_hws = (const struct clk_hw *[]) {
1200			&axg_vapb_0_div.hw
1201		},
1202		.num_parents = 1,
1203		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1204	},
1205};
1206
1207static struct clk_regmap axg_vapb_1_sel = {
1208	.data = &(struct clk_regmap_mux_data){
1209		.offset = HHI_VAPBCLK_CNTL,
1210		.mask = 0x3,
1211		.shift = 25,
1212	},
1213	.hw.init = &(struct clk_init_data){
1214		.name = "vapb_1_sel",
1215		.ops = &clk_regmap_mux_ops,
1216		.parent_hws = axg_vpu_parent_hws,
1217		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1218		.flags = CLK_SET_RATE_NO_REPARENT,
1219	},
1220};
1221
1222static struct clk_regmap axg_vapb_1_div = {
1223	.data = &(struct clk_regmap_div_data){
1224		.offset = HHI_VAPBCLK_CNTL,
1225		.shift = 16,
1226		.width = 7,
1227	},
1228	.hw.init = &(struct clk_init_data){
1229		.name = "vapb_1_div",
1230		.ops = &clk_regmap_divider_ops,
1231		.parent_hws = (const struct clk_hw *[]) {
1232			&axg_vapb_1_sel.hw
1233		},
1234		.num_parents = 1,
1235		.flags = CLK_SET_RATE_PARENT,
1236	},
1237};
1238
1239static struct clk_regmap axg_vapb_1 = {
1240	.data = &(struct clk_regmap_gate_data){
1241		.offset = HHI_VAPBCLK_CNTL,
1242		.bit_idx = 24,
1243	},
1244	.hw.init = &(struct clk_init_data) {
1245		.name = "vapb_1",
1246		.ops = &clk_regmap_gate_ops,
1247		.parent_hws = (const struct clk_hw *[]) {
1248			&axg_vapb_1_div.hw
1249		},
1250		.num_parents = 1,
1251		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1252	},
1253};
1254
1255static struct clk_regmap axg_vapb_sel = {
1256	.data = &(struct clk_regmap_mux_data){
1257		.offset = HHI_VAPBCLK_CNTL,
1258		.mask = 1,
1259		.shift = 31,
1260	},
1261	.hw.init = &(struct clk_init_data){
1262		.name = "vapb_sel",
1263		.ops = &clk_regmap_mux_ops,
1264		.parent_hws = (const struct clk_hw *[]) {
1265			&axg_vapb_0.hw,
1266			&axg_vapb_1.hw
1267		},
1268		.num_parents = 2,
1269		.flags = CLK_SET_RATE_NO_REPARENT,
1270	},
1271};
1272
1273static struct clk_regmap axg_vapb = {
1274	.data = &(struct clk_regmap_gate_data){
1275		.offset = HHI_VAPBCLK_CNTL,
1276		.bit_idx = 30,
1277	},
1278	.hw.init = &(struct clk_init_data) {
1279		.name = "vapb",
1280		.ops = &clk_regmap_gate_ops,
1281		.parent_hws = (const struct clk_hw *[]) { &axg_vapb_sel.hw },
1282		.num_parents = 1,
1283		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1284	},
1285};
1286
1287/* Video Clocks */
1288
1289static const struct clk_hw *axg_vclk_parent_hws[] = {
1290	&axg_gp0_pll.hw,
1291	&axg_fclk_div4.hw,
1292	&axg_fclk_div3.hw,
1293	&axg_fclk_div5.hw,
1294	&axg_fclk_div2.hw,
1295	&axg_fclk_div7.hw,
1296	&axg_mpll1.hw,
1297};
1298
1299static struct clk_regmap axg_vclk_sel = {
1300	.data = &(struct clk_regmap_mux_data){
1301		.offset = HHI_VID_CLK_CNTL,
1302		.mask = 0x7,
1303		.shift = 16,
1304	},
1305	.hw.init = &(struct clk_init_data){
1306		.name = "vclk_sel",
1307		.ops = &clk_regmap_mux_ops,
1308		.parent_hws = axg_vclk_parent_hws,
1309		.num_parents = ARRAY_SIZE(axg_vclk_parent_hws),
1310		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1311	},
1312};
1313
1314static struct clk_regmap axg_vclk2_sel = {
1315	.data = &(struct clk_regmap_mux_data){
1316		.offset = HHI_VIID_CLK_CNTL,
1317		.mask = 0x7,
1318		.shift = 16,
1319	},
1320	.hw.init = &(struct clk_init_data){
1321		.name = "vclk2_sel",
1322		.ops = &clk_regmap_mux_ops,
1323		.parent_hws = axg_vclk_parent_hws,
1324		.num_parents = ARRAY_SIZE(axg_vclk_parent_hws),
1325		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1326	},
1327};
1328
1329static struct clk_regmap axg_vclk_input = {
1330	.data = &(struct clk_regmap_gate_data){
1331		.offset = HHI_VID_CLK_DIV,
1332		.bit_idx = 16,
1333	},
1334	.hw.init = &(struct clk_init_data) {
1335		.name = "vclk_input",
1336		.ops = &clk_regmap_gate_ops,
1337		.parent_hws = (const struct clk_hw *[]) { &axg_vclk_sel.hw },
1338		.num_parents = 1,
1339		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1340	},
1341};
1342
1343static struct clk_regmap axg_vclk2_input = {
1344	.data = &(struct clk_regmap_gate_data){
1345		.offset = HHI_VIID_CLK_DIV,
1346		.bit_idx = 16,
1347	},
1348	.hw.init = &(struct clk_init_data) {
1349		.name = "vclk2_input",
1350		.ops = &clk_regmap_gate_ops,
1351		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2_sel.hw },
1352		.num_parents = 1,
1353		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1354	},
1355};
1356
1357static struct clk_regmap axg_vclk_div = {
1358	.data = &(struct clk_regmap_div_data){
1359		.offset = HHI_VID_CLK_DIV,
1360		.shift = 0,
1361		.width = 8,
1362	},
1363	.hw.init = &(struct clk_init_data){
1364		.name = "vclk_div",
1365		.ops = &clk_regmap_divider_ops,
1366		.parent_hws = (const struct clk_hw *[]) {
1367			&axg_vclk_input.hw
1368		},
1369		.num_parents = 1,
1370		.flags = CLK_GET_RATE_NOCACHE,
1371	},
1372};
1373
1374static struct clk_regmap axg_vclk2_div = {
1375	.data = &(struct clk_regmap_div_data){
1376		.offset = HHI_VIID_CLK_DIV,
1377		.shift = 0,
1378		.width = 8,
1379	},
1380	.hw.init = &(struct clk_init_data){
1381		.name = "vclk2_div",
1382		.ops = &clk_regmap_divider_ops,
1383		.parent_hws = (const struct clk_hw *[]) {
1384			&axg_vclk2_input.hw
1385		},
1386		.num_parents = 1,
1387		.flags = CLK_GET_RATE_NOCACHE,
1388	},
1389};
1390
1391static struct clk_regmap axg_vclk = {
1392	.data = &(struct clk_regmap_gate_data){
1393		.offset = HHI_VID_CLK_CNTL,
1394		.bit_idx = 19,
1395	},
1396	.hw.init = &(struct clk_init_data) {
1397		.name = "vclk",
1398		.ops = &clk_regmap_gate_ops,
1399		.parent_hws = (const struct clk_hw *[]) { &axg_vclk_div.hw },
1400		.num_parents = 1,
1401		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1402	},
1403};
1404
1405static struct clk_regmap axg_vclk2 = {
1406	.data = &(struct clk_regmap_gate_data){
1407		.offset = HHI_VIID_CLK_CNTL,
1408		.bit_idx = 19,
1409	},
1410	.hw.init = &(struct clk_init_data) {
1411		.name = "vclk2",
1412		.ops = &clk_regmap_gate_ops,
1413		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2_div.hw },
1414		.num_parents = 1,
1415		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1416	},
1417};
1418
1419static struct clk_regmap axg_vclk_div1 = {
1420	.data = &(struct clk_regmap_gate_data){
1421		.offset = HHI_VID_CLK_CNTL,
1422		.bit_idx = 0,
1423	},
1424	.hw.init = &(struct clk_init_data) {
1425		.name = "vclk_div1",
1426		.ops = &clk_regmap_gate_ops,
1427		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1428		.num_parents = 1,
1429		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1430	},
1431};
1432
1433static struct clk_regmap axg_vclk_div2_en = {
1434	.data = &(struct clk_regmap_gate_data){
1435		.offset = HHI_VID_CLK_CNTL,
1436		.bit_idx = 1,
1437	},
1438	.hw.init = &(struct clk_init_data) {
1439		.name = "vclk_div2_en",
1440		.ops = &clk_regmap_gate_ops,
1441		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1442		.num_parents = 1,
1443		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1444	},
1445};
1446
1447static struct clk_regmap axg_vclk_div4_en = {
1448	.data = &(struct clk_regmap_gate_data){
1449		.offset = HHI_VID_CLK_CNTL,
1450		.bit_idx = 2,
1451	},
1452	.hw.init = &(struct clk_init_data) {
1453		.name = "vclk_div4_en",
1454		.ops = &clk_regmap_gate_ops,
1455		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1456		.num_parents = 1,
1457		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1458	},
1459};
1460
1461static struct clk_regmap axg_vclk_div6_en = {
1462	.data = &(struct clk_regmap_gate_data){
1463		.offset = HHI_VID_CLK_CNTL,
1464		.bit_idx = 3,
1465	},
1466	.hw.init = &(struct clk_init_data) {
1467		.name = "vclk_div6_en",
1468		.ops = &clk_regmap_gate_ops,
1469		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1470		.num_parents = 1,
1471		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1472	},
1473};
1474
1475static struct clk_regmap axg_vclk_div12_en = {
1476	.data = &(struct clk_regmap_gate_data){
1477		.offset = HHI_VID_CLK_CNTL,
1478		.bit_idx = 4,
1479	},
1480	.hw.init = &(struct clk_init_data) {
1481		.name = "vclk_div12_en",
1482		.ops = &clk_regmap_gate_ops,
1483		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1484		.num_parents = 1,
1485		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1486	},
1487};
1488
1489static struct clk_regmap axg_vclk2_div1 = {
1490	.data = &(struct clk_regmap_gate_data){
1491		.offset = HHI_VIID_CLK_CNTL,
1492		.bit_idx = 0,
1493	},
1494	.hw.init = &(struct clk_init_data) {
1495		.name = "vclk2_div1",
1496		.ops = &clk_regmap_gate_ops,
1497		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1498		.num_parents = 1,
1499		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1500	},
1501};
1502
1503static struct clk_regmap axg_vclk2_div2_en = {
1504	.data = &(struct clk_regmap_gate_data){
1505		.offset = HHI_VIID_CLK_CNTL,
1506		.bit_idx = 1,
1507	},
1508	.hw.init = &(struct clk_init_data) {
1509		.name = "vclk2_div2_en",
1510		.ops = &clk_regmap_gate_ops,
1511		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1512		.num_parents = 1,
1513		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1514	},
1515};
1516
1517static struct clk_regmap axg_vclk2_div4_en = {
1518	.data = &(struct clk_regmap_gate_data){
1519		.offset = HHI_VIID_CLK_CNTL,
1520		.bit_idx = 2,
1521	},
1522	.hw.init = &(struct clk_init_data) {
1523		.name = "vclk2_div4_en",
1524		.ops = &clk_regmap_gate_ops,
1525		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1526		.num_parents = 1,
1527		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1528	},
1529};
1530
1531static struct clk_regmap axg_vclk2_div6_en = {
1532	.data = &(struct clk_regmap_gate_data){
1533		.offset = HHI_VIID_CLK_CNTL,
1534		.bit_idx = 3,
1535	},
1536	.hw.init = &(struct clk_init_data) {
1537		.name = "vclk2_div6_en",
1538		.ops = &clk_regmap_gate_ops,
1539		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1540		.num_parents = 1,
1541		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1542	},
1543};
1544
1545static struct clk_regmap axg_vclk2_div12_en = {
1546	.data = &(struct clk_regmap_gate_data){
1547		.offset = HHI_VIID_CLK_CNTL,
1548		.bit_idx = 4,
1549	},
1550	.hw.init = &(struct clk_init_data) {
1551		.name = "vclk2_div12_en",
1552		.ops = &clk_regmap_gate_ops,
1553		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1554		.num_parents = 1,
1555		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1556	},
1557};
1558
1559static struct clk_fixed_factor axg_vclk_div2 = {
1560	.mult = 1,
1561	.div = 2,
1562	.hw.init = &(struct clk_init_data){
1563		.name = "vclk_div2",
1564		.ops = &clk_fixed_factor_ops,
1565		.parent_hws = (const struct clk_hw *[]) {
1566			&axg_vclk_div2_en.hw
1567		},
1568		.num_parents = 1,
1569	},
1570};
1571
1572static struct clk_fixed_factor axg_vclk_div4 = {
1573	.mult = 1,
1574	.div = 4,
1575	.hw.init = &(struct clk_init_data){
1576		.name = "vclk_div4",
1577		.ops = &clk_fixed_factor_ops,
1578		.parent_hws = (const struct clk_hw *[]) {
1579			&axg_vclk_div4_en.hw
1580		},
1581		.num_parents = 1,
1582	},
1583};
1584
1585static struct clk_fixed_factor axg_vclk_div6 = {
1586	.mult = 1,
1587	.div = 6,
1588	.hw.init = &(struct clk_init_data){
1589		.name = "vclk_div6",
1590		.ops = &clk_fixed_factor_ops,
1591		.parent_hws = (const struct clk_hw *[]) {
1592			&axg_vclk_div6_en.hw
1593		},
1594		.num_parents = 1,
1595	},
1596};
1597
1598static struct clk_fixed_factor axg_vclk_div12 = {
1599	.mult = 1,
1600	.div = 12,
1601	.hw.init = &(struct clk_init_data){
1602		.name = "vclk_div12",
1603		.ops = &clk_fixed_factor_ops,
1604		.parent_hws = (const struct clk_hw *[]) {
1605			&axg_vclk_div12_en.hw
1606		},
1607		.num_parents = 1,
1608	},
1609};
1610
1611static struct clk_fixed_factor axg_vclk2_div2 = {
1612	.mult = 1,
1613	.div = 2,
1614	.hw.init = &(struct clk_init_data){
1615		.name = "vclk2_div2",
1616		.ops = &clk_fixed_factor_ops,
1617		.parent_hws = (const struct clk_hw *[]) {
1618			&axg_vclk2_div2_en.hw
1619		},
1620		.num_parents = 1,
1621	},
1622};
1623
1624static struct clk_fixed_factor axg_vclk2_div4 = {
1625	.mult = 1,
1626	.div = 4,
1627	.hw.init = &(struct clk_init_data){
1628		.name = "vclk2_div4",
1629		.ops = &clk_fixed_factor_ops,
1630		.parent_hws = (const struct clk_hw *[]) {
1631			&axg_vclk2_div4_en.hw
1632		},
1633		.num_parents = 1,
1634	},
1635};
1636
1637static struct clk_fixed_factor axg_vclk2_div6 = {
1638	.mult = 1,
1639	.div = 6,
1640	.hw.init = &(struct clk_init_data){
1641		.name = "vclk2_div6",
1642		.ops = &clk_fixed_factor_ops,
1643		.parent_hws = (const struct clk_hw *[]) {
1644			&axg_vclk2_div6_en.hw
1645		},
1646		.num_parents = 1,
1647	},
1648};
1649
1650static struct clk_fixed_factor axg_vclk2_div12 = {
1651	.mult = 1,
1652	.div = 12,
1653	.hw.init = &(struct clk_init_data){
1654		.name = "vclk2_div12",
1655		.ops = &clk_fixed_factor_ops,
1656		.parent_hws = (const struct clk_hw *[]) {
1657			&axg_vclk2_div12_en.hw
1658		},
1659		.num_parents = 1,
1660	},
1661};
1662
1663static u32 mux_table_cts_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
1664static const struct clk_hw *axg_cts_parent_hws[] = {
1665	&axg_vclk_div1.hw,
1666	&axg_vclk_div2.hw,
1667	&axg_vclk_div4.hw,
1668	&axg_vclk_div6.hw,
1669	&axg_vclk_div12.hw,
1670	&axg_vclk2_div1.hw,
1671	&axg_vclk2_div2.hw,
1672	&axg_vclk2_div4.hw,
1673	&axg_vclk2_div6.hw,
1674	&axg_vclk2_div12.hw,
1675};
1676
1677static struct clk_regmap axg_cts_encl_sel = {
1678	.data = &(struct clk_regmap_mux_data){
1679		.offset = HHI_VIID_CLK_DIV,
1680		.mask = 0xf,
1681		.shift = 12,
1682		.table = mux_table_cts_sel,
1683	},
1684	.hw.init = &(struct clk_init_data){
1685		.name = "cts_encl_sel",
1686		.ops = &clk_regmap_mux_ops,
1687		.parent_hws = axg_cts_parent_hws,
1688		.num_parents = ARRAY_SIZE(axg_cts_parent_hws),
1689		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1690	},
1691};
1692
1693static struct clk_regmap axg_cts_encl = {
1694	.data = &(struct clk_regmap_gate_data){
1695		.offset = HHI_VID_CLK_CNTL2,
1696		.bit_idx = 3,
1697	},
1698	.hw.init = &(struct clk_init_data) {
1699		.name = "cts_encl",
1700		.ops = &clk_regmap_gate_ops,
1701		.parent_hws = (const struct clk_hw *[]) {
1702			&axg_cts_encl_sel.hw
1703		},
1704		.num_parents = 1,
1705		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1706	},
1707};
1708
1709/* MIPI DSI Host Clock */
1710
1711static u32 mux_table_axg_vdin_meas[]    = { 0, 1, 2, 3, 6, 7 };
1712static const struct clk_parent_data axg_vdin_meas_parent_data[] = {
1713	{ .fw_name = "xtal", },
1714	{ .hw = &axg_fclk_div4.hw },
1715	{ .hw = &axg_fclk_div3.hw },
1716	{ .hw = &axg_fclk_div5.hw },
1717	{ .hw = &axg_fclk_div2.hw },
1718	{ .hw = &axg_fclk_div7.hw },
1719};
1720
1721static struct clk_regmap axg_vdin_meas_sel = {
1722	.data = &(struct clk_regmap_mux_data){
1723		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1724		.mask = 0x7,
1725		.shift = 21,
1726		.flags = CLK_MUX_ROUND_CLOSEST,
1727		.table = mux_table_axg_vdin_meas,
1728	},
1729	.hw.init = &(struct clk_init_data){
1730		.name = "vdin_meas_sel",
1731		.ops = &clk_regmap_mux_ops,
1732		.parent_data = axg_vdin_meas_parent_data,
1733		.num_parents = ARRAY_SIZE(axg_vdin_meas_parent_data),
1734		.flags = CLK_SET_RATE_PARENT,
1735	},
1736};
1737
1738static struct clk_regmap axg_vdin_meas_div = {
1739	.data = &(struct clk_regmap_div_data){
1740		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1741		.shift = 12,
1742		.width = 7,
1743	},
1744	.hw.init = &(struct clk_init_data){
1745		.name = "vdin_meas_div",
1746		.ops = &clk_regmap_divider_ops,
1747		.parent_hws = (const struct clk_hw *[]) {
1748			&axg_vdin_meas_sel.hw },
1749		.num_parents = 1,
1750		.flags = CLK_SET_RATE_PARENT,
1751	},
1752};
1753
1754static struct clk_regmap axg_vdin_meas = {
1755	.data = &(struct clk_regmap_gate_data){
1756		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1757		.bit_idx = 20,
1758	},
1759	.hw.init = &(struct clk_init_data) {
1760		.name = "vdin_meas",
1761		.ops = &clk_regmap_gate_ops,
1762		.parent_hws = (const struct clk_hw *[]) {
1763			&axg_vdin_meas_div.hw },
1764		.num_parents = 1,
1765		.flags = CLK_SET_RATE_PARENT,
1766	},
1767};
1768
1769static u32 mux_table_gen_clk[]	= { 0, 4, 5, 6, 7, 8,
1770				    9, 10, 11, 13, 14, };
1771static const struct clk_parent_data gen_clk_parent_data[] = {
1772	{ .fw_name = "xtal", },
1773	{ .hw = &axg_hifi_pll.hw },
1774	{ .hw = &axg_mpll0.hw },
1775	{ .hw = &axg_mpll1.hw },
1776	{ .hw = &axg_mpll2.hw },
1777	{ .hw = &axg_mpll3.hw },
1778	{ .hw = &axg_fclk_div4.hw },
1779	{ .hw = &axg_fclk_div3.hw },
1780	{ .hw = &axg_fclk_div5.hw },
1781	{ .hw = &axg_fclk_div7.hw },
1782	{ .hw = &axg_gp0_pll.hw },
1783};
1784
1785static struct clk_regmap axg_gen_clk_sel = {
1786	.data = &(struct clk_regmap_mux_data){
1787		.offset = HHI_GEN_CLK_CNTL,
1788		.mask = 0xf,
1789		.shift = 12,
1790		.table = mux_table_gen_clk,
1791	},
1792	.hw.init = &(struct clk_init_data){
1793		.name = "gen_clk_sel",
1794		.ops = &clk_regmap_mux_ops,
1795		/*
1796		 * bits 15:12 selects from 14 possible parents:
1797		 * xtal, [rtc_oscin_i], [sys_cpu_div16], [ddr_dpll_pt],
1798		 * hifi_pll, mpll0, mpll1, mpll2, mpll3, fdiv4,
1799		 * fdiv3, fdiv5, [cts_msr_clk], fdiv7, gp0_pll
1800		 */
1801		.parent_data = gen_clk_parent_data,
1802		.num_parents = ARRAY_SIZE(gen_clk_parent_data),
1803	},
1804};
1805
1806static struct clk_regmap axg_gen_clk_div = {
1807	.data = &(struct clk_regmap_div_data){
1808		.offset = HHI_GEN_CLK_CNTL,
1809		.shift = 0,
1810		.width = 11,
1811	},
1812	.hw.init = &(struct clk_init_data){
1813		.name = "gen_clk_div",
1814		.ops = &clk_regmap_divider_ops,
1815		.parent_hws = (const struct clk_hw *[]) {
1816			&axg_gen_clk_sel.hw
1817		},
1818		.num_parents = 1,
1819		.flags = CLK_SET_RATE_PARENT,
1820	},
1821};
1822
1823static struct clk_regmap axg_gen_clk = {
1824	.data = &(struct clk_regmap_gate_data){
1825		.offset = HHI_GEN_CLK_CNTL,
1826		.bit_idx = 7,
1827	},
1828	.hw.init = &(struct clk_init_data){
1829		.name = "gen_clk",
1830		.ops = &clk_regmap_gate_ops,
1831		.parent_hws = (const struct clk_hw *[]) {
1832			&axg_gen_clk_div.hw
1833		},
1834		.num_parents = 1,
1835		.flags = CLK_SET_RATE_PARENT,
1836	},
1837};
1838
1839#define MESON_GATE(_name, _reg, _bit) \
1840	MESON_PCLK(_name, _reg, _bit, &axg_clk81.hw)
1841
1842/* Everything Else (EE) domain gates */
1843static MESON_GATE(axg_ddr, HHI_GCLK_MPEG0, 0);
1844static MESON_GATE(axg_audio_locker, HHI_GCLK_MPEG0, 2);
1845static MESON_GATE(axg_mipi_dsi_host, HHI_GCLK_MPEG0, 3);
1846static MESON_GATE(axg_isa, HHI_GCLK_MPEG0, 5);
1847static MESON_GATE(axg_pl301, HHI_GCLK_MPEG0, 6);
1848static MESON_GATE(axg_periphs, HHI_GCLK_MPEG0, 7);
1849static MESON_GATE(axg_spicc_0, HHI_GCLK_MPEG0, 8);
1850static MESON_GATE(axg_i2c, HHI_GCLK_MPEG0, 9);
1851static MESON_GATE(axg_rng0, HHI_GCLK_MPEG0, 12);
1852static MESON_GATE(axg_uart0, HHI_GCLK_MPEG0, 13);
1853static MESON_GATE(axg_mipi_dsi_phy, HHI_GCLK_MPEG0, 14);
1854static MESON_GATE(axg_spicc_1, HHI_GCLK_MPEG0, 15);
1855static MESON_GATE(axg_pcie_a, HHI_GCLK_MPEG0, 16);
1856static MESON_GATE(axg_pcie_b, HHI_GCLK_MPEG0, 17);
1857static MESON_GATE(axg_hiu_reg, HHI_GCLK_MPEG0, 19);
1858static MESON_GATE(axg_assist_misc, HHI_GCLK_MPEG0, 23);
1859static MESON_GATE(axg_emmc_b, HHI_GCLK_MPEG0, 25);
1860static MESON_GATE(axg_emmc_c, HHI_GCLK_MPEG0, 26);
1861static MESON_GATE(axg_dma, HHI_GCLK_MPEG0, 27);
1862static MESON_GATE(axg_spi, HHI_GCLK_MPEG0, 30);
1863
1864static MESON_GATE(axg_audio, HHI_GCLK_MPEG1, 0);
1865static MESON_GATE(axg_eth_core, HHI_GCLK_MPEG1, 3);
1866static MESON_GATE(axg_uart1, HHI_GCLK_MPEG1, 16);
1867static MESON_GATE(axg_g2d, HHI_GCLK_MPEG1, 20);
1868static MESON_GATE(axg_usb0, HHI_GCLK_MPEG1, 21);
1869static MESON_GATE(axg_usb1, HHI_GCLK_MPEG1, 22);
1870static MESON_GATE(axg_reset, HHI_GCLK_MPEG1, 23);
1871static MESON_GATE(axg_usb_general, HHI_GCLK_MPEG1, 26);
1872static MESON_GATE(axg_ahb_arb0, HHI_GCLK_MPEG1, 29);
1873static MESON_GATE(axg_efuse, HHI_GCLK_MPEG1, 30);
1874static MESON_GATE(axg_boot_rom, HHI_GCLK_MPEG1, 31);
1875
1876static MESON_GATE(axg_ahb_data_bus, HHI_GCLK_MPEG2, 1);
1877static MESON_GATE(axg_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
1878static MESON_GATE(axg_usb1_to_ddr, HHI_GCLK_MPEG2, 8);
1879static MESON_GATE(axg_usb0_to_ddr, HHI_GCLK_MPEG2, 9);
1880static MESON_GATE(axg_mmc_pclk, HHI_GCLK_MPEG2, 11);
1881static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25);
1882static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
1883static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30);
1884
1885/* Always On (AO) domain gates */
1886
1887static MESON_GATE(axg_ao_media_cpu, HHI_GCLK_AO, 0);
1888static MESON_GATE(axg_ao_ahb_sram, HHI_GCLK_AO, 1);
1889static MESON_GATE(axg_ao_ahb_bus, HHI_GCLK_AO, 2);
1890static MESON_GATE(axg_ao_iface, HHI_GCLK_AO, 3);
1891static MESON_GATE(axg_ao_i2c, HHI_GCLK_AO, 4);
1892
1893/* Array of all clocks provided by this provider */
1894
1895static struct clk_hw *axg_hw_clks[] = {
1896	[CLKID_SYS_PLL]			= &axg_sys_pll.hw,
1897	[CLKID_FIXED_PLL]		= &axg_fixed_pll.hw,
1898	[CLKID_FCLK_DIV2]		= &axg_fclk_div2.hw,
1899	[CLKID_FCLK_DIV3]		= &axg_fclk_div3.hw,
1900	[CLKID_FCLK_DIV4]		= &axg_fclk_div4.hw,
1901	[CLKID_FCLK_DIV5]		= &axg_fclk_div5.hw,
1902	[CLKID_FCLK_DIV7]		= &axg_fclk_div7.hw,
1903	[CLKID_GP0_PLL]			= &axg_gp0_pll.hw,
1904	[CLKID_MPEG_SEL]		= &axg_mpeg_clk_sel.hw,
1905	[CLKID_MPEG_DIV]		= &axg_mpeg_clk_div.hw,
1906	[CLKID_CLK81]			= &axg_clk81.hw,
1907	[CLKID_MPLL0]			= &axg_mpll0.hw,
1908	[CLKID_MPLL1]			= &axg_mpll1.hw,
1909	[CLKID_MPLL2]			= &axg_mpll2.hw,
1910	[CLKID_MPLL3]			= &axg_mpll3.hw,
1911	[CLKID_DDR]			= &axg_ddr.hw,
1912	[CLKID_AUDIO_LOCKER]		= &axg_audio_locker.hw,
1913	[CLKID_MIPI_DSI_HOST]		= &axg_mipi_dsi_host.hw,
1914	[CLKID_ISA]			= &axg_isa.hw,
1915	[CLKID_PL301]			= &axg_pl301.hw,
1916	[CLKID_PERIPHS]			= &axg_periphs.hw,
1917	[CLKID_SPICC0]			= &axg_spicc_0.hw,
1918	[CLKID_I2C]			= &axg_i2c.hw,
1919	[CLKID_RNG0]			= &axg_rng0.hw,
1920	[CLKID_UART0]			= &axg_uart0.hw,
1921	[CLKID_MIPI_DSI_PHY]		= &axg_mipi_dsi_phy.hw,
1922	[CLKID_SPICC1]			= &axg_spicc_1.hw,
1923	[CLKID_PCIE_A]			= &axg_pcie_a.hw,
1924	[CLKID_PCIE_B]			= &axg_pcie_b.hw,
1925	[CLKID_HIU_IFACE]		= &axg_hiu_reg.hw,
1926	[CLKID_ASSIST_MISC]		= &axg_assist_misc.hw,
1927	[CLKID_SD_EMMC_B]		= &axg_emmc_b.hw,
1928	[CLKID_SD_EMMC_C]		= &axg_emmc_c.hw,
1929	[CLKID_DMA]			= &axg_dma.hw,
1930	[CLKID_SPI]			= &axg_spi.hw,
1931	[CLKID_AUDIO]			= &axg_audio.hw,
1932	[CLKID_ETH]			= &axg_eth_core.hw,
1933	[CLKID_UART1]			= &axg_uart1.hw,
1934	[CLKID_G2D]			= &axg_g2d.hw,
1935	[CLKID_USB0]			= &axg_usb0.hw,
1936	[CLKID_USB1]			= &axg_usb1.hw,
1937	[CLKID_RESET]			= &axg_reset.hw,
1938	[CLKID_USB]			= &axg_usb_general.hw,
1939	[CLKID_AHB_ARB0]		= &axg_ahb_arb0.hw,
1940	[CLKID_EFUSE]			= &axg_efuse.hw,
1941	[CLKID_BOOT_ROM]		= &axg_boot_rom.hw,
1942	[CLKID_AHB_DATA_BUS]		= &axg_ahb_data_bus.hw,
1943	[CLKID_AHB_CTRL_BUS]		= &axg_ahb_ctrl_bus.hw,
1944	[CLKID_USB1_DDR_BRIDGE]		= &axg_usb1_to_ddr.hw,
1945	[CLKID_USB0_DDR_BRIDGE]		= &axg_usb0_to_ddr.hw,
1946	[CLKID_MMC_PCLK]		= &axg_mmc_pclk.hw,
1947	[CLKID_VPU_INTR]		= &axg_vpu_intr.hw,
1948	[CLKID_SEC_AHB_AHB3_BRIDGE]	= &axg_sec_ahb_ahb3_bridge.hw,
1949	[CLKID_GIC]			= &axg_gic.hw,
1950	[CLKID_AO_MEDIA_CPU]		= &axg_ao_media_cpu.hw,
1951	[CLKID_AO_AHB_SRAM]		= &axg_ao_ahb_sram.hw,
1952	[CLKID_AO_AHB_BUS]		= &axg_ao_ahb_bus.hw,
1953	[CLKID_AO_IFACE]		= &axg_ao_iface.hw,
1954	[CLKID_AO_I2C]			= &axg_ao_i2c.hw,
1955	[CLKID_SD_EMMC_B_CLK0_SEL]	= &axg_sd_emmc_b_clk0_sel.hw,
1956	[CLKID_SD_EMMC_B_CLK0_DIV]	= &axg_sd_emmc_b_clk0_div.hw,
1957	[CLKID_SD_EMMC_B_CLK0]		= &axg_sd_emmc_b_clk0.hw,
1958	[CLKID_SD_EMMC_C_CLK0_SEL]	= &axg_sd_emmc_c_clk0_sel.hw,
1959	[CLKID_SD_EMMC_C_CLK0_DIV]	= &axg_sd_emmc_c_clk0_div.hw,
1960	[CLKID_SD_EMMC_C_CLK0]		= &axg_sd_emmc_c_clk0.hw,
1961	[CLKID_MPLL0_DIV]		= &axg_mpll0_div.hw,
1962	[CLKID_MPLL1_DIV]		= &axg_mpll1_div.hw,
1963	[CLKID_MPLL2_DIV]		= &axg_mpll2_div.hw,
1964	[CLKID_MPLL3_DIV]		= &axg_mpll3_div.hw,
1965	[CLKID_HIFI_PLL]		= &axg_hifi_pll.hw,
1966	[CLKID_MPLL_PREDIV]		= &axg_mpll_prediv.hw,
1967	[CLKID_FCLK_DIV2_DIV]		= &axg_fclk_div2_div.hw,
1968	[CLKID_FCLK_DIV3_DIV]		= &axg_fclk_div3_div.hw,
1969	[CLKID_FCLK_DIV4_DIV]		= &axg_fclk_div4_div.hw,
1970	[CLKID_FCLK_DIV5_DIV]		= &axg_fclk_div5_div.hw,
1971	[CLKID_FCLK_DIV7_DIV]		= &axg_fclk_div7_div.hw,
1972	[CLKID_PCIE_PLL]		= &axg_pcie_pll.hw,
1973	[CLKID_PCIE_MUX]		= &axg_pcie_mux.hw,
1974	[CLKID_PCIE_REF]		= &axg_pcie_ref.hw,
1975	[CLKID_PCIE_CML_EN0]		= &axg_pcie_cml_en0.hw,
1976	[CLKID_PCIE_CML_EN1]		= &axg_pcie_cml_en1.hw,
1977	[CLKID_GEN_CLK_SEL]		= &axg_gen_clk_sel.hw,
1978	[CLKID_GEN_CLK_DIV]		= &axg_gen_clk_div.hw,
1979	[CLKID_GEN_CLK]			= &axg_gen_clk.hw,
1980	[CLKID_SYS_PLL_DCO]		= &axg_sys_pll_dco.hw,
1981	[CLKID_FIXED_PLL_DCO]		= &axg_fixed_pll_dco.hw,
1982	[CLKID_GP0_PLL_DCO]		= &axg_gp0_pll_dco.hw,
1983	[CLKID_HIFI_PLL_DCO]		= &axg_hifi_pll_dco.hw,
1984	[CLKID_PCIE_PLL_DCO]		= &axg_pcie_pll_dco.hw,
1985	[CLKID_PCIE_PLL_OD]		= &axg_pcie_pll_od.hw,
1986	[CLKID_VPU_0_DIV]		= &axg_vpu_0_div.hw,
1987	[CLKID_VPU_0_SEL]		= &axg_vpu_0_sel.hw,
1988	[CLKID_VPU_0]			= &axg_vpu_0.hw,
1989	[CLKID_VPU_1_DIV]		= &axg_vpu_1_div.hw,
1990	[CLKID_VPU_1_SEL]		= &axg_vpu_1_sel.hw,
1991	[CLKID_VPU_1]			= &axg_vpu_1.hw,
1992	[CLKID_VPU]			= &axg_vpu.hw,
1993	[CLKID_VAPB_0_DIV]		= &axg_vapb_0_div.hw,
1994	[CLKID_VAPB_0_SEL]		= &axg_vapb_0_sel.hw,
1995	[CLKID_VAPB_0]			= &axg_vapb_0.hw,
1996	[CLKID_VAPB_1_DIV]		= &axg_vapb_1_div.hw,
1997	[CLKID_VAPB_1_SEL]		= &axg_vapb_1_sel.hw,
1998	[CLKID_VAPB_1]			= &axg_vapb_1.hw,
1999	[CLKID_VAPB_SEL]		= &axg_vapb_sel.hw,
2000	[CLKID_VAPB]			= &axg_vapb.hw,
2001	[CLKID_VCLK]			= &axg_vclk.hw,
2002	[CLKID_VCLK2]			= &axg_vclk2.hw,
2003	[CLKID_VCLK_SEL]		= &axg_vclk_sel.hw,
2004	[CLKID_VCLK2_SEL]		= &axg_vclk2_sel.hw,
2005	[CLKID_VCLK_INPUT]		= &axg_vclk_input.hw,
2006	[CLKID_VCLK2_INPUT]		= &axg_vclk2_input.hw,
2007	[CLKID_VCLK_DIV]		= &axg_vclk_div.hw,
2008	[CLKID_VCLK2_DIV]		= &axg_vclk2_div.hw,
2009	[CLKID_VCLK_DIV2_EN]		= &axg_vclk_div2_en.hw,
2010	[CLKID_VCLK_DIV4_EN]		= &axg_vclk_div4_en.hw,
2011	[CLKID_VCLK_DIV6_EN]		= &axg_vclk_div6_en.hw,
2012	[CLKID_VCLK_DIV12_EN]		= &axg_vclk_div12_en.hw,
2013	[CLKID_VCLK2_DIV2_EN]		= &axg_vclk2_div2_en.hw,
2014	[CLKID_VCLK2_DIV4_EN]		= &axg_vclk2_div4_en.hw,
2015	[CLKID_VCLK2_DIV6_EN]		= &axg_vclk2_div6_en.hw,
2016	[CLKID_VCLK2_DIV12_EN]		= &axg_vclk2_div12_en.hw,
2017	[CLKID_VCLK_DIV1]		= &axg_vclk_div1.hw,
2018	[CLKID_VCLK_DIV2]		= &axg_vclk_div2.hw,
2019	[CLKID_VCLK_DIV4]		= &axg_vclk_div4.hw,
2020	[CLKID_VCLK_DIV6]		= &axg_vclk_div6.hw,
2021	[CLKID_VCLK_DIV12]		= &axg_vclk_div12.hw,
2022	[CLKID_VCLK2_DIV1]		= &axg_vclk2_div1.hw,
2023	[CLKID_VCLK2_DIV2]		= &axg_vclk2_div2.hw,
2024	[CLKID_VCLK2_DIV4]		= &axg_vclk2_div4.hw,
2025	[CLKID_VCLK2_DIV6]		= &axg_vclk2_div6.hw,
2026	[CLKID_VCLK2_DIV12]		= &axg_vclk2_div12.hw,
2027	[CLKID_CTS_ENCL_SEL]		= &axg_cts_encl_sel.hw,
2028	[CLKID_CTS_ENCL]		= &axg_cts_encl.hw,
2029	[CLKID_VDIN_MEAS_SEL]		= &axg_vdin_meas_sel.hw,
2030	[CLKID_VDIN_MEAS_DIV]		= &axg_vdin_meas_div.hw,
2031	[CLKID_VDIN_MEAS]		= &axg_vdin_meas.hw,
 
 
 
 
2032};
2033
2034/* Convenience table to populate regmap in .probe */
2035static struct clk_regmap *const axg_clk_regmaps[] = {
2036	&axg_clk81,
2037	&axg_ddr,
2038	&axg_audio_locker,
2039	&axg_mipi_dsi_host,
2040	&axg_isa,
2041	&axg_pl301,
2042	&axg_periphs,
2043	&axg_spicc_0,
2044	&axg_i2c,
2045	&axg_rng0,
2046	&axg_uart0,
2047	&axg_mipi_dsi_phy,
2048	&axg_spicc_1,
2049	&axg_pcie_a,
2050	&axg_pcie_b,
2051	&axg_hiu_reg,
2052	&axg_assist_misc,
2053	&axg_emmc_b,
2054	&axg_emmc_c,
2055	&axg_dma,
2056	&axg_spi,
2057	&axg_audio,
2058	&axg_eth_core,
2059	&axg_uart1,
2060	&axg_g2d,
2061	&axg_usb0,
2062	&axg_usb1,
2063	&axg_reset,
2064	&axg_usb_general,
2065	&axg_ahb_arb0,
2066	&axg_efuse,
2067	&axg_boot_rom,
2068	&axg_ahb_data_bus,
2069	&axg_ahb_ctrl_bus,
2070	&axg_usb1_to_ddr,
2071	&axg_usb0_to_ddr,
2072	&axg_mmc_pclk,
2073	&axg_vpu_intr,
2074	&axg_sec_ahb_ahb3_bridge,
2075	&axg_gic,
2076	&axg_ao_media_cpu,
2077	&axg_ao_ahb_sram,
2078	&axg_ao_ahb_bus,
2079	&axg_ao_iface,
2080	&axg_ao_i2c,
2081	&axg_sd_emmc_b_clk0,
2082	&axg_sd_emmc_c_clk0,
2083	&axg_mpeg_clk_div,
2084	&axg_sd_emmc_b_clk0_div,
2085	&axg_sd_emmc_c_clk0_div,
2086	&axg_mpeg_clk_sel,
2087	&axg_sd_emmc_b_clk0_sel,
2088	&axg_sd_emmc_c_clk0_sel,
2089	&axg_mpll0,
2090	&axg_mpll1,
2091	&axg_mpll2,
2092	&axg_mpll3,
2093	&axg_mpll0_div,
2094	&axg_mpll1_div,
2095	&axg_mpll2_div,
2096	&axg_mpll3_div,
2097	&axg_fixed_pll,
2098	&axg_sys_pll,
2099	&axg_gp0_pll,
2100	&axg_hifi_pll,
2101	&axg_mpll_prediv,
2102	&axg_fclk_div2,
2103	&axg_fclk_div3,
2104	&axg_fclk_div4,
2105	&axg_fclk_div5,
2106	&axg_fclk_div7,
2107	&axg_pcie_pll_dco,
2108	&axg_pcie_pll_od,
2109	&axg_pcie_pll,
2110	&axg_pcie_mux,
2111	&axg_pcie_ref,
2112	&axg_pcie_cml_en0,
2113	&axg_pcie_cml_en1,
2114	&axg_gen_clk_sel,
2115	&axg_gen_clk_div,
2116	&axg_gen_clk,
2117	&axg_fixed_pll_dco,
2118	&axg_sys_pll_dco,
2119	&axg_gp0_pll_dco,
2120	&axg_hifi_pll_dco,
2121	&axg_pcie_pll_dco,
2122	&axg_pcie_pll_od,
2123	&axg_vpu_0_div,
2124	&axg_vpu_0_sel,
2125	&axg_vpu_0,
2126	&axg_vpu_1_div,
2127	&axg_vpu_1_sel,
2128	&axg_vpu_1,
2129	&axg_vpu,
2130	&axg_vapb_0_div,
2131	&axg_vapb_0_sel,
2132	&axg_vapb_0,
2133	&axg_vapb_1_div,
2134	&axg_vapb_1_sel,
2135	&axg_vapb_1,
2136	&axg_vapb_sel,
2137	&axg_vapb,
2138	&axg_vclk,
2139	&axg_vclk2,
2140	&axg_vclk_sel,
2141	&axg_vclk2_sel,
2142	&axg_vclk_input,
2143	&axg_vclk2_input,
2144	&axg_vclk_div,
2145	&axg_vclk2_div,
2146	&axg_vclk_div2_en,
2147	&axg_vclk_div4_en,
2148	&axg_vclk_div6_en,
2149	&axg_vclk_div12_en,
2150	&axg_vclk2_div2_en,
2151	&axg_vclk2_div4_en,
2152	&axg_vclk2_div6_en,
2153	&axg_vclk2_div12_en,
2154	&axg_cts_encl_sel,
2155	&axg_cts_encl,
2156	&axg_vdin_meas_sel,
2157	&axg_vdin_meas_div,
2158	&axg_vdin_meas,
2159};
2160
2161static const struct meson_eeclkc_data axg_clkc_data = {
2162	.regmap_clks = axg_clk_regmaps,
2163	.regmap_clk_num = ARRAY_SIZE(axg_clk_regmaps),
2164	.hw_clks = {
2165		.hws = axg_hw_clks,
2166		.num = ARRAY_SIZE(axg_hw_clks),
2167	},
2168};
2169
2170
2171static const struct of_device_id clkc_match_table[] = {
2172	{ .compatible = "amlogic,axg-clkc", .data = &axg_clkc_data },
2173	{}
2174};
2175MODULE_DEVICE_TABLE(of, clkc_match_table);
2176
2177static struct platform_driver axg_driver = {
2178	.probe		= meson_eeclkc_probe,
2179	.driver		= {
2180		.name	= "axg-clkc",
2181		.of_match_table = clkc_match_table,
2182	},
2183};
2184
2185module_platform_driver(axg_driver);
2186MODULE_LICENSE("GPL v2");
v6.2
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * AmLogic Meson-AXG Clock Controller Driver
   4 *
   5 * Copyright (c) 2016 Baylibre SAS.
   6 * Author: Michael Turquette <mturquette@baylibre.com>
   7 *
   8 * Copyright (c) 2017 Amlogic, inc.
   9 * Author: Qiufang Dai <qiufang.dai@amlogic.com>
  10 */
  11
  12#include <linux/clk-provider.h>
  13#include <linux/init.h>
  14#include <linux/of_device.h>
  15#include <linux/platform_device.h>
  16#include <linux/module.h>
  17
  18#include "clk-regmap.h"
  19#include "clk-pll.h"
  20#include "clk-mpll.h"
  21#include "axg.h"
  22#include "meson-eeclk.h"
  23
 
 
  24static DEFINE_SPINLOCK(meson_clk_lock);
  25
  26static struct clk_regmap axg_fixed_pll_dco = {
  27	.data = &(struct meson_clk_pll_data){
  28		.en = {
  29			.reg_off = HHI_MPLL_CNTL,
  30			.shift   = 30,
  31			.width   = 1,
  32		},
  33		.m = {
  34			.reg_off = HHI_MPLL_CNTL,
  35			.shift   = 0,
  36			.width   = 9,
  37		},
  38		.n = {
  39			.reg_off = HHI_MPLL_CNTL,
  40			.shift   = 9,
  41			.width   = 5,
  42		},
  43		.frac = {
  44			.reg_off = HHI_MPLL_CNTL2,
  45			.shift   = 0,
  46			.width   = 12,
  47		},
  48		.l = {
  49			.reg_off = HHI_MPLL_CNTL,
  50			.shift   = 31,
  51			.width   = 1,
  52		},
  53		.rst = {
  54			.reg_off = HHI_MPLL_CNTL,
  55			.shift   = 29,
  56			.width   = 1,
  57		},
  58	},
  59	.hw.init = &(struct clk_init_data){
  60		.name = "fixed_pll_dco",
  61		.ops = &meson_clk_pll_ro_ops,
  62		.parent_data = &(const struct clk_parent_data) {
  63			.fw_name = "xtal",
  64		},
  65		.num_parents = 1,
  66	},
  67};
  68
  69static struct clk_regmap axg_fixed_pll = {
  70	.data = &(struct clk_regmap_div_data){
  71		.offset = HHI_MPLL_CNTL,
  72		.shift = 16,
  73		.width = 2,
  74		.flags = CLK_DIVIDER_POWER_OF_TWO,
  75	},
  76	.hw.init = &(struct clk_init_data){
  77		.name = "fixed_pll",
  78		.ops = &clk_regmap_divider_ro_ops,
  79		.parent_hws = (const struct clk_hw *[]) {
  80			&axg_fixed_pll_dco.hw
  81		},
  82		.num_parents = 1,
  83		/*
  84		 * This clock won't ever change at runtime so
  85		 * CLK_SET_RATE_PARENT is not required
  86		 */
  87	},
  88};
  89
  90static struct clk_regmap axg_sys_pll_dco = {
  91	.data = &(struct meson_clk_pll_data){
  92		.en = {
  93			.reg_off = HHI_SYS_PLL_CNTL,
  94			.shift   = 30,
  95			.width   = 1,
  96		},
  97		.m = {
  98			.reg_off = HHI_SYS_PLL_CNTL,
  99			.shift   = 0,
 100			.width   = 9,
 101		},
 102		.n = {
 103			.reg_off = HHI_SYS_PLL_CNTL,
 104			.shift   = 9,
 105			.width   = 5,
 106		},
 107		.l = {
 108			.reg_off = HHI_SYS_PLL_CNTL,
 109			.shift   = 31,
 110			.width   = 1,
 111		},
 112		.rst = {
 113			.reg_off = HHI_SYS_PLL_CNTL,
 114			.shift   = 29,
 115			.width   = 1,
 116		},
 117	},
 118	.hw.init = &(struct clk_init_data){
 119		.name = "sys_pll_dco",
 120		.ops = &meson_clk_pll_ro_ops,
 121		.parent_data = &(const struct clk_parent_data) {
 122			.fw_name = "xtal",
 123		},
 124		.num_parents = 1,
 125	},
 126};
 127
 128static struct clk_regmap axg_sys_pll = {
 129	.data = &(struct clk_regmap_div_data){
 130		.offset = HHI_SYS_PLL_CNTL,
 131		.shift = 16,
 132		.width = 2,
 133		.flags = CLK_DIVIDER_POWER_OF_TWO,
 134	},
 135	.hw.init = &(struct clk_init_data){
 136		.name = "sys_pll",
 137		.ops = &clk_regmap_divider_ro_ops,
 138		.parent_hws = (const struct clk_hw *[]) {
 139			&axg_sys_pll_dco.hw
 140		},
 141		.num_parents = 1,
 142		.flags = CLK_SET_RATE_PARENT,
 143	},
 144};
 145
 146static const struct pll_params_table axg_gp0_pll_params_table[] = {
 147	PLL_PARAMS(40, 1),
 148	PLL_PARAMS(41, 1),
 149	PLL_PARAMS(42, 1),
 150	PLL_PARAMS(43, 1),
 151	PLL_PARAMS(44, 1),
 152	PLL_PARAMS(45, 1),
 153	PLL_PARAMS(46, 1),
 154	PLL_PARAMS(47, 1),
 155	PLL_PARAMS(48, 1),
 156	PLL_PARAMS(49, 1),
 157	PLL_PARAMS(50, 1),
 158	PLL_PARAMS(51, 1),
 159	PLL_PARAMS(52, 1),
 160	PLL_PARAMS(53, 1),
 161	PLL_PARAMS(54, 1),
 162	PLL_PARAMS(55, 1),
 163	PLL_PARAMS(56, 1),
 164	PLL_PARAMS(57, 1),
 165	PLL_PARAMS(58, 1),
 166	PLL_PARAMS(59, 1),
 167	PLL_PARAMS(60, 1),
 168	PLL_PARAMS(61, 1),
 169	PLL_PARAMS(62, 1),
 170	PLL_PARAMS(63, 1),
 171	PLL_PARAMS(64, 1),
 172	PLL_PARAMS(65, 1),
 173	PLL_PARAMS(66, 1),
 174	PLL_PARAMS(67, 1),
 175	PLL_PARAMS(68, 1),
 176	{ /* sentinel */ },
 177};
 178
 179static const struct reg_sequence axg_gp0_init_regs[] = {
 180	{ .reg = HHI_GP0_PLL_CNTL1,	.def = 0xc084b000 },
 181	{ .reg = HHI_GP0_PLL_CNTL2,	.def = 0xb75020be },
 182	{ .reg = HHI_GP0_PLL_CNTL3,	.def = 0x0a59a288 },
 183	{ .reg = HHI_GP0_PLL_CNTL4,	.def = 0xc000004d },
 184	{ .reg = HHI_GP0_PLL_CNTL5,	.def = 0x00078000 },
 185};
 186
 187static struct clk_regmap axg_gp0_pll_dco = {
 188	.data = &(struct meson_clk_pll_data){
 189		.en = {
 190			.reg_off = HHI_GP0_PLL_CNTL,
 191			.shift   = 30,
 192			.width   = 1,
 193		},
 194		.m = {
 195			.reg_off = HHI_GP0_PLL_CNTL,
 196			.shift   = 0,
 197			.width   = 9,
 198		},
 199		.n = {
 200			.reg_off = HHI_GP0_PLL_CNTL,
 201			.shift   = 9,
 202			.width   = 5,
 203		},
 204		.frac = {
 205			.reg_off = HHI_GP0_PLL_CNTL1,
 206			.shift   = 0,
 207			.width   = 10,
 208		},
 209		.l = {
 210			.reg_off = HHI_GP0_PLL_CNTL,
 211			.shift   = 31,
 212			.width   = 1,
 213		},
 214		.rst = {
 215			.reg_off = HHI_GP0_PLL_CNTL,
 216			.shift   = 29,
 217			.width   = 1,
 218		},
 219		.table = axg_gp0_pll_params_table,
 220		.init_regs = axg_gp0_init_regs,
 221		.init_count = ARRAY_SIZE(axg_gp0_init_regs),
 222	},
 223	.hw.init = &(struct clk_init_data){
 224		.name = "gp0_pll_dco",
 225		.ops = &meson_clk_pll_ops,
 226		.parent_data = &(const struct clk_parent_data) {
 227			.fw_name = "xtal",
 228		},
 229		.num_parents = 1,
 230	},
 231};
 232
 233static struct clk_regmap axg_gp0_pll = {
 234	.data = &(struct clk_regmap_div_data){
 235		.offset = HHI_GP0_PLL_CNTL,
 236		.shift = 16,
 237		.width = 2,
 238		.flags = CLK_DIVIDER_POWER_OF_TWO,
 239	},
 240	.hw.init = &(struct clk_init_data){
 241		.name = "gp0_pll",
 242		.ops = &clk_regmap_divider_ops,
 243		.parent_hws = (const struct clk_hw *[]) {
 244			&axg_gp0_pll_dco.hw
 245		},
 246		.num_parents = 1,
 247		.flags = CLK_SET_RATE_PARENT,
 248	},
 249};
 250
 251static const struct reg_sequence axg_hifi_init_regs[] = {
 252	{ .reg = HHI_HIFI_PLL_CNTL1,	.def = 0xc084b000 },
 253	{ .reg = HHI_HIFI_PLL_CNTL2,	.def = 0xb75020be },
 254	{ .reg = HHI_HIFI_PLL_CNTL3,	.def = 0x0a6a3a88 },
 255	{ .reg = HHI_HIFI_PLL_CNTL4,	.def = 0xc000004d },
 256	{ .reg = HHI_HIFI_PLL_CNTL5,	.def = 0x00058000 },
 257};
 258
 259static struct clk_regmap axg_hifi_pll_dco = {
 260	.data = &(struct meson_clk_pll_data){
 261		.en = {
 262			.reg_off = HHI_HIFI_PLL_CNTL,
 263			.shift   = 30,
 264			.width   = 1,
 265		},
 266		.m = {
 267			.reg_off = HHI_HIFI_PLL_CNTL,
 268			.shift   = 0,
 269			.width   = 9,
 270		},
 271		.n = {
 272			.reg_off = HHI_HIFI_PLL_CNTL,
 273			.shift   = 9,
 274			.width   = 5,
 275		},
 276		.frac = {
 277			.reg_off = HHI_HIFI_PLL_CNTL5,
 278			.shift   = 0,
 279			.width   = 13,
 280		},
 281		.l = {
 282			.reg_off = HHI_HIFI_PLL_CNTL,
 283			.shift   = 31,
 284			.width   = 1,
 285		},
 286		.rst = {
 287			.reg_off = HHI_HIFI_PLL_CNTL,
 288			.shift   = 29,
 289			.width   = 1,
 290		},
 291		.table = axg_gp0_pll_params_table,
 292		.init_regs = axg_hifi_init_regs,
 293		.init_count = ARRAY_SIZE(axg_hifi_init_regs),
 294		.flags = CLK_MESON_PLL_ROUND_CLOSEST,
 295	},
 296	.hw.init = &(struct clk_init_data){
 297		.name = "hifi_pll_dco",
 298		.ops = &meson_clk_pll_ops,
 299		.parent_data = &(const struct clk_parent_data) {
 300			.fw_name = "xtal",
 301		},
 302		.num_parents = 1,
 303	},
 304};
 305
 306static struct clk_regmap axg_hifi_pll = {
 307	.data = &(struct clk_regmap_div_data){
 308		.offset = HHI_HIFI_PLL_CNTL,
 309		.shift = 16,
 310		.width = 2,
 311		.flags = CLK_DIVIDER_POWER_OF_TWO,
 312	},
 313	.hw.init = &(struct clk_init_data){
 314		.name = "hifi_pll",
 315		.ops = &clk_regmap_divider_ops,
 316		.parent_hws = (const struct clk_hw *[]) {
 317			&axg_hifi_pll_dco.hw
 318		},
 319		.num_parents = 1,
 320		.flags = CLK_SET_RATE_PARENT,
 321	},
 322};
 323
 324static struct clk_fixed_factor axg_fclk_div2_div = {
 325	.mult = 1,
 326	.div = 2,
 327	.hw.init = &(struct clk_init_data){
 328		.name = "fclk_div2_div",
 329		.ops = &clk_fixed_factor_ops,
 330		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 331		.num_parents = 1,
 332	},
 333};
 334
 335static struct clk_regmap axg_fclk_div2 = {
 336	.data = &(struct clk_regmap_gate_data){
 337		.offset = HHI_MPLL_CNTL6,
 338		.bit_idx = 27,
 339	},
 340	.hw.init = &(struct clk_init_data){
 341		.name = "fclk_div2",
 342		.ops = &clk_regmap_gate_ops,
 343		.parent_hws = (const struct clk_hw *[]) {
 344			&axg_fclk_div2_div.hw
 345		},
 346		.num_parents = 1,
 347		.flags = CLK_IS_CRITICAL,
 348	},
 349};
 350
 351static struct clk_fixed_factor axg_fclk_div3_div = {
 352	.mult = 1,
 353	.div = 3,
 354	.hw.init = &(struct clk_init_data){
 355		.name = "fclk_div3_div",
 356		.ops = &clk_fixed_factor_ops,
 357		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 358		.num_parents = 1,
 359	},
 360};
 361
 362static struct clk_regmap axg_fclk_div3 = {
 363	.data = &(struct clk_regmap_gate_data){
 364		.offset = HHI_MPLL_CNTL6,
 365		.bit_idx = 28,
 366	},
 367	.hw.init = &(struct clk_init_data){
 368		.name = "fclk_div3",
 369		.ops = &clk_regmap_gate_ops,
 370		.parent_hws = (const struct clk_hw *[]) {
 371			&axg_fclk_div3_div.hw
 372		},
 373		.num_parents = 1,
 374		/*
 375		 * FIXME:
 376		 * This clock, as fdiv2, is used by the SCPI FW and is required
 377		 * by the platform to operate correctly.
 378		 * Until the following condition are met, we need this clock to
 379		 * be marked as critical:
 380		 * a) The SCPI generic driver claims and enable all the clocks
 381		 *    it needs
 382		 * b) CCF has a clock hand-off mechanism to make the sure the
 383		 *    clock stays on until the proper driver comes along
 384		 */
 385		.flags = CLK_IS_CRITICAL,
 386	},
 387};
 388
 389static struct clk_fixed_factor axg_fclk_div4_div = {
 390	.mult = 1,
 391	.div = 4,
 392	.hw.init = &(struct clk_init_data){
 393		.name = "fclk_div4_div",
 394		.ops = &clk_fixed_factor_ops,
 395		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 396		.num_parents = 1,
 397	},
 398};
 399
 400static struct clk_regmap axg_fclk_div4 = {
 401	.data = &(struct clk_regmap_gate_data){
 402		.offset = HHI_MPLL_CNTL6,
 403		.bit_idx = 29,
 404	},
 405	.hw.init = &(struct clk_init_data){
 406		.name = "fclk_div4",
 407		.ops = &clk_regmap_gate_ops,
 408		.parent_hws = (const struct clk_hw *[]) {
 409			&axg_fclk_div4_div.hw
 410		},
 411		.num_parents = 1,
 412	},
 413};
 414
 415static struct clk_fixed_factor axg_fclk_div5_div = {
 416	.mult = 1,
 417	.div = 5,
 418	.hw.init = &(struct clk_init_data){
 419		.name = "fclk_div5_div",
 420		.ops = &clk_fixed_factor_ops,
 421		.parent_hws = (const struct clk_hw *[]) { &axg_fixed_pll.hw },
 422		.num_parents = 1,
 423	},
 424};
 425
 426static struct clk_regmap axg_fclk_div5 = {
 427	.data = &(struct clk_regmap_gate_data){
 428		.offset = HHI_MPLL_CNTL6,
 429		.bit_idx = 30,
 430	},
 431	.hw.init = &(struct clk_init_data){
 432		.name = "fclk_div5",
 433		.ops = &clk_regmap_gate_ops,
 434		.parent_hws = (const struct clk_hw *[]) {
 435			&axg_fclk_div5_div.hw
 436		},
 437		.num_parents = 1,
 438	},
 439};
 440
 441static struct clk_fixed_factor axg_fclk_div7_div = {
 442	.mult = 1,
 443	.div = 7,
 444	.hw.init = &(struct clk_init_data){
 445		.name = "fclk_div7_div",
 446		.ops = &clk_fixed_factor_ops,
 447		.parent_hws = (const struct clk_hw *[]) {
 448			&axg_fixed_pll.hw
 449		},
 450		.num_parents = 1,
 451	},
 452};
 453
 454static struct clk_regmap axg_fclk_div7 = {
 455	.data = &(struct clk_regmap_gate_data){
 456		.offset = HHI_MPLL_CNTL6,
 457		.bit_idx = 31,
 458	},
 459	.hw.init = &(struct clk_init_data){
 460		.name = "fclk_div7",
 461		.ops = &clk_regmap_gate_ops,
 462		.parent_hws = (const struct clk_hw *[]) {
 463			&axg_fclk_div7_div.hw
 464		},
 465		.num_parents = 1,
 466	},
 467};
 468
 469static struct clk_regmap axg_mpll_prediv = {
 470	.data = &(struct clk_regmap_div_data){
 471		.offset = HHI_MPLL_CNTL5,
 472		.shift = 12,
 473		.width = 1,
 474	},
 475	.hw.init = &(struct clk_init_data){
 476		.name = "mpll_prediv",
 477		.ops = &clk_regmap_divider_ro_ops,
 478		.parent_hws = (const struct clk_hw *[]) {
 479			&axg_fixed_pll.hw
 480		},
 481		.num_parents = 1,
 482	},
 483};
 484
 485static struct clk_regmap axg_mpll0_div = {
 486	.data = &(struct meson_clk_mpll_data){
 487		.sdm = {
 488			.reg_off = HHI_MPLL_CNTL7,
 489			.shift   = 0,
 490			.width   = 14,
 491		},
 492		.sdm_en = {
 493			.reg_off = HHI_MPLL_CNTL7,
 494			.shift   = 15,
 495			.width	 = 1,
 496		},
 497		.n2 = {
 498			.reg_off = HHI_MPLL_CNTL7,
 499			.shift   = 16,
 500			.width   = 9,
 501		},
 502		.misc = {
 503			.reg_off = HHI_PLL_TOP_MISC,
 504			.shift   = 0,
 505			.width	 = 1,
 506		},
 507		.lock = &meson_clk_lock,
 508		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 509	},
 510	.hw.init = &(struct clk_init_data){
 511		.name = "mpll0_div",
 512		.ops = &meson_clk_mpll_ops,
 513		.parent_hws = (const struct clk_hw *[]) {
 514			&axg_mpll_prediv.hw
 515		},
 516		.num_parents = 1,
 517	},
 518};
 519
 520static struct clk_regmap axg_mpll0 = {
 521	.data = &(struct clk_regmap_gate_data){
 522		.offset = HHI_MPLL_CNTL7,
 523		.bit_idx = 14,
 524	},
 525	.hw.init = &(struct clk_init_data){
 526		.name = "mpll0",
 527		.ops = &clk_regmap_gate_ops,
 528		.parent_hws = (const struct clk_hw *[]) {
 529			&axg_mpll0_div.hw
 530		},
 531		.num_parents = 1,
 532		.flags = CLK_SET_RATE_PARENT,
 533	},
 534};
 535
 536static struct clk_regmap axg_mpll1_div = {
 537	.data = &(struct meson_clk_mpll_data){
 538		.sdm = {
 539			.reg_off = HHI_MPLL_CNTL8,
 540			.shift   = 0,
 541			.width   = 14,
 542		},
 543		.sdm_en = {
 544			.reg_off = HHI_MPLL_CNTL8,
 545			.shift   = 15,
 546			.width	 = 1,
 547		},
 548		.n2 = {
 549			.reg_off = HHI_MPLL_CNTL8,
 550			.shift   = 16,
 551			.width   = 9,
 552		},
 553		.misc = {
 554			.reg_off = HHI_PLL_TOP_MISC,
 555			.shift   = 1,
 556			.width	 = 1,
 557		},
 558		.lock = &meson_clk_lock,
 559		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 560	},
 561	.hw.init = &(struct clk_init_data){
 562		.name = "mpll1_div",
 563		.ops = &meson_clk_mpll_ops,
 564		.parent_hws = (const struct clk_hw *[]) {
 565			&axg_mpll_prediv.hw
 566		},
 567		.num_parents = 1,
 568	},
 569};
 570
 571static struct clk_regmap axg_mpll1 = {
 572	.data = &(struct clk_regmap_gate_data){
 573		.offset = HHI_MPLL_CNTL8,
 574		.bit_idx = 14,
 575	},
 576	.hw.init = &(struct clk_init_data){
 577		.name = "mpll1",
 578		.ops = &clk_regmap_gate_ops,
 579		.parent_hws = (const struct clk_hw *[]) {
 580			&axg_mpll1_div.hw
 581		},
 582		.num_parents = 1,
 583		.flags = CLK_SET_RATE_PARENT,
 584	},
 585};
 586
 587static struct clk_regmap axg_mpll2_div = {
 588	.data = &(struct meson_clk_mpll_data){
 589		.sdm = {
 590			.reg_off = HHI_MPLL_CNTL9,
 591			.shift   = 0,
 592			.width   = 14,
 593		},
 594		.sdm_en = {
 595			.reg_off = HHI_MPLL_CNTL9,
 596			.shift   = 15,
 597			.width	 = 1,
 598		},
 599		.n2 = {
 600			.reg_off = HHI_MPLL_CNTL9,
 601			.shift   = 16,
 602			.width   = 9,
 603		},
 604		.ssen = {
 605			.reg_off = HHI_MPLL_CNTL,
 606			.shift   = 25,
 607			.width	 = 1,
 608		},
 609		.misc = {
 610			.reg_off = HHI_PLL_TOP_MISC,
 611			.shift   = 2,
 612			.width	 = 1,
 613		},
 614		.lock = &meson_clk_lock,
 615		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 616	},
 617	.hw.init = &(struct clk_init_data){
 618		.name = "mpll2_div",
 619		.ops = &meson_clk_mpll_ops,
 620		.parent_hws = (const struct clk_hw *[]) {
 621			&axg_mpll_prediv.hw
 622		},
 623		.num_parents = 1,
 624	},
 625};
 626
 627static struct clk_regmap axg_mpll2 = {
 628	.data = &(struct clk_regmap_gate_data){
 629		.offset = HHI_MPLL_CNTL9,
 630		.bit_idx = 14,
 631	},
 632	.hw.init = &(struct clk_init_data){
 633		.name = "mpll2",
 634		.ops = &clk_regmap_gate_ops,
 635		.parent_hws = (const struct clk_hw *[]) {
 636			&axg_mpll2_div.hw
 637		},
 638		.num_parents = 1,
 639		.flags = CLK_SET_RATE_PARENT,
 640	},
 641};
 642
 643static struct clk_regmap axg_mpll3_div = {
 644	.data = &(struct meson_clk_mpll_data){
 645		.sdm = {
 646			.reg_off = HHI_MPLL3_CNTL0,
 647			.shift   = 12,
 648			.width   = 14,
 649		},
 650		.sdm_en = {
 651			.reg_off = HHI_MPLL3_CNTL0,
 652			.shift   = 11,
 653			.width	 = 1,
 654		},
 655		.n2 = {
 656			.reg_off = HHI_MPLL3_CNTL0,
 657			.shift   = 2,
 658			.width   = 9,
 659		},
 660		.misc = {
 661			.reg_off = HHI_PLL_TOP_MISC,
 662			.shift   = 3,
 663			.width	 = 1,
 664		},
 665		.lock = &meson_clk_lock,
 666		.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
 667	},
 668	.hw.init = &(struct clk_init_data){
 669		.name = "mpll3_div",
 670		.ops = &meson_clk_mpll_ops,
 671		.parent_hws = (const struct clk_hw *[]) {
 672			&axg_mpll_prediv.hw
 673		},
 674		.num_parents = 1,
 675	},
 676};
 677
 678static struct clk_regmap axg_mpll3 = {
 679	.data = &(struct clk_regmap_gate_data){
 680		.offset = HHI_MPLL3_CNTL0,
 681		.bit_idx = 0,
 682	},
 683	.hw.init = &(struct clk_init_data){
 684		.name = "mpll3",
 685		.ops = &clk_regmap_gate_ops,
 686		.parent_hws = (const struct clk_hw *[]) {
 687			&axg_mpll3_div.hw
 688		},
 689		.num_parents = 1,
 690		.flags = CLK_SET_RATE_PARENT,
 691	},
 692};
 693
 694static const struct pll_params_table axg_pcie_pll_params_table[] = {
 695	{
 696		.m = 200,
 697		.n = 3,
 698	},
 699	{ /* sentinel */ },
 700};
 701
 702static const struct reg_sequence axg_pcie_init_regs[] = {
 703	{ .reg = HHI_PCIE_PLL_CNTL1,	.def = 0x0084a2aa },
 704	{ .reg = HHI_PCIE_PLL_CNTL2,	.def = 0xb75020be },
 705	{ .reg = HHI_PCIE_PLL_CNTL3,	.def = 0x0a47488e },
 706	{ .reg = HHI_PCIE_PLL_CNTL4,	.def = 0xc000004d },
 707	{ .reg = HHI_PCIE_PLL_CNTL5,	.def = 0x00078000 },
 708	{ .reg = HHI_PCIE_PLL_CNTL6,	.def = 0x002323c6 },
 709	{ .reg = HHI_PCIE_PLL_CNTL,     .def = 0x400106c8 },
 710};
 711
 712static struct clk_regmap axg_pcie_pll_dco = {
 713	.data = &(struct meson_clk_pll_data){
 714		.en = {
 715			.reg_off = HHI_PCIE_PLL_CNTL,
 716			.shift   = 30,
 717			.width   = 1,
 718		},
 719		.m = {
 720			.reg_off = HHI_PCIE_PLL_CNTL,
 721			.shift   = 0,
 722			.width   = 9,
 723		},
 724		.n = {
 725			.reg_off = HHI_PCIE_PLL_CNTL,
 726			.shift   = 9,
 727			.width   = 5,
 728		},
 729		.frac = {
 730			.reg_off = HHI_PCIE_PLL_CNTL1,
 731			.shift   = 0,
 732			.width   = 12,
 733		},
 734		.l = {
 735			.reg_off = HHI_PCIE_PLL_CNTL,
 736			.shift   = 31,
 737			.width   = 1,
 738		},
 739		.rst = {
 740			.reg_off = HHI_PCIE_PLL_CNTL,
 741			.shift   = 29,
 742			.width   = 1,
 743		},
 744		.table = axg_pcie_pll_params_table,
 745		.init_regs = axg_pcie_init_regs,
 746		.init_count = ARRAY_SIZE(axg_pcie_init_regs),
 747	},
 748	.hw.init = &(struct clk_init_data){
 749		.name = "pcie_pll_dco",
 750		.ops = &meson_clk_pll_ops,
 751		.parent_data = &(const struct clk_parent_data) {
 752			.fw_name = "xtal",
 753		},
 754		.num_parents = 1,
 755	},
 756};
 757
 758static struct clk_regmap axg_pcie_pll_od = {
 759	.data = &(struct clk_regmap_div_data){
 760		.offset = HHI_PCIE_PLL_CNTL,
 761		.shift = 16,
 762		.width = 2,
 763		.flags = CLK_DIVIDER_POWER_OF_TWO,
 764	},
 765	.hw.init = &(struct clk_init_data){
 766		.name = "pcie_pll_od",
 767		.ops = &clk_regmap_divider_ops,
 768		.parent_hws = (const struct clk_hw *[]) {
 769			&axg_pcie_pll_dco.hw
 770		},
 771		.num_parents = 1,
 772		.flags = CLK_SET_RATE_PARENT,
 773	},
 774};
 775
 776static struct clk_regmap axg_pcie_pll = {
 777	.data = &(struct clk_regmap_div_data){
 778		.offset = HHI_PCIE_PLL_CNTL6,
 779		.shift = 6,
 780		.width = 2,
 781		.flags = CLK_DIVIDER_POWER_OF_TWO,
 782	},
 783	.hw.init = &(struct clk_init_data){
 784		.name = "pcie_pll",
 785		.ops = &clk_regmap_divider_ops,
 786		.parent_hws = (const struct clk_hw *[]) {
 787			&axg_pcie_pll_od.hw
 788		},
 789		.num_parents = 1,
 790		.flags = CLK_SET_RATE_PARENT,
 791	},
 792};
 793
 794static struct clk_regmap axg_pcie_mux = {
 795	.data = &(struct clk_regmap_mux_data){
 796		.offset = HHI_PCIE_PLL_CNTL6,
 797		.mask = 0x1,
 798		.shift = 2,
 799		/* skip the parent mpll3, reserved for debug */
 800		.table = (u32[]){ 1 },
 801	},
 802	.hw.init = &(struct clk_init_data){
 803		.name = "pcie_mux",
 804		.ops = &clk_regmap_mux_ops,
 805		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_pll.hw },
 806		.num_parents = 1,
 807		.flags = CLK_SET_RATE_PARENT,
 808	},
 809};
 810
 811static struct clk_regmap axg_pcie_ref = {
 812	.data = &(struct clk_regmap_mux_data){
 813		.offset = HHI_PCIE_PLL_CNTL6,
 814		.mask = 0x1,
 815		.shift = 1,
 816		/* skip the parent 0, reserved for debug */
 817		.table = (u32[]){ 1 },
 818	},
 819	.hw.init = &(struct clk_init_data){
 820		.name = "pcie_ref",
 821		.ops = &clk_regmap_mux_ops,
 822		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_mux.hw },
 823		.num_parents = 1,
 824		.flags = CLK_SET_RATE_PARENT,
 825	},
 826};
 827
 828static struct clk_regmap axg_pcie_cml_en0 = {
 829	.data = &(struct clk_regmap_gate_data){
 830		.offset = HHI_PCIE_PLL_CNTL6,
 831		.bit_idx = 4,
 832	},
 833	.hw.init = &(struct clk_init_data) {
 834		.name = "pcie_cml_en0",
 835		.ops = &clk_regmap_gate_ops,
 836		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_ref.hw },
 837		.num_parents = 1,
 838		.flags = CLK_SET_RATE_PARENT,
 839
 840	},
 841};
 842
 843static struct clk_regmap axg_pcie_cml_en1 = {
 844	.data = &(struct clk_regmap_gate_data){
 845		.offset = HHI_PCIE_PLL_CNTL6,
 846		.bit_idx = 3,
 847	},
 848	.hw.init = &(struct clk_init_data) {
 849		.name = "pcie_cml_en1",
 850		.ops = &clk_regmap_gate_ops,
 851		.parent_hws = (const struct clk_hw *[]) { &axg_pcie_ref.hw },
 852		.num_parents = 1,
 853		.flags = CLK_SET_RATE_PARENT,
 854	},
 855};
 856
 857static u32 mux_table_clk81[]	= { 0, 2, 3, 4, 5, 6, 7 };
 858static const struct clk_parent_data clk81_parent_data[] = {
 859	{ .fw_name = "xtal", },
 860	{ .hw = &axg_fclk_div7.hw },
 861	{ .hw = &axg_mpll1.hw },
 862	{ .hw = &axg_mpll2.hw },
 863	{ .hw = &axg_fclk_div4.hw },
 864	{ .hw = &axg_fclk_div3.hw },
 865	{ .hw = &axg_fclk_div5.hw },
 866};
 867
 868static struct clk_regmap axg_mpeg_clk_sel = {
 869	.data = &(struct clk_regmap_mux_data){
 870		.offset = HHI_MPEG_CLK_CNTL,
 871		.mask = 0x7,
 872		.shift = 12,
 873		.table = mux_table_clk81,
 874	},
 875	.hw.init = &(struct clk_init_data){
 876		.name = "mpeg_clk_sel",
 877		.ops = &clk_regmap_mux_ro_ops,
 878		.parent_data = clk81_parent_data,
 879		.num_parents = ARRAY_SIZE(clk81_parent_data),
 880	},
 881};
 882
 883static struct clk_regmap axg_mpeg_clk_div = {
 884	.data = &(struct clk_regmap_div_data){
 885		.offset = HHI_MPEG_CLK_CNTL,
 886		.shift = 0,
 887		.width = 7,
 888	},
 889	.hw.init = &(struct clk_init_data){
 890		.name = "mpeg_clk_div",
 891		.ops = &clk_regmap_divider_ops,
 892		.parent_hws = (const struct clk_hw *[]) {
 893			&axg_mpeg_clk_sel.hw
 894		},
 895		.num_parents = 1,
 896		.flags = CLK_SET_RATE_PARENT,
 897	},
 898};
 899
 900static struct clk_regmap axg_clk81 = {
 901	.data = &(struct clk_regmap_gate_data){
 902		.offset = HHI_MPEG_CLK_CNTL,
 903		.bit_idx = 7,
 904	},
 905	.hw.init = &(struct clk_init_data){
 906		.name = "clk81",
 907		.ops = &clk_regmap_gate_ops,
 908		.parent_hws = (const struct clk_hw *[]) {
 909			&axg_mpeg_clk_div.hw
 910		},
 911		.num_parents = 1,
 912		.flags = (CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
 913	},
 914};
 915
 916static const struct clk_parent_data axg_sd_emmc_clk0_parent_data[] = {
 917	{ .fw_name = "xtal", },
 918	{ .hw = &axg_fclk_div2.hw },
 919	{ .hw = &axg_fclk_div3.hw },
 920	{ .hw = &axg_fclk_div5.hw },
 921	{ .hw = &axg_fclk_div7.hw },
 922	/*
 923	 * Following these parent clocks, we should also have had mpll2, mpll3
 924	 * and gp0_pll but these clocks are too precious to be used here. All
 925	 * the necessary rates for MMC and NAND operation can be acheived using
 926	 * xtal or fclk_div clocks
 927	 */
 928};
 929
 930/* SDcard clock */
 931static struct clk_regmap axg_sd_emmc_b_clk0_sel = {
 932	.data = &(struct clk_regmap_mux_data){
 933		.offset = HHI_SD_EMMC_CLK_CNTL,
 934		.mask = 0x7,
 935		.shift = 25,
 936	},
 937	.hw.init = &(struct clk_init_data) {
 938		.name = "sd_emmc_b_clk0_sel",
 939		.ops = &clk_regmap_mux_ops,
 940		.parent_data = axg_sd_emmc_clk0_parent_data,
 941		.num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_data),
 942		.flags = CLK_SET_RATE_PARENT,
 943	},
 944};
 945
 946static struct clk_regmap axg_sd_emmc_b_clk0_div = {
 947	.data = &(struct clk_regmap_div_data){
 948		.offset = HHI_SD_EMMC_CLK_CNTL,
 949		.shift = 16,
 950		.width = 7,
 951		.flags = CLK_DIVIDER_ROUND_CLOSEST,
 952	},
 953	.hw.init = &(struct clk_init_data) {
 954		.name = "sd_emmc_b_clk0_div",
 955		.ops = &clk_regmap_divider_ops,
 956		.parent_hws = (const struct clk_hw *[]) {
 957			&axg_sd_emmc_b_clk0_sel.hw
 958		},
 959		.num_parents = 1,
 960		.flags = CLK_SET_RATE_PARENT,
 961	},
 962};
 963
 964static struct clk_regmap axg_sd_emmc_b_clk0 = {
 965	.data = &(struct clk_regmap_gate_data){
 966		.offset = HHI_SD_EMMC_CLK_CNTL,
 967		.bit_idx = 23,
 968	},
 969	.hw.init = &(struct clk_init_data){
 970		.name = "sd_emmc_b_clk0",
 971		.ops = &clk_regmap_gate_ops,
 972		.parent_hws = (const struct clk_hw *[]) {
 973			&axg_sd_emmc_b_clk0_div.hw
 974		},
 975		.num_parents = 1,
 976		.flags = CLK_SET_RATE_PARENT,
 977	},
 978};
 979
 980/* EMMC/NAND clock */
 981static struct clk_regmap axg_sd_emmc_c_clk0_sel = {
 982	.data = &(struct clk_regmap_mux_data){
 983		.offset = HHI_NAND_CLK_CNTL,
 984		.mask = 0x7,
 985		.shift = 9,
 986	},
 987	.hw.init = &(struct clk_init_data) {
 988		.name = "sd_emmc_c_clk0_sel",
 989		.ops = &clk_regmap_mux_ops,
 990		.parent_data = axg_sd_emmc_clk0_parent_data,
 991		.num_parents = ARRAY_SIZE(axg_sd_emmc_clk0_parent_data),
 992		.flags = CLK_SET_RATE_PARENT,
 993	},
 994};
 995
 996static struct clk_regmap axg_sd_emmc_c_clk0_div = {
 997	.data = &(struct clk_regmap_div_data){
 998		.offset = HHI_NAND_CLK_CNTL,
 999		.shift = 0,
1000		.width = 7,
1001		.flags = CLK_DIVIDER_ROUND_CLOSEST,
1002	},
1003	.hw.init = &(struct clk_init_data) {
1004		.name = "sd_emmc_c_clk0_div",
1005		.ops = &clk_regmap_divider_ops,
1006		.parent_hws = (const struct clk_hw *[]) {
1007			&axg_sd_emmc_c_clk0_sel.hw
1008		},
1009		.num_parents = 1,
1010		.flags = CLK_SET_RATE_PARENT,
1011	},
1012};
1013
1014static struct clk_regmap axg_sd_emmc_c_clk0 = {
1015	.data = &(struct clk_regmap_gate_data){
1016		.offset = HHI_NAND_CLK_CNTL,
1017		.bit_idx = 7,
1018	},
1019	.hw.init = &(struct clk_init_data){
1020		.name = "sd_emmc_c_clk0",
1021		.ops = &clk_regmap_gate_ops,
1022		.parent_hws = (const struct clk_hw *[]) {
1023			&axg_sd_emmc_c_clk0_div.hw
1024		},
1025		.num_parents = 1,
1026		.flags = CLK_SET_RATE_PARENT,
1027	},
1028};
1029
1030/* VPU Clock */
1031
1032static const struct clk_hw *axg_vpu_parent_hws[] = {
1033	&axg_fclk_div4.hw,
1034	&axg_fclk_div3.hw,
1035	&axg_fclk_div5.hw,
1036	&axg_fclk_div7.hw,
1037};
1038
1039static struct clk_regmap axg_vpu_0_sel = {
1040	.data = &(struct clk_regmap_mux_data){
1041		.offset = HHI_VPU_CLK_CNTL,
1042		.mask = 0x3,
1043		.shift = 9,
1044	},
1045	.hw.init = &(struct clk_init_data){
1046		.name = "vpu_0_sel",
1047		.ops = &clk_regmap_mux_ops,
1048		.parent_hws = axg_vpu_parent_hws,
1049		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1050		/* We need a specific parent for VPU clock source, let it be set in DT */
1051		.flags = CLK_SET_RATE_NO_REPARENT,
1052	},
1053};
1054
1055static struct clk_regmap axg_vpu_0_div = {
1056	.data = &(struct clk_regmap_div_data){
1057		.offset = HHI_VPU_CLK_CNTL,
1058		.shift = 0,
1059		.width = 7,
1060	},
1061	.hw.init = &(struct clk_init_data){
1062		.name = "vpu_0_div",
1063		.ops = &clk_regmap_divider_ops,
1064		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_0_sel.hw },
1065		.num_parents = 1,
1066		.flags = CLK_SET_RATE_PARENT,
1067	},
1068};
1069
1070static struct clk_regmap axg_vpu_0 = {
1071	.data = &(struct clk_regmap_gate_data){
1072		.offset = HHI_VPU_CLK_CNTL,
1073		.bit_idx = 8,
1074	},
1075	.hw.init = &(struct clk_init_data) {
1076		.name = "vpu_0",
1077		.ops = &clk_regmap_gate_ops,
1078		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_0_div.hw },
1079		.num_parents = 1,
1080		/*
1081		 * We want to avoid CCF to disable the VPU clock if
1082		 * display has been set by Bootloader
1083		 */
1084		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1085	},
1086};
1087
1088static struct clk_regmap axg_vpu_1_sel = {
1089	.data = &(struct clk_regmap_mux_data){
1090		.offset = HHI_VPU_CLK_CNTL,
1091		.mask = 0x3,
1092		.shift = 25,
1093	},
1094	.hw.init = &(struct clk_init_data){
1095		.name = "vpu_1_sel",
1096		.ops = &clk_regmap_mux_ops,
1097		.parent_hws = axg_vpu_parent_hws,
1098		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1099		/* We need a specific parent for VPU clock source, let it be set in DT */
1100		.flags = CLK_SET_RATE_NO_REPARENT,
1101	},
1102};
1103
1104static struct clk_regmap axg_vpu_1_div = {
1105	.data = &(struct clk_regmap_div_data){
1106		.offset = HHI_VPU_CLK_CNTL,
1107		.shift = 16,
1108		.width = 7,
1109	},
1110	.hw.init = &(struct clk_init_data){
1111		.name = "vpu_1_div",
1112		.ops = &clk_regmap_divider_ops,
1113		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_1_sel.hw },
1114		.num_parents = 1,
1115		.flags = CLK_SET_RATE_PARENT,
1116	},
1117};
1118
1119static struct clk_regmap axg_vpu_1 = {
1120	.data = &(struct clk_regmap_gate_data){
1121		.offset = HHI_VPU_CLK_CNTL,
1122		.bit_idx = 24,
1123	},
1124	.hw.init = &(struct clk_init_data) {
1125		.name = "vpu_1",
1126		.ops = &clk_regmap_gate_ops,
1127		.parent_hws = (const struct clk_hw *[]) { &axg_vpu_1_div.hw },
1128		.num_parents = 1,
1129		/*
1130		 * We want to avoid CCF to disable the VPU clock if
1131		 * display has been set by Bootloader
1132		 */
1133		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1134	},
1135};
1136
1137static struct clk_regmap axg_vpu = {
1138	.data = &(struct clk_regmap_mux_data){
1139		.offset = HHI_VPU_CLK_CNTL,
1140		.mask = 1,
1141		.shift = 31,
1142	},
1143	.hw.init = &(struct clk_init_data){
1144		.name = "vpu",
1145		.ops = &clk_regmap_mux_ops,
1146		.parent_hws = (const struct clk_hw *[]) {
1147			&axg_vpu_0.hw,
1148			&axg_vpu_1.hw
1149		},
1150		.num_parents = 2,
1151		.flags = CLK_SET_RATE_NO_REPARENT,
1152	},
1153};
1154
1155/* VAPB Clock */
1156
1157static struct clk_regmap axg_vapb_0_sel = {
1158	.data = &(struct clk_regmap_mux_data){
1159		.offset = HHI_VAPBCLK_CNTL,
1160		.mask = 0x3,
1161		.shift = 9,
1162	},
1163	.hw.init = &(struct clk_init_data){
1164		.name = "vapb_0_sel",
1165		.ops = &clk_regmap_mux_ops,
1166		.parent_hws = axg_vpu_parent_hws,
1167		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1168		.flags = CLK_SET_RATE_NO_REPARENT,
1169	},
1170};
1171
1172static struct clk_regmap axg_vapb_0_div = {
1173	.data = &(struct clk_regmap_div_data){
1174		.offset = HHI_VAPBCLK_CNTL,
1175		.shift = 0,
1176		.width = 7,
1177	},
1178	.hw.init = &(struct clk_init_data){
1179		.name = "vapb_0_div",
1180		.ops = &clk_regmap_divider_ops,
1181		.parent_hws = (const struct clk_hw *[]) {
1182			&axg_vapb_0_sel.hw
1183		},
1184		.num_parents = 1,
1185		.flags = CLK_SET_RATE_PARENT,
1186	},
1187};
1188
1189static struct clk_regmap axg_vapb_0 = {
1190	.data = &(struct clk_regmap_gate_data){
1191		.offset = HHI_VAPBCLK_CNTL,
1192		.bit_idx = 8,
1193	},
1194	.hw.init = &(struct clk_init_data) {
1195		.name = "vapb_0",
1196		.ops = &clk_regmap_gate_ops,
1197		.parent_hws = (const struct clk_hw *[]) {
1198			&axg_vapb_0_div.hw
1199		},
1200		.num_parents = 1,
1201		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1202	},
1203};
1204
1205static struct clk_regmap axg_vapb_1_sel = {
1206	.data = &(struct clk_regmap_mux_data){
1207		.offset = HHI_VAPBCLK_CNTL,
1208		.mask = 0x3,
1209		.shift = 25,
1210	},
1211	.hw.init = &(struct clk_init_data){
1212		.name = "vapb_1_sel",
1213		.ops = &clk_regmap_mux_ops,
1214		.parent_hws = axg_vpu_parent_hws,
1215		.num_parents = ARRAY_SIZE(axg_vpu_parent_hws),
1216		.flags = CLK_SET_RATE_NO_REPARENT,
1217	},
1218};
1219
1220static struct clk_regmap axg_vapb_1_div = {
1221	.data = &(struct clk_regmap_div_data){
1222		.offset = HHI_VAPBCLK_CNTL,
1223		.shift = 16,
1224		.width = 7,
1225	},
1226	.hw.init = &(struct clk_init_data){
1227		.name = "vapb_1_div",
1228		.ops = &clk_regmap_divider_ops,
1229		.parent_hws = (const struct clk_hw *[]) {
1230			&axg_vapb_1_sel.hw
1231		},
1232		.num_parents = 1,
1233		.flags = CLK_SET_RATE_PARENT,
1234	},
1235};
1236
1237static struct clk_regmap axg_vapb_1 = {
1238	.data = &(struct clk_regmap_gate_data){
1239		.offset = HHI_VAPBCLK_CNTL,
1240		.bit_idx = 24,
1241	},
1242	.hw.init = &(struct clk_init_data) {
1243		.name = "vapb_1",
1244		.ops = &clk_regmap_gate_ops,
1245		.parent_hws = (const struct clk_hw *[]) {
1246			&axg_vapb_1_div.hw
1247		},
1248		.num_parents = 1,
1249		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1250	},
1251};
1252
1253static struct clk_regmap axg_vapb_sel = {
1254	.data = &(struct clk_regmap_mux_data){
1255		.offset = HHI_VAPBCLK_CNTL,
1256		.mask = 1,
1257		.shift = 31,
1258	},
1259	.hw.init = &(struct clk_init_data){
1260		.name = "vapb_sel",
1261		.ops = &clk_regmap_mux_ops,
1262		.parent_hws = (const struct clk_hw *[]) {
1263			&axg_vapb_0.hw,
1264			&axg_vapb_1.hw
1265		},
1266		.num_parents = 2,
1267		.flags = CLK_SET_RATE_NO_REPARENT,
1268	},
1269};
1270
1271static struct clk_regmap axg_vapb = {
1272	.data = &(struct clk_regmap_gate_data){
1273		.offset = HHI_VAPBCLK_CNTL,
1274		.bit_idx = 30,
1275	},
1276	.hw.init = &(struct clk_init_data) {
1277		.name = "vapb",
1278		.ops = &clk_regmap_gate_ops,
1279		.parent_hws = (const struct clk_hw *[]) { &axg_vapb_sel.hw },
1280		.num_parents = 1,
1281		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1282	},
1283};
1284
1285/* Video Clocks */
1286
1287static const struct clk_hw *axg_vclk_parent_hws[] = {
1288	&axg_gp0_pll.hw,
1289	&axg_fclk_div4.hw,
1290	&axg_fclk_div3.hw,
1291	&axg_fclk_div5.hw,
1292	&axg_fclk_div2.hw,
1293	&axg_fclk_div7.hw,
1294	&axg_mpll1.hw,
1295};
1296
1297static struct clk_regmap axg_vclk_sel = {
1298	.data = &(struct clk_regmap_mux_data){
1299		.offset = HHI_VID_CLK_CNTL,
1300		.mask = 0x7,
1301		.shift = 16,
1302	},
1303	.hw.init = &(struct clk_init_data){
1304		.name = "vclk_sel",
1305		.ops = &clk_regmap_mux_ops,
1306		.parent_hws = axg_vclk_parent_hws,
1307		.num_parents = ARRAY_SIZE(axg_vclk_parent_hws),
1308		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1309	},
1310};
1311
1312static struct clk_regmap axg_vclk2_sel = {
1313	.data = &(struct clk_regmap_mux_data){
1314		.offset = HHI_VIID_CLK_CNTL,
1315		.mask = 0x7,
1316		.shift = 16,
1317	},
1318	.hw.init = &(struct clk_init_data){
1319		.name = "vclk2_sel",
1320		.ops = &clk_regmap_mux_ops,
1321		.parent_hws = axg_vclk_parent_hws,
1322		.num_parents = ARRAY_SIZE(axg_vclk_parent_hws),
1323		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1324	},
1325};
1326
1327static struct clk_regmap axg_vclk_input = {
1328	.data = &(struct clk_regmap_gate_data){
1329		.offset = HHI_VID_CLK_DIV,
1330		.bit_idx = 16,
1331	},
1332	.hw.init = &(struct clk_init_data) {
1333		.name = "vclk_input",
1334		.ops = &clk_regmap_gate_ops,
1335		.parent_hws = (const struct clk_hw *[]) { &axg_vclk_sel.hw },
1336		.num_parents = 1,
1337		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1338	},
1339};
1340
1341static struct clk_regmap axg_vclk2_input = {
1342	.data = &(struct clk_regmap_gate_data){
1343		.offset = HHI_VIID_CLK_DIV,
1344		.bit_idx = 16,
1345	},
1346	.hw.init = &(struct clk_init_data) {
1347		.name = "vclk2_input",
1348		.ops = &clk_regmap_gate_ops,
1349		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2_sel.hw },
1350		.num_parents = 1,
1351		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1352	},
1353};
1354
1355static struct clk_regmap axg_vclk_div = {
1356	.data = &(struct clk_regmap_div_data){
1357		.offset = HHI_VID_CLK_DIV,
1358		.shift = 0,
1359		.width = 8,
1360	},
1361	.hw.init = &(struct clk_init_data){
1362		.name = "vclk_div",
1363		.ops = &clk_regmap_divider_ops,
1364		.parent_hws = (const struct clk_hw *[]) {
1365			&axg_vclk_input.hw
1366		},
1367		.num_parents = 1,
1368		.flags = CLK_GET_RATE_NOCACHE,
1369	},
1370};
1371
1372static struct clk_regmap axg_vclk2_div = {
1373	.data = &(struct clk_regmap_div_data){
1374		.offset = HHI_VIID_CLK_DIV,
1375		.shift = 0,
1376		.width = 8,
1377	},
1378	.hw.init = &(struct clk_init_data){
1379		.name = "vclk2_div",
1380		.ops = &clk_regmap_divider_ops,
1381		.parent_hws = (const struct clk_hw *[]) {
1382			&axg_vclk2_input.hw
1383		},
1384		.num_parents = 1,
1385		.flags = CLK_GET_RATE_NOCACHE,
1386	},
1387};
1388
1389static struct clk_regmap axg_vclk = {
1390	.data = &(struct clk_regmap_gate_data){
1391		.offset = HHI_VID_CLK_CNTL,
1392		.bit_idx = 19,
1393	},
1394	.hw.init = &(struct clk_init_data) {
1395		.name = "vclk",
1396		.ops = &clk_regmap_gate_ops,
1397		.parent_hws = (const struct clk_hw *[]) { &axg_vclk_div.hw },
1398		.num_parents = 1,
1399		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1400	},
1401};
1402
1403static struct clk_regmap axg_vclk2 = {
1404	.data = &(struct clk_regmap_gate_data){
1405		.offset = HHI_VIID_CLK_CNTL,
1406		.bit_idx = 19,
1407	},
1408	.hw.init = &(struct clk_init_data) {
1409		.name = "vclk2",
1410		.ops = &clk_regmap_gate_ops,
1411		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2_div.hw },
1412		.num_parents = 1,
1413		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1414	},
1415};
1416
1417static struct clk_regmap axg_vclk_div1 = {
1418	.data = &(struct clk_regmap_gate_data){
1419		.offset = HHI_VID_CLK_CNTL,
1420		.bit_idx = 0,
1421	},
1422	.hw.init = &(struct clk_init_data) {
1423		.name = "vclk_div1",
1424		.ops = &clk_regmap_gate_ops,
1425		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1426		.num_parents = 1,
1427		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1428	},
1429};
1430
1431static struct clk_regmap axg_vclk_div2_en = {
1432	.data = &(struct clk_regmap_gate_data){
1433		.offset = HHI_VID_CLK_CNTL,
1434		.bit_idx = 1,
1435	},
1436	.hw.init = &(struct clk_init_data) {
1437		.name = "vclk_div2_en",
1438		.ops = &clk_regmap_gate_ops,
1439		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1440		.num_parents = 1,
1441		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1442	},
1443};
1444
1445static struct clk_regmap axg_vclk_div4_en = {
1446	.data = &(struct clk_regmap_gate_data){
1447		.offset = HHI_VID_CLK_CNTL,
1448		.bit_idx = 2,
1449	},
1450	.hw.init = &(struct clk_init_data) {
1451		.name = "vclk_div4_en",
1452		.ops = &clk_regmap_gate_ops,
1453		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1454		.num_parents = 1,
1455		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1456	},
1457};
1458
1459static struct clk_regmap axg_vclk_div6_en = {
1460	.data = &(struct clk_regmap_gate_data){
1461		.offset = HHI_VID_CLK_CNTL,
1462		.bit_idx = 3,
1463	},
1464	.hw.init = &(struct clk_init_data) {
1465		.name = "vclk_div6_en",
1466		.ops = &clk_regmap_gate_ops,
1467		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1468		.num_parents = 1,
1469		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1470	},
1471};
1472
1473static struct clk_regmap axg_vclk_div12_en = {
1474	.data = &(struct clk_regmap_gate_data){
1475		.offset = HHI_VID_CLK_CNTL,
1476		.bit_idx = 4,
1477	},
1478	.hw.init = &(struct clk_init_data) {
1479		.name = "vclk_div12_en",
1480		.ops = &clk_regmap_gate_ops,
1481		.parent_hws = (const struct clk_hw *[]) { &axg_vclk.hw },
1482		.num_parents = 1,
1483		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1484	},
1485};
1486
1487static struct clk_regmap axg_vclk2_div1 = {
1488	.data = &(struct clk_regmap_gate_data){
1489		.offset = HHI_VIID_CLK_CNTL,
1490		.bit_idx = 0,
1491	},
1492	.hw.init = &(struct clk_init_data) {
1493		.name = "vclk2_div1",
1494		.ops = &clk_regmap_gate_ops,
1495		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1496		.num_parents = 1,
1497		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1498	},
1499};
1500
1501static struct clk_regmap axg_vclk2_div2_en = {
1502	.data = &(struct clk_regmap_gate_data){
1503		.offset = HHI_VIID_CLK_CNTL,
1504		.bit_idx = 1,
1505	},
1506	.hw.init = &(struct clk_init_data) {
1507		.name = "vclk2_div2_en",
1508		.ops = &clk_regmap_gate_ops,
1509		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1510		.num_parents = 1,
1511		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1512	},
1513};
1514
1515static struct clk_regmap axg_vclk2_div4_en = {
1516	.data = &(struct clk_regmap_gate_data){
1517		.offset = HHI_VIID_CLK_CNTL,
1518		.bit_idx = 2,
1519	},
1520	.hw.init = &(struct clk_init_data) {
1521		.name = "vclk2_div4_en",
1522		.ops = &clk_regmap_gate_ops,
1523		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1524		.num_parents = 1,
1525		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1526	},
1527};
1528
1529static struct clk_regmap axg_vclk2_div6_en = {
1530	.data = &(struct clk_regmap_gate_data){
1531		.offset = HHI_VIID_CLK_CNTL,
1532		.bit_idx = 3,
1533	},
1534	.hw.init = &(struct clk_init_data) {
1535		.name = "vclk2_div6_en",
1536		.ops = &clk_regmap_gate_ops,
1537		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1538		.num_parents = 1,
1539		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1540	},
1541};
1542
1543static struct clk_regmap axg_vclk2_div12_en = {
1544	.data = &(struct clk_regmap_gate_data){
1545		.offset = HHI_VIID_CLK_CNTL,
1546		.bit_idx = 4,
1547	},
1548	.hw.init = &(struct clk_init_data) {
1549		.name = "vclk2_div12_en",
1550		.ops = &clk_regmap_gate_ops,
1551		.parent_hws = (const struct clk_hw *[]) { &axg_vclk2.hw },
1552		.num_parents = 1,
1553		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1554	},
1555};
1556
1557static struct clk_fixed_factor axg_vclk_div2 = {
1558	.mult = 1,
1559	.div = 2,
1560	.hw.init = &(struct clk_init_data){
1561		.name = "vclk_div2",
1562		.ops = &clk_fixed_factor_ops,
1563		.parent_hws = (const struct clk_hw *[]) {
1564			&axg_vclk_div2_en.hw
1565		},
1566		.num_parents = 1,
1567	},
1568};
1569
1570static struct clk_fixed_factor axg_vclk_div4 = {
1571	.mult = 1,
1572	.div = 4,
1573	.hw.init = &(struct clk_init_data){
1574		.name = "vclk_div4",
1575		.ops = &clk_fixed_factor_ops,
1576		.parent_hws = (const struct clk_hw *[]) {
1577			&axg_vclk_div4_en.hw
1578		},
1579		.num_parents = 1,
1580	},
1581};
1582
1583static struct clk_fixed_factor axg_vclk_div6 = {
1584	.mult = 1,
1585	.div = 6,
1586	.hw.init = &(struct clk_init_data){
1587		.name = "vclk_div6",
1588		.ops = &clk_fixed_factor_ops,
1589		.parent_hws = (const struct clk_hw *[]) {
1590			&axg_vclk_div6_en.hw
1591		},
1592		.num_parents = 1,
1593	},
1594};
1595
1596static struct clk_fixed_factor axg_vclk_div12 = {
1597	.mult = 1,
1598	.div = 12,
1599	.hw.init = &(struct clk_init_data){
1600		.name = "vclk_div12",
1601		.ops = &clk_fixed_factor_ops,
1602		.parent_hws = (const struct clk_hw *[]) {
1603			&axg_vclk_div12_en.hw
1604		},
1605		.num_parents = 1,
1606	},
1607};
1608
1609static struct clk_fixed_factor axg_vclk2_div2 = {
1610	.mult = 1,
1611	.div = 2,
1612	.hw.init = &(struct clk_init_data){
1613		.name = "vclk2_div2",
1614		.ops = &clk_fixed_factor_ops,
1615		.parent_hws = (const struct clk_hw *[]) {
1616			&axg_vclk2_div2_en.hw
1617		},
1618		.num_parents = 1,
1619	},
1620};
1621
1622static struct clk_fixed_factor axg_vclk2_div4 = {
1623	.mult = 1,
1624	.div = 4,
1625	.hw.init = &(struct clk_init_data){
1626		.name = "vclk2_div4",
1627		.ops = &clk_fixed_factor_ops,
1628		.parent_hws = (const struct clk_hw *[]) {
1629			&axg_vclk2_div4_en.hw
1630		},
1631		.num_parents = 1,
1632	},
1633};
1634
1635static struct clk_fixed_factor axg_vclk2_div6 = {
1636	.mult = 1,
1637	.div = 6,
1638	.hw.init = &(struct clk_init_data){
1639		.name = "vclk2_div6",
1640		.ops = &clk_fixed_factor_ops,
1641		.parent_hws = (const struct clk_hw *[]) {
1642			&axg_vclk2_div6_en.hw
1643		},
1644		.num_parents = 1,
1645	},
1646};
1647
1648static struct clk_fixed_factor axg_vclk2_div12 = {
1649	.mult = 1,
1650	.div = 12,
1651	.hw.init = &(struct clk_init_data){
1652		.name = "vclk2_div12",
1653		.ops = &clk_fixed_factor_ops,
1654		.parent_hws = (const struct clk_hw *[]) {
1655			&axg_vclk2_div12_en.hw
1656		},
1657		.num_parents = 1,
1658	},
1659};
1660
1661static u32 mux_table_cts_sel[] = { 0, 1, 2, 3, 4, 8, 9, 10, 11, 12 };
1662static const struct clk_hw *axg_cts_parent_hws[] = {
1663	&axg_vclk_div1.hw,
1664	&axg_vclk_div2.hw,
1665	&axg_vclk_div4.hw,
1666	&axg_vclk_div6.hw,
1667	&axg_vclk_div12.hw,
1668	&axg_vclk2_div1.hw,
1669	&axg_vclk2_div2.hw,
1670	&axg_vclk2_div4.hw,
1671	&axg_vclk2_div6.hw,
1672	&axg_vclk2_div12.hw,
1673};
1674
1675static struct clk_regmap axg_cts_encl_sel = {
1676	.data = &(struct clk_regmap_mux_data){
1677		.offset = HHI_VIID_CLK_DIV,
1678		.mask = 0xf,
1679		.shift = 12,
1680		.table = mux_table_cts_sel,
1681	},
1682	.hw.init = &(struct clk_init_data){
1683		.name = "cts_encl_sel",
1684		.ops = &clk_regmap_mux_ops,
1685		.parent_hws = axg_cts_parent_hws,
1686		.num_parents = ARRAY_SIZE(axg_cts_parent_hws),
1687		.flags = CLK_SET_RATE_NO_REPARENT | CLK_GET_RATE_NOCACHE,
1688	},
1689};
1690
1691static struct clk_regmap axg_cts_encl = {
1692	.data = &(struct clk_regmap_gate_data){
1693		.offset = HHI_VID_CLK_CNTL2,
1694		.bit_idx = 3,
1695	},
1696	.hw.init = &(struct clk_init_data) {
1697		.name = "cts_encl",
1698		.ops = &clk_regmap_gate_ops,
1699		.parent_hws = (const struct clk_hw *[]) {
1700			&axg_cts_encl_sel.hw
1701		},
1702		.num_parents = 1,
1703		.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
1704	},
1705};
1706
1707/* MIPI DSI Host Clock */
1708
1709static u32 mux_table_axg_vdin_meas[]    = { 0, 1, 2, 3, 6, 7 };
1710static const struct clk_parent_data axg_vdin_meas_parent_data[] = {
1711	{ .fw_name = "xtal", },
1712	{ .hw = &axg_fclk_div4.hw },
1713	{ .hw = &axg_fclk_div3.hw },
1714	{ .hw = &axg_fclk_div5.hw },
1715	{ .hw = &axg_fclk_div2.hw },
1716	{ .hw = &axg_fclk_div7.hw },
1717};
1718
1719static struct clk_regmap axg_vdin_meas_sel = {
1720	.data = &(struct clk_regmap_mux_data){
1721		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1722		.mask = 0x7,
1723		.shift = 21,
1724		.flags = CLK_MUX_ROUND_CLOSEST,
1725		.table = mux_table_axg_vdin_meas,
1726	},
1727	.hw.init = &(struct clk_init_data){
1728		.name = "vdin_meas_sel",
1729		.ops = &clk_regmap_mux_ops,
1730		.parent_data = axg_vdin_meas_parent_data,
1731		.num_parents = ARRAY_SIZE(axg_vdin_meas_parent_data),
1732		.flags = CLK_SET_RATE_PARENT,
1733	},
1734};
1735
1736static struct clk_regmap axg_vdin_meas_div = {
1737	.data = &(struct clk_regmap_div_data){
1738		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1739		.shift = 12,
1740		.width = 7,
1741	},
1742	.hw.init = &(struct clk_init_data){
1743		.name = "vdin_meas_div",
1744		.ops = &clk_regmap_divider_ops,
1745		.parent_hws = (const struct clk_hw *[]) {
1746			&axg_vdin_meas_sel.hw },
1747		.num_parents = 1,
1748		.flags = CLK_SET_RATE_PARENT,
1749	},
1750};
1751
1752static struct clk_regmap axg_vdin_meas = {
1753	.data = &(struct clk_regmap_gate_data){
1754		.offset = HHI_VDIN_MEAS_CLK_CNTL,
1755		.bit_idx = 20,
1756	},
1757	.hw.init = &(struct clk_init_data) {
1758		.name = "vdin_meas",
1759		.ops = &clk_regmap_gate_ops,
1760		.parent_hws = (const struct clk_hw *[]) {
1761			&axg_vdin_meas_div.hw },
1762		.num_parents = 1,
1763		.flags = CLK_SET_RATE_PARENT,
1764	},
1765};
1766
1767static u32 mux_table_gen_clk[]	= { 0, 4, 5, 6, 7, 8,
1768				    9, 10, 11, 13, 14, };
1769static const struct clk_parent_data gen_clk_parent_data[] = {
1770	{ .fw_name = "xtal", },
1771	{ .hw = &axg_hifi_pll.hw },
1772	{ .hw = &axg_mpll0.hw },
1773	{ .hw = &axg_mpll1.hw },
1774	{ .hw = &axg_mpll2.hw },
1775	{ .hw = &axg_mpll3.hw },
1776	{ .hw = &axg_fclk_div4.hw },
1777	{ .hw = &axg_fclk_div3.hw },
1778	{ .hw = &axg_fclk_div5.hw },
1779	{ .hw = &axg_fclk_div7.hw },
1780	{ .hw = &axg_gp0_pll.hw },
1781};
1782
1783static struct clk_regmap axg_gen_clk_sel = {
1784	.data = &(struct clk_regmap_mux_data){
1785		.offset = HHI_GEN_CLK_CNTL,
1786		.mask = 0xf,
1787		.shift = 12,
1788		.table = mux_table_gen_clk,
1789	},
1790	.hw.init = &(struct clk_init_data){
1791		.name = "gen_clk_sel",
1792		.ops = &clk_regmap_mux_ops,
1793		/*
1794		 * bits 15:12 selects from 14 possible parents:
1795		 * xtal, [rtc_oscin_i], [sys_cpu_div16], [ddr_dpll_pt],
1796		 * hifi_pll, mpll0, mpll1, mpll2, mpll3, fdiv4,
1797		 * fdiv3, fdiv5, [cts_msr_clk], fdiv7, gp0_pll
1798		 */
1799		.parent_data = gen_clk_parent_data,
1800		.num_parents = ARRAY_SIZE(gen_clk_parent_data),
1801	},
1802};
1803
1804static struct clk_regmap axg_gen_clk_div = {
1805	.data = &(struct clk_regmap_div_data){
1806		.offset = HHI_GEN_CLK_CNTL,
1807		.shift = 0,
1808		.width = 11,
1809	},
1810	.hw.init = &(struct clk_init_data){
1811		.name = "gen_clk_div",
1812		.ops = &clk_regmap_divider_ops,
1813		.parent_hws = (const struct clk_hw *[]) {
1814			&axg_gen_clk_sel.hw
1815		},
1816		.num_parents = 1,
1817		.flags = CLK_SET_RATE_PARENT,
1818	},
1819};
1820
1821static struct clk_regmap axg_gen_clk = {
1822	.data = &(struct clk_regmap_gate_data){
1823		.offset = HHI_GEN_CLK_CNTL,
1824		.bit_idx = 7,
1825	},
1826	.hw.init = &(struct clk_init_data){
1827		.name = "gen_clk",
1828		.ops = &clk_regmap_gate_ops,
1829		.parent_hws = (const struct clk_hw *[]) {
1830			&axg_gen_clk_div.hw
1831		},
1832		.num_parents = 1,
1833		.flags = CLK_SET_RATE_PARENT,
1834	},
1835};
1836
1837#define MESON_GATE(_name, _reg, _bit) \
1838	MESON_PCLK(_name, _reg, _bit, &axg_clk81.hw)
1839
1840/* Everything Else (EE) domain gates */
1841static MESON_GATE(axg_ddr, HHI_GCLK_MPEG0, 0);
1842static MESON_GATE(axg_audio_locker, HHI_GCLK_MPEG0, 2);
1843static MESON_GATE(axg_mipi_dsi_host, HHI_GCLK_MPEG0, 3);
1844static MESON_GATE(axg_isa, HHI_GCLK_MPEG0, 5);
1845static MESON_GATE(axg_pl301, HHI_GCLK_MPEG0, 6);
1846static MESON_GATE(axg_periphs, HHI_GCLK_MPEG0, 7);
1847static MESON_GATE(axg_spicc_0, HHI_GCLK_MPEG0, 8);
1848static MESON_GATE(axg_i2c, HHI_GCLK_MPEG0, 9);
1849static MESON_GATE(axg_rng0, HHI_GCLK_MPEG0, 12);
1850static MESON_GATE(axg_uart0, HHI_GCLK_MPEG0, 13);
1851static MESON_GATE(axg_mipi_dsi_phy, HHI_GCLK_MPEG0, 14);
1852static MESON_GATE(axg_spicc_1, HHI_GCLK_MPEG0, 15);
1853static MESON_GATE(axg_pcie_a, HHI_GCLK_MPEG0, 16);
1854static MESON_GATE(axg_pcie_b, HHI_GCLK_MPEG0, 17);
1855static MESON_GATE(axg_hiu_reg, HHI_GCLK_MPEG0, 19);
1856static MESON_GATE(axg_assist_misc, HHI_GCLK_MPEG0, 23);
1857static MESON_GATE(axg_emmc_b, HHI_GCLK_MPEG0, 25);
1858static MESON_GATE(axg_emmc_c, HHI_GCLK_MPEG0, 26);
1859static MESON_GATE(axg_dma, HHI_GCLK_MPEG0, 27);
1860static MESON_GATE(axg_spi, HHI_GCLK_MPEG0, 30);
1861
1862static MESON_GATE(axg_audio, HHI_GCLK_MPEG1, 0);
1863static MESON_GATE(axg_eth_core, HHI_GCLK_MPEG1, 3);
1864static MESON_GATE(axg_uart1, HHI_GCLK_MPEG1, 16);
1865static MESON_GATE(axg_g2d, HHI_GCLK_MPEG1, 20);
1866static MESON_GATE(axg_usb0, HHI_GCLK_MPEG1, 21);
1867static MESON_GATE(axg_usb1, HHI_GCLK_MPEG1, 22);
1868static MESON_GATE(axg_reset, HHI_GCLK_MPEG1, 23);
1869static MESON_GATE(axg_usb_general, HHI_GCLK_MPEG1, 26);
1870static MESON_GATE(axg_ahb_arb0, HHI_GCLK_MPEG1, 29);
1871static MESON_GATE(axg_efuse, HHI_GCLK_MPEG1, 30);
1872static MESON_GATE(axg_boot_rom, HHI_GCLK_MPEG1, 31);
1873
1874static MESON_GATE(axg_ahb_data_bus, HHI_GCLK_MPEG2, 1);
1875static MESON_GATE(axg_ahb_ctrl_bus, HHI_GCLK_MPEG2, 2);
1876static MESON_GATE(axg_usb1_to_ddr, HHI_GCLK_MPEG2, 8);
1877static MESON_GATE(axg_usb0_to_ddr, HHI_GCLK_MPEG2, 9);
1878static MESON_GATE(axg_mmc_pclk, HHI_GCLK_MPEG2, 11);
1879static MESON_GATE(axg_vpu_intr, HHI_GCLK_MPEG2, 25);
1880static MESON_GATE(axg_sec_ahb_ahb3_bridge, HHI_GCLK_MPEG2, 26);
1881static MESON_GATE(axg_gic, HHI_GCLK_MPEG2, 30);
1882
1883/* Always On (AO) domain gates */
1884
1885static MESON_GATE(axg_ao_media_cpu, HHI_GCLK_AO, 0);
1886static MESON_GATE(axg_ao_ahb_sram, HHI_GCLK_AO, 1);
1887static MESON_GATE(axg_ao_ahb_bus, HHI_GCLK_AO, 2);
1888static MESON_GATE(axg_ao_iface, HHI_GCLK_AO, 3);
1889static MESON_GATE(axg_ao_i2c, HHI_GCLK_AO, 4);
1890
1891/* Array of all clocks provided by this provider */
1892
1893static struct clk_hw_onecell_data axg_hw_onecell_data = {
1894	.hws = {
1895		[CLKID_SYS_PLL]			= &axg_sys_pll.hw,
1896		[CLKID_FIXED_PLL]		= &axg_fixed_pll.hw,
1897		[CLKID_FCLK_DIV2]		= &axg_fclk_div2.hw,
1898		[CLKID_FCLK_DIV3]		= &axg_fclk_div3.hw,
1899		[CLKID_FCLK_DIV4]		= &axg_fclk_div4.hw,
1900		[CLKID_FCLK_DIV5]		= &axg_fclk_div5.hw,
1901		[CLKID_FCLK_DIV7]		= &axg_fclk_div7.hw,
1902		[CLKID_GP0_PLL]			= &axg_gp0_pll.hw,
1903		[CLKID_MPEG_SEL]		= &axg_mpeg_clk_sel.hw,
1904		[CLKID_MPEG_DIV]		= &axg_mpeg_clk_div.hw,
1905		[CLKID_CLK81]			= &axg_clk81.hw,
1906		[CLKID_MPLL0]			= &axg_mpll0.hw,
1907		[CLKID_MPLL1]			= &axg_mpll1.hw,
1908		[CLKID_MPLL2]			= &axg_mpll2.hw,
1909		[CLKID_MPLL3]			= &axg_mpll3.hw,
1910		[CLKID_DDR]			= &axg_ddr.hw,
1911		[CLKID_AUDIO_LOCKER]		= &axg_audio_locker.hw,
1912		[CLKID_MIPI_DSI_HOST]		= &axg_mipi_dsi_host.hw,
1913		[CLKID_ISA]			= &axg_isa.hw,
1914		[CLKID_PL301]			= &axg_pl301.hw,
1915		[CLKID_PERIPHS]			= &axg_periphs.hw,
1916		[CLKID_SPICC0]			= &axg_spicc_0.hw,
1917		[CLKID_I2C]			= &axg_i2c.hw,
1918		[CLKID_RNG0]			= &axg_rng0.hw,
1919		[CLKID_UART0]			= &axg_uart0.hw,
1920		[CLKID_MIPI_DSI_PHY]		= &axg_mipi_dsi_phy.hw,
1921		[CLKID_SPICC1]			= &axg_spicc_1.hw,
1922		[CLKID_PCIE_A]			= &axg_pcie_a.hw,
1923		[CLKID_PCIE_B]			= &axg_pcie_b.hw,
1924		[CLKID_HIU_IFACE]		= &axg_hiu_reg.hw,
1925		[CLKID_ASSIST_MISC]		= &axg_assist_misc.hw,
1926		[CLKID_SD_EMMC_B]		= &axg_emmc_b.hw,
1927		[CLKID_SD_EMMC_C]		= &axg_emmc_c.hw,
1928		[CLKID_DMA]			= &axg_dma.hw,
1929		[CLKID_SPI]			= &axg_spi.hw,
1930		[CLKID_AUDIO]			= &axg_audio.hw,
1931		[CLKID_ETH]			= &axg_eth_core.hw,
1932		[CLKID_UART1]			= &axg_uart1.hw,
1933		[CLKID_G2D]			= &axg_g2d.hw,
1934		[CLKID_USB0]			= &axg_usb0.hw,
1935		[CLKID_USB1]			= &axg_usb1.hw,
1936		[CLKID_RESET]			= &axg_reset.hw,
1937		[CLKID_USB]			= &axg_usb_general.hw,
1938		[CLKID_AHB_ARB0]		= &axg_ahb_arb0.hw,
1939		[CLKID_EFUSE]			= &axg_efuse.hw,
1940		[CLKID_BOOT_ROM]		= &axg_boot_rom.hw,
1941		[CLKID_AHB_DATA_BUS]		= &axg_ahb_data_bus.hw,
1942		[CLKID_AHB_CTRL_BUS]		= &axg_ahb_ctrl_bus.hw,
1943		[CLKID_USB1_DDR_BRIDGE]		= &axg_usb1_to_ddr.hw,
1944		[CLKID_USB0_DDR_BRIDGE]		= &axg_usb0_to_ddr.hw,
1945		[CLKID_MMC_PCLK]		= &axg_mmc_pclk.hw,
1946		[CLKID_VPU_INTR]		= &axg_vpu_intr.hw,
1947		[CLKID_SEC_AHB_AHB3_BRIDGE]	= &axg_sec_ahb_ahb3_bridge.hw,
1948		[CLKID_GIC]			= &axg_gic.hw,
1949		[CLKID_AO_MEDIA_CPU]		= &axg_ao_media_cpu.hw,
1950		[CLKID_AO_AHB_SRAM]		= &axg_ao_ahb_sram.hw,
1951		[CLKID_AO_AHB_BUS]		= &axg_ao_ahb_bus.hw,
1952		[CLKID_AO_IFACE]		= &axg_ao_iface.hw,
1953		[CLKID_AO_I2C]			= &axg_ao_i2c.hw,
1954		[CLKID_SD_EMMC_B_CLK0_SEL]	= &axg_sd_emmc_b_clk0_sel.hw,
1955		[CLKID_SD_EMMC_B_CLK0_DIV]	= &axg_sd_emmc_b_clk0_div.hw,
1956		[CLKID_SD_EMMC_B_CLK0]		= &axg_sd_emmc_b_clk0.hw,
1957		[CLKID_SD_EMMC_C_CLK0_SEL]	= &axg_sd_emmc_c_clk0_sel.hw,
1958		[CLKID_SD_EMMC_C_CLK0_DIV]	= &axg_sd_emmc_c_clk0_div.hw,
1959		[CLKID_SD_EMMC_C_CLK0]		= &axg_sd_emmc_c_clk0.hw,
1960		[CLKID_MPLL0_DIV]		= &axg_mpll0_div.hw,
1961		[CLKID_MPLL1_DIV]		= &axg_mpll1_div.hw,
1962		[CLKID_MPLL2_DIV]		= &axg_mpll2_div.hw,
1963		[CLKID_MPLL3_DIV]		= &axg_mpll3_div.hw,
1964		[CLKID_HIFI_PLL]		= &axg_hifi_pll.hw,
1965		[CLKID_MPLL_PREDIV]		= &axg_mpll_prediv.hw,
1966		[CLKID_FCLK_DIV2_DIV]		= &axg_fclk_div2_div.hw,
1967		[CLKID_FCLK_DIV3_DIV]		= &axg_fclk_div3_div.hw,
1968		[CLKID_FCLK_DIV4_DIV]		= &axg_fclk_div4_div.hw,
1969		[CLKID_FCLK_DIV5_DIV]		= &axg_fclk_div5_div.hw,
1970		[CLKID_FCLK_DIV7_DIV]		= &axg_fclk_div7_div.hw,
1971		[CLKID_PCIE_PLL]		= &axg_pcie_pll.hw,
1972		[CLKID_PCIE_MUX]		= &axg_pcie_mux.hw,
1973		[CLKID_PCIE_REF]		= &axg_pcie_ref.hw,
1974		[CLKID_PCIE_CML_EN0]		= &axg_pcie_cml_en0.hw,
1975		[CLKID_PCIE_CML_EN1]		= &axg_pcie_cml_en1.hw,
1976		[CLKID_GEN_CLK_SEL]		= &axg_gen_clk_sel.hw,
1977		[CLKID_GEN_CLK_DIV]		= &axg_gen_clk_div.hw,
1978		[CLKID_GEN_CLK]			= &axg_gen_clk.hw,
1979		[CLKID_SYS_PLL_DCO]		= &axg_sys_pll_dco.hw,
1980		[CLKID_FIXED_PLL_DCO]		= &axg_fixed_pll_dco.hw,
1981		[CLKID_GP0_PLL_DCO]		= &axg_gp0_pll_dco.hw,
1982		[CLKID_HIFI_PLL_DCO]		= &axg_hifi_pll_dco.hw,
1983		[CLKID_PCIE_PLL_DCO]		= &axg_pcie_pll_dco.hw,
1984		[CLKID_PCIE_PLL_OD]		= &axg_pcie_pll_od.hw,
1985		[CLKID_VPU_0_DIV]		= &axg_vpu_0_div.hw,
1986		[CLKID_VPU_0_SEL]		= &axg_vpu_0_sel.hw,
1987		[CLKID_VPU_0]			= &axg_vpu_0.hw,
1988		[CLKID_VPU_1_DIV]		= &axg_vpu_1_div.hw,
1989		[CLKID_VPU_1_SEL]		= &axg_vpu_1_sel.hw,
1990		[CLKID_VPU_1]			= &axg_vpu_1.hw,
1991		[CLKID_VPU]			= &axg_vpu.hw,
1992		[CLKID_VAPB_0_DIV]		= &axg_vapb_0_div.hw,
1993		[CLKID_VAPB_0_SEL]		= &axg_vapb_0_sel.hw,
1994		[CLKID_VAPB_0]			= &axg_vapb_0.hw,
1995		[CLKID_VAPB_1_DIV]		= &axg_vapb_1_div.hw,
1996		[CLKID_VAPB_1_SEL]		= &axg_vapb_1_sel.hw,
1997		[CLKID_VAPB_1]			= &axg_vapb_1.hw,
1998		[CLKID_VAPB_SEL]		= &axg_vapb_sel.hw,
1999		[CLKID_VAPB]			= &axg_vapb.hw,
2000		[CLKID_VCLK]			= &axg_vclk.hw,
2001		[CLKID_VCLK2]			= &axg_vclk2.hw,
2002		[CLKID_VCLK_SEL]		= &axg_vclk_sel.hw,
2003		[CLKID_VCLK2_SEL]		= &axg_vclk2_sel.hw,
2004		[CLKID_VCLK_INPUT]		= &axg_vclk_input.hw,
2005		[CLKID_VCLK2_INPUT]		= &axg_vclk2_input.hw,
2006		[CLKID_VCLK_DIV]		= &axg_vclk_div.hw,
2007		[CLKID_VCLK2_DIV]		= &axg_vclk2_div.hw,
2008		[CLKID_VCLK_DIV2_EN]		= &axg_vclk_div2_en.hw,
2009		[CLKID_VCLK_DIV4_EN]		= &axg_vclk_div4_en.hw,
2010		[CLKID_VCLK_DIV6_EN]		= &axg_vclk_div6_en.hw,
2011		[CLKID_VCLK_DIV12_EN]		= &axg_vclk_div12_en.hw,
2012		[CLKID_VCLK2_DIV2_EN]		= &axg_vclk2_div2_en.hw,
2013		[CLKID_VCLK2_DIV4_EN]		= &axg_vclk2_div4_en.hw,
2014		[CLKID_VCLK2_DIV6_EN]		= &axg_vclk2_div6_en.hw,
2015		[CLKID_VCLK2_DIV12_EN]		= &axg_vclk2_div12_en.hw,
2016		[CLKID_VCLK_DIV1]		= &axg_vclk_div1.hw,
2017		[CLKID_VCLK_DIV2]		= &axg_vclk_div2.hw,
2018		[CLKID_VCLK_DIV4]		= &axg_vclk_div4.hw,
2019		[CLKID_VCLK_DIV6]		= &axg_vclk_div6.hw,
2020		[CLKID_VCLK_DIV12]		= &axg_vclk_div12.hw,
2021		[CLKID_VCLK2_DIV1]		= &axg_vclk2_div1.hw,
2022		[CLKID_VCLK2_DIV2]		= &axg_vclk2_div2.hw,
2023		[CLKID_VCLK2_DIV4]		= &axg_vclk2_div4.hw,
2024		[CLKID_VCLK2_DIV6]		= &axg_vclk2_div6.hw,
2025		[CLKID_VCLK2_DIV12]		= &axg_vclk2_div12.hw,
2026		[CLKID_CTS_ENCL_SEL]		= &axg_cts_encl_sel.hw,
2027		[CLKID_CTS_ENCL]		= &axg_cts_encl.hw,
2028		[CLKID_VDIN_MEAS_SEL]		= &axg_vdin_meas_sel.hw,
2029		[CLKID_VDIN_MEAS_DIV]		= &axg_vdin_meas_div.hw,
2030		[CLKID_VDIN_MEAS]		= &axg_vdin_meas.hw,
2031		[NR_CLKS]			= NULL,
2032	},
2033	.num = NR_CLKS,
2034};
2035
2036/* Convenience table to populate regmap in .probe */
2037static struct clk_regmap *const axg_clk_regmaps[] = {
2038	&axg_clk81,
2039	&axg_ddr,
2040	&axg_audio_locker,
2041	&axg_mipi_dsi_host,
2042	&axg_isa,
2043	&axg_pl301,
2044	&axg_periphs,
2045	&axg_spicc_0,
2046	&axg_i2c,
2047	&axg_rng0,
2048	&axg_uart0,
2049	&axg_mipi_dsi_phy,
2050	&axg_spicc_1,
2051	&axg_pcie_a,
2052	&axg_pcie_b,
2053	&axg_hiu_reg,
2054	&axg_assist_misc,
2055	&axg_emmc_b,
2056	&axg_emmc_c,
2057	&axg_dma,
2058	&axg_spi,
2059	&axg_audio,
2060	&axg_eth_core,
2061	&axg_uart1,
2062	&axg_g2d,
2063	&axg_usb0,
2064	&axg_usb1,
2065	&axg_reset,
2066	&axg_usb_general,
2067	&axg_ahb_arb0,
2068	&axg_efuse,
2069	&axg_boot_rom,
2070	&axg_ahb_data_bus,
2071	&axg_ahb_ctrl_bus,
2072	&axg_usb1_to_ddr,
2073	&axg_usb0_to_ddr,
2074	&axg_mmc_pclk,
2075	&axg_vpu_intr,
2076	&axg_sec_ahb_ahb3_bridge,
2077	&axg_gic,
2078	&axg_ao_media_cpu,
2079	&axg_ao_ahb_sram,
2080	&axg_ao_ahb_bus,
2081	&axg_ao_iface,
2082	&axg_ao_i2c,
2083	&axg_sd_emmc_b_clk0,
2084	&axg_sd_emmc_c_clk0,
2085	&axg_mpeg_clk_div,
2086	&axg_sd_emmc_b_clk0_div,
2087	&axg_sd_emmc_c_clk0_div,
2088	&axg_mpeg_clk_sel,
2089	&axg_sd_emmc_b_clk0_sel,
2090	&axg_sd_emmc_c_clk0_sel,
2091	&axg_mpll0,
2092	&axg_mpll1,
2093	&axg_mpll2,
2094	&axg_mpll3,
2095	&axg_mpll0_div,
2096	&axg_mpll1_div,
2097	&axg_mpll2_div,
2098	&axg_mpll3_div,
2099	&axg_fixed_pll,
2100	&axg_sys_pll,
2101	&axg_gp0_pll,
2102	&axg_hifi_pll,
2103	&axg_mpll_prediv,
2104	&axg_fclk_div2,
2105	&axg_fclk_div3,
2106	&axg_fclk_div4,
2107	&axg_fclk_div5,
2108	&axg_fclk_div7,
2109	&axg_pcie_pll_dco,
2110	&axg_pcie_pll_od,
2111	&axg_pcie_pll,
2112	&axg_pcie_mux,
2113	&axg_pcie_ref,
2114	&axg_pcie_cml_en0,
2115	&axg_pcie_cml_en1,
2116	&axg_gen_clk_sel,
2117	&axg_gen_clk_div,
2118	&axg_gen_clk,
2119	&axg_fixed_pll_dco,
2120	&axg_sys_pll_dco,
2121	&axg_gp0_pll_dco,
2122	&axg_hifi_pll_dco,
2123	&axg_pcie_pll_dco,
2124	&axg_pcie_pll_od,
2125	&axg_vpu_0_div,
2126	&axg_vpu_0_sel,
2127	&axg_vpu_0,
2128	&axg_vpu_1_div,
2129	&axg_vpu_1_sel,
2130	&axg_vpu_1,
2131	&axg_vpu,
2132	&axg_vapb_0_div,
2133	&axg_vapb_0_sel,
2134	&axg_vapb_0,
2135	&axg_vapb_1_div,
2136	&axg_vapb_1_sel,
2137	&axg_vapb_1,
2138	&axg_vapb_sel,
2139	&axg_vapb,
2140	&axg_vclk,
2141	&axg_vclk2,
2142	&axg_vclk_sel,
2143	&axg_vclk2_sel,
2144	&axg_vclk_input,
2145	&axg_vclk2_input,
2146	&axg_vclk_div,
2147	&axg_vclk2_div,
2148	&axg_vclk_div2_en,
2149	&axg_vclk_div4_en,
2150	&axg_vclk_div6_en,
2151	&axg_vclk_div12_en,
2152	&axg_vclk2_div2_en,
2153	&axg_vclk2_div4_en,
2154	&axg_vclk2_div6_en,
2155	&axg_vclk2_div12_en,
2156	&axg_cts_encl_sel,
2157	&axg_cts_encl,
2158	&axg_vdin_meas_sel,
2159	&axg_vdin_meas_div,
2160	&axg_vdin_meas,
2161};
2162
2163static const struct meson_eeclkc_data axg_clkc_data = {
2164	.regmap_clks = axg_clk_regmaps,
2165	.regmap_clk_num = ARRAY_SIZE(axg_clk_regmaps),
2166	.hw_onecell_data = &axg_hw_onecell_data,
 
 
 
2167};
2168
2169
2170static const struct of_device_id clkc_match_table[] = {
2171	{ .compatible = "amlogic,axg-clkc", .data = &axg_clkc_data },
2172	{}
2173};
2174MODULE_DEVICE_TABLE(of, clkc_match_table);
2175
2176static struct platform_driver axg_driver = {
2177	.probe		= meson_eeclkc_probe,
2178	.driver		= {
2179		.name	= "axg-clkc",
2180		.of_match_table = clkc_match_table,
2181	},
2182};
2183
2184module_platform_driver(axg_driver);
2185MODULE_LICENSE("GPL v2");