17a01c190SPaul Cercueil // SPDX-License-Identifier: GPL-2.0 27a01c190SPaul Cercueil /* 37a01c190SPaul Cercueil * JZ4770 SoC CGU driver 47a01c190SPaul Cercueil * Copyright 2018, Paul Cercueil <paul@crapouillou.net> 57a01c190SPaul Cercueil */ 67a01c190SPaul Cercueil 77a01c190SPaul Cercueil #include <linux/bitops.h> 87a01c190SPaul Cercueil #include <linux/clk-provider.h> 97a01c190SPaul Cercueil #include <linux/delay.h> 1062e59c4eSStephen Boyd #include <linux/io.h> 117a01c190SPaul Cercueil #include <linux/of.h> 129d9cc58aS周琰杰 (Zhou Yanjie) 13*c4a11bf4SPaul Cercueil #include <dt-bindings/clock/ingenic,jz4770-cgu.h> 149d9cc58aS周琰杰 (Zhou Yanjie) 157a01c190SPaul Cercueil #include "cgu.h" 162ee93e3cSPaul Cercueil #include "pm.h" 177a01c190SPaul Cercueil 187a01c190SPaul Cercueil /* 197a01c190SPaul Cercueil * CPM registers offset address definition 207a01c190SPaul Cercueil */ 217a01c190SPaul Cercueil #define CGU_REG_CPCCR 0x00 227a01c190SPaul Cercueil #define CGU_REG_LCR 0x04 237a01c190SPaul Cercueil #define CGU_REG_CPPCR0 0x10 247a01c190SPaul Cercueil #define CGU_REG_CLKGR0 0x20 257a01c190SPaul Cercueil #define CGU_REG_OPCR 0x24 267a01c190SPaul Cercueil #define CGU_REG_CLKGR1 0x28 277a01c190SPaul Cercueil #define CGU_REG_CPPCR1 0x30 287a01c190SPaul Cercueil #define CGU_REG_USBPCR1 0x48 297a01c190SPaul Cercueil #define CGU_REG_USBCDR 0x50 307a01c190SPaul Cercueil #define CGU_REG_I2SCDR 0x60 317a01c190SPaul Cercueil #define CGU_REG_LPCDR 0x64 327a01c190SPaul Cercueil #define CGU_REG_MSC0CDR 0x68 337a01c190SPaul Cercueil #define CGU_REG_UHCCDR 0x6c 347a01c190SPaul Cercueil #define CGU_REG_SSICDR 0x74 357a01c190SPaul Cercueil #define CGU_REG_CIMCDR 0x7c 367a01c190SPaul Cercueil #define CGU_REG_GPSCDR 0x80 377a01c190SPaul Cercueil #define CGU_REG_PCMCDR 0x84 387a01c190SPaul Cercueil #define CGU_REG_GPUCDR 0x88 397a01c190SPaul Cercueil #define CGU_REG_MSC1CDR 0xA4 407a01c190SPaul Cercueil #define CGU_REG_MSC2CDR 0xA8 417a01c190SPaul Cercueil #define CGU_REG_BCHCDR 0xAC 427a01c190SPaul Cercueil 437a01c190SPaul Cercueil /* bits within the OPCR register */ 447a01c190SPaul Cercueil #define OPCR_SPENDH BIT(5) /* UHC PHY suspend */ 457a01c190SPaul Cercueil 467a01c190SPaul Cercueil /* bits within the USBPCR1 register */ 477a01c190SPaul Cercueil #define USBPCR1_UHC_POWER BIT(5) /* UHC PHY power down */ 487a01c190SPaul Cercueil 497a01c190SPaul Cercueil static struct ingenic_cgu *cgu; 507a01c190SPaul Cercueil 517a01c190SPaul Cercueil static int jz4770_uhc_phy_enable(struct clk_hw *hw) 527a01c190SPaul Cercueil { 537a01c190SPaul Cercueil void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 547a01c190SPaul Cercueil void __iomem *reg_usbpcr1 = cgu->base + CGU_REG_USBPCR1; 557a01c190SPaul Cercueil 567a01c190SPaul Cercueil writel(readl(reg_opcr) & ~OPCR_SPENDH, reg_opcr); 577a01c190SPaul Cercueil writel(readl(reg_usbpcr1) | USBPCR1_UHC_POWER, reg_usbpcr1); 587a01c190SPaul Cercueil return 0; 597a01c190SPaul Cercueil } 607a01c190SPaul Cercueil 617a01c190SPaul Cercueil static void jz4770_uhc_phy_disable(struct clk_hw *hw) 627a01c190SPaul Cercueil { 637a01c190SPaul Cercueil void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 647a01c190SPaul Cercueil void __iomem *reg_usbpcr1 = cgu->base + CGU_REG_USBPCR1; 657a01c190SPaul Cercueil 667a01c190SPaul Cercueil writel(readl(reg_usbpcr1) & ~USBPCR1_UHC_POWER, reg_usbpcr1); 677a01c190SPaul Cercueil writel(readl(reg_opcr) | OPCR_SPENDH, reg_opcr); 687a01c190SPaul Cercueil } 697a01c190SPaul Cercueil 707a01c190SPaul Cercueil static int jz4770_uhc_phy_is_enabled(struct clk_hw *hw) 717a01c190SPaul Cercueil { 727a01c190SPaul Cercueil void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 737a01c190SPaul Cercueil void __iomem *reg_usbpcr1 = cgu->base + CGU_REG_USBPCR1; 747a01c190SPaul Cercueil 757a01c190SPaul Cercueil return !(readl(reg_opcr) & OPCR_SPENDH) && 767a01c190SPaul Cercueil (readl(reg_usbpcr1) & USBPCR1_UHC_POWER); 777a01c190SPaul Cercueil } 787a01c190SPaul Cercueil 797a01c190SPaul Cercueil static const struct clk_ops jz4770_uhc_phy_ops = { 807a01c190SPaul Cercueil .enable = jz4770_uhc_phy_enable, 817a01c190SPaul Cercueil .disable = jz4770_uhc_phy_disable, 827a01c190SPaul Cercueil .is_enabled = jz4770_uhc_phy_is_enabled, 837a01c190SPaul Cercueil }; 847a01c190SPaul Cercueil 857a01c190SPaul Cercueil static const s8 pll_od_encoding[8] = { 867a01c190SPaul Cercueil 0x0, 0x1, -1, 0x2, -1, -1, -1, 0x3, 877a01c190SPaul Cercueil }; 887a01c190SPaul Cercueil 8944b06a76SPaul Cercueil static const u8 jz4770_cgu_cpccr_div_table[] = { 9044b06a76SPaul Cercueil 1, 2, 3, 4, 6, 8, 12, 9144b06a76SPaul Cercueil }; 9244b06a76SPaul Cercueil 937a01c190SPaul Cercueil static const struct ingenic_cgu_clk_info jz4770_cgu_clocks[] = { 947a01c190SPaul Cercueil 957a01c190SPaul Cercueil /* External clocks */ 967a01c190SPaul Cercueil 977a01c190SPaul Cercueil [JZ4770_CLK_EXT] = { "ext", CGU_CLK_EXT }, 987a01c190SPaul Cercueil [JZ4770_CLK_OSC32K] = { "osc32k", CGU_CLK_EXT }, 997a01c190SPaul Cercueil 1007a01c190SPaul Cercueil /* PLLs */ 1017a01c190SPaul Cercueil 1027a01c190SPaul Cercueil [JZ4770_CLK_PLL0] = { 1037a01c190SPaul Cercueil "pll0", CGU_CLK_PLL, 1047a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT }, 1057a01c190SPaul Cercueil .pll = { 1067a01c190SPaul Cercueil .reg = CGU_REG_CPPCR0, 1079d9cc58aS周琰杰 (Zhou Yanjie) .rate_multiplier = 1, 1087a01c190SPaul Cercueil .m_shift = 24, 1097a01c190SPaul Cercueil .m_bits = 7, 1107a01c190SPaul Cercueil .m_offset = 1, 1117a01c190SPaul Cercueil .n_shift = 18, 1127a01c190SPaul Cercueil .n_bits = 5, 1137a01c190SPaul Cercueil .n_offset = 1, 1147a01c190SPaul Cercueil .od_shift = 16, 1157a01c190SPaul Cercueil .od_bits = 2, 1167a01c190SPaul Cercueil .od_max = 8, 1177a01c190SPaul Cercueil .od_encoding = pll_od_encoding, 1189d9cc58aS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR0, 1197a01c190SPaul Cercueil .bypass_bit = 9, 1207a01c190SPaul Cercueil .enable_bit = 8, 1217a01c190SPaul Cercueil .stable_bit = 10, 1227a01c190SPaul Cercueil }, 1237a01c190SPaul Cercueil }, 1247a01c190SPaul Cercueil 1257a01c190SPaul Cercueil [JZ4770_CLK_PLL1] = { 1267a01c190SPaul Cercueil /* TODO: PLL1 can depend on PLL0 */ 1277a01c190SPaul Cercueil "pll1", CGU_CLK_PLL, 1287a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT }, 1297a01c190SPaul Cercueil .pll = { 1307a01c190SPaul Cercueil .reg = CGU_REG_CPPCR1, 1319d9cc58aS周琰杰 (Zhou Yanjie) .rate_multiplier = 1, 1327a01c190SPaul Cercueil .m_shift = 24, 1337a01c190SPaul Cercueil .m_bits = 7, 1347a01c190SPaul Cercueil .m_offset = 1, 1357a01c190SPaul Cercueil .n_shift = 18, 1367a01c190SPaul Cercueil .n_bits = 5, 1377a01c190SPaul Cercueil .n_offset = 1, 1387a01c190SPaul Cercueil .od_shift = 16, 1397a01c190SPaul Cercueil .od_bits = 2, 1407a01c190SPaul Cercueil .od_max = 8, 1417a01c190SPaul Cercueil .od_encoding = pll_od_encoding, 142037f1ffdSPaul Cercueil .bypass_bit = -1, 1437a01c190SPaul Cercueil .enable_bit = 7, 1447a01c190SPaul Cercueil .stable_bit = 6, 1457a01c190SPaul Cercueil }, 1467a01c190SPaul Cercueil }, 1477a01c190SPaul Cercueil 1487a01c190SPaul Cercueil /* Main clocks */ 1497a01c190SPaul Cercueil 1507a01c190SPaul Cercueil [JZ4770_CLK_CCLK] = { 1517a01c190SPaul Cercueil "cclk", CGU_CLK_DIV, 1527a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 15344b06a76SPaul Cercueil .div = { 154249592bfSPaul Cercueil CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1, 0, 15544b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 15644b06a76SPaul Cercueil }, 1577a01c190SPaul Cercueil }, 1587a01c190SPaul Cercueil [JZ4770_CLK_H0CLK] = { 1597a01c190SPaul Cercueil "h0clk", CGU_CLK_DIV, 1607a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 16144b06a76SPaul Cercueil .div = { 162249592bfSPaul Cercueil CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1, 0, 16344b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 16444b06a76SPaul Cercueil }, 1657a01c190SPaul Cercueil }, 1667a01c190SPaul Cercueil [JZ4770_CLK_H1CLK] = { 1677a01c190SPaul Cercueil "h1clk", CGU_CLK_DIV | CGU_CLK_GATE, 1687a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 16944b06a76SPaul Cercueil .div = { 170249592bfSPaul Cercueil CGU_REG_CPCCR, 24, 1, 4, 22, -1, -1, 0, 17144b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 17244b06a76SPaul Cercueil }, 173a6523b6fSPaul Cercueil .gate = { CGU_REG_CLKGR1, 7 }, 1747a01c190SPaul Cercueil }, 1757a01c190SPaul Cercueil [JZ4770_CLK_H2CLK] = { 1767a01c190SPaul Cercueil "h2clk", CGU_CLK_DIV, 1777a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 17844b06a76SPaul Cercueil .div = { 179249592bfSPaul Cercueil CGU_REG_CPCCR, 16, 1, 4, 22, -1, -1, 0, 18044b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 18144b06a76SPaul Cercueil }, 1827a01c190SPaul Cercueil }, 1837a01c190SPaul Cercueil [JZ4770_CLK_C1CLK] = { 18445ba63a2SPaul Cercueil "c1clk", CGU_CLK_DIV | CGU_CLK_GATE, 1857a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 18644b06a76SPaul Cercueil .div = { 187249592bfSPaul Cercueil CGU_REG_CPCCR, 12, 1, 4, 22, -1, -1, 0, 18844b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 18944b06a76SPaul Cercueil }, 19045ba63a2SPaul Cercueil .gate = { CGU_REG_OPCR, 31, true }, // disable CCLK stop on idle 1917a01c190SPaul Cercueil }, 1927a01c190SPaul Cercueil [JZ4770_CLK_PCLK] = { 1937a01c190SPaul Cercueil "pclk", CGU_CLK_DIV, 1947a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, }, 19544b06a76SPaul Cercueil .div = { 196249592bfSPaul Cercueil CGU_REG_CPCCR, 8, 1, 4, 22, -1, -1, 0, 19744b06a76SPaul Cercueil jz4770_cgu_cpccr_div_table, 19844b06a76SPaul Cercueil }, 1997a01c190SPaul Cercueil }, 2007a01c190SPaul Cercueil 2017a01c190SPaul Cercueil /* Those divided clocks can connect to PLL0 or PLL1 */ 2027a01c190SPaul Cercueil 2037a01c190SPaul Cercueil [JZ4770_CLK_MMC0_MUX] = { 2047a01c190SPaul Cercueil "mmc0_mux", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2057a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2067a01c190SPaul Cercueil .mux = { CGU_REG_MSC0CDR, 30, 1 }, 2077a01c190SPaul Cercueil .div = { CGU_REG_MSC0CDR, 0, 1, 7, -1, -1, 31 }, 2087a01c190SPaul Cercueil .gate = { CGU_REG_MSC0CDR, 31 }, 2097a01c190SPaul Cercueil }, 2107a01c190SPaul Cercueil [JZ4770_CLK_MMC1_MUX] = { 2117a01c190SPaul Cercueil "mmc1_mux", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2127a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2137a01c190SPaul Cercueil .mux = { CGU_REG_MSC1CDR, 30, 1 }, 2147a01c190SPaul Cercueil .div = { CGU_REG_MSC1CDR, 0, 1, 7, -1, -1, 31 }, 2157a01c190SPaul Cercueil .gate = { CGU_REG_MSC1CDR, 31 }, 2167a01c190SPaul Cercueil }, 2177a01c190SPaul Cercueil [JZ4770_CLK_MMC2_MUX] = { 2187a01c190SPaul Cercueil "mmc2_mux", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2197a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2207a01c190SPaul Cercueil .mux = { CGU_REG_MSC2CDR, 30, 1 }, 2217a01c190SPaul Cercueil .div = { CGU_REG_MSC2CDR, 0, 1, 7, -1, -1, 31 }, 2227a01c190SPaul Cercueil .gate = { CGU_REG_MSC2CDR, 31 }, 2237a01c190SPaul Cercueil }, 2247a01c190SPaul Cercueil [JZ4770_CLK_CIM] = { 2257a01c190SPaul Cercueil "cim", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2267a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2277a01c190SPaul Cercueil .mux = { CGU_REG_CIMCDR, 31, 1 }, 2287a01c190SPaul Cercueil .div = { CGU_REG_CIMCDR, 0, 1, 8, -1, -1, -1 }, 2297a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 26 }, 2307a01c190SPaul Cercueil }, 2317a01c190SPaul Cercueil [JZ4770_CLK_UHC] = { 2327a01c190SPaul Cercueil "uhc", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2337a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2347a01c190SPaul Cercueil .mux = { CGU_REG_UHCCDR, 29, 1 }, 2357a01c190SPaul Cercueil .div = { CGU_REG_UHCCDR, 0, 1, 4, -1, -1, -1 }, 2367a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 24 }, 2377a01c190SPaul Cercueil }, 2387a01c190SPaul Cercueil [JZ4770_CLK_GPU] = { 2397a01c190SPaul Cercueil "gpu", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2407a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, -1 }, 2417a01c190SPaul Cercueil .mux = { CGU_REG_GPUCDR, 31, 1 }, 2427a01c190SPaul Cercueil .div = { CGU_REG_GPUCDR, 0, 1, 3, -1, -1, -1 }, 2437a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 9 }, 2447a01c190SPaul Cercueil }, 2457a01c190SPaul Cercueil [JZ4770_CLK_BCH] = { 2467a01c190SPaul Cercueil "bch", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2477a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2487a01c190SPaul Cercueil .mux = { CGU_REG_BCHCDR, 31, 1 }, 2497a01c190SPaul Cercueil .div = { CGU_REG_BCHCDR, 0, 1, 3, -1, -1, -1 }, 2507a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 1 }, 2517a01c190SPaul Cercueil }, 2527a01c190SPaul Cercueil [JZ4770_CLK_LPCLK_MUX] = { 2537a01c190SPaul Cercueil "lpclk", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2547a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2557a01c190SPaul Cercueil .mux = { CGU_REG_LPCDR, 29, 1 }, 2567a01c190SPaul Cercueil .div = { CGU_REG_LPCDR, 0, 1, 11, -1, -1, -1 }, 2577a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 28 }, 2587a01c190SPaul Cercueil }, 2597a01c190SPaul Cercueil [JZ4770_CLK_GPS] = { 2607a01c190SPaul Cercueil "gps", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2617a01c190SPaul Cercueil .parents = { JZ4770_CLK_PLL0, JZ4770_CLK_PLL1, }, 2627a01c190SPaul Cercueil .mux = { CGU_REG_GPSCDR, 31, 1 }, 2637a01c190SPaul Cercueil .div = { CGU_REG_GPSCDR, 0, 1, 4, -1, -1, -1 }, 2647a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 22 }, 2657a01c190SPaul Cercueil }, 2667a01c190SPaul Cercueil 2677a01c190SPaul Cercueil /* Those divided clocks can connect to EXT, PLL0 or PLL1 */ 2687a01c190SPaul Cercueil 2697a01c190SPaul Cercueil [JZ4770_CLK_SSI_MUX] = { 2707a01c190SPaul Cercueil "ssi_mux", CGU_CLK_DIV | CGU_CLK_MUX, 2717a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, -1, 2727a01c190SPaul Cercueil JZ4770_CLK_PLL0, JZ4770_CLK_PLL1 }, 2737a01c190SPaul Cercueil .mux = { CGU_REG_SSICDR, 30, 2 }, 2747a01c190SPaul Cercueil .div = { CGU_REG_SSICDR, 0, 1, 6, -1, -1, -1 }, 2757a01c190SPaul Cercueil }, 2767a01c190SPaul Cercueil [JZ4770_CLK_PCM_MUX] = { 2777a01c190SPaul Cercueil "pcm_mux", CGU_CLK_DIV | CGU_CLK_MUX, 2787a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, -1, 2797a01c190SPaul Cercueil JZ4770_CLK_PLL0, JZ4770_CLK_PLL1 }, 2807a01c190SPaul Cercueil .mux = { CGU_REG_PCMCDR, 30, 2 }, 2817a01c190SPaul Cercueil .div = { CGU_REG_PCMCDR, 0, 1, 9, -1, -1, -1 }, 2827a01c190SPaul Cercueil }, 2837a01c190SPaul Cercueil [JZ4770_CLK_I2S] = { 2847a01c190SPaul Cercueil "i2s", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2857a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, -1, 2867a01c190SPaul Cercueil JZ4770_CLK_PLL0, JZ4770_CLK_PLL1 }, 2877a01c190SPaul Cercueil .mux = { CGU_REG_I2SCDR, 30, 2 }, 2887a01c190SPaul Cercueil .div = { CGU_REG_I2SCDR, 0, 1, 9, -1, -1, -1 }, 2897a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 13 }, 2907a01c190SPaul Cercueil }, 2917a01c190SPaul Cercueil [JZ4770_CLK_OTG] = { 2927a01c190SPaul Cercueil "usb", CGU_CLK_DIV | CGU_CLK_GATE | CGU_CLK_MUX, 2937a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, -1, 2947a01c190SPaul Cercueil JZ4770_CLK_PLL0, JZ4770_CLK_PLL1 }, 2957a01c190SPaul Cercueil .mux = { CGU_REG_USBCDR, 30, 2 }, 2967a01c190SPaul Cercueil .div = { CGU_REG_USBCDR, 0, 1, 8, -1, -1, -1 }, 2977a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 2 }, 2987a01c190SPaul Cercueil }, 2997a01c190SPaul Cercueil 3007a01c190SPaul Cercueil /* Gate-only clocks */ 3017a01c190SPaul Cercueil 3027a01c190SPaul Cercueil [JZ4770_CLK_SSI0] = { 3037a01c190SPaul Cercueil "ssi0", CGU_CLK_GATE, 3047a01c190SPaul Cercueil .parents = { JZ4770_CLK_SSI_MUX, }, 3057a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 4 }, 3067a01c190SPaul Cercueil }, 3077a01c190SPaul Cercueil [JZ4770_CLK_SSI1] = { 3087a01c190SPaul Cercueil "ssi1", CGU_CLK_GATE, 3097a01c190SPaul Cercueil .parents = { JZ4770_CLK_SSI_MUX, }, 3107a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 19 }, 3117a01c190SPaul Cercueil }, 3127a01c190SPaul Cercueil [JZ4770_CLK_SSI2] = { 3137a01c190SPaul Cercueil "ssi2", CGU_CLK_GATE, 3147a01c190SPaul Cercueil .parents = { JZ4770_CLK_SSI_MUX, }, 3157a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 20 }, 3167a01c190SPaul Cercueil }, 3177a01c190SPaul Cercueil [JZ4770_CLK_PCM0] = { 3187a01c190SPaul Cercueil "pcm0", CGU_CLK_GATE, 3197a01c190SPaul Cercueil .parents = { JZ4770_CLK_PCM_MUX, }, 3207a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 8 }, 3217a01c190SPaul Cercueil }, 3227a01c190SPaul Cercueil [JZ4770_CLK_PCM1] = { 3237a01c190SPaul Cercueil "pcm1", CGU_CLK_GATE, 3247a01c190SPaul Cercueil .parents = { JZ4770_CLK_PCM_MUX, }, 3257a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 10 }, 3267a01c190SPaul Cercueil }, 3277a01c190SPaul Cercueil [JZ4770_CLK_DMA] = { 3287a01c190SPaul Cercueil "dma", CGU_CLK_GATE, 3297a01c190SPaul Cercueil .parents = { JZ4770_CLK_H2CLK, }, 3307a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 21 }, 3317a01c190SPaul Cercueil }, 3327a01c190SPaul Cercueil [JZ4770_CLK_I2C0] = { 3337a01c190SPaul Cercueil "i2c0", CGU_CLK_GATE, 3347a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3357a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 5 }, 3367a01c190SPaul Cercueil }, 3377a01c190SPaul Cercueil [JZ4770_CLK_I2C1] = { 3387a01c190SPaul Cercueil "i2c1", CGU_CLK_GATE, 3397a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3407a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 6 }, 3417a01c190SPaul Cercueil }, 3427a01c190SPaul Cercueil [JZ4770_CLK_I2C2] = { 3437a01c190SPaul Cercueil "i2c2", CGU_CLK_GATE, 3447a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3457a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 15 }, 3467a01c190SPaul Cercueil }, 3477a01c190SPaul Cercueil [JZ4770_CLK_UART0] = { 3487a01c190SPaul Cercueil "uart0", CGU_CLK_GATE, 3497a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3507a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 15 }, 3517a01c190SPaul Cercueil }, 3527a01c190SPaul Cercueil [JZ4770_CLK_UART1] = { 3537a01c190SPaul Cercueil "uart1", CGU_CLK_GATE, 3547a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3557a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 16 }, 3567a01c190SPaul Cercueil }, 3577a01c190SPaul Cercueil [JZ4770_CLK_UART2] = { 3587a01c190SPaul Cercueil "uart2", CGU_CLK_GATE, 3597a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3607a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 17 }, 3617a01c190SPaul Cercueil }, 3627a01c190SPaul Cercueil [JZ4770_CLK_UART3] = { 3637a01c190SPaul Cercueil "uart3", CGU_CLK_GATE, 3647a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3657a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 18 }, 3667a01c190SPaul Cercueil }, 3677a01c190SPaul Cercueil [JZ4770_CLK_IPU] = { 3687a01c190SPaul Cercueil "ipu", CGU_CLK_GATE, 3697a01c190SPaul Cercueil .parents = { JZ4770_CLK_H0CLK, }, 3707a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 29 }, 3717a01c190SPaul Cercueil }, 3727a01c190SPaul Cercueil [JZ4770_CLK_ADC] = { 3737a01c190SPaul Cercueil "adc", CGU_CLK_GATE, 3747a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3757a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 14 }, 3767a01c190SPaul Cercueil }, 3777a01c190SPaul Cercueil [JZ4770_CLK_AIC] = { 3787a01c190SPaul Cercueil "aic", CGU_CLK_GATE, 3797a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT, }, 3807a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 8 }, 3817a01c190SPaul Cercueil }, 3827a01c190SPaul Cercueil [JZ4770_CLK_AUX] = { 3837a01c190SPaul Cercueil "aux", CGU_CLK_GATE, 3847a01c190SPaul Cercueil .parents = { JZ4770_CLK_C1CLK, }, 3857a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR1, 14 }, 3867a01c190SPaul Cercueil }, 3877a01c190SPaul Cercueil [JZ4770_CLK_VPU] = { 3887a01c190SPaul Cercueil "vpu", CGU_CLK_GATE, 3897a01c190SPaul Cercueil .parents = { JZ4770_CLK_H1CLK, }, 3906ee3d385SPaul Cercueil .gate = { CGU_REG_LCR, 30, false, 150 }, 3917a01c190SPaul Cercueil }, 3927a01c190SPaul Cercueil [JZ4770_CLK_MMC0] = { 3937a01c190SPaul Cercueil "mmc0", CGU_CLK_GATE, 3947a01c190SPaul Cercueil .parents = { JZ4770_CLK_MMC0_MUX, }, 3957a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 3 }, 3967a01c190SPaul Cercueil }, 3977a01c190SPaul Cercueil [JZ4770_CLK_MMC1] = { 3987a01c190SPaul Cercueil "mmc1", CGU_CLK_GATE, 3997a01c190SPaul Cercueil .parents = { JZ4770_CLK_MMC1_MUX, }, 4007a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 11 }, 4017a01c190SPaul Cercueil }, 4027a01c190SPaul Cercueil [JZ4770_CLK_MMC2] = { 4037a01c190SPaul Cercueil "mmc2", CGU_CLK_GATE, 4047a01c190SPaul Cercueil .parents = { JZ4770_CLK_MMC2_MUX, }, 4057a01c190SPaul Cercueil .gate = { CGU_REG_CLKGR0, 12 }, 4067a01c190SPaul Cercueil }, 40711b689a3SPaul Cercueil [JZ4770_CLK_OTG_PHY] = { 40811b689a3SPaul Cercueil "usb_phy", CGU_CLK_GATE, 40911b689a3SPaul Cercueil .parents = { JZ4770_CLK_OTG }, 41011b689a3SPaul Cercueil .gate = { CGU_REG_OPCR, 7, true, 50 }, 41111b689a3SPaul Cercueil }, 4127a01c190SPaul Cercueil 4137a01c190SPaul Cercueil /* Custom clocks */ 4147a01c190SPaul Cercueil 4157a01c190SPaul Cercueil [JZ4770_CLK_UHC_PHY] = { 4167a01c190SPaul Cercueil "uhc_phy", CGU_CLK_CUSTOM, 4177a01c190SPaul Cercueil .parents = { JZ4770_CLK_UHC, -1, -1, -1 }, 4187a01c190SPaul Cercueil .custom = { &jz4770_uhc_phy_ops }, 4197a01c190SPaul Cercueil }, 4207a01c190SPaul Cercueil 4217a01c190SPaul Cercueil [JZ4770_CLK_EXT512] = { 4227a01c190SPaul Cercueil "ext/512", CGU_CLK_FIXDIV, 4237a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT }, 4247a01c190SPaul Cercueil .fixdiv = { 512 }, 4257a01c190SPaul Cercueil }, 4267a01c190SPaul Cercueil 4277a01c190SPaul Cercueil [JZ4770_CLK_RTC] = { 4287a01c190SPaul Cercueil "rtc", CGU_CLK_MUX, 4297a01c190SPaul Cercueil .parents = { JZ4770_CLK_EXT512, JZ4770_CLK_OSC32K, }, 4307a01c190SPaul Cercueil .mux = { CGU_REG_OPCR, 2, 1}, 4317a01c190SPaul Cercueil }, 4327a01c190SPaul Cercueil }; 4337a01c190SPaul Cercueil 4347a01c190SPaul Cercueil static void __init jz4770_cgu_init(struct device_node *np) 4357a01c190SPaul Cercueil { 4367a01c190SPaul Cercueil int retval; 4377a01c190SPaul Cercueil 4387a01c190SPaul Cercueil cgu = ingenic_cgu_new(jz4770_cgu_clocks, 4397a01c190SPaul Cercueil ARRAY_SIZE(jz4770_cgu_clocks), np); 440c067b46dSPaul Cercueil if (!cgu) { 4417a01c190SPaul Cercueil pr_err("%s: failed to initialise CGU\n", __func__); 442c067b46dSPaul Cercueil return; 443c067b46dSPaul Cercueil } 4447a01c190SPaul Cercueil 4457a01c190SPaul Cercueil retval = ingenic_cgu_register_clocks(cgu); 4467a01c190SPaul Cercueil if (retval) 4477a01c190SPaul Cercueil pr_err("%s: failed to register CGU Clocks\n", __func__); 4487a01c190SPaul Cercueil 4492ee93e3cSPaul Cercueil ingenic_cgu_register_syscore_ops(cgu); 4507a01c190SPaul Cercueil } 4517a01c190SPaul Cercueil 4527a01c190SPaul Cercueil /* We only probe via devicetree, no need for a platform driver */ 45303d570e1SPaul Cercueil CLK_OF_DECLARE_DRIVER(jz4770_cgu, "ingenic,jz4770-cgu", jz4770_cgu_init); 454