18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Ingenic JZ4780 SoC CGU driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2013-2015 Imagination Technologies 68c2ecf20Sopenharmony_ci * Author: Paul Burton <paul.burton@mips.com> 78c2ecf20Sopenharmony_ci * Copyright (c) 2020 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 118c2ecf20Sopenharmony_ci#include <linux/delay.h> 128c2ecf20Sopenharmony_ci#include <linux/io.h> 138c2ecf20Sopenharmony_ci#include <linux/iopoll.h> 148c2ecf20Sopenharmony_ci#include <linux/of.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <dt-bindings/clock/jz4780-cgu.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include "cgu.h" 198c2ecf20Sopenharmony_ci#include "pm.h" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* CGU register offsets */ 228c2ecf20Sopenharmony_ci#define CGU_REG_CLOCKCONTROL 0x00 238c2ecf20Sopenharmony_ci#define CGU_REG_LCR 0x04 248c2ecf20Sopenharmony_ci#define CGU_REG_APLL 0x10 258c2ecf20Sopenharmony_ci#define CGU_REG_MPLL 0x14 268c2ecf20Sopenharmony_ci#define CGU_REG_EPLL 0x18 278c2ecf20Sopenharmony_ci#define CGU_REG_VPLL 0x1c 288c2ecf20Sopenharmony_ci#define CGU_REG_CLKGR0 0x20 298c2ecf20Sopenharmony_ci#define CGU_REG_OPCR 0x24 308c2ecf20Sopenharmony_ci#define CGU_REG_CLKGR1 0x28 318c2ecf20Sopenharmony_ci#define CGU_REG_DDRCDR 0x2c 328c2ecf20Sopenharmony_ci#define CGU_REG_VPUCDR 0x30 338c2ecf20Sopenharmony_ci#define CGU_REG_USBPCR 0x3c 348c2ecf20Sopenharmony_ci#define CGU_REG_USBRDT 0x40 358c2ecf20Sopenharmony_ci#define CGU_REG_USBVBFIL 0x44 368c2ecf20Sopenharmony_ci#define CGU_REG_USBPCR1 0x48 378c2ecf20Sopenharmony_ci#define CGU_REG_LP0CDR 0x54 388c2ecf20Sopenharmony_ci#define CGU_REG_I2SCDR 0x60 398c2ecf20Sopenharmony_ci#define CGU_REG_LP1CDR 0x64 408c2ecf20Sopenharmony_ci#define CGU_REG_MSC0CDR 0x68 418c2ecf20Sopenharmony_ci#define CGU_REG_UHCCDR 0x6c 428c2ecf20Sopenharmony_ci#define CGU_REG_SSICDR 0x74 438c2ecf20Sopenharmony_ci#define CGU_REG_CIMCDR 0x7c 448c2ecf20Sopenharmony_ci#define CGU_REG_PCMCDR 0x84 458c2ecf20Sopenharmony_ci#define CGU_REG_GPUCDR 0x88 468c2ecf20Sopenharmony_ci#define CGU_REG_HDMICDR 0x8c 478c2ecf20Sopenharmony_ci#define CGU_REG_MSC1CDR 0xa4 488c2ecf20Sopenharmony_ci#define CGU_REG_MSC2CDR 0xa8 498c2ecf20Sopenharmony_ci#define CGU_REG_BCHCDR 0xac 508c2ecf20Sopenharmony_ci#define CGU_REG_CLOCKSTATUS 0xd4 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* bits within the OPCR register */ 538c2ecf20Sopenharmony_ci#define OPCR_SPENDN0 BIT(7) 548c2ecf20Sopenharmony_ci#define OPCR_SPENDN1 BIT(6) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* bits within the USBPCR register */ 578c2ecf20Sopenharmony_ci#define USBPCR_USB_MODE BIT(31) 588c2ecf20Sopenharmony_ci#define USBPCR_IDPULLUP_MASK (0x3 << 28) 598c2ecf20Sopenharmony_ci#define USBPCR_COMMONONN BIT(25) 608c2ecf20Sopenharmony_ci#define USBPCR_VBUSVLDEXT BIT(24) 618c2ecf20Sopenharmony_ci#define USBPCR_VBUSVLDEXTSEL BIT(23) 628c2ecf20Sopenharmony_ci#define USBPCR_POR BIT(22) 638c2ecf20Sopenharmony_ci#define USBPCR_SIDDQ BIT(21) 648c2ecf20Sopenharmony_ci#define USBPCR_OTG_DISABLE BIT(20) 658c2ecf20Sopenharmony_ci#define USBPCR_COMPDISTUNE_MASK (0x7 << 17) 668c2ecf20Sopenharmony_ci#define USBPCR_OTGTUNE_MASK (0x7 << 14) 678c2ecf20Sopenharmony_ci#define USBPCR_SQRXTUNE_MASK (0x7 << 11) 688c2ecf20Sopenharmony_ci#define USBPCR_TXFSLSTUNE_MASK (0xf << 7) 698c2ecf20Sopenharmony_ci#define USBPCR_TXPREEMPHTUNE BIT(6) 708c2ecf20Sopenharmony_ci#define USBPCR_TXHSXVTUNE_MASK (0x3 << 4) 718c2ecf20Sopenharmony_ci#define USBPCR_TXVREFTUNE_MASK 0xf 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* bits within the USBPCR1 register */ 748c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKSEL_SHIFT 26 758c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKSEL_MASK (0x3 << USBPCR1_REFCLKSEL_SHIFT) 768c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKSEL_CORE (0x2 << USBPCR1_REFCLKSEL_SHIFT) 778c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_SHIFT 24 788c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_MASK (0x3 << USBPCR1_REFCLKDIV_SHIFT) 798c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_19_2 (0x3 << USBPCR1_REFCLKDIV_SHIFT) 808c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_48 (0x2 << USBPCR1_REFCLKDIV_SHIFT) 818c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_24 (0x1 << USBPCR1_REFCLKDIV_SHIFT) 828c2ecf20Sopenharmony_ci#define USBPCR1_REFCLKDIV_12 (0x0 << USBPCR1_REFCLKDIV_SHIFT) 838c2ecf20Sopenharmony_ci#define USBPCR1_USB_SEL BIT(28) 848c2ecf20Sopenharmony_ci#define USBPCR1_WORD_IF0 BIT(19) 858c2ecf20Sopenharmony_ci#define USBPCR1_WORD_IF1 BIT(18) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* bits within the USBRDT register */ 888c2ecf20Sopenharmony_ci#define USBRDT_VBFIL_LD_EN BIT(25) 898c2ecf20Sopenharmony_ci#define USBRDT_USBRDT_MASK 0x7fffff 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* bits within the USBVBFIL register */ 928c2ecf20Sopenharmony_ci#define USBVBFIL_IDDIGFIL_SHIFT 16 938c2ecf20Sopenharmony_ci#define USBVBFIL_IDDIGFIL_MASK (0xffff << USBVBFIL_IDDIGFIL_SHIFT) 948c2ecf20Sopenharmony_ci#define USBVBFIL_USBVBFIL_MASK (0xffff) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* bits within the LCR register */ 978c2ecf20Sopenharmony_ci#define LCR_PD_SCPU BIT(31) 988c2ecf20Sopenharmony_ci#define LCR_SCPUS BIT(27) 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/* bits within the CLKGR1 register */ 1018c2ecf20Sopenharmony_ci#define CLKGR1_CORE1 BIT(15) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic struct ingenic_cgu *cgu; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic unsigned long jz4780_otg_phy_recalc_rate(struct clk_hw *hw, 1068c2ecf20Sopenharmony_ci unsigned long parent_rate) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci u32 usbpcr1; 1098c2ecf20Sopenharmony_ci unsigned refclk_div; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); 1128c2ecf20Sopenharmony_ci refclk_div = usbpcr1 & USBPCR1_REFCLKDIV_MASK; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci switch (refclk_div) { 1158c2ecf20Sopenharmony_ci case USBPCR1_REFCLKDIV_12: 1168c2ecf20Sopenharmony_ci return 12000000; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci case USBPCR1_REFCLKDIV_24: 1198c2ecf20Sopenharmony_ci return 24000000; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci case USBPCR1_REFCLKDIV_48: 1228c2ecf20Sopenharmony_ci return 48000000; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci case USBPCR1_REFCLKDIV_19_2: 1258c2ecf20Sopenharmony_ci return 19200000; 1268c2ecf20Sopenharmony_ci } 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci return parent_rate; 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistatic long jz4780_otg_phy_round_rate(struct clk_hw *hw, unsigned long req_rate, 1328c2ecf20Sopenharmony_ci unsigned long *parent_rate) 1338c2ecf20Sopenharmony_ci{ 1348c2ecf20Sopenharmony_ci if (req_rate < 15600000) 1358c2ecf20Sopenharmony_ci return 12000000; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci if (req_rate < 21600000) 1388c2ecf20Sopenharmony_ci return 19200000; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci if (req_rate < 36000000) 1418c2ecf20Sopenharmony_ci return 24000000; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci return 48000000; 1448c2ecf20Sopenharmony_ci} 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistatic int jz4780_otg_phy_set_rate(struct clk_hw *hw, unsigned long req_rate, 1478c2ecf20Sopenharmony_ci unsigned long parent_rate) 1488c2ecf20Sopenharmony_ci{ 1498c2ecf20Sopenharmony_ci unsigned long flags; 1508c2ecf20Sopenharmony_ci u32 usbpcr1, div_bits; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci switch (req_rate) { 1538c2ecf20Sopenharmony_ci case 12000000: 1548c2ecf20Sopenharmony_ci div_bits = USBPCR1_REFCLKDIV_12; 1558c2ecf20Sopenharmony_ci break; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci case 19200000: 1588c2ecf20Sopenharmony_ci div_bits = USBPCR1_REFCLKDIV_19_2; 1598c2ecf20Sopenharmony_ci break; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci case 24000000: 1628c2ecf20Sopenharmony_ci div_bits = USBPCR1_REFCLKDIV_24; 1638c2ecf20Sopenharmony_ci break; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci case 48000000: 1668c2ecf20Sopenharmony_ci div_bits = USBPCR1_REFCLKDIV_48; 1678c2ecf20Sopenharmony_ci break; 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci default: 1708c2ecf20Sopenharmony_ci return -EINVAL; 1718c2ecf20Sopenharmony_ci } 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci spin_lock_irqsave(&cgu->lock, flags); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); 1768c2ecf20Sopenharmony_ci usbpcr1 &= ~USBPCR1_REFCLKDIV_MASK; 1778c2ecf20Sopenharmony_ci usbpcr1 |= div_bits; 1788c2ecf20Sopenharmony_ci writel(usbpcr1, cgu->base + CGU_REG_USBPCR1); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&cgu->lock, flags); 1818c2ecf20Sopenharmony_ci return 0; 1828c2ecf20Sopenharmony_ci} 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cistatic int jz4780_otg_phy_enable(struct clk_hw *hw) 1858c2ecf20Sopenharmony_ci{ 1868c2ecf20Sopenharmony_ci void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 1878c2ecf20Sopenharmony_ci void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci writel(readl(reg_opcr) | OPCR_SPENDN0, reg_opcr); 1908c2ecf20Sopenharmony_ci writel(readl(reg_usbpcr) & ~USBPCR_OTG_DISABLE & ~USBPCR_SIDDQ, reg_usbpcr); 1918c2ecf20Sopenharmony_ci return 0; 1928c2ecf20Sopenharmony_ci} 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic void jz4780_otg_phy_disable(struct clk_hw *hw) 1958c2ecf20Sopenharmony_ci{ 1968c2ecf20Sopenharmony_ci void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 1978c2ecf20Sopenharmony_ci void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci writel(readl(reg_opcr) & ~OPCR_SPENDN0, reg_opcr); 2008c2ecf20Sopenharmony_ci writel(readl(reg_usbpcr) | USBPCR_OTG_DISABLE | USBPCR_SIDDQ, reg_usbpcr); 2018c2ecf20Sopenharmony_ci} 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistatic int jz4780_otg_phy_is_enabled(struct clk_hw *hw) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 2068c2ecf20Sopenharmony_ci void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci return (readl(reg_opcr) & OPCR_SPENDN0) && 2098c2ecf20Sopenharmony_ci !(readl(reg_usbpcr) & USBPCR_SIDDQ) && 2108c2ecf20Sopenharmony_ci !(readl(reg_usbpcr) & USBPCR_OTG_DISABLE); 2118c2ecf20Sopenharmony_ci} 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_cistatic const struct clk_ops jz4780_otg_phy_ops = { 2148c2ecf20Sopenharmony_ci .recalc_rate = jz4780_otg_phy_recalc_rate, 2158c2ecf20Sopenharmony_ci .round_rate = jz4780_otg_phy_round_rate, 2168c2ecf20Sopenharmony_ci .set_rate = jz4780_otg_phy_set_rate, 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci .enable = jz4780_otg_phy_enable, 2198c2ecf20Sopenharmony_ci .disable = jz4780_otg_phy_disable, 2208c2ecf20Sopenharmony_ci .is_enabled = jz4780_otg_phy_is_enabled, 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistatic int jz4780_core1_enable(struct clk_hw *hw) 2248c2ecf20Sopenharmony_ci{ 2258c2ecf20Sopenharmony_ci struct ingenic_clk *ingenic_clk = to_ingenic_clk(hw); 2268c2ecf20Sopenharmony_ci struct ingenic_cgu *cgu = ingenic_clk->cgu; 2278c2ecf20Sopenharmony_ci const unsigned int timeout = 5000; 2288c2ecf20Sopenharmony_ci unsigned long flags; 2298c2ecf20Sopenharmony_ci int retval; 2308c2ecf20Sopenharmony_ci u32 lcr, clkgr1; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci spin_lock_irqsave(&cgu->lock, flags); 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci lcr = readl(cgu->base + CGU_REG_LCR); 2358c2ecf20Sopenharmony_ci lcr &= ~LCR_PD_SCPU; 2368c2ecf20Sopenharmony_ci writel(lcr, cgu->base + CGU_REG_LCR); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci clkgr1 = readl(cgu->base + CGU_REG_CLKGR1); 2398c2ecf20Sopenharmony_ci clkgr1 &= ~CLKGR1_CORE1; 2408c2ecf20Sopenharmony_ci writel(clkgr1, cgu->base + CGU_REG_CLKGR1); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&cgu->lock, flags); 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /* wait for the CPU to be powered up */ 2458c2ecf20Sopenharmony_ci retval = readl_poll_timeout(cgu->base + CGU_REG_LCR, lcr, 2468c2ecf20Sopenharmony_ci !(lcr & LCR_SCPUS), 10, timeout); 2478c2ecf20Sopenharmony_ci if (retval == -ETIMEDOUT) { 2488c2ecf20Sopenharmony_ci pr_err("%s: Wait for power up core1 timeout\n", __func__); 2498c2ecf20Sopenharmony_ci return retval; 2508c2ecf20Sopenharmony_ci } 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci return 0; 2538c2ecf20Sopenharmony_ci} 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_cistatic const struct clk_ops jz4780_core1_ops = { 2568c2ecf20Sopenharmony_ci .enable = jz4780_core1_enable, 2578c2ecf20Sopenharmony_ci}; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cistatic const s8 pll_od_encoding[16] = { 2608c2ecf20Sopenharmony_ci 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 2618c2ecf20Sopenharmony_ci 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistatic const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = { 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* External clocks */ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci [JZ4780_CLK_EXCLK] = { "ext", CGU_CLK_EXT }, 2698c2ecf20Sopenharmony_ci [JZ4780_CLK_RTCLK] = { "rtc", CGU_CLK_EXT }, 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci /* PLLs */ 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define DEF_PLL(name) { \ 2748c2ecf20Sopenharmony_ci .reg = CGU_REG_ ## name, \ 2758c2ecf20Sopenharmony_ci .rate_multiplier = 1, \ 2768c2ecf20Sopenharmony_ci .m_shift = 19, \ 2778c2ecf20Sopenharmony_ci .m_bits = 13, \ 2788c2ecf20Sopenharmony_ci .m_offset = 1, \ 2798c2ecf20Sopenharmony_ci .n_shift = 13, \ 2808c2ecf20Sopenharmony_ci .n_bits = 6, \ 2818c2ecf20Sopenharmony_ci .n_offset = 1, \ 2828c2ecf20Sopenharmony_ci .od_shift = 9, \ 2838c2ecf20Sopenharmony_ci .od_bits = 4, \ 2848c2ecf20Sopenharmony_ci .od_max = 16, \ 2858c2ecf20Sopenharmony_ci .od_encoding = pll_od_encoding, \ 2868c2ecf20Sopenharmony_ci .stable_bit = 6, \ 2878c2ecf20Sopenharmony_ci .bypass_reg = CGU_REG_ ## name, \ 2888c2ecf20Sopenharmony_ci .bypass_bit = 1, \ 2898c2ecf20Sopenharmony_ci .enable_bit = 0, \ 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci [JZ4780_CLK_APLL] = { 2938c2ecf20Sopenharmony_ci "apll", CGU_CLK_PLL, 2948c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 2958c2ecf20Sopenharmony_ci .pll = DEF_PLL(APLL), 2968c2ecf20Sopenharmony_ci }, 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci [JZ4780_CLK_MPLL] = { 2998c2ecf20Sopenharmony_ci "mpll", CGU_CLK_PLL, 3008c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 3018c2ecf20Sopenharmony_ci .pll = DEF_PLL(MPLL), 3028c2ecf20Sopenharmony_ci }, 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci [JZ4780_CLK_EPLL] = { 3058c2ecf20Sopenharmony_ci "epll", CGU_CLK_PLL, 3068c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 3078c2ecf20Sopenharmony_ci .pll = DEF_PLL(EPLL), 3088c2ecf20Sopenharmony_ci }, 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci [JZ4780_CLK_VPLL] = { 3118c2ecf20Sopenharmony_ci "vpll", CGU_CLK_PLL, 3128c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 3138c2ecf20Sopenharmony_ci .pll = DEF_PLL(VPLL), 3148c2ecf20Sopenharmony_ci }, 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#undef DEF_PLL 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci /* Custom (SoC-specific) OTG PHY */ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci [JZ4780_CLK_OTGPHY] = { 3218c2ecf20Sopenharmony_ci "otg_phy", CGU_CLK_CUSTOM, 3228c2ecf20Sopenharmony_ci .parents = { -1, -1, JZ4780_CLK_EXCLK, -1 }, 3238c2ecf20Sopenharmony_ci .custom = { &jz4780_otg_phy_ops }, 3248c2ecf20Sopenharmony_ci }, 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci /* Muxes & dividers */ 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci [JZ4780_CLK_SCLKA] = { 3298c2ecf20Sopenharmony_ci "sclk_a", CGU_CLK_MUX, 3308c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_APLL, JZ4780_CLK_EXCLK, 3318c2ecf20Sopenharmony_ci JZ4780_CLK_RTCLK }, 3328c2ecf20Sopenharmony_ci .mux = { CGU_REG_CLOCKCONTROL, 30, 2 }, 3338c2ecf20Sopenharmony_ci }, 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci [JZ4780_CLK_CPUMUX] = { 3368c2ecf20Sopenharmony_ci "cpumux", CGU_CLK_MUX, 3378c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 3388c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL }, 3398c2ecf20Sopenharmony_ci .mux = { CGU_REG_CLOCKCONTROL, 28, 2 }, 3408c2ecf20Sopenharmony_ci }, 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci [JZ4780_CLK_CPU] = { 3438c2ecf20Sopenharmony_ci "cpu", CGU_CLK_DIV, 3448c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 }, 3458c2ecf20Sopenharmony_ci .div = { CGU_REG_CLOCKCONTROL, 0, 1, 4, 22, -1, -1 }, 3468c2ecf20Sopenharmony_ci }, 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci [JZ4780_CLK_L2CACHE] = { 3498c2ecf20Sopenharmony_ci "l2cache", CGU_CLK_DIV, 3508c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_CPUMUX, -1, -1, -1 }, 3518c2ecf20Sopenharmony_ci .div = { CGU_REG_CLOCKCONTROL, 4, 1, 4, -1, -1, -1 }, 3528c2ecf20Sopenharmony_ci }, 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci [JZ4780_CLK_AHB0] = { 3558c2ecf20Sopenharmony_ci "ahb0", CGU_CLK_MUX | CGU_CLK_DIV, 3568c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 3578c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL }, 3588c2ecf20Sopenharmony_ci .mux = { CGU_REG_CLOCKCONTROL, 26, 2 }, 3598c2ecf20Sopenharmony_ci .div = { CGU_REG_CLOCKCONTROL, 8, 1, 4, 21, -1, -1 }, 3608c2ecf20Sopenharmony_ci }, 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci [JZ4780_CLK_AHB2PMUX] = { 3638c2ecf20Sopenharmony_ci "ahb2_apb_mux", CGU_CLK_MUX, 3648c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 3658c2ecf20Sopenharmony_ci JZ4780_CLK_RTCLK }, 3668c2ecf20Sopenharmony_ci .mux = { CGU_REG_CLOCKCONTROL, 24, 2 }, 3678c2ecf20Sopenharmony_ci }, 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci [JZ4780_CLK_AHB2] = { 3708c2ecf20Sopenharmony_ci "ahb2", CGU_CLK_DIV, 3718c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 }, 3728c2ecf20Sopenharmony_ci .div = { CGU_REG_CLOCKCONTROL, 12, 1, 4, 20, -1, -1 }, 3738c2ecf20Sopenharmony_ci }, 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci [JZ4780_CLK_PCLK] = { 3768c2ecf20Sopenharmony_ci "pclk", CGU_CLK_DIV, 3778c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_AHB2PMUX, -1, -1, -1 }, 3788c2ecf20Sopenharmony_ci .div = { CGU_REG_CLOCKCONTROL, 16, 1, 4, 20, -1, -1 }, 3798c2ecf20Sopenharmony_ci }, 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci [JZ4780_CLK_DDR] = { 3828c2ecf20Sopenharmony_ci "ddr", CGU_CLK_MUX | CGU_CLK_DIV, 3838c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1 }, 3848c2ecf20Sopenharmony_ci .mux = { CGU_REG_DDRCDR, 30, 2 }, 3858c2ecf20Sopenharmony_ci .div = { CGU_REG_DDRCDR, 0, 1, 4, 29, 28, 27 }, 3868c2ecf20Sopenharmony_ci }, 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci [JZ4780_CLK_VPU] = { 3898c2ecf20Sopenharmony_ci "vpu", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 3908c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 3918c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL, -1 }, 3928c2ecf20Sopenharmony_ci .mux = { CGU_REG_VPUCDR, 30, 2 }, 3938c2ecf20Sopenharmony_ci .div = { CGU_REG_VPUCDR, 0, 1, 4, 29, 28, 27 }, 3948c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 2 }, 3958c2ecf20Sopenharmony_ci }, 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci [JZ4780_CLK_I2SPLL] = { 3988c2ecf20Sopenharmony_ci "i2s_pll", CGU_CLK_MUX | CGU_CLK_DIV, 3998c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_EPLL, -1, -1 }, 4008c2ecf20Sopenharmony_ci .mux = { CGU_REG_I2SCDR, 30, 1 }, 4018c2ecf20Sopenharmony_ci .div = { CGU_REG_I2SCDR, 0, 1, 8, 29, 28, 27 }, 4028c2ecf20Sopenharmony_ci }, 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci [JZ4780_CLK_I2S] = { 4058c2ecf20Sopenharmony_ci "i2s", CGU_CLK_MUX, 4068c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, JZ4780_CLK_I2SPLL, -1, -1 }, 4078c2ecf20Sopenharmony_ci .mux = { CGU_REG_I2SCDR, 31, 1 }, 4088c2ecf20Sopenharmony_ci }, 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci [JZ4780_CLK_LCD0PIXCLK] = { 4118c2ecf20Sopenharmony_ci "lcd0pixclk", CGU_CLK_MUX | CGU_CLK_DIV, 4128c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 4138c2ecf20Sopenharmony_ci JZ4780_CLK_VPLL, -1 }, 4148c2ecf20Sopenharmony_ci .mux = { CGU_REG_LP0CDR, 30, 2 }, 4158c2ecf20Sopenharmony_ci .div = { CGU_REG_LP0CDR, 0, 1, 8, 28, 27, 26 }, 4168c2ecf20Sopenharmony_ci }, 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci [JZ4780_CLK_LCD1PIXCLK] = { 4198c2ecf20Sopenharmony_ci "lcd1pixclk", CGU_CLK_MUX | CGU_CLK_DIV, 4208c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 4218c2ecf20Sopenharmony_ci JZ4780_CLK_VPLL, -1 }, 4228c2ecf20Sopenharmony_ci .mux = { CGU_REG_LP1CDR, 30, 2 }, 4238c2ecf20Sopenharmony_ci .div = { CGU_REG_LP1CDR, 0, 1, 8, 28, 27, 26 }, 4248c2ecf20Sopenharmony_ci }, 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci [JZ4780_CLK_MSCMUX] = { 4278c2ecf20Sopenharmony_ci "msc_mux", CGU_CLK_MUX, 4288c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1 }, 4298c2ecf20Sopenharmony_ci .mux = { CGU_REG_MSC0CDR, 30, 2 }, 4308c2ecf20Sopenharmony_ci }, 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci [JZ4780_CLK_MSC0] = { 4338c2ecf20Sopenharmony_ci "msc0", CGU_CLK_DIV | CGU_CLK_GATE, 4348c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, 4358c2ecf20Sopenharmony_ci .div = { CGU_REG_MSC0CDR, 0, 2, 8, 29, 28, 27 }, 4368c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 3 }, 4378c2ecf20Sopenharmony_ci }, 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci [JZ4780_CLK_MSC1] = { 4408c2ecf20Sopenharmony_ci "msc1", CGU_CLK_DIV | CGU_CLK_GATE, 4418c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, 4428c2ecf20Sopenharmony_ci .div = { CGU_REG_MSC1CDR, 0, 2, 8, 29, 28, 27 }, 4438c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 11 }, 4448c2ecf20Sopenharmony_ci }, 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci [JZ4780_CLK_MSC2] = { 4478c2ecf20Sopenharmony_ci "msc2", CGU_CLK_DIV | CGU_CLK_GATE, 4488c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_MSCMUX, -1, -1, -1 }, 4498c2ecf20Sopenharmony_ci .div = { CGU_REG_MSC2CDR, 0, 2, 8, 29, 28, 27 }, 4508c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 12 }, 4518c2ecf20Sopenharmony_ci }, 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci [JZ4780_CLK_UHC] = { 4548c2ecf20Sopenharmony_ci "uhc", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 4558c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 4568c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL, JZ4780_CLK_OTGPHY }, 4578c2ecf20Sopenharmony_ci .mux = { CGU_REG_UHCCDR, 30, 2 }, 4588c2ecf20Sopenharmony_ci .div = { CGU_REG_UHCCDR, 0, 1, 8, 29, 28, 27 }, 4598c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 24 }, 4608c2ecf20Sopenharmony_ci }, 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci [JZ4780_CLK_SSIPLL] = { 4638c2ecf20Sopenharmony_ci "ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV, 4648c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 }, 4658c2ecf20Sopenharmony_ci .mux = { CGU_REG_SSICDR, 30, 1 }, 4668c2ecf20Sopenharmony_ci .div = { CGU_REG_SSICDR, 0, 1, 8, 29, 28, 27 }, 4678c2ecf20Sopenharmony_ci }, 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci [JZ4780_CLK_SSI] = { 4708c2ecf20Sopenharmony_ci "ssi", CGU_CLK_MUX, 4718c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, JZ4780_CLK_SSIPLL, -1, -1 }, 4728c2ecf20Sopenharmony_ci .mux = { CGU_REG_SSICDR, 31, 1 }, 4738c2ecf20Sopenharmony_ci }, 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci [JZ4780_CLK_CIMMCLK] = { 4768c2ecf20Sopenharmony_ci "cim_mclk", CGU_CLK_MUX | CGU_CLK_DIV, 4778c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, -1, -1 }, 4788c2ecf20Sopenharmony_ci .mux = { CGU_REG_CIMCDR, 31, 1 }, 4798c2ecf20Sopenharmony_ci .div = { CGU_REG_CIMCDR, 0, 1, 8, 30, 29, 28 }, 4808c2ecf20Sopenharmony_ci }, 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci [JZ4780_CLK_PCMPLL] = { 4838c2ecf20Sopenharmony_ci "pcm_pll", CGU_CLK_MUX | CGU_CLK_DIV, 4848c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 4858c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL, JZ4780_CLK_VPLL }, 4868c2ecf20Sopenharmony_ci .mux = { CGU_REG_PCMCDR, 29, 2 }, 4878c2ecf20Sopenharmony_ci .div = { CGU_REG_PCMCDR, 0, 1, 8, 28, 27, 26 }, 4888c2ecf20Sopenharmony_ci }, 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci [JZ4780_CLK_PCM] = { 4918c2ecf20Sopenharmony_ci "pcm", CGU_CLK_MUX | CGU_CLK_GATE, 4928c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, JZ4780_CLK_PCMPLL, -1, -1 }, 4938c2ecf20Sopenharmony_ci .mux = { CGU_REG_PCMCDR, 31, 1 }, 4948c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 3 }, 4958c2ecf20Sopenharmony_ci }, 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci [JZ4780_CLK_GPU] = { 4988c2ecf20Sopenharmony_ci "gpu", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 4998c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 5008c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL }, 5018c2ecf20Sopenharmony_ci .mux = { CGU_REG_GPUCDR, 30, 2 }, 5028c2ecf20Sopenharmony_ci .div = { CGU_REG_GPUCDR, 0, 1, 4, 29, 28, 27 }, 5038c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 4 }, 5048c2ecf20Sopenharmony_ci }, 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci [JZ4780_CLK_HDMI] = { 5078c2ecf20Sopenharmony_ci "hdmi", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 5088c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 5098c2ecf20Sopenharmony_ci JZ4780_CLK_VPLL, -1 }, 5108c2ecf20Sopenharmony_ci .mux = { CGU_REG_HDMICDR, 30, 2 }, 5118c2ecf20Sopenharmony_ci .div = { CGU_REG_HDMICDR, 0, 1, 8, 29, 28, 26 }, 5128c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 9 }, 5138c2ecf20Sopenharmony_ci }, 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci [JZ4780_CLK_BCH] = { 5168c2ecf20Sopenharmony_ci "bch", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 5178c2ecf20Sopenharmony_ci .parents = { -1, JZ4780_CLK_SCLKA, JZ4780_CLK_MPLL, 5188c2ecf20Sopenharmony_ci JZ4780_CLK_EPLL }, 5198c2ecf20Sopenharmony_ci .mux = { CGU_REG_BCHCDR, 30, 2 }, 5208c2ecf20Sopenharmony_ci .div = { CGU_REG_BCHCDR, 0, 1, 4, 29, 28, 27 }, 5218c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 1 }, 5228c2ecf20Sopenharmony_ci }, 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci [JZ4780_CLK_EXCLK_DIV512] = { 5258c2ecf20Sopenharmony_ci "exclk_div512", CGU_CLK_FIXDIV, 5268c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK }, 5278c2ecf20Sopenharmony_ci .fixdiv = { 512 }, 5288c2ecf20Sopenharmony_ci }, 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci [JZ4780_CLK_RTC] = { 5318c2ecf20Sopenharmony_ci "rtc_ercs", CGU_CLK_MUX | CGU_CLK_GATE, 5328c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK_DIV512, JZ4780_CLK_RTCLK }, 5338c2ecf20Sopenharmony_ci .mux = { CGU_REG_OPCR, 2, 1}, 5348c2ecf20Sopenharmony_ci }, 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci /* Gate-only clocks */ 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci [JZ4780_CLK_NEMC] = { 5398c2ecf20Sopenharmony_ci "nemc", CGU_CLK_GATE, 5408c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_AHB2, -1, -1, -1 }, 5418c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 0 }, 5428c2ecf20Sopenharmony_ci }, 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci [JZ4780_CLK_OTG0] = { 5458c2ecf20Sopenharmony_ci "otg0", CGU_CLK_GATE, 5468c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5478c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 2 }, 5488c2ecf20Sopenharmony_ci }, 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci [JZ4780_CLK_SSI0] = { 5518c2ecf20Sopenharmony_ci "ssi0", CGU_CLK_GATE, 5528c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SSI, -1, -1, -1 }, 5538c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 4 }, 5548c2ecf20Sopenharmony_ci }, 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci [JZ4780_CLK_SMB0] = { 5578c2ecf20Sopenharmony_ci "smb0", CGU_CLK_GATE, 5588c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_PCLK, -1, -1, -1 }, 5598c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 5 }, 5608c2ecf20Sopenharmony_ci }, 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci [JZ4780_CLK_SMB1] = { 5638c2ecf20Sopenharmony_ci "smb1", CGU_CLK_GATE, 5648c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_PCLK, -1, -1, -1 }, 5658c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 6 }, 5668c2ecf20Sopenharmony_ci }, 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci [JZ4780_CLK_SCC] = { 5698c2ecf20Sopenharmony_ci "scc", CGU_CLK_GATE, 5708c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5718c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 7 }, 5728c2ecf20Sopenharmony_ci }, 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci [JZ4780_CLK_AIC] = { 5758c2ecf20Sopenharmony_ci "aic", CGU_CLK_GATE, 5768c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5778c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 8 }, 5788c2ecf20Sopenharmony_ci }, 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci [JZ4780_CLK_TSSI0] = { 5818c2ecf20Sopenharmony_ci "tssi0", CGU_CLK_GATE, 5828c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5838c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 9 }, 5848c2ecf20Sopenharmony_ci }, 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci [JZ4780_CLK_OWI] = { 5878c2ecf20Sopenharmony_ci "owi", CGU_CLK_GATE, 5888c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5898c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 10 }, 5908c2ecf20Sopenharmony_ci }, 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci [JZ4780_CLK_KBC] = { 5938c2ecf20Sopenharmony_ci "kbc", CGU_CLK_GATE, 5948c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 5958c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 13 }, 5968c2ecf20Sopenharmony_ci }, 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci [JZ4780_CLK_SADC] = { 5998c2ecf20Sopenharmony_ci "sadc", CGU_CLK_GATE, 6008c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6018c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 14 }, 6028c2ecf20Sopenharmony_ci }, 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_ci [JZ4780_CLK_UART0] = { 6058c2ecf20Sopenharmony_ci "uart0", CGU_CLK_GATE, 6068c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6078c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 15 }, 6088c2ecf20Sopenharmony_ci }, 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci [JZ4780_CLK_UART1] = { 6118c2ecf20Sopenharmony_ci "uart1", CGU_CLK_GATE, 6128c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6138c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 16 }, 6148c2ecf20Sopenharmony_ci }, 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_ci [JZ4780_CLK_UART2] = { 6178c2ecf20Sopenharmony_ci "uart2", CGU_CLK_GATE, 6188c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6198c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 17 }, 6208c2ecf20Sopenharmony_ci }, 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci [JZ4780_CLK_UART3] = { 6238c2ecf20Sopenharmony_ci "uart3", CGU_CLK_GATE, 6248c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6258c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 18 }, 6268c2ecf20Sopenharmony_ci }, 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci [JZ4780_CLK_SSI1] = { 6298c2ecf20Sopenharmony_ci "ssi1", CGU_CLK_GATE, 6308c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SSI, -1, -1, -1 }, 6318c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 19 }, 6328c2ecf20Sopenharmony_ci }, 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_ci [JZ4780_CLK_SSI2] = { 6358c2ecf20Sopenharmony_ci "ssi2", CGU_CLK_GATE, 6368c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_SSI, -1, -1, -1 }, 6378c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 20 }, 6388c2ecf20Sopenharmony_ci }, 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci [JZ4780_CLK_PDMA] = { 6418c2ecf20Sopenharmony_ci "pdma", CGU_CLK_GATE, 6428c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6438c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 21 }, 6448c2ecf20Sopenharmony_ci }, 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci [JZ4780_CLK_GPS] = { 6478c2ecf20Sopenharmony_ci "gps", CGU_CLK_GATE, 6488c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6498c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 22 }, 6508c2ecf20Sopenharmony_ci }, 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci [JZ4780_CLK_MAC] = { 6538c2ecf20Sopenharmony_ci "mac", CGU_CLK_GATE, 6548c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6558c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 23 }, 6568c2ecf20Sopenharmony_ci }, 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci [JZ4780_CLK_SMB2] = { 6598c2ecf20Sopenharmony_ci "smb2", CGU_CLK_GATE, 6608c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_PCLK, -1, -1, -1 }, 6618c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 24 }, 6628c2ecf20Sopenharmony_ci }, 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci [JZ4780_CLK_CIM] = { 6658c2ecf20Sopenharmony_ci "cim", CGU_CLK_GATE, 6668c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6678c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 26 }, 6688c2ecf20Sopenharmony_ci }, 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci [JZ4780_CLK_LCD] = { 6718c2ecf20Sopenharmony_ci "lcd", CGU_CLK_GATE, 6728c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6738c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 28 }, 6748c2ecf20Sopenharmony_ci }, 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci [JZ4780_CLK_TVE] = { 6778c2ecf20Sopenharmony_ci "tve", CGU_CLK_GATE, 6788c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_LCD, -1, -1, -1 }, 6798c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 27 }, 6808c2ecf20Sopenharmony_ci }, 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci [JZ4780_CLK_IPU] = { 6838c2ecf20Sopenharmony_ci "ipu", CGU_CLK_GATE, 6848c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 6858c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 29 }, 6868c2ecf20Sopenharmony_ci }, 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci [JZ4780_CLK_DDR0] = { 6898c2ecf20Sopenharmony_ci "ddr0", CGU_CLK_GATE, 6908c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_DDR, -1, -1, -1 }, 6918c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 30 }, 6928c2ecf20Sopenharmony_ci }, 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci [JZ4780_CLK_DDR1] = { 6958c2ecf20Sopenharmony_ci "ddr1", CGU_CLK_GATE, 6968c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_DDR, -1, -1, -1 }, 6978c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR0, 31 }, 6988c2ecf20Sopenharmony_ci }, 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci [JZ4780_CLK_SMB3] = { 7018c2ecf20Sopenharmony_ci "smb3", CGU_CLK_GATE, 7028c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_PCLK, -1, -1, -1 }, 7038c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 0 }, 7048c2ecf20Sopenharmony_ci }, 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci [JZ4780_CLK_TSSI1] = { 7078c2ecf20Sopenharmony_ci "tssi1", CGU_CLK_GATE, 7088c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7098c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 1 }, 7108c2ecf20Sopenharmony_ci }, 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci [JZ4780_CLK_COMPRESS] = { 7138c2ecf20Sopenharmony_ci "compress", CGU_CLK_GATE, 7148c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7158c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 5 }, 7168c2ecf20Sopenharmony_ci }, 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ci [JZ4780_CLK_AIC1] = { 7198c2ecf20Sopenharmony_ci "aic1", CGU_CLK_GATE, 7208c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7218c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 6 }, 7228c2ecf20Sopenharmony_ci }, 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci [JZ4780_CLK_GPVLC] = { 7258c2ecf20Sopenharmony_ci "gpvlc", CGU_CLK_GATE, 7268c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7278c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 7 }, 7288c2ecf20Sopenharmony_ci }, 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci [JZ4780_CLK_OTG1] = { 7318c2ecf20Sopenharmony_ci "otg1", CGU_CLK_GATE, 7328c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7338c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 8 }, 7348c2ecf20Sopenharmony_ci }, 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci [JZ4780_CLK_UART4] = { 7378c2ecf20Sopenharmony_ci "uart4", CGU_CLK_GATE, 7388c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7398c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 10 }, 7408c2ecf20Sopenharmony_ci }, 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ci [JZ4780_CLK_AHBMON] = { 7438c2ecf20Sopenharmony_ci "ahb_mon", CGU_CLK_GATE, 7448c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7458c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 11 }, 7468c2ecf20Sopenharmony_ci }, 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_ci [JZ4780_CLK_SMB4] = { 7498c2ecf20Sopenharmony_ci "smb4", CGU_CLK_GATE, 7508c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_PCLK, -1, -1, -1 }, 7518c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 12 }, 7528c2ecf20Sopenharmony_ci }, 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci [JZ4780_CLK_DES] = { 7558c2ecf20Sopenharmony_ci "des", CGU_CLK_GATE, 7568c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7578c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 13 }, 7588c2ecf20Sopenharmony_ci }, 7598c2ecf20Sopenharmony_ci 7608c2ecf20Sopenharmony_ci [JZ4780_CLK_X2D] = { 7618c2ecf20Sopenharmony_ci "x2d", CGU_CLK_GATE, 7628c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_EXCLK, -1, -1, -1 }, 7638c2ecf20Sopenharmony_ci .gate = { CGU_REG_CLKGR1, 14 }, 7648c2ecf20Sopenharmony_ci }, 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci [JZ4780_CLK_CORE1] = { 7678c2ecf20Sopenharmony_ci "core1", CGU_CLK_CUSTOM, 7688c2ecf20Sopenharmony_ci .parents = { JZ4780_CLK_CPU, -1, -1, -1 }, 7698c2ecf20Sopenharmony_ci .custom = { &jz4780_core1_ops }, 7708c2ecf20Sopenharmony_ci }, 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ci}; 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_cistatic void __init jz4780_cgu_init(struct device_node *np) 7758c2ecf20Sopenharmony_ci{ 7768c2ecf20Sopenharmony_ci int retval; 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci cgu = ingenic_cgu_new(jz4780_cgu_clocks, 7798c2ecf20Sopenharmony_ci ARRAY_SIZE(jz4780_cgu_clocks), np); 7808c2ecf20Sopenharmony_ci if (!cgu) { 7818c2ecf20Sopenharmony_ci pr_err("%s: failed to initialise CGU\n", __func__); 7828c2ecf20Sopenharmony_ci return; 7838c2ecf20Sopenharmony_ci } 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci retval = ingenic_cgu_register_clocks(cgu); 7868c2ecf20Sopenharmony_ci if (retval) { 7878c2ecf20Sopenharmony_ci pr_err("%s: failed to register CGU Clocks\n", __func__); 7888c2ecf20Sopenharmony_ci return; 7898c2ecf20Sopenharmony_ci } 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci ingenic_cgu_register_syscore_ops(cgu); 7928c2ecf20Sopenharmony_ci} 7938c2ecf20Sopenharmony_ciCLK_OF_DECLARE_DRIVER(jz4780_cgu, "ingenic,jz4780-cgu", jz4780_cgu_init); 794