1ce1d86dcS周琰杰 (Zhou Yanjie) // SPDX-License-Identifier: GPL-2.0 2ce1d86dcS周琰杰 (Zhou Yanjie) /* 3ce1d86dcS周琰杰 (Zhou Yanjie) * X1830 SoC CGU driver 4ce1d86dcS周琰杰 (Zhou Yanjie) * Copyright (c) 2019 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 5ce1d86dcS周琰杰 (Zhou Yanjie) */ 6ce1d86dcS周琰杰 (Zhou Yanjie) 7ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/clk-provider.h> 8ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/delay.h> 9ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/io.h> 10ce1d86dcS周琰杰 (Zhou Yanjie) #include <linux/of.h> 11ce1d86dcS周琰杰 (Zhou Yanjie) 12*c4a11bf4SPaul Cercueil #include <dt-bindings/clock/ingenic,x1830-cgu.h> 13ce1d86dcS周琰杰 (Zhou Yanjie) 14ce1d86dcS周琰杰 (Zhou Yanjie) #include "cgu.h" 15ce1d86dcS周琰杰 (Zhou Yanjie) #include "pm.h" 16ce1d86dcS周琰杰 (Zhou Yanjie) 17ce1d86dcS周琰杰 (Zhou Yanjie) /* CGU register offsets */ 18ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPCCR 0x00 19ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPPCR 0x0c 20ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_APLL 0x10 21ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MPLL 0x14 22ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CLKGR0 0x20 23ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_OPCR 0x24 24ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CLKGR1 0x28 25ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_DDRCDR 0x2c 26ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBPCR 0x3c 27ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBRDT 0x40 28ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBVBFIL 0x44 29ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_USBPCR1 0x48 30ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MACCDR 0x54 31ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_EPLL 0x58 32ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_I2SCDR 0x60 33ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_LPCDR 0x64 34ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MSC0CDR 0x68 35ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_I2SCDR1 0x70 36ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_SSICDR 0x74 37ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CIMCDR 0x7c 38ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MSC1CDR 0xa4 39ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CMP_INTR 0xb0 40ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CMP_INTRE 0xb4 41ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_DRCG 0xd0 42ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_CPCSR 0xd4 43ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_VPLL 0xe0 44ce1d86dcS周琰杰 (Zhou Yanjie) #define CGU_REG_MACPHYC 0xe8 45ce1d86dcS周琰杰 (Zhou Yanjie) 46ce1d86dcS周琰杰 (Zhou Yanjie) /* bits within the OPCR register */ 47ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_GATE_USBPHYCLK BIT(23) 48ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_SPENDN0 BIT(7) 49ce1d86dcS周琰杰 (Zhou Yanjie) #define OPCR_SPENDN1 BIT(6) 50ce1d86dcS周琰杰 (Zhou Yanjie) 51ce1d86dcS周琰杰 (Zhou Yanjie) /* bits within the USBPCR register */ 52ce1d86dcS周琰杰 (Zhou Yanjie) #define USBPCR_SIDDQ BIT(21) 53ce1d86dcS周琰杰 (Zhou Yanjie) #define USBPCR_OTG_DISABLE BIT(20) 54ce1d86dcS周琰杰 (Zhou Yanjie) 55ce1d86dcS周琰杰 (Zhou Yanjie) static struct ingenic_cgu *cgu; 56ce1d86dcS周琰杰 (Zhou Yanjie) 57ce1d86dcS周琰杰 (Zhou Yanjie) static int x1830_usb_phy_enable(struct clk_hw *hw) 58ce1d86dcS周琰杰 (Zhou Yanjie) { 59ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 60ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 61ce1d86dcS周琰杰 (Zhou Yanjie) 62ce1d86dcS周琰杰 (Zhou Yanjie) writel((readl(reg_opcr) | OPCR_SPENDN0) & ~OPCR_GATE_USBPHYCLK, reg_opcr); 63ce1d86dcS周琰杰 (Zhou Yanjie) writel(readl(reg_usbpcr) & ~USBPCR_OTG_DISABLE & ~USBPCR_SIDDQ, reg_usbpcr); 64ce1d86dcS周琰杰 (Zhou Yanjie) return 0; 65ce1d86dcS周琰杰 (Zhou Yanjie) } 66ce1d86dcS周琰杰 (Zhou Yanjie) 67ce1d86dcS周琰杰 (Zhou Yanjie) static void x1830_usb_phy_disable(struct clk_hw *hw) 68ce1d86dcS周琰杰 (Zhou Yanjie) { 69ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 70ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 71ce1d86dcS周琰杰 (Zhou Yanjie) 72ce1d86dcS周琰杰 (Zhou Yanjie) writel((readl(reg_opcr) & ~OPCR_SPENDN0) | OPCR_GATE_USBPHYCLK, reg_opcr); 73ce1d86dcS周琰杰 (Zhou Yanjie) writel(readl(reg_usbpcr) | USBPCR_OTG_DISABLE | USBPCR_SIDDQ, reg_usbpcr); 74ce1d86dcS周琰杰 (Zhou Yanjie) } 75ce1d86dcS周琰杰 (Zhou Yanjie) 76ce1d86dcS周琰杰 (Zhou Yanjie) static int x1830_usb_phy_is_enabled(struct clk_hw *hw) 77ce1d86dcS周琰杰 (Zhou Yanjie) { 78ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; 79ce1d86dcS周琰杰 (Zhou Yanjie) void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR; 80ce1d86dcS周琰杰 (Zhou Yanjie) 81ce1d86dcS周琰杰 (Zhou Yanjie) return (readl(reg_opcr) & OPCR_SPENDN0) && 82ce1d86dcS周琰杰 (Zhou Yanjie) !(readl(reg_usbpcr) & USBPCR_SIDDQ) && 83ce1d86dcS周琰杰 (Zhou Yanjie) !(readl(reg_usbpcr) & USBPCR_OTG_DISABLE); 84ce1d86dcS周琰杰 (Zhou Yanjie) } 85ce1d86dcS周琰杰 (Zhou Yanjie) 86ce1d86dcS周琰杰 (Zhou Yanjie) static const struct clk_ops x1830_otg_phy_ops = { 87ce1d86dcS周琰杰 (Zhou Yanjie) .enable = x1830_usb_phy_enable, 88ce1d86dcS周琰杰 (Zhou Yanjie) .disable = x1830_usb_phy_disable, 89ce1d86dcS周琰杰 (Zhou Yanjie) .is_enabled = x1830_usb_phy_is_enabled, 90ce1d86dcS周琰杰 (Zhou Yanjie) }; 91ce1d86dcS周琰杰 (Zhou Yanjie) 92ce1d86dcS周琰杰 (Zhou Yanjie) static const s8 pll_od_encoding[64] = { 93ce1d86dcS周琰杰 (Zhou Yanjie) 0x0, 0x1, -1, 0x2, -1, -1, -1, 0x3, 94ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x4, 95ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1, 96ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x5, 97ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1, 98ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1, 99ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, -1, 100ce1d86dcS周琰杰 (Zhou Yanjie) -1, -1, -1, -1, -1, -1, -1, 0x6, 101ce1d86dcS周琰杰 (Zhou Yanjie) }; 102ce1d86dcS周琰杰 (Zhou Yanjie) 103ce1d86dcS周琰杰 (Zhou Yanjie) static const struct ingenic_cgu_clk_info x1830_cgu_clocks[] = { 104ce1d86dcS周琰杰 (Zhou Yanjie) 105ce1d86dcS周琰杰 (Zhou Yanjie) /* External clocks */ 106ce1d86dcS周琰杰 (Zhou Yanjie) 107ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EXCLK] = { "ext", CGU_CLK_EXT }, 108ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_RTCLK] = { "rtc", CGU_CLK_EXT }, 109ce1d86dcS周琰杰 (Zhou Yanjie) 110ce1d86dcS周琰杰 (Zhou Yanjie) /* PLLs */ 111ce1d86dcS周琰杰 (Zhou Yanjie) 112ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_APLL] = { 113ce1d86dcS周琰杰 (Zhou Yanjie) "apll", CGU_CLK_PLL, 114ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 115ce1d86dcS周琰杰 (Zhou Yanjie) .pll = { 116ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_APLL, 117ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2, 118ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20, 119ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9, 120ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1, 121ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14, 122ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6, 123ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1, 124ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11, 125ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3, 126ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64, 127ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding, 128ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR, 129ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 30, 130ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0, 131ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3, 132ce1d86dcS周琰杰 (Zhou Yanjie) }, 133ce1d86dcS周琰杰 (Zhou Yanjie) }, 134ce1d86dcS周琰杰 (Zhou Yanjie) 135ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MPLL] = { 136ce1d86dcS周琰杰 (Zhou Yanjie) "mpll", CGU_CLK_PLL, 137ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 138ce1d86dcS周琰杰 (Zhou Yanjie) .pll = { 139ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_MPLL, 140ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2, 141ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20, 142ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9, 143ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1, 144ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14, 145ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6, 146ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1, 147ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11, 148ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3, 149ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64, 150ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding, 151ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR, 152ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 28, 153ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0, 154ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3, 155ce1d86dcS周琰杰 (Zhou Yanjie) }, 156ce1d86dcS周琰杰 (Zhou Yanjie) }, 157ce1d86dcS周琰杰 (Zhou Yanjie) 158ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EPLL] = { 159ce1d86dcS周琰杰 (Zhou Yanjie) "epll", CGU_CLK_PLL, 160ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 161ce1d86dcS周琰杰 (Zhou Yanjie) .pll = { 162ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_EPLL, 163ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2, 164ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20, 165ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9, 166ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1, 167ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14, 168ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6, 169ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1, 170ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11, 171ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3, 172ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64, 173ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding, 174ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR, 175ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 24, 176ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0, 177ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3, 178ce1d86dcS周琰杰 (Zhou Yanjie) }, 179ce1d86dcS周琰杰 (Zhou Yanjie) }, 180ce1d86dcS周琰杰 (Zhou Yanjie) 181ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_VPLL] = { 182ce1d86dcS周琰杰 (Zhou Yanjie) "vpll", CGU_CLK_PLL, 183ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 184ce1d86dcS周琰杰 (Zhou Yanjie) .pll = { 185ce1d86dcS周琰杰 (Zhou Yanjie) .reg = CGU_REG_VPLL, 186ce1d86dcS周琰杰 (Zhou Yanjie) .rate_multiplier = 2, 187ce1d86dcS周琰杰 (Zhou Yanjie) .m_shift = 20, 188ce1d86dcS周琰杰 (Zhou Yanjie) .m_bits = 9, 189ce1d86dcS周琰杰 (Zhou Yanjie) .m_offset = 1, 190ce1d86dcS周琰杰 (Zhou Yanjie) .n_shift = 14, 191ce1d86dcS周琰杰 (Zhou Yanjie) .n_bits = 6, 192ce1d86dcS周琰杰 (Zhou Yanjie) .n_offset = 1, 193ce1d86dcS周琰杰 (Zhou Yanjie) .od_shift = 11, 194ce1d86dcS周琰杰 (Zhou Yanjie) .od_bits = 3, 195ce1d86dcS周琰杰 (Zhou Yanjie) .od_max = 64, 196ce1d86dcS周琰杰 (Zhou Yanjie) .od_encoding = pll_od_encoding, 197ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_reg = CGU_REG_CPPCR, 198ce1d86dcS周琰杰 (Zhou Yanjie) .bypass_bit = 26, 199ce1d86dcS周琰杰 (Zhou Yanjie) .enable_bit = 0, 200ce1d86dcS周琰杰 (Zhou Yanjie) .stable_bit = 3, 201ce1d86dcS周琰杰 (Zhou Yanjie) }, 202ce1d86dcS周琰杰 (Zhou Yanjie) }, 203ce1d86dcS周琰杰 (Zhou Yanjie) 204ce1d86dcS周琰杰 (Zhou Yanjie) /* Custom (SoC-specific) OTG PHY */ 205ce1d86dcS周琰杰 (Zhou Yanjie) 206ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OTGPHY] = { 207ce1d86dcS周琰杰 (Zhou Yanjie) "otg_phy", CGU_CLK_CUSTOM, 208ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 209ce1d86dcS周琰杰 (Zhou Yanjie) .custom = { &x1830_otg_phy_ops }, 210ce1d86dcS周琰杰 (Zhou Yanjie) }, 211ce1d86dcS周琰杰 (Zhou Yanjie) 212ce1d86dcS周琰杰 (Zhou Yanjie) /* Muxes & dividers */ 213ce1d86dcS周琰杰 (Zhou Yanjie) 214ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SCLKA] = { 215ce1d86dcS周琰杰 (Zhou Yanjie) "sclk_a", CGU_CLK_MUX, 216ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_EXCLK, X1830_CLK_APLL, -1 }, 217ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 30, 2 }, 218ce1d86dcS周琰杰 (Zhou Yanjie) }, 219ce1d86dcS周琰杰 (Zhou Yanjie) 220ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_CPUMUX] = { 221ce1d86dcS周琰杰 (Zhou Yanjie) "cpu_mux", CGU_CLK_MUX, 222ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 }, 223ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 28, 2 }, 224ce1d86dcS周琰杰 (Zhou Yanjie) }, 225ce1d86dcS周琰杰 (Zhou Yanjie) 226ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_CPU] = { 227ce1d86dcS周琰杰 (Zhou Yanjie) "cpu", CGU_CLK_DIV | CGU_CLK_GATE, 228ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_CPUMUX, -1, -1, -1 }, 229ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 0, 1, 4, 22, -1, -1 }, 230ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 15 }, 231ce1d86dcS周琰杰 (Zhou Yanjie) }, 232ce1d86dcS周琰杰 (Zhou Yanjie) 233ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_L2CACHE] = { 234ce1d86dcS周琰杰 (Zhou Yanjie) "l2cache", CGU_CLK_DIV, 235ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_CPUMUX, -1, -1, -1 }, 236ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 4, 1, 4, 22, -1, -1 }, 237ce1d86dcS周琰杰 (Zhou Yanjie) }, 238ce1d86dcS周琰杰 (Zhou Yanjie) 239ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB0] = { 240ce1d86dcS周琰杰 (Zhou Yanjie) "ahb0", CGU_CLK_MUX | CGU_CLK_DIV, 241ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 }, 242ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 26, 2 }, 243ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 8, 1, 4, 21, -1, -1 }, 244ce1d86dcS周琰杰 (Zhou Yanjie) }, 245ce1d86dcS周琰杰 (Zhou Yanjie) 246ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB2PMUX] = { 247ce1d86dcS周琰杰 (Zhou Yanjie) "ahb2_apb_mux", CGU_CLK_MUX, 248ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 }, 249ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_CPCCR, 24, 2 }, 250ce1d86dcS周琰杰 (Zhou Yanjie) }, 251ce1d86dcS周琰杰 (Zhou Yanjie) 252ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_AHB2] = { 253ce1d86dcS周琰杰 (Zhou Yanjie) "ahb2", CGU_CLK_DIV, 254ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2PMUX, -1, -1, -1 }, 255ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 12, 1, 4, 20, -1, -1 }, 256ce1d86dcS周琰杰 (Zhou Yanjie) }, 257ce1d86dcS周琰杰 (Zhou Yanjie) 258ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_PCLK] = { 259ce1d86dcS周琰杰 (Zhou Yanjie) "pclk", CGU_CLK_DIV | CGU_CLK_GATE, 260ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2PMUX, -1, -1, -1 }, 261ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_CPCCR, 16, 1, 4, 20, -1, -1 }, 262ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 14 }, 263ce1d86dcS周琰杰 (Zhou Yanjie) }, 264ce1d86dcS周琰杰 (Zhou Yanjie) 265ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_DDR] = { 266ce1d86dcS周琰杰 (Zhou Yanjie) "ddr", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 267ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { -1, X1830_CLK_SCLKA, X1830_CLK_MPLL, -1 }, 268ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_DDRCDR, 30, 2 }, 269ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_DDRCDR, 0, 1, 4, 29, 28, 27 }, 270ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 31 }, 271ce1d86dcS周琰杰 (Zhou Yanjie) }, 272ce1d86dcS周琰杰 (Zhou Yanjie) 273ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MAC] = { 274ce1d86dcS周琰杰 (Zhou Yanjie) "mac", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 275ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL, 276ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL }, 277ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_MACCDR, 30, 2 }, 278ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MACCDR, 0, 1, 8, 29, 28, 27 }, 279ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 4 }, 280ce1d86dcS周琰杰 (Zhou Yanjie) }, 281ce1d86dcS周琰杰 (Zhou Yanjie) 282ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_LCD] = { 283ce1d86dcS周琰杰 (Zhou Yanjie) "lcd", CGU_CLK_MUX | CGU_CLK_DIV | CGU_CLK_GATE, 284ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL, 285ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL }, 286ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_LPCDR, 30, 2 }, 287ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_LPCDR, 0, 1, 8, 28, 27, 26 }, 288ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 9 }, 289ce1d86dcS周琰杰 (Zhou Yanjie) }, 290ce1d86dcS周琰杰 (Zhou Yanjie) 291ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSCMUX] = { 292ce1d86dcS周琰杰 (Zhou Yanjie) "msc_mux", CGU_CLK_MUX, 293ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL, 294ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL }, 295ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_MSC0CDR, 30, 2 }, 296ce1d86dcS周琰杰 (Zhou Yanjie) }, 297ce1d86dcS周琰杰 (Zhou Yanjie) 298ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSC0] = { 299ce1d86dcS周琰杰 (Zhou Yanjie) "msc0", CGU_CLK_DIV | CGU_CLK_GATE, 300ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_MSCMUX, -1, -1, -1 }, 301ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MSC0CDR, 0, 2, 8, 29, 28, 27 }, 302ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 4 }, 303ce1d86dcS周琰杰 (Zhou Yanjie) }, 304ce1d86dcS周琰杰 (Zhou Yanjie) 305ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_MSC1] = { 306ce1d86dcS周琰杰 (Zhou Yanjie) "msc1", CGU_CLK_DIV | CGU_CLK_GATE, 307ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_MSCMUX, -1, -1, -1 }, 308ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_MSC1CDR, 0, 2, 8, 29, 28, 27 }, 309ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 5 }, 310ce1d86dcS周琰杰 (Zhou Yanjie) }, 311ce1d86dcS周琰杰 (Zhou Yanjie) 312ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIPLL] = { 313ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_pll", CGU_CLK_MUX | CGU_CLK_DIV, 314ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SCLKA, X1830_CLK_MPLL, 315ce1d86dcS周琰杰 (Zhou Yanjie) X1830_CLK_VPLL, X1830_CLK_EPLL }, 316ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_SSICDR, 30, 2 }, 317ce1d86dcS周琰杰 (Zhou Yanjie) .div = { CGU_REG_SSICDR, 0, 1, 8, 28, 27, 26 }, 318ce1d86dcS周琰杰 (Zhou Yanjie) }, 319ce1d86dcS周琰杰 (Zhou Yanjie) 320ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIPLL_DIV2] = { 321ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_pll_div2", CGU_CLK_FIXDIV, 322ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIPLL }, 323ce1d86dcS周琰杰 (Zhou Yanjie) .fixdiv = { 2 }, 324ce1d86dcS周琰杰 (Zhou Yanjie) }, 325ce1d86dcS周琰杰 (Zhou Yanjie) 326ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSIMUX] = { 327ce1d86dcS周琰杰 (Zhou Yanjie) "ssi_mux", CGU_CLK_MUX, 328ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, X1830_CLK_SSIPLL_DIV2, -1, -1 }, 329ce1d86dcS周琰杰 (Zhou Yanjie) .mux = { CGU_REG_SSICDR, 29, 1 }, 330ce1d86dcS周琰杰 (Zhou Yanjie) }, 331ce1d86dcS周琰杰 (Zhou Yanjie) 33282df5b73S周琰杰 (Zhou Yanjie) [X1830_CLK_EXCLK_DIV512] = { 33382df5b73S周琰杰 (Zhou Yanjie) "exclk_div512", CGU_CLK_FIXDIV, 33482df5b73S周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK }, 33582df5b73S周琰杰 (Zhou Yanjie) .fixdiv = { 512 }, 33682df5b73S周琰杰 (Zhou Yanjie) }, 33782df5b73S周琰杰 (Zhou Yanjie) 33882df5b73S周琰杰 (Zhou Yanjie) [X1830_CLK_RTC] = { 33982df5b73S周琰杰 (Zhou Yanjie) "rtc_ercs", CGU_CLK_MUX | CGU_CLK_GATE, 34082df5b73S周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK_DIV512, X1830_CLK_RTCLK }, 34182df5b73S周琰杰 (Zhou Yanjie) .mux = { CGU_REG_OPCR, 2, 1}, 34282df5b73S周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 29 }, 34382df5b73S周琰杰 (Zhou Yanjie) }, 34482df5b73S周琰杰 (Zhou Yanjie) 345ce1d86dcS周琰杰 (Zhou Yanjie) /* Gate-only clocks */ 346ce1d86dcS周琰杰 (Zhou Yanjie) 347ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EMC] = { 348ce1d86dcS周琰杰 (Zhou Yanjie) "emc", CGU_CLK_GATE, 349ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2, -1, -1, -1 }, 350ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 0 }, 351ce1d86dcS周琰杰 (Zhou Yanjie) }, 352ce1d86dcS周琰杰 (Zhou Yanjie) 353ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_EFUSE] = { 354ce1d86dcS周琰杰 (Zhou Yanjie) "efuse", CGU_CLK_GATE, 355ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_AHB2, -1, -1, -1 }, 356ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 1 }, 357ce1d86dcS周琰杰 (Zhou Yanjie) }, 358ce1d86dcS周琰杰 (Zhou Yanjie) 359ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OTG] = { 360ce1d86dcS周琰杰 (Zhou Yanjie) "otg", CGU_CLK_GATE, 361ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 362ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 3 }, 363ce1d86dcS周琰杰 (Zhou Yanjie) }, 364ce1d86dcS周琰杰 (Zhou Yanjie) 365ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSI0] = { 366ce1d86dcS周琰杰 (Zhou Yanjie) "ssi0", CGU_CLK_GATE, 367ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIMUX, -1, -1, -1 }, 368ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 6 }, 369ce1d86dcS周琰杰 (Zhou Yanjie) }, 370ce1d86dcS周琰杰 (Zhou Yanjie) 371ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB0] = { 372ce1d86dcS周琰杰 (Zhou Yanjie) "smb0", CGU_CLK_GATE, 373ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 }, 374ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 7 }, 375ce1d86dcS周琰杰 (Zhou Yanjie) }, 376ce1d86dcS周琰杰 (Zhou Yanjie) 377ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB1] = { 378ce1d86dcS周琰杰 (Zhou Yanjie) "smb1", CGU_CLK_GATE, 379ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 }, 380ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 8 }, 381ce1d86dcS周琰杰 (Zhou Yanjie) }, 382ce1d86dcS周琰杰 (Zhou Yanjie) 383ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SMB2] = { 384ce1d86dcS周琰杰 (Zhou Yanjie) "smb2", CGU_CLK_GATE, 385ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 }, 386ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 9 }, 387ce1d86dcS周琰杰 (Zhou Yanjie) }, 388ce1d86dcS周琰杰 (Zhou Yanjie) 389ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_UART0] = { 390ce1d86dcS周琰杰 (Zhou Yanjie) "uart0", CGU_CLK_GATE, 391ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 392ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 14 }, 393ce1d86dcS周琰杰 (Zhou Yanjie) }, 394ce1d86dcS周琰杰 (Zhou Yanjie) 395ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_UART1] = { 396ce1d86dcS周琰杰 (Zhou Yanjie) "uart1", CGU_CLK_GATE, 397ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 398ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 15 }, 399ce1d86dcS周琰杰 (Zhou Yanjie) }, 400ce1d86dcS周琰杰 (Zhou Yanjie) 401ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SSI1] = { 402ce1d86dcS周琰杰 (Zhou Yanjie) "ssi1", CGU_CLK_GATE, 403ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIMUX, -1, -1, -1 }, 404ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 19 }, 405ce1d86dcS周琰杰 (Zhou Yanjie) }, 406ce1d86dcS周琰杰 (Zhou Yanjie) 407ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_SFC] = { 408ce1d86dcS周琰杰 (Zhou Yanjie) "sfc", CGU_CLK_GATE, 409ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_SSIPLL, -1, -1, -1 }, 410ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 20 }, 411ce1d86dcS周琰杰 (Zhou Yanjie) }, 412ce1d86dcS周琰杰 (Zhou Yanjie) 413ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_PDMA] = { 414ce1d86dcS周琰杰 (Zhou Yanjie) "pdma", CGU_CLK_GATE, 415ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 416ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 21 }, 417ce1d86dcS周琰杰 (Zhou Yanjie) }, 418ce1d86dcS周琰杰 (Zhou Yanjie) 419ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_TCU] = { 420ce1d86dcS周琰杰 (Zhou Yanjie) "tcu", CGU_CLK_GATE, 421ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 422ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR0, 30 }, 423ce1d86dcS周琰杰 (Zhou Yanjie) }, 424ce1d86dcS周琰杰 (Zhou Yanjie) 425ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_DTRNG] = { 426ce1d86dcS周琰杰 (Zhou Yanjie) "dtrng", CGU_CLK_GATE, 427ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_PCLK, -1, -1, -1 }, 428ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 1 }, 429ce1d86dcS周琰杰 (Zhou Yanjie) }, 430ce1d86dcS周琰杰 (Zhou Yanjie) 431ce1d86dcS周琰杰 (Zhou Yanjie) [X1830_CLK_OST] = { 432ce1d86dcS周琰杰 (Zhou Yanjie) "ost", CGU_CLK_GATE, 433ce1d86dcS周琰杰 (Zhou Yanjie) .parents = { X1830_CLK_EXCLK, -1, -1, -1 }, 434ce1d86dcS周琰杰 (Zhou Yanjie) .gate = { CGU_REG_CLKGR1, 11 }, 435ce1d86dcS周琰杰 (Zhou Yanjie) }, 436ce1d86dcS周琰杰 (Zhou Yanjie) }; 437ce1d86dcS周琰杰 (Zhou Yanjie) 438ce1d86dcS周琰杰 (Zhou Yanjie) static void __init x1830_cgu_init(struct device_node *np) 439ce1d86dcS周琰杰 (Zhou Yanjie) { 440ce1d86dcS周琰杰 (Zhou Yanjie) int retval; 441ce1d86dcS周琰杰 (Zhou Yanjie) 442ce1d86dcS周琰杰 (Zhou Yanjie) cgu = ingenic_cgu_new(x1830_cgu_clocks, 443ce1d86dcS周琰杰 (Zhou Yanjie) ARRAY_SIZE(x1830_cgu_clocks), np); 444ce1d86dcS周琰杰 (Zhou Yanjie) if (!cgu) { 445ce1d86dcS周琰杰 (Zhou Yanjie) pr_err("%s: failed to initialise CGU\n", __func__); 446ce1d86dcS周琰杰 (Zhou Yanjie) return; 447ce1d86dcS周琰杰 (Zhou Yanjie) } 448ce1d86dcS周琰杰 (Zhou Yanjie) 449ce1d86dcS周琰杰 (Zhou Yanjie) retval = ingenic_cgu_register_clocks(cgu); 450ce1d86dcS周琰杰 (Zhou Yanjie) if (retval) { 451ce1d86dcS周琰杰 (Zhou Yanjie) pr_err("%s: failed to register CGU Clocks\n", __func__); 452ce1d86dcS周琰杰 (Zhou Yanjie) return; 453ce1d86dcS周琰杰 (Zhou Yanjie) } 454ce1d86dcS周琰杰 (Zhou Yanjie) 455ce1d86dcS周琰杰 (Zhou Yanjie) ingenic_cgu_register_syscore_ops(cgu); 456ce1d86dcS周琰杰 (Zhou Yanjie) } 457ce1d86dcS周琰杰 (Zhou Yanjie) /* 458ce1d86dcS周琰杰 (Zhou Yanjie) * CGU has some children devices, this is useful for probing children devices 459ce1d86dcS周琰杰 (Zhou Yanjie) * in the case where the device node is compatible with "simple-mfd". 460ce1d86dcS周琰杰 (Zhou Yanjie) */ 461ce1d86dcS周琰杰 (Zhou Yanjie) CLK_OF_DECLARE_DRIVER(x1830_cgu, "ingenic,x1830-cgu", x1830_cgu_init); 462