18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * mmp2 clock framework source file 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Marvell 58c2ecf20Sopenharmony_ci * Chao Xie <xiechao.mail@gmail.com> 68c2ecf20Sopenharmony_ci * Copyright (C) 2020 Lubomir Rintel <lkundrak@v3.sk> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public 98c2ecf20Sopenharmony_ci * License version 2. This program is licensed "as is" without any 108c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/module.h> 148c2ecf20Sopenharmony_ci#include <linux/kernel.h> 158c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 168c2ecf20Sopenharmony_ci#include <linux/io.h> 178c2ecf20Sopenharmony_ci#include <linux/delay.h> 188c2ecf20Sopenharmony_ci#include <linux/err.h> 198c2ecf20Sopenharmony_ci#include <linux/of_address.h> 208c2ecf20Sopenharmony_ci#include <linux/clk.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <dt-bindings/clock/marvell,mmp2.h> 238c2ecf20Sopenharmony_ci#include <dt-bindings/power/marvell,mmp2.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include "clk.h" 268c2ecf20Sopenharmony_ci#include "reset.h" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define APBC_RTC 0x0 298c2ecf20Sopenharmony_ci#define APBC_TWSI0 0x4 308c2ecf20Sopenharmony_ci#define APBC_TWSI1 0x8 318c2ecf20Sopenharmony_ci#define APBC_TWSI2 0xc 328c2ecf20Sopenharmony_ci#define APBC_TWSI3 0x10 338c2ecf20Sopenharmony_ci#define APBC_TWSI4 0x7c 348c2ecf20Sopenharmony_ci#define APBC_TWSI5 0x80 358c2ecf20Sopenharmony_ci#define APBC_KPC 0x18 368c2ecf20Sopenharmony_ci#define APBC_TIMER 0x24 378c2ecf20Sopenharmony_ci#define APBC_UART0 0x2c 388c2ecf20Sopenharmony_ci#define APBC_UART1 0x30 398c2ecf20Sopenharmony_ci#define APBC_UART2 0x34 408c2ecf20Sopenharmony_ci#define APBC_UART3 0x88 418c2ecf20Sopenharmony_ci#define APBC_GPIO 0x38 428c2ecf20Sopenharmony_ci#define APBC_PWM0 0x3c 438c2ecf20Sopenharmony_ci#define APBC_PWM1 0x40 448c2ecf20Sopenharmony_ci#define APBC_PWM2 0x44 458c2ecf20Sopenharmony_ci#define APBC_PWM3 0x48 468c2ecf20Sopenharmony_ci#define APBC_SSP0 0x50 478c2ecf20Sopenharmony_ci#define APBC_SSP1 0x54 488c2ecf20Sopenharmony_ci#define APBC_SSP2 0x58 498c2ecf20Sopenharmony_ci#define APBC_SSP3 0x5c 508c2ecf20Sopenharmony_ci#define APBC_THERMAL0 0x90 518c2ecf20Sopenharmony_ci#define APBC_THERMAL1 0x98 528c2ecf20Sopenharmony_ci#define APBC_THERMAL2 0x9c 538c2ecf20Sopenharmony_ci#define APBC_THERMAL3 0xa0 548c2ecf20Sopenharmony_ci#define APMU_SDH0 0x54 558c2ecf20Sopenharmony_ci#define APMU_SDH1 0x58 568c2ecf20Sopenharmony_ci#define APMU_SDH2 0xe8 578c2ecf20Sopenharmony_ci#define APMU_SDH3 0xec 588c2ecf20Sopenharmony_ci#define APMU_SDH4 0x15c 598c2ecf20Sopenharmony_ci#define APMU_USB 0x5c 608c2ecf20Sopenharmony_ci#define APMU_DISP0 0x4c 618c2ecf20Sopenharmony_ci#define APMU_DISP1 0x110 628c2ecf20Sopenharmony_ci#define APMU_CCIC0 0x50 638c2ecf20Sopenharmony_ci#define APMU_CCIC1 0xf4 648c2ecf20Sopenharmony_ci#define APMU_USBHSIC0 0xf8 658c2ecf20Sopenharmony_ci#define APMU_USBHSIC1 0xfc 668c2ecf20Sopenharmony_ci#define APMU_GPU 0xcc 678c2ecf20Sopenharmony_ci#define APMU_AUDIO 0x10c 688c2ecf20Sopenharmony_ci#define APMU_CAMERA 0x1fc 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define MPMU_FCCR 0x8 718c2ecf20Sopenharmony_ci#define MPMU_POSR 0x10 728c2ecf20Sopenharmony_ci#define MPMU_UART_PLL 0x14 738c2ecf20Sopenharmony_ci#define MPMU_PLL2_CR 0x34 748c2ecf20Sopenharmony_ci#define MPMU_I2S0_PLL 0x40 758c2ecf20Sopenharmony_ci#define MPMU_I2S1_PLL 0x44 768c2ecf20Sopenharmony_ci#define MPMU_ACGR 0x1024 778c2ecf20Sopenharmony_ci/* MMP3 specific below */ 788c2ecf20Sopenharmony_ci#define MPMU_PLL3_CR 0x50 798c2ecf20Sopenharmony_ci#define MPMU_PLL3_CTRL1 0x58 808c2ecf20Sopenharmony_ci#define MPMU_PLL1_CTRL 0x5c 818c2ecf20Sopenharmony_ci#define MPMU_PLL_DIFF_CTRL 0x68 828c2ecf20Sopenharmony_ci#define MPMU_PLL2_CTRL1 0x414 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cienum mmp2_clk_model { 858c2ecf20Sopenharmony_ci CLK_MODEL_MMP2, 868c2ecf20Sopenharmony_ci CLK_MODEL_MMP3, 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct mmp2_clk_unit { 908c2ecf20Sopenharmony_ci struct mmp_clk_unit unit; 918c2ecf20Sopenharmony_ci enum mmp2_clk_model model; 928c2ecf20Sopenharmony_ci struct genpd_onecell_data pd_data; 938c2ecf20Sopenharmony_ci struct generic_pm_domain *pm_domains[MMP2_NR_POWER_DOMAINS]; 948c2ecf20Sopenharmony_ci void __iomem *mpmu_base; 958c2ecf20Sopenharmony_ci void __iomem *apmu_base; 968c2ecf20Sopenharmony_ci void __iomem *apbc_base; 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic struct mmp_param_fixed_rate_clk fixed_rate_clks[] = { 1008c2ecf20Sopenharmony_ci {MMP2_CLK_CLK32, "clk32", NULL, 0, 32768}, 1018c2ecf20Sopenharmony_ci {MMP2_CLK_VCTCXO, "vctcxo", NULL, 0, 26000000}, 1028c2ecf20Sopenharmony_ci {MMP2_CLK_USB_PLL, "usb_pll", NULL, 0, 480000000}, 1038c2ecf20Sopenharmony_ci {0, "i2s_pll", NULL, 0, 99666667}, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic struct mmp_param_pll_clk pll_clks[] = { 1078c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1, "pll1", 797330000, MPMU_FCCR, 0x4000, MPMU_POSR, 0}, 1088c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2, "pll2", 0, MPMU_PLL2_CR, 0x0300, MPMU_PLL2_CR, 10}, 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistatic struct mmp_param_pll_clk mmp3_pll_clks[] = { 1128c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2, "pll1", 797330000, MPMU_FCCR, 0x4000, MPMU_POSR, 0, 26000000, MPMU_PLL1_CTRL, 25}, 1138c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2, "pll2", 0, MPMU_PLL2_CR, 0x0300, MPMU_PLL2_CR, 10, 26000000, MPMU_PLL2_CTRL1, 25}, 1148c2ecf20Sopenharmony_ci {MMP3_CLK_PLL1_P, "pll1_p", 0, MPMU_PLL_DIFF_CTRL, 0x0010, 0, 0, 797330000, MPMU_PLL_DIFF_CTRL, 0}, 1158c2ecf20Sopenharmony_ci {MMP3_CLK_PLL2_P, "pll2_p", 0, MPMU_PLL_DIFF_CTRL, 0x0100, MPMU_PLL2_CR, 10, 26000000, MPMU_PLL_DIFF_CTRL, 5}, 1168c2ecf20Sopenharmony_ci {MMP3_CLK_PLL3, "pll3", 0, MPMU_PLL3_CR, 0x0300, MPMU_PLL3_CR, 10, 26000000, MPMU_PLL3_CTRL1, 25}, 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic struct mmp_param_fixed_factor_clk fixed_factor_clks[] = { 1208c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_2, "pll1_2", "pll1", 1, 2, 0}, 1218c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_4, "pll1_4", "pll1_2", 1, 2, 0}, 1228c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_8, "pll1_8", "pll1_4", 1, 2, 0}, 1238c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_16, "pll1_16", "pll1_8", 1, 2, 0}, 1248c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_20, "pll1_20", "pll1_4", 1, 5, 0}, 1258c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_3, "pll1_3", "pll1", 1, 3, 0}, 1268c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_6, "pll1_6", "pll1_3", 1, 2, 0}, 1278c2ecf20Sopenharmony_ci {MMP2_CLK_PLL1_12, "pll1_12", "pll1_6", 1, 2, 0}, 1288c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_2, "pll2_2", "pll2", 1, 2, 0}, 1298c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_4, "pll2_4", "pll2_2", 1, 2, 0}, 1308c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_8, "pll2_8", "pll2_4", 1, 2, 0}, 1318c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_16, "pll2_16", "pll2_8", 1, 2, 0}, 1328c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_3, "pll2_3", "pll2", 1, 3, 0}, 1338c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_6, "pll2_6", "pll2_3", 1, 2, 0}, 1348c2ecf20Sopenharmony_ci {MMP2_CLK_PLL2_12, "pll2_12", "pll2_6", 1, 2, 0}, 1358c2ecf20Sopenharmony_ci {MMP2_CLK_VCTCXO_2, "vctcxo_2", "vctcxo", 1, 2, 0}, 1368c2ecf20Sopenharmony_ci {MMP2_CLK_VCTCXO_4, "vctcxo_4", "vctcxo_2", 1, 2, 0}, 1378c2ecf20Sopenharmony_ci}; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_masks uart_factor_masks = { 1408c2ecf20Sopenharmony_ci .factor = 2, 1418c2ecf20Sopenharmony_ci .num_mask = 0x1fff, 1428c2ecf20Sopenharmony_ci .den_mask = 0x1fff, 1438c2ecf20Sopenharmony_ci .num_shift = 16, 1448c2ecf20Sopenharmony_ci .den_shift = 0, 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_tbl uart_factor_tbl[] = { 1488c2ecf20Sopenharmony_ci {.num = 8125, .den = 1536}, /*14.745MHZ */ 1498c2ecf20Sopenharmony_ci {.num = 3521, .den = 689}, /*19.23MHZ */ 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_masks i2s_factor_masks = { 1538c2ecf20Sopenharmony_ci .factor = 2, 1548c2ecf20Sopenharmony_ci .num_mask = 0x7fff, 1558c2ecf20Sopenharmony_ci .den_mask = 0x1fff, 1568c2ecf20Sopenharmony_ci .num_shift = 0, 1578c2ecf20Sopenharmony_ci .den_shift = 15, 1588c2ecf20Sopenharmony_ci .enable_mask = 0xd0000000, 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_tbl i2s_factor_tbl[] = { 1628c2ecf20Sopenharmony_ci {.num = 24868, .den = 511}, /* 2.0480 MHz */ 1638c2ecf20Sopenharmony_ci {.num = 28003, .den = 793}, /* 2.8224 MHz */ 1648c2ecf20Sopenharmony_ci {.num = 24941, .den = 1025}, /* 4.0960 MHz */ 1658c2ecf20Sopenharmony_ci {.num = 28003, .den = 1586}, /* 5.6448 MHz */ 1668c2ecf20Sopenharmony_ci {.num = 31158, .den = 2561}, /* 8.1920 MHz */ 1678c2ecf20Sopenharmony_ci {.num = 16288, .den = 1845}, /* 11.2896 MHz */ 1688c2ecf20Sopenharmony_ci {.num = 20772, .den = 2561}, /* 12.2880 MHz */ 1698c2ecf20Sopenharmony_ci {.num = 8144, .den = 1845}, /* 22.5792 MHz */ 1708c2ecf20Sopenharmony_ci {.num = 10386, .den = 2561}, /* 24.5760 MHz */ 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(acgr_lock); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk mpmu_gate_clks[] = { 1768c2ecf20Sopenharmony_ci {MMP2_CLK_I2S0, "i2s0_clk", "i2s0_pll", CLK_SET_RATE_PARENT, MPMU_ACGR, 0x200000, 0x200000, 0x0, 0, &acgr_lock}, 1778c2ecf20Sopenharmony_ci {MMP2_CLK_I2S1, "i2s1_clk", "i2s1_pll", CLK_SET_RATE_PARENT, MPMU_ACGR, 0x100000, 0x100000, 0x0, 0, &acgr_lock}, 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_cistatic void mmp2_main_clk_init(struct mmp2_clk_unit *pxa_unit) 1818c2ecf20Sopenharmony_ci{ 1828c2ecf20Sopenharmony_ci struct clk *clk; 1838c2ecf20Sopenharmony_ci struct mmp_clk_unit *unit = &pxa_unit->unit; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci mmp_register_fixed_rate_clks(unit, fixed_rate_clks, 1868c2ecf20Sopenharmony_ci ARRAY_SIZE(fixed_rate_clks)); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci if (pxa_unit->model == CLK_MODEL_MMP3) { 1898c2ecf20Sopenharmony_ci mmp_register_pll_clks(unit, mmp3_pll_clks, 1908c2ecf20Sopenharmony_ci pxa_unit->mpmu_base, 1918c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp3_pll_clks)); 1928c2ecf20Sopenharmony_ci } else { 1938c2ecf20Sopenharmony_ci mmp_register_pll_clks(unit, pll_clks, 1948c2ecf20Sopenharmony_ci pxa_unit->mpmu_base, 1958c2ecf20Sopenharmony_ci ARRAY_SIZE(pll_clks)); 1968c2ecf20Sopenharmony_ci } 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci mmp_register_fixed_factor_clks(unit, fixed_factor_clks, 1998c2ecf20Sopenharmony_ci ARRAY_SIZE(fixed_factor_clks)); 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci clk = mmp_clk_register_factor("uart_pll", "pll1_4", 2028c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 2038c2ecf20Sopenharmony_ci pxa_unit->mpmu_base + MPMU_UART_PLL, 2048c2ecf20Sopenharmony_ci &uart_factor_masks, uart_factor_tbl, 2058c2ecf20Sopenharmony_ci ARRAY_SIZE(uart_factor_tbl), NULL); 2068c2ecf20Sopenharmony_ci mmp_clk_add(unit, MMP2_CLK_UART_PLL, clk); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci mmp_clk_register_factor("i2s0_pll", "pll1_4", 2098c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 2108c2ecf20Sopenharmony_ci pxa_unit->mpmu_base + MPMU_I2S0_PLL, 2118c2ecf20Sopenharmony_ci &i2s_factor_masks, i2s_factor_tbl, 2128c2ecf20Sopenharmony_ci ARRAY_SIZE(i2s_factor_tbl), NULL); 2138c2ecf20Sopenharmony_ci mmp_clk_register_factor("i2s1_pll", "pll1_4", 2148c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 2158c2ecf20Sopenharmony_ci pxa_unit->mpmu_base + MPMU_I2S1_PLL, 2168c2ecf20Sopenharmony_ci &i2s_factor_masks, i2s_factor_tbl, 2178c2ecf20Sopenharmony_ci ARRAY_SIZE(i2s_factor_tbl), NULL); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, mpmu_gate_clks, pxa_unit->mpmu_base, 2208c2ecf20Sopenharmony_ci ARRAY_SIZE(mpmu_gate_clks)); 2218c2ecf20Sopenharmony_ci} 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart0_lock); 2248c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart1_lock); 2258c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart2_lock); 2268c2ecf20Sopenharmony_cistatic const char * const uart_parent_names[] = {"uart_pll", "vctcxo"}; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp0_lock); 2298c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp1_lock); 2308c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp2_lock); 2318c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp3_lock); 2328c2ecf20Sopenharmony_cistatic const char * const ssp_parent_names[] = {"vctcxo_4", "vctcxo_2", "vctcxo", "pll1_16"}; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(timer_lock); 2358c2ecf20Sopenharmony_cistatic const char * const timer_parent_names[] = {"clk32", "vctcxo_4", "vctcxo_2", "vctcxo"}; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(reset_lock); 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistatic struct mmp_param_mux_clk apbc_mux_clks[] = { 2408c2ecf20Sopenharmony_ci {0, "uart0_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART0, 4, 3, 0, &uart0_lock}, 2418c2ecf20Sopenharmony_ci {0, "uart1_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART1, 4, 3, 0, &uart1_lock}, 2428c2ecf20Sopenharmony_ci {0, "uart2_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART2, 4, 3, 0, &uart2_lock}, 2438c2ecf20Sopenharmony_ci {0, "uart3_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, APBC_UART3, 4, 3, 0, &uart2_lock}, 2448c2ecf20Sopenharmony_ci {0, "ssp0_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP0, 4, 3, 0, &ssp0_lock}, 2458c2ecf20Sopenharmony_ci {0, "ssp1_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP1, 4, 3, 0, &ssp1_lock}, 2468c2ecf20Sopenharmony_ci {0, "ssp2_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP2, 4, 3, 0, &ssp2_lock}, 2478c2ecf20Sopenharmony_ci {0, "ssp3_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, APBC_SSP3, 4, 3, 0, &ssp3_lock}, 2488c2ecf20Sopenharmony_ci {0, "timer_mux", timer_parent_names, ARRAY_SIZE(timer_parent_names), CLK_SET_RATE_PARENT, APBC_TIMER, 4, 3, 0, &timer_lock}, 2498c2ecf20Sopenharmony_ci}; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk apbc_gate_clks[] = { 2528c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI0, "twsi0_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI0, 0x7, 0x3, 0x0, 0, &reset_lock}, 2538c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI1, "twsi1_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI1, 0x7, 0x3, 0x0, 0, &reset_lock}, 2548c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI2, "twsi2_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI2, 0x7, 0x3, 0x0, 0, &reset_lock}, 2558c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI3, "twsi3_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI3, 0x7, 0x3, 0x0, 0, &reset_lock}, 2568c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI4, "twsi4_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI4, 0x7, 0x3, 0x0, 0, &reset_lock}, 2578c2ecf20Sopenharmony_ci {MMP2_CLK_TWSI5, "twsi5_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_TWSI5, 0x7, 0x3, 0x0, 0, &reset_lock}, 2588c2ecf20Sopenharmony_ci {MMP2_CLK_GPIO, "gpio_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_GPIO, 0x7, 0x3, 0x0, 0, &reset_lock}, 2598c2ecf20Sopenharmony_ci {MMP2_CLK_KPC, "kpc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_KPC, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2608c2ecf20Sopenharmony_ci {MMP2_CLK_RTC, "rtc_clk", "clk32", CLK_SET_RATE_PARENT, APBC_RTC, 0x87, 0x83, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2618c2ecf20Sopenharmony_ci {MMP2_CLK_PWM0, "pwm0_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM0, 0x7, 0x3, 0x0, 0, &reset_lock}, 2628c2ecf20Sopenharmony_ci {MMP2_CLK_PWM1, "pwm1_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM1, 0x7, 0x3, 0x0, 0, &reset_lock}, 2638c2ecf20Sopenharmony_ci {MMP2_CLK_PWM2, "pwm2_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM2, 0x7, 0x3, 0x0, 0, &reset_lock}, 2648c2ecf20Sopenharmony_ci {MMP2_CLK_PWM3, "pwm3_clk", "pll1_48", CLK_SET_RATE_PARENT, APBC_PWM3, 0x7, 0x3, 0x0, 0, &reset_lock}, 2658c2ecf20Sopenharmony_ci /* The gate clocks has mux parent. */ 2668c2ecf20Sopenharmony_ci {MMP2_CLK_UART0, "uart0_clk", "uart0_mux", CLK_SET_RATE_PARENT, APBC_UART0, 0x7, 0x3, 0x0, 0, &uart0_lock}, 2678c2ecf20Sopenharmony_ci {MMP2_CLK_UART1, "uart1_clk", "uart1_mux", CLK_SET_RATE_PARENT, APBC_UART1, 0x7, 0x3, 0x0, 0, &uart1_lock}, 2688c2ecf20Sopenharmony_ci {MMP2_CLK_UART2, "uart2_clk", "uart2_mux", CLK_SET_RATE_PARENT, APBC_UART2, 0x7, 0x3, 0x0, 0, &uart2_lock}, 2698c2ecf20Sopenharmony_ci {MMP2_CLK_UART3, "uart3_clk", "uart3_mux", CLK_SET_RATE_PARENT, APBC_UART3, 0x7, 0x3, 0x0, 0, &uart2_lock}, 2708c2ecf20Sopenharmony_ci {MMP2_CLK_SSP0, "ssp0_clk", "ssp0_mux", CLK_SET_RATE_PARENT, APBC_SSP0, 0x7, 0x3, 0x0, 0, &ssp0_lock}, 2718c2ecf20Sopenharmony_ci {MMP2_CLK_SSP1, "ssp1_clk", "ssp1_mux", CLK_SET_RATE_PARENT, APBC_SSP1, 0x7, 0x3, 0x0, 0, &ssp1_lock}, 2728c2ecf20Sopenharmony_ci {MMP2_CLK_SSP2, "ssp2_clk", "ssp2_mux", CLK_SET_RATE_PARENT, APBC_SSP2, 0x7, 0x3, 0x0, 0, &ssp2_lock}, 2738c2ecf20Sopenharmony_ci {MMP2_CLK_SSP3, "ssp3_clk", "ssp3_mux", CLK_SET_RATE_PARENT, APBC_SSP3, 0x7, 0x3, 0x0, 0, &ssp3_lock}, 2748c2ecf20Sopenharmony_ci {MMP2_CLK_TIMER, "timer_clk", "timer_mux", CLK_SET_RATE_PARENT, APBC_TIMER, 0x7, 0x3, 0x0, 0, &timer_lock}, 2758c2ecf20Sopenharmony_ci {MMP2_CLK_THERMAL0, "thermal0_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_THERMAL0, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2768c2ecf20Sopenharmony_ci}; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk mmp3_apbc_gate_clks[] = { 2798c2ecf20Sopenharmony_ci {MMP3_CLK_THERMAL1, "thermal1_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_THERMAL1, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2808c2ecf20Sopenharmony_ci {MMP3_CLK_THERMAL2, "thermal2_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_THERMAL2, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2818c2ecf20Sopenharmony_ci {MMP3_CLK_THERMAL3, "thermal3_clk", "vctcxo", CLK_SET_RATE_PARENT, APBC_THERMAL3, 0x7, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, &reset_lock}, 2828c2ecf20Sopenharmony_ci}; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_cistatic void mmp2_apb_periph_clk_init(struct mmp2_clk_unit *pxa_unit) 2858c2ecf20Sopenharmony_ci{ 2868c2ecf20Sopenharmony_ci struct mmp_clk_unit *unit = &pxa_unit->unit; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci mmp_register_mux_clks(unit, apbc_mux_clks, pxa_unit->apbc_base, 2898c2ecf20Sopenharmony_ci ARRAY_SIZE(apbc_mux_clks)); 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, apbc_gate_clks, pxa_unit->apbc_base, 2928c2ecf20Sopenharmony_ci ARRAY_SIZE(apbc_gate_clks)); 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci if (pxa_unit->model == CLK_MODEL_MMP3) { 2958c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, mmp3_apbc_gate_clks, pxa_unit->apbc_base, 2968c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp3_apbc_gate_clks)); 2978c2ecf20Sopenharmony_ci } 2988c2ecf20Sopenharmony_ci} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh_lock); 3018c2ecf20Sopenharmony_cistatic const char * const sdh_parent_names[] = {"pll1_4", "pll2", "usb_pll", "pll1"}; 3028c2ecf20Sopenharmony_cistatic struct mmp_clk_mix_config sdh_mix_config = { 3038c2ecf20Sopenharmony_ci .reg_info = DEFINE_MIX_REG_INFO(4, 10, 2, 8, 32), 3048c2ecf20Sopenharmony_ci}; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(usb_lock); 3078c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(usbhsic0_lock); 3088c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(usbhsic1_lock); 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(disp0_lock); 3118c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(disp1_lock); 3128c2ecf20Sopenharmony_cistatic const char * const disp_parent_names[] = {"pll1", "pll1_16", "pll2", "vctcxo"}; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ccic0_lock); 3158c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ccic1_lock); 3168c2ecf20Sopenharmony_cistatic const char * const ccic_parent_names[] = {"pll1_2", "pll1_16", "vctcxo"}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(gpu_lock); 3198c2ecf20Sopenharmony_cistatic const char * const mmp2_gpu_gc_parent_names[] = {"pll1_2", "pll1_3", "pll2_2", "pll2_3", "pll2", "usb_pll"}; 3208c2ecf20Sopenharmony_cistatic u32 mmp2_gpu_gc_parent_table[] = { 0x0000, 0x0040, 0x0080, 0x00c0, 0x1000, 0x1040 }; 3218c2ecf20Sopenharmony_cistatic const char * const mmp2_gpu_bus_parent_names[] = {"pll1_4", "pll2", "pll2_2", "usb_pll"}; 3228c2ecf20Sopenharmony_cistatic u32 mmp2_gpu_bus_parent_table[] = { 0x0000, 0x0020, 0x0030, 0x4020 }; 3238c2ecf20Sopenharmony_cistatic const char * const mmp3_gpu_bus_parent_names[] = {"pll1_4", "pll1_6", "pll1_2", "pll2_2"}; 3248c2ecf20Sopenharmony_cistatic const char * const mmp3_gpu_gc_parent_names[] = {"pll1", "pll2", "pll1_p", "pll2_p"}; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(audio_lock); 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic struct mmp_clk_mix_config ccic0_mix_config = { 3298c2ecf20Sopenharmony_ci .reg_info = DEFINE_MIX_REG_INFO(4, 17, 2, 6, 32), 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_cistatic struct mmp_clk_mix_config ccic1_mix_config = { 3328c2ecf20Sopenharmony_ci .reg_info = DEFINE_MIX_REG_INFO(4, 16, 2, 6, 32), 3338c2ecf20Sopenharmony_ci}; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic struct mmp_param_mux_clk apmu_mux_clks[] = { 3368c2ecf20Sopenharmony_ci {MMP2_CLK_DISP0_MUX, "disp0_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP0, 6, 2, 0, &disp0_lock}, 3378c2ecf20Sopenharmony_ci {MMP2_CLK_DISP1_MUX, "disp1_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP1, 6, 2, 0, &disp1_lock}, 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cistatic struct mmp_param_mux_clk mmp3_apmu_mux_clks[] = { 3418c2ecf20Sopenharmony_ci {0, "gpu_bus_mux", mmp3_gpu_bus_parent_names, ARRAY_SIZE(mmp3_gpu_bus_parent_names), 3428c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, APMU_GPU, 4, 2, 0, &gpu_lock}, 3438c2ecf20Sopenharmony_ci {0, "gpu_3d_mux", mmp3_gpu_gc_parent_names, ARRAY_SIZE(mmp3_gpu_gc_parent_names), 3448c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, APMU_GPU, 6, 2, 0, &gpu_lock}, 3458c2ecf20Sopenharmony_ci {0, "gpu_2d_mux", mmp3_gpu_gc_parent_names, ARRAY_SIZE(mmp3_gpu_gc_parent_names), 3468c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, APMU_GPU, 12, 2, 0, &gpu_lock}, 3478c2ecf20Sopenharmony_ci}; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_cistatic struct mmp_param_div_clk apmu_div_clks[] = { 3508c2ecf20Sopenharmony_ci {0, "disp0_div", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 8, 4, CLK_DIVIDER_ONE_BASED, &disp0_lock}, 3518c2ecf20Sopenharmony_ci {0, "disp0_sphy_div", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 15, 5, 0, &disp0_lock}, 3528c2ecf20Sopenharmony_ci {0, "disp1_div", "disp1_mux", CLK_SET_RATE_PARENT, APMU_DISP1, 8, 4, CLK_DIVIDER_ONE_BASED, &disp1_lock}, 3538c2ecf20Sopenharmony_ci {0, "ccic0_sphy_div", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 10, 5, 0, &ccic0_lock}, 3548c2ecf20Sopenharmony_ci {0, "ccic1_sphy_div", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 10, 5, 0, &ccic1_lock}, 3558c2ecf20Sopenharmony_ci}; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cistatic struct mmp_param_div_clk mmp3_apmu_div_clks[] = { 3588c2ecf20Sopenharmony_ci {0, "gpu_3d_div", "gpu_3d_mux", CLK_SET_RATE_PARENT, APMU_GPU, 24, 4, 0, &gpu_lock}, 3598c2ecf20Sopenharmony_ci {0, "gpu_2d_div", "gpu_2d_mux", CLK_SET_RATE_PARENT, APMU_GPU, 28, 4, 0, &gpu_lock}, 3608c2ecf20Sopenharmony_ci}; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk apmu_gate_clks[] = { 3638c2ecf20Sopenharmony_ci {MMP2_CLK_USB, "usb_clk", "usb_pll", 0, APMU_USB, 0x9, 0x9, 0x0, 0, &usb_lock}, 3648c2ecf20Sopenharmony_ci {MMP2_CLK_USBHSIC0, "usbhsic0_clk", "usb_pll", 0, APMU_USBHSIC0, 0x1b, 0x1b, 0x0, 0, &usbhsic0_lock}, 3658c2ecf20Sopenharmony_ci {MMP2_CLK_USBHSIC1, "usbhsic1_clk", "usb_pll", 0, APMU_USBHSIC1, 0x1b, 0x1b, 0x0, 0, &usbhsic1_lock}, 3668c2ecf20Sopenharmony_ci /* The gate clocks has mux parent. */ 3678c2ecf20Sopenharmony_ci {MMP2_CLK_SDH0, "sdh0_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH0, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, 3688c2ecf20Sopenharmony_ci {MMP2_CLK_SDH1, "sdh1_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH1, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, 3698c2ecf20Sopenharmony_ci {MMP2_CLK_SDH2, "sdh2_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH2, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, 3708c2ecf20Sopenharmony_ci {MMP2_CLK_SDH3, "sdh3_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH3, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, 3718c2ecf20Sopenharmony_ci {MMP2_CLK_DISP0, "disp0_clk", "disp0_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x12, 0x12, 0x0, 0, &disp0_lock}, 3728c2ecf20Sopenharmony_ci {MMP2_CLK_DISP0_LCDC, "disp0_lcdc_clk", "disp0_mux", CLK_SET_RATE_PARENT, APMU_DISP0, 0x09, 0x09, 0x0, 0, &disp0_lock}, 3738c2ecf20Sopenharmony_ci {MMP2_CLK_DISP0_SPHY, "disp0_sphy_clk", "disp0_sphy_div", CLK_SET_RATE_PARENT, APMU_DISP0, 0x1024, 0x1024, 0x0, 0, &disp0_lock}, 3748c2ecf20Sopenharmony_ci {MMP2_CLK_DISP1, "disp1_clk", "disp1_div", CLK_SET_RATE_PARENT, APMU_DISP1, 0x09, 0x09, 0x0, 0, &disp1_lock}, 3758c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC_ARBITER, "ccic_arbiter", "vctcxo", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1800, 0x1800, 0x0, 0, &ccic0_lock}, 3768c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC0, "ccic0_clk", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x1b, 0x1b, 0x0, 0, &ccic0_lock}, 3778c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC0_PHY, "ccic0_phy_clk", "ccic0_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x24, 0x24, 0x0, 0, &ccic0_lock}, 3788c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC0_SPHY, "ccic0_sphy_clk", "ccic0_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC0, 0x300, 0x300, 0x0, 0, &ccic0_lock}, 3798c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC1, "ccic1_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x1b, 0x1b, 0x0, 0, &ccic1_lock}, 3808c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC1_PHY, "ccic1_phy_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x24, 0x24, 0x0, 0, &ccic1_lock}, 3818c2ecf20Sopenharmony_ci {MMP2_CLK_CCIC1_SPHY, "ccic1_sphy_clk", "ccic1_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x300, 0x300, 0x0, 0, &ccic1_lock}, 3828c2ecf20Sopenharmony_ci {MMP2_CLK_GPU_BUS, "gpu_bus_clk", "gpu_bus_mux", CLK_SET_RATE_PARENT, APMU_GPU, 0xa, 0xa, 0x0, MMP_CLK_GATE_NEED_DELAY, &gpu_lock}, 3838c2ecf20Sopenharmony_ci {MMP2_CLK_AUDIO, "audio_clk", "audio_mix_clk", CLK_SET_RATE_PARENT, APMU_AUDIO, 0x12, 0x12, 0x0, 0, &audio_lock}, 3848c2ecf20Sopenharmony_ci}; 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk mmp2_apmu_gate_clks[] = { 3878c2ecf20Sopenharmony_ci {MMP2_CLK_GPU_3D, "gpu_3d_clk", "gpu_3d_mux", CLK_SET_RATE_PARENT, APMU_GPU, 0x5, 0x5, 0x0, MMP_CLK_GATE_NEED_DELAY, &gpu_lock}, 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk mmp3_apmu_gate_clks[] = { 3918c2ecf20Sopenharmony_ci {MMP3_CLK_SDH4, "sdh4_clk", "sdh_mix_clk", CLK_SET_RATE_PARENT, APMU_SDH4, 0x1b, 0x1b, 0x0, 0, &sdh_lock}, 3928c2ecf20Sopenharmony_ci {MMP3_CLK_GPU_3D, "gpu_3d_clk", "gpu_3d_div", CLK_SET_RATE_PARENT, APMU_GPU, 0x5, 0x5, 0x0, MMP_CLK_GATE_NEED_DELAY, &gpu_lock}, 3938c2ecf20Sopenharmony_ci {MMP3_CLK_GPU_2D, "gpu_2d_clk", "gpu_2d_div", CLK_SET_RATE_PARENT, APMU_GPU, 0x1c0000, 0x1c0000, 0x0, MMP_CLK_GATE_NEED_DELAY, &gpu_lock}, 3948c2ecf20Sopenharmony_ci}; 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_cistatic void mmp2_axi_periph_clk_init(struct mmp2_clk_unit *pxa_unit) 3978c2ecf20Sopenharmony_ci{ 3988c2ecf20Sopenharmony_ci struct clk *clk; 3998c2ecf20Sopenharmony_ci struct mmp_clk_unit *unit = &pxa_unit->unit; 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci sdh_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_SDH0; 4028c2ecf20Sopenharmony_ci clk = mmp_clk_register_mix(NULL, "sdh_mix_clk", sdh_parent_names, 4038c2ecf20Sopenharmony_ci ARRAY_SIZE(sdh_parent_names), 4048c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 4058c2ecf20Sopenharmony_ci &sdh_mix_config, &sdh_lock); 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci ccic0_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_CCIC0; 4088c2ecf20Sopenharmony_ci clk = mmp_clk_register_mix(NULL, "ccic0_mix_clk", ccic_parent_names, 4098c2ecf20Sopenharmony_ci ARRAY_SIZE(ccic_parent_names), 4108c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 4118c2ecf20Sopenharmony_ci &ccic0_mix_config, &ccic0_lock); 4128c2ecf20Sopenharmony_ci mmp_clk_add(unit, MMP2_CLK_CCIC0_MIX, clk); 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci ccic1_mix_config.reg_info.reg_clk_ctrl = pxa_unit->apmu_base + APMU_CCIC1; 4158c2ecf20Sopenharmony_ci clk = mmp_clk_register_mix(NULL, "ccic1_mix_clk", ccic_parent_names, 4168c2ecf20Sopenharmony_ci ARRAY_SIZE(ccic_parent_names), 4178c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 4188c2ecf20Sopenharmony_ci &ccic1_mix_config, &ccic1_lock); 4198c2ecf20Sopenharmony_ci mmp_clk_add(unit, MMP2_CLK_CCIC1_MIX, clk); 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci mmp_register_mux_clks(unit, apmu_mux_clks, pxa_unit->apmu_base, 4228c2ecf20Sopenharmony_ci ARRAY_SIZE(apmu_mux_clks)); 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci mmp_register_div_clks(unit, apmu_div_clks, pxa_unit->apmu_base, 4258c2ecf20Sopenharmony_ci ARRAY_SIZE(apmu_div_clks)); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, apmu_gate_clks, pxa_unit->apmu_base, 4288c2ecf20Sopenharmony_ci ARRAY_SIZE(apmu_gate_clks)); 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci if (pxa_unit->model == CLK_MODEL_MMP3) { 4318c2ecf20Sopenharmony_ci mmp_register_mux_clks(unit, mmp3_apmu_mux_clks, pxa_unit->apmu_base, 4328c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp3_apmu_mux_clks)); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci mmp_register_div_clks(unit, mmp3_apmu_div_clks, pxa_unit->apmu_base, 4358c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp3_apmu_div_clks)); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, mmp3_apmu_gate_clks, pxa_unit->apmu_base, 4388c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp3_apmu_gate_clks)); 4398c2ecf20Sopenharmony_ci } else { 4408c2ecf20Sopenharmony_ci clk_register_mux_table(NULL, "gpu_3d_mux", mmp2_gpu_gc_parent_names, 4418c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp2_gpu_gc_parent_names), 4428c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 4438c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_GPU, 4448c2ecf20Sopenharmony_ci 0, 0x10c0, 0, 4458c2ecf20Sopenharmony_ci mmp2_gpu_gc_parent_table, &gpu_lock); 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci clk_register_mux_table(NULL, "gpu_bus_mux", mmp2_gpu_bus_parent_names, 4488c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp2_gpu_bus_parent_names), 4498c2ecf20Sopenharmony_ci CLK_SET_RATE_PARENT, 4508c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_GPU, 4518c2ecf20Sopenharmony_ci 0, 0x4030, 0, 4528c2ecf20Sopenharmony_ci mmp2_gpu_bus_parent_table, &gpu_lock); 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci mmp_register_gate_clks(unit, mmp2_apmu_gate_clks, pxa_unit->apmu_base, 4558c2ecf20Sopenharmony_ci ARRAY_SIZE(mmp2_apmu_gate_clks)); 4568c2ecf20Sopenharmony_ci } 4578c2ecf20Sopenharmony_ci} 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_cistatic void mmp2_clk_reset_init(struct device_node *np, 4608c2ecf20Sopenharmony_ci struct mmp2_clk_unit *pxa_unit) 4618c2ecf20Sopenharmony_ci{ 4628c2ecf20Sopenharmony_ci struct mmp_clk_reset_cell *cells; 4638c2ecf20Sopenharmony_ci int i, nr_resets; 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci nr_resets = ARRAY_SIZE(apbc_gate_clks); 4668c2ecf20Sopenharmony_ci cells = kcalloc(nr_resets, sizeof(*cells), GFP_KERNEL); 4678c2ecf20Sopenharmony_ci if (!cells) 4688c2ecf20Sopenharmony_ci return; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci for (i = 0; i < nr_resets; i++) { 4718c2ecf20Sopenharmony_ci cells[i].clk_id = apbc_gate_clks[i].id; 4728c2ecf20Sopenharmony_ci cells[i].reg = pxa_unit->apbc_base + apbc_gate_clks[i].offset; 4738c2ecf20Sopenharmony_ci cells[i].flags = 0; 4748c2ecf20Sopenharmony_ci cells[i].lock = apbc_gate_clks[i].lock; 4758c2ecf20Sopenharmony_ci cells[i].bits = 0x4; 4768c2ecf20Sopenharmony_ci } 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci mmp_clk_reset_register(np, cells, nr_resets); 4798c2ecf20Sopenharmony_ci} 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_cistatic void mmp2_pm_domain_init(struct device_node *np, 4828c2ecf20Sopenharmony_ci struct mmp2_clk_unit *pxa_unit) 4838c2ecf20Sopenharmony_ci{ 4848c2ecf20Sopenharmony_ci if (pxa_unit->model == CLK_MODEL_MMP3) { 4858c2ecf20Sopenharmony_ci pxa_unit->pm_domains[MMP2_POWER_DOMAIN_GPU] 4868c2ecf20Sopenharmony_ci = mmp_pm_domain_register("gpu", 4878c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_GPU, 4888c2ecf20Sopenharmony_ci 0x0600, 0x40003, 0x18000c, 0, &gpu_lock); 4898c2ecf20Sopenharmony_ci } else { 4908c2ecf20Sopenharmony_ci pxa_unit->pm_domains[MMP2_POWER_DOMAIN_GPU] 4918c2ecf20Sopenharmony_ci = mmp_pm_domain_register("gpu", 4928c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_GPU, 4938c2ecf20Sopenharmony_ci 0x8600, 0x00003, 0x00000c, 4948c2ecf20Sopenharmony_ci MMP_PM_DOMAIN_NO_DISABLE, &gpu_lock); 4958c2ecf20Sopenharmony_ci } 4968c2ecf20Sopenharmony_ci pxa_unit->pd_data.num_domains++; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci pxa_unit->pm_domains[MMP2_POWER_DOMAIN_AUDIO] 4998c2ecf20Sopenharmony_ci = mmp_pm_domain_register("audio", 5008c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_AUDIO, 5018c2ecf20Sopenharmony_ci 0x600, 0x2, 0, 0, &audio_lock); 5028c2ecf20Sopenharmony_ci pxa_unit->pd_data.num_domains++; 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci if (pxa_unit->model == CLK_MODEL_MMP3) { 5058c2ecf20Sopenharmony_ci pxa_unit->pm_domains[MMP3_POWER_DOMAIN_CAMERA] 5068c2ecf20Sopenharmony_ci = mmp_pm_domain_register("camera", 5078c2ecf20Sopenharmony_ci pxa_unit->apmu_base + APMU_CAMERA, 5088c2ecf20Sopenharmony_ci 0x600, 0, 0, 0, NULL); 5098c2ecf20Sopenharmony_ci pxa_unit->pd_data.num_domains++; 5108c2ecf20Sopenharmony_ci } 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci pxa_unit->pd_data.domains = pxa_unit->pm_domains; 5138c2ecf20Sopenharmony_ci of_genpd_add_provider_onecell(np, &pxa_unit->pd_data); 5148c2ecf20Sopenharmony_ci} 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_cistatic void __init mmp2_clk_init(struct device_node *np) 5178c2ecf20Sopenharmony_ci{ 5188c2ecf20Sopenharmony_ci struct mmp2_clk_unit *pxa_unit; 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL); 5218c2ecf20Sopenharmony_ci if (!pxa_unit) 5228c2ecf20Sopenharmony_ci return; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci if (of_device_is_compatible(np, "marvell,mmp3-clock")) 5258c2ecf20Sopenharmony_ci pxa_unit->model = CLK_MODEL_MMP3; 5268c2ecf20Sopenharmony_ci else 5278c2ecf20Sopenharmony_ci pxa_unit->model = CLK_MODEL_MMP2; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci pxa_unit->mpmu_base = of_iomap(np, 0); 5308c2ecf20Sopenharmony_ci if (!pxa_unit->mpmu_base) { 5318c2ecf20Sopenharmony_ci pr_err("failed to map mpmu registers\n"); 5328c2ecf20Sopenharmony_ci goto free_memory; 5338c2ecf20Sopenharmony_ci } 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci pxa_unit->apmu_base = of_iomap(np, 1); 5368c2ecf20Sopenharmony_ci if (!pxa_unit->apmu_base) { 5378c2ecf20Sopenharmony_ci pr_err("failed to map apmu registers\n"); 5388c2ecf20Sopenharmony_ci goto unmap_mpmu_region; 5398c2ecf20Sopenharmony_ci } 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci pxa_unit->apbc_base = of_iomap(np, 2); 5428c2ecf20Sopenharmony_ci if (!pxa_unit->apbc_base) { 5438c2ecf20Sopenharmony_ci pr_err("failed to map apbc registers\n"); 5448c2ecf20Sopenharmony_ci goto unmap_apmu_region; 5458c2ecf20Sopenharmony_ci } 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci mmp2_pm_domain_init(np, pxa_unit); 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci mmp_clk_init(np, &pxa_unit->unit, MMP2_NR_CLKS); 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci mmp2_main_clk_init(pxa_unit); 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci mmp2_apb_periph_clk_init(pxa_unit); 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci mmp2_axi_periph_clk_init(pxa_unit); 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci mmp2_clk_reset_init(np, pxa_unit); 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci return; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ciunmap_apmu_region: 5628c2ecf20Sopenharmony_ci iounmap(pxa_unit->apmu_base); 5638c2ecf20Sopenharmony_ciunmap_mpmu_region: 5648c2ecf20Sopenharmony_ci iounmap(pxa_unit->mpmu_base); 5658c2ecf20Sopenharmony_cifree_memory: 5668c2ecf20Sopenharmony_ci kfree(pxa_unit); 5678c2ecf20Sopenharmony_ci} 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mmp2_clk, "marvell,mmp2-clock", mmp2_clk_init); 5708c2ecf20Sopenharmony_ciCLK_OF_DECLARE(mmp3_clk, "marvell,mmp3-clock", mmp2_clk_init); 571