18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/sh/kernel/cpu/sh4a/clock-sh7723.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * SH7723 clock framework support 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2009 Magnus Damm 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#include <linux/init.h> 108c2ecf20Sopenharmony_ci#include <linux/kernel.h> 118c2ecf20Sopenharmony_ci#include <linux/io.h> 128c2ecf20Sopenharmony_ci#include <linux/clk.h> 138c2ecf20Sopenharmony_ci#include <linux/clkdev.h> 148c2ecf20Sopenharmony_ci#include <linux/sh_clk.h> 158c2ecf20Sopenharmony_ci#include <asm/clock.h> 168c2ecf20Sopenharmony_ci#include <cpu/sh7723.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* SH7723 registers */ 198c2ecf20Sopenharmony_ci#define FRQCR 0xa4150000 208c2ecf20Sopenharmony_ci#define VCLKCR 0xa4150004 218c2ecf20Sopenharmony_ci#define SCLKACR 0xa4150008 228c2ecf20Sopenharmony_ci#define SCLKBCR 0xa415000c 238c2ecf20Sopenharmony_ci#define IRDACLKCR 0xa4150018 248c2ecf20Sopenharmony_ci#define PLLCR 0xa4150024 258c2ecf20Sopenharmony_ci#define MSTPCR0 0xa4150030 268c2ecf20Sopenharmony_ci#define MSTPCR1 0xa4150034 278c2ecf20Sopenharmony_ci#define MSTPCR2 0xa4150038 288c2ecf20Sopenharmony_ci#define DLLFRQ 0xa4150050 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* Fixed 32 KHz root clock for RTC and Power Management purposes */ 318c2ecf20Sopenharmony_cistatic struct clk r_clk = { 328c2ecf20Sopenharmony_ci .rate = 32768, 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * Default rate for the root input clock, reset this with clk_set_rate() 378c2ecf20Sopenharmony_ci * from the platform code. 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_cistruct clk extal_clk = { 408c2ecf20Sopenharmony_ci .rate = 33333333, 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* The dll multiplies the 32khz r_clk, may be used instead of extal */ 448c2ecf20Sopenharmony_cistatic unsigned long dll_recalc(struct clk *clk) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci unsigned long mult; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (__raw_readl(PLLCR) & 0x1000) 498c2ecf20Sopenharmony_ci mult = __raw_readl(DLLFRQ); 508c2ecf20Sopenharmony_ci else 518c2ecf20Sopenharmony_ci mult = 0; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci return clk->parent->rate * mult; 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic struct sh_clk_ops dll_clk_ops = { 578c2ecf20Sopenharmony_ci .recalc = dll_recalc, 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic struct clk dll_clk = { 618c2ecf20Sopenharmony_ci .ops = &dll_clk_ops, 628c2ecf20Sopenharmony_ci .parent = &r_clk, 638c2ecf20Sopenharmony_ci .flags = CLK_ENABLE_ON_INIT, 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic unsigned long pll_recalc(struct clk *clk) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci unsigned long mult = 1; 698c2ecf20Sopenharmony_ci unsigned long div = 1; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci if (__raw_readl(PLLCR) & 0x4000) 728c2ecf20Sopenharmony_ci mult = (((__raw_readl(FRQCR) >> 24) & 0x1f) + 1); 738c2ecf20Sopenharmony_ci else 748c2ecf20Sopenharmony_ci div = 2; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci return (clk->parent->rate * mult) / div; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic struct sh_clk_ops pll_clk_ops = { 808c2ecf20Sopenharmony_ci .recalc = pll_recalc, 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic struct clk pll_clk = { 848c2ecf20Sopenharmony_ci .ops = &pll_clk_ops, 858c2ecf20Sopenharmony_ci .flags = CLK_ENABLE_ON_INIT, 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistruct clk *main_clks[] = { 898c2ecf20Sopenharmony_ci &r_clk, 908c2ecf20Sopenharmony_ci &extal_clk, 918c2ecf20Sopenharmony_ci &dll_clk, 928c2ecf20Sopenharmony_ci &pll_clk, 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; 968c2ecf20Sopenharmony_cistatic int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 }; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic struct clk_div_mult_table div4_div_mult_table = { 998c2ecf20Sopenharmony_ci .divisors = divisors, 1008c2ecf20Sopenharmony_ci .nr_divisors = ARRAY_SIZE(divisors), 1018c2ecf20Sopenharmony_ci .multipliers = multipliers, 1028c2ecf20Sopenharmony_ci .nr_multipliers = ARRAY_SIZE(multipliers), 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic struct clk_div4_table div4_table = { 1068c2ecf20Sopenharmony_ci .div_mult_table = &div4_div_mult_table, 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cienum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR }; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define DIV4(_reg, _bit, _mask, _flags) \ 1128c2ecf20Sopenharmony_ci SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags) 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistruct clk div4_clks[DIV4_NR] = { 1158c2ecf20Sopenharmony_ci [DIV4_I] = DIV4(FRQCR, 20, 0x0dbf, CLK_ENABLE_ON_INIT), 1168c2ecf20Sopenharmony_ci [DIV4_U] = DIV4(FRQCR, 16, 0x0dbf, CLK_ENABLE_ON_INIT), 1178c2ecf20Sopenharmony_ci [DIV4_SH] = DIV4(FRQCR, 12, 0x0dbf, CLK_ENABLE_ON_INIT), 1188c2ecf20Sopenharmony_ci [DIV4_B] = DIV4(FRQCR, 8, 0x0dbf, CLK_ENABLE_ON_INIT), 1198c2ecf20Sopenharmony_ci [DIV4_B3] = DIV4(FRQCR, 4, 0x0db4, CLK_ENABLE_ON_INIT), 1208c2ecf20Sopenharmony_ci [DIV4_P] = DIV4(FRQCR, 0, 0x0dbf, 0), 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cienum { DIV4_IRDA, DIV4_ENABLE_NR }; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistruct clk div4_enable_clks[DIV4_ENABLE_NR] = { 1268c2ecf20Sopenharmony_ci [DIV4_IRDA] = DIV4(IRDACLKCR, 0, 0x0dbf, 0), 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cienum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR }; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistruct clk div4_reparent_clks[DIV4_REPARENT_NR] = { 1328c2ecf20Sopenharmony_ci [DIV4_SIUA] = DIV4(SCLKACR, 0, 0x0dbf, 0), 1338c2ecf20Sopenharmony_ci [DIV4_SIUB] = DIV4(SCLKBCR, 0, 0x0dbf, 0), 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_cienum { DIV6_V, DIV6_NR }; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistruct clk div6_clks[DIV6_NR] = { 1388c2ecf20Sopenharmony_ci [DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0), 1398c2ecf20Sopenharmony_ci}; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cistatic struct clk mstp_clks[] = { 1428c2ecf20Sopenharmony_ci /* See page 60 of Datasheet V1.0: Overview -> Block Diagram */ 1438c2ecf20Sopenharmony_ci [HWBLK_TLB] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 31, CLK_ENABLE_ON_INIT), 1448c2ecf20Sopenharmony_ci [HWBLK_IC] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 30, CLK_ENABLE_ON_INIT), 1458c2ecf20Sopenharmony_ci [HWBLK_OC] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 29, CLK_ENABLE_ON_INIT), 1468c2ecf20Sopenharmony_ci [HWBLK_L2C] = SH_CLK_MSTP32(&div4_clks[DIV4_SH], MSTPCR0, 28, CLK_ENABLE_ON_INIT), 1478c2ecf20Sopenharmony_ci [HWBLK_ILMEM] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 27, CLK_ENABLE_ON_INIT), 1488c2ecf20Sopenharmony_ci [HWBLK_FPU] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 24, CLK_ENABLE_ON_INIT), 1498c2ecf20Sopenharmony_ci [HWBLK_INTC] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 22, CLK_ENABLE_ON_INIT), 1508c2ecf20Sopenharmony_ci [HWBLK_DMAC0] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 21, 0), 1518c2ecf20Sopenharmony_ci [HWBLK_SHYWAY] = SH_CLK_MSTP32(&div4_clks[DIV4_SH], MSTPCR0, 20, CLK_ENABLE_ON_INIT), 1528c2ecf20Sopenharmony_ci [HWBLK_HUDI] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 19, 0), 1538c2ecf20Sopenharmony_ci [HWBLK_UBC] = SH_CLK_MSTP32(&div4_clks[DIV4_I], MSTPCR0, 17, 0), 1548c2ecf20Sopenharmony_ci [HWBLK_TMU0] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 15, 0), 1558c2ecf20Sopenharmony_ci [HWBLK_CMT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 14, 0), 1568c2ecf20Sopenharmony_ci [HWBLK_RWDT] = SH_CLK_MSTP32(&r_clk, MSTPCR0, 13, 0), 1578c2ecf20Sopenharmony_ci [HWBLK_DMAC1] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 12, 0), 1588c2ecf20Sopenharmony_ci [HWBLK_TMU1] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 11, 0), 1598c2ecf20Sopenharmony_ci [HWBLK_FLCTL] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 10, 0), 1608c2ecf20Sopenharmony_ci [HWBLK_SCIF0] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 9, 0), 1618c2ecf20Sopenharmony_ci [HWBLK_SCIF1] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 8, 0), 1628c2ecf20Sopenharmony_ci [HWBLK_SCIF2] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 7, 0), 1638c2ecf20Sopenharmony_ci [HWBLK_SCIF3] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 6, 0), 1648c2ecf20Sopenharmony_ci [HWBLK_SCIF4] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 5, 0), 1658c2ecf20Sopenharmony_ci [HWBLK_SCIF5] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 4, 0), 1668c2ecf20Sopenharmony_ci [HWBLK_MSIOF0] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 2, 0), 1678c2ecf20Sopenharmony_ci [HWBLK_MSIOF1] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR0, 1, 0), 1688c2ecf20Sopenharmony_ci [HWBLK_MERAM] = SH_CLK_MSTP32(&div4_clks[DIV4_SH], MSTPCR0, 0, 0), 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci [HWBLK_IIC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 9, 0), 1718c2ecf20Sopenharmony_ci [HWBLK_RTC] = SH_CLK_MSTP32(&r_clk, MSTPCR1, 8, 0), 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci [HWBLK_ATAPI] = SH_CLK_MSTP32(&div4_clks[DIV4_SH], MSTPCR2, 28, 0), 1748c2ecf20Sopenharmony_ci [HWBLK_ADC] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 27, 0), 1758c2ecf20Sopenharmony_ci [HWBLK_TPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 25, 0), 1768c2ecf20Sopenharmony_ci [HWBLK_IRDA] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR2, 24, 0), 1778c2ecf20Sopenharmony_ci [HWBLK_TSIF] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 22, 0), 1788c2ecf20Sopenharmony_ci [HWBLK_ICB] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 21, CLK_ENABLE_ON_INIT), 1798c2ecf20Sopenharmony_ci [HWBLK_SDHI0] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 18, 0), 1808c2ecf20Sopenharmony_ci [HWBLK_SDHI1] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 17, 0), 1818c2ecf20Sopenharmony_ci [HWBLK_KEYSC] = SH_CLK_MSTP32(&r_clk, MSTPCR2, 14, 0), 1828c2ecf20Sopenharmony_ci [HWBLK_USB] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 11, 0), 1838c2ecf20Sopenharmony_ci [HWBLK_2DG] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 10, 0), 1848c2ecf20Sopenharmony_ci [HWBLK_SIU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 8, 0), 1858c2ecf20Sopenharmony_ci [HWBLK_VEU2H1] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 6, 0), 1868c2ecf20Sopenharmony_ci [HWBLK_VOU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 5, 0), 1878c2ecf20Sopenharmony_ci [HWBLK_BEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 4, 0), 1888c2ecf20Sopenharmony_ci [HWBLK_CEU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 3, 0), 1898c2ecf20Sopenharmony_ci [HWBLK_VEU2H0] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 2, 0), 1908c2ecf20Sopenharmony_ci [HWBLK_VPU] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 1, 0), 1918c2ecf20Sopenharmony_ci [HWBLK_LCDC] = SH_CLK_MSTP32(&div4_clks[DIV4_B], MSTPCR2, 0, 0), 1928c2ecf20Sopenharmony_ci}; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic struct clk_lookup lookups[] = { 1958c2ecf20Sopenharmony_ci /* main clocks */ 1968c2ecf20Sopenharmony_ci CLKDEV_CON_ID("rclk", &r_clk), 1978c2ecf20Sopenharmony_ci CLKDEV_CON_ID("extal", &extal_clk), 1988c2ecf20Sopenharmony_ci CLKDEV_CON_ID("dll_clk", &dll_clk), 1998c2ecf20Sopenharmony_ci CLKDEV_CON_ID("pll_clk", &pll_clk), 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci /* DIV4 clocks */ 2028c2ecf20Sopenharmony_ci CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]), 2038c2ecf20Sopenharmony_ci CLKDEV_CON_ID("umem_clk", &div4_clks[DIV4_U]), 2048c2ecf20Sopenharmony_ci CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]), 2058c2ecf20Sopenharmony_ci CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]), 2068c2ecf20Sopenharmony_ci CLKDEV_CON_ID("b3_clk", &div4_clks[DIV4_B3]), 2078c2ecf20Sopenharmony_ci CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]), 2088c2ecf20Sopenharmony_ci CLKDEV_CON_ID("irda_clk", &div4_enable_clks[DIV4_IRDA]), 2098c2ecf20Sopenharmony_ci CLKDEV_CON_ID("siua_clk", &div4_reparent_clks[DIV4_SIUA]), 2108c2ecf20Sopenharmony_ci CLKDEV_CON_ID("siub_clk", &div4_reparent_clks[DIV4_SIUB]), 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci /* DIV6 clocks */ 2138c2ecf20Sopenharmony_ci CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]), 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /* MSTP clocks */ 2168c2ecf20Sopenharmony_ci CLKDEV_CON_ID("tlb0", &mstp_clks[HWBLK_TLB]), 2178c2ecf20Sopenharmony_ci CLKDEV_CON_ID("ic0", &mstp_clks[HWBLK_IC]), 2188c2ecf20Sopenharmony_ci CLKDEV_CON_ID("oc0", &mstp_clks[HWBLK_OC]), 2198c2ecf20Sopenharmony_ci CLKDEV_CON_ID("l2c0", &mstp_clks[HWBLK_L2C]), 2208c2ecf20Sopenharmony_ci CLKDEV_CON_ID("ilmem0", &mstp_clks[HWBLK_ILMEM]), 2218c2ecf20Sopenharmony_ci CLKDEV_CON_ID("fpu0", &mstp_clks[HWBLK_FPU]), 2228c2ecf20Sopenharmony_ci CLKDEV_CON_ID("intc0", &mstp_clks[HWBLK_INTC]), 2238c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[HWBLK_DMAC0]), 2248c2ecf20Sopenharmony_ci CLKDEV_CON_ID("sh0", &mstp_clks[HWBLK_SHYWAY]), 2258c2ecf20Sopenharmony_ci CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]), 2268c2ecf20Sopenharmony_ci CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]), 2278c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]), 2288c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), 2298c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]), 2308c2ecf20Sopenharmony_ci CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]), 2318c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("spi_sh_msiof.0", &mstp_clks[HWBLK_MSIOF0]), 2328c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("spi_sh_msiof.1", &mstp_clks[HWBLK_MSIOF1]), 2338c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh_mobile_meram.0", &mstp_clks[HWBLK_MERAM]), 2348c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[HWBLK_IIC]), 2358c2ecf20Sopenharmony_ci CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]), 2368c2ecf20Sopenharmony_ci CLKDEV_CON_ID("atapi0", &mstp_clks[HWBLK_ATAPI]), 2378c2ecf20Sopenharmony_ci CLKDEV_CON_ID("adc0", &mstp_clks[HWBLK_ADC]), 2388c2ecf20Sopenharmony_ci CLKDEV_CON_ID("tpu0", &mstp_clks[HWBLK_TPU]), 2398c2ecf20Sopenharmony_ci CLKDEV_CON_ID("irda0", &mstp_clks[HWBLK_IRDA]), 2408c2ecf20Sopenharmony_ci CLKDEV_CON_ID("tsif0", &mstp_clks[HWBLK_TSIF]), 2418c2ecf20Sopenharmony_ci CLKDEV_CON_ID("icb0", &mstp_clks[HWBLK_ICB]), 2428c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[HWBLK_SDHI0]), 2438c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[HWBLK_SDHI1]), 2448c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[HWBLK_KEYSC]), 2458c2ecf20Sopenharmony_ci CLKDEV_CON_ID("usb0", &mstp_clks[HWBLK_USB]), 2468c2ecf20Sopenharmony_ci CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]), 2478c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("siu-pcm-audio", &mstp_clks[HWBLK_SIU]), 2488c2ecf20Sopenharmony_ci CLKDEV_CON_ID("veu1", &mstp_clks[HWBLK_VEU2H1]), 2498c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]), 2508c2ecf20Sopenharmony_ci CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]), 2518c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("ceu.0", &mstp_clks[HWBLK_CEU]), 2528c2ecf20Sopenharmony_ci CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU2H0]), 2538c2ecf20Sopenharmony_ci CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]), 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU0]), 2568c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[HWBLK_TMU1]), 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.0", &mstp_clks[HWBLK_SCIF0]), 2598c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.1", &mstp_clks[HWBLK_SCIF1]), 2608c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.2", &mstp_clks[HWBLK_SCIF2]), 2618c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.3", &mstp_clks[HWBLK_SCIF3]), 2628c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.4", &mstp_clks[HWBLK_SCIF4]), 2638c2ecf20Sopenharmony_ci CLKDEV_ICK_ID("fck", "sh-sci.5", &mstp_clks[HWBLK_SCIF5]), 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[HWBLK_LCDC]), 2668c2ecf20Sopenharmony_ci}; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ciint __init arch_clk_init(void) 2698c2ecf20Sopenharmony_ci{ 2708c2ecf20Sopenharmony_ci int k, ret = 0; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci /* autodetect extal or dll configuration */ 2738c2ecf20Sopenharmony_ci if (__raw_readl(PLLCR) & 0x1000) 2748c2ecf20Sopenharmony_ci pll_clk.parent = &dll_clk; 2758c2ecf20Sopenharmony_ci else 2768c2ecf20Sopenharmony_ci pll_clk.parent = &extal_clk; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) 2798c2ecf20Sopenharmony_ci ret |= clk_register(main_clks[k]); 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci if (!ret) 2848c2ecf20Sopenharmony_ci ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci if (!ret) 2878c2ecf20Sopenharmony_ci ret = sh_clk_div4_enable_register(div4_enable_clks, 2888c2ecf20Sopenharmony_ci DIV4_ENABLE_NR, &div4_table); 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci if (!ret) 2918c2ecf20Sopenharmony_ci ret = sh_clk_div4_reparent_register(div4_reparent_clks, 2928c2ecf20Sopenharmony_ci DIV4_REPARENT_NR, &div4_table); 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci if (!ret) 2958c2ecf20Sopenharmony_ci ret = sh_clk_div6_register(div6_clks, DIV6_NR); 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci if (!ret) 2988c2ecf20Sopenharmony_ci ret = sh_clk_mstp_register(mstp_clks, HWBLK_NR); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci return ret; 3018c2ecf20Sopenharmony_ci} 302