18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * pxa1928 clock framework source file
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2015 Linaro, Ltd.
58c2ecf20Sopenharmony_ci * Rob Herring <robh@kernel.org>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Based on drivers/clk/mmp/clk-of-mmp2.c:
88c2ecf20Sopenharmony_ci * Copyright (C) 2012 Marvell
98c2ecf20Sopenharmony_ci * Chao Xie <xiechao.mail@gmail.com>
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
128c2ecf20Sopenharmony_ci * License version 2. This program is licensed "as is" without any
138c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci#include <linux/kernel.h>
168c2ecf20Sopenharmony_ci#include <linux/io.h>
178c2ecf20Sopenharmony_ci#include <linux/of_address.h>
188c2ecf20Sopenharmony_ci#include <linux/slab.h>
198c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <dt-bindings/clock/marvell,pxa1928.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include "clk.h"
248c2ecf20Sopenharmony_ci#include "reset.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define MPMU_UART_PLL	0x14
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistruct pxa1928_clk_unit {
298c2ecf20Sopenharmony_ci	struct mmp_clk_unit unit;
308c2ecf20Sopenharmony_ci	void __iomem *mpmu_base;
318c2ecf20Sopenharmony_ci	void __iomem *apmu_base;
328c2ecf20Sopenharmony_ci	void __iomem *apbc_base;
338c2ecf20Sopenharmony_ci	void __iomem *apbcp_base;
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic struct mmp_param_fixed_rate_clk fixed_rate_clks[] = {
378c2ecf20Sopenharmony_ci	{0, "clk32", NULL, 0, 32768},
388c2ecf20Sopenharmony_ci	{0, "vctcxo", NULL, 0, 26000000},
398c2ecf20Sopenharmony_ci	{0, "pll1_624", NULL, 0, 624000000},
408c2ecf20Sopenharmony_ci	{0, "pll5p", NULL, 0, 832000000},
418c2ecf20Sopenharmony_ci	{0, "pll5", NULL, 0, 1248000000},
428c2ecf20Sopenharmony_ci	{0, "usb_pll", NULL, 0, 480000000},
438c2ecf20Sopenharmony_ci};
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistatic struct mmp_param_fixed_factor_clk fixed_factor_clks[] = {
468c2ecf20Sopenharmony_ci	{0, "pll1_d2", "pll1_624", 1, 2, 0},
478c2ecf20Sopenharmony_ci	{0, "pll1_d9", "pll1_624", 1, 9, 0},
488c2ecf20Sopenharmony_ci	{0, "pll1_d12", "pll1_624", 1, 12, 0},
498c2ecf20Sopenharmony_ci	{0, "pll1_d16", "pll1_624", 1, 16, 0},
508c2ecf20Sopenharmony_ci	{0, "pll1_d20", "pll1_624", 1, 20, 0},
518c2ecf20Sopenharmony_ci	{0, "pll1_416", "pll1_624", 2, 3, 0},
528c2ecf20Sopenharmony_ci	{0, "vctcxo_d2", "vctcxo", 1, 2, 0},
538c2ecf20Sopenharmony_ci	{0, "vctcxo_d4", "vctcxo", 1, 4, 0},
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_masks uart_factor_masks = {
578c2ecf20Sopenharmony_ci	.factor = 2,
588c2ecf20Sopenharmony_ci	.num_mask = 0x1fff,
598c2ecf20Sopenharmony_ci	.den_mask = 0x1fff,
608c2ecf20Sopenharmony_ci	.num_shift = 16,
618c2ecf20Sopenharmony_ci	.den_shift = 0,
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic struct mmp_clk_factor_tbl uart_factor_tbl[] = {
658c2ecf20Sopenharmony_ci	{.num = 832, .den = 234},	/*58.5MHZ */
668c2ecf20Sopenharmony_ci	{.num = 1, .den = 1},		/*26MHZ */
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic void pxa1928_pll_init(struct pxa1928_clk_unit *pxa_unit)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	struct mmp_clk_unit *unit = &pxa_unit->unit;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	mmp_register_fixed_rate_clks(unit, fixed_rate_clks,
748c2ecf20Sopenharmony_ci					ARRAY_SIZE(fixed_rate_clks));
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	mmp_register_fixed_factor_clks(unit, fixed_factor_clks,
778c2ecf20Sopenharmony_ci					ARRAY_SIZE(fixed_factor_clks));
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	mmp_clk_register_factor("uart_pll", "pll1_416",
808c2ecf20Sopenharmony_ci				CLK_SET_RATE_PARENT,
818c2ecf20Sopenharmony_ci				pxa_unit->mpmu_base + MPMU_UART_PLL,
828c2ecf20Sopenharmony_ci				&uart_factor_masks, uart_factor_tbl,
838c2ecf20Sopenharmony_ci				ARRAY_SIZE(uart_factor_tbl), NULL);
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart0_lock);
878c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart1_lock);
888c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart2_lock);
898c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(uart3_lock);
908c2ecf20Sopenharmony_cistatic const char *uart_parent_names[] = {"uart_pll", "vctcxo"};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp0_lock);
938c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(ssp1_lock);
948c2ecf20Sopenharmony_cistatic const char *ssp_parent_names[] = {"vctcxo_d4", "vctcxo_d2", "vctcxo", "pll1_d12"};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(reset_lock);
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic struct mmp_param_mux_clk apbc_mux_clks[] = {
998c2ecf20Sopenharmony_ci	{0, "uart0_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_UART0 * 4, 4, 3, 0, &uart0_lock},
1008c2ecf20Sopenharmony_ci	{0, "uart1_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_UART1 * 4, 4, 3, 0, &uart1_lock},
1018c2ecf20Sopenharmony_ci	{0, "uart2_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_UART2 * 4, 4, 3, 0, &uart2_lock},
1028c2ecf20Sopenharmony_ci	{0, "uart3_mux", uart_parent_names, ARRAY_SIZE(uart_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_UART3 * 4, 4, 3, 0, &uart3_lock},
1038c2ecf20Sopenharmony_ci	{0, "ssp0_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_SSP0 * 4, 4, 3, 0, &ssp0_lock},
1048c2ecf20Sopenharmony_ci	{0, "ssp1_mux", ssp_parent_names, ARRAY_SIZE(ssp_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_SSP1 * 4, 4, 3, 0, &ssp1_lock},
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk apbc_gate_clks[] = {
1088c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI0, "twsi0_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI0 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1098c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI1, "twsi1_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI1 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1108c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI2, "twsi2_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI2 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1118c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI3, "twsi3_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI3 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1128c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI4, "twsi4_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI4 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1138c2ecf20Sopenharmony_ci	{PXA1928_CLK_TWSI5, "twsi5_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_TWSI5 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1148c2ecf20Sopenharmony_ci	{PXA1928_CLK_GPIO, "gpio_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_GPIO * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1158c2ecf20Sopenharmony_ci	{PXA1928_CLK_KPC, "kpc_clk", "clk32", CLK_SET_RATE_PARENT, PXA1928_CLK_KPC * 4, 0x3, 0x3, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL},
1168c2ecf20Sopenharmony_ci	{PXA1928_CLK_RTC, "rtc_clk", "clk32", CLK_SET_RATE_PARENT, PXA1928_CLK_RTC * 4, 0x83, 0x83, 0x0, MMP_CLK_GATE_NEED_DELAY, NULL},
1178c2ecf20Sopenharmony_ci	{PXA1928_CLK_PWM0, "pwm0_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_PWM0 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1188c2ecf20Sopenharmony_ci	{PXA1928_CLK_PWM1, "pwm1_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_PWM1 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1198c2ecf20Sopenharmony_ci	{PXA1928_CLK_PWM2, "pwm2_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_PWM2 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1208c2ecf20Sopenharmony_ci	{PXA1928_CLK_PWM3, "pwm3_clk", "vctcxo", CLK_SET_RATE_PARENT, PXA1928_CLK_PWM3 * 4, 0x3, 0x3, 0x0, 0, &reset_lock},
1218c2ecf20Sopenharmony_ci	/* The gate clocks has mux parent. */
1228c2ecf20Sopenharmony_ci	{PXA1928_CLK_UART0, "uart0_clk", "uart0_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_UART0 * 4, 0x3, 0x3, 0x0, 0, &uart0_lock},
1238c2ecf20Sopenharmony_ci	{PXA1928_CLK_UART1, "uart1_clk", "uart1_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_UART1 * 4, 0x3, 0x3, 0x0, 0, &uart1_lock},
1248c2ecf20Sopenharmony_ci	{PXA1928_CLK_UART2, "uart2_clk", "uart2_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_UART2 * 4, 0x3, 0x3, 0x0, 0, &uart2_lock},
1258c2ecf20Sopenharmony_ci	{PXA1928_CLK_UART3, "uart3_clk", "uart3_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_UART3 * 4, 0x3, 0x3, 0x0, 0, &uart3_lock},
1268c2ecf20Sopenharmony_ci	{PXA1928_CLK_SSP0, "ssp0_clk", "ssp0_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_SSP0 * 4, 0x3, 0x3, 0x0, 0, &ssp0_lock},
1278c2ecf20Sopenharmony_ci	{PXA1928_CLK_SSP1, "ssp1_clk", "ssp1_mux", CLK_SET_RATE_PARENT, PXA1928_CLK_SSP1 * 4, 0x3, 0x3, 0x0, 0, &ssp1_lock},
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cistatic void pxa1928_apb_periph_clk_init(struct pxa1928_clk_unit *pxa_unit)
1318c2ecf20Sopenharmony_ci{
1328c2ecf20Sopenharmony_ci	struct mmp_clk_unit *unit = &pxa_unit->unit;
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	mmp_register_mux_clks(unit, apbc_mux_clks, pxa_unit->apbc_base,
1358c2ecf20Sopenharmony_ci				ARRAY_SIZE(apbc_mux_clks));
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	mmp_register_gate_clks(unit, apbc_gate_clks, pxa_unit->apbc_base,
1388c2ecf20Sopenharmony_ci				ARRAY_SIZE(apbc_gate_clks));
1398c2ecf20Sopenharmony_ci}
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh0_lock);
1428c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh1_lock);
1438c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh2_lock);
1448c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh3_lock);
1458c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(sdh4_lock);
1468c2ecf20Sopenharmony_cistatic const char *sdh_parent_names[] = {"pll1_624", "pll5p", "pll5", "pll1_416"};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(usb_lock);
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_cistatic struct mmp_param_mux_clk apmu_mux_clks[] = {
1518c2ecf20Sopenharmony_ci	{0, "sdh_mux", sdh_parent_names, ARRAY_SIZE(sdh_parent_names), CLK_SET_RATE_PARENT, PXA1928_CLK_SDH0 * 4, 8, 2, 0, &sdh0_lock},
1528c2ecf20Sopenharmony_ci};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cistatic struct mmp_param_div_clk apmu_div_clks[] = {
1558c2ecf20Sopenharmony_ci	{0, "sdh_div", "sdh_mux", 0, PXA1928_CLK_SDH0 * 4, 10, 4, CLK_DIVIDER_ONE_BASED, &sdh0_lock},
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic struct mmp_param_gate_clk apmu_gate_clks[] = {
1598c2ecf20Sopenharmony_ci	{PXA1928_CLK_USB, "usb_clk", "usb_pll", 0, PXA1928_CLK_USB * 4, 0x9, 0x9, 0x0, 0, &usb_lock},
1608c2ecf20Sopenharmony_ci	{PXA1928_CLK_HSIC, "hsic_clk", "usb_pll", 0, PXA1928_CLK_HSIC * 4, 0x9, 0x9, 0x0, 0, &usb_lock},
1618c2ecf20Sopenharmony_ci	/* The gate clocks has mux parent. */
1628c2ecf20Sopenharmony_ci	{PXA1928_CLK_SDH0, "sdh0_clk", "sdh_div", CLK_SET_RATE_PARENT, PXA1928_CLK_SDH0 * 4, 0x1b, 0x1b, 0x0, 0, &sdh0_lock},
1638c2ecf20Sopenharmony_ci	{PXA1928_CLK_SDH1, "sdh1_clk", "sdh_div", CLK_SET_RATE_PARENT, PXA1928_CLK_SDH1 * 4, 0x1b, 0x1b, 0x0, 0, &sdh1_lock},
1648c2ecf20Sopenharmony_ci	{PXA1928_CLK_SDH2, "sdh2_clk", "sdh_div", CLK_SET_RATE_PARENT, PXA1928_CLK_SDH2 * 4, 0x1b, 0x1b, 0x0, 0, &sdh2_lock},
1658c2ecf20Sopenharmony_ci	{PXA1928_CLK_SDH3, "sdh3_clk", "sdh_div", CLK_SET_RATE_PARENT, PXA1928_CLK_SDH3 * 4, 0x1b, 0x1b, 0x0, 0, &sdh3_lock},
1668c2ecf20Sopenharmony_ci	{PXA1928_CLK_SDH4, "sdh4_clk", "sdh_div", CLK_SET_RATE_PARENT, PXA1928_CLK_SDH4 * 4, 0x1b, 0x1b, 0x0, 0, &sdh4_lock},
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistatic void pxa1928_axi_periph_clk_init(struct pxa1928_clk_unit *pxa_unit)
1708c2ecf20Sopenharmony_ci{
1718c2ecf20Sopenharmony_ci	struct mmp_clk_unit *unit = &pxa_unit->unit;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	mmp_register_mux_clks(unit, apmu_mux_clks, pxa_unit->apmu_base,
1748c2ecf20Sopenharmony_ci				ARRAY_SIZE(apmu_mux_clks));
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	mmp_register_div_clks(unit, apmu_div_clks, pxa_unit->apmu_base,
1778c2ecf20Sopenharmony_ci				ARRAY_SIZE(apmu_div_clks));
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	mmp_register_gate_clks(unit, apmu_gate_clks, pxa_unit->apmu_base,
1808c2ecf20Sopenharmony_ci				ARRAY_SIZE(apmu_gate_clks));
1818c2ecf20Sopenharmony_ci}
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_cistatic void pxa1928_clk_reset_init(struct device_node *np,
1848c2ecf20Sopenharmony_ci				struct pxa1928_clk_unit *pxa_unit)
1858c2ecf20Sopenharmony_ci{
1868c2ecf20Sopenharmony_ci	struct mmp_clk_reset_cell *cells;
1878c2ecf20Sopenharmony_ci	int i, base, nr_resets;
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	nr_resets = ARRAY_SIZE(apbc_gate_clks);
1908c2ecf20Sopenharmony_ci	cells = kcalloc(nr_resets, sizeof(*cells), GFP_KERNEL);
1918c2ecf20Sopenharmony_ci	if (!cells)
1928c2ecf20Sopenharmony_ci		return;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	base = 0;
1958c2ecf20Sopenharmony_ci	for (i = 0; i < nr_resets; i++) {
1968c2ecf20Sopenharmony_ci		cells[base + i].clk_id = apbc_gate_clks[i].id;
1978c2ecf20Sopenharmony_ci		cells[base + i].reg =
1988c2ecf20Sopenharmony_ci			pxa_unit->apbc_base + apbc_gate_clks[i].offset;
1998c2ecf20Sopenharmony_ci		cells[base + i].flags = 0;
2008c2ecf20Sopenharmony_ci		cells[base + i].lock = apbc_gate_clks[i].lock;
2018c2ecf20Sopenharmony_ci		cells[base + i].bits = 0x4;
2028c2ecf20Sopenharmony_ci	}
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	mmp_clk_reset_register(np, cells, nr_resets);
2058c2ecf20Sopenharmony_ci}
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_cistatic void __init pxa1928_mpmu_clk_init(struct device_node *np)
2088c2ecf20Sopenharmony_ci{
2098c2ecf20Sopenharmony_ci	struct pxa1928_clk_unit *pxa_unit;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL);
2128c2ecf20Sopenharmony_ci	if (!pxa_unit)
2138c2ecf20Sopenharmony_ci		return;
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	pxa_unit->mpmu_base = of_iomap(np, 0);
2168c2ecf20Sopenharmony_ci	if (!pxa_unit->mpmu_base) {
2178c2ecf20Sopenharmony_ci		pr_err("failed to map mpmu registers\n");
2188c2ecf20Sopenharmony_ci		kfree(pxa_unit);
2198c2ecf20Sopenharmony_ci		return;
2208c2ecf20Sopenharmony_ci	}
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	pxa1928_pll_init(pxa_unit);
2238c2ecf20Sopenharmony_ci}
2248c2ecf20Sopenharmony_ciCLK_OF_DECLARE(pxa1928_mpmu_clk, "marvell,pxa1928-mpmu", pxa1928_mpmu_clk_init);
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_cistatic void __init pxa1928_apmu_clk_init(struct device_node *np)
2278c2ecf20Sopenharmony_ci{
2288c2ecf20Sopenharmony_ci	struct pxa1928_clk_unit *pxa_unit;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL);
2318c2ecf20Sopenharmony_ci	if (!pxa_unit)
2328c2ecf20Sopenharmony_ci		return;
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	pxa_unit->apmu_base = of_iomap(np, 0);
2358c2ecf20Sopenharmony_ci	if (!pxa_unit->apmu_base) {
2368c2ecf20Sopenharmony_ci		pr_err("failed to map apmu registers\n");
2378c2ecf20Sopenharmony_ci		kfree(pxa_unit);
2388c2ecf20Sopenharmony_ci		return;
2398c2ecf20Sopenharmony_ci	}
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	mmp_clk_init(np, &pxa_unit->unit, PXA1928_APMU_NR_CLKS);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	pxa1928_axi_periph_clk_init(pxa_unit);
2448c2ecf20Sopenharmony_ci}
2458c2ecf20Sopenharmony_ciCLK_OF_DECLARE(pxa1928_apmu_clk, "marvell,pxa1928-apmu", pxa1928_apmu_clk_init);
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistatic void __init pxa1928_apbc_clk_init(struct device_node *np)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci	struct pxa1928_clk_unit *pxa_unit;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	pxa_unit = kzalloc(sizeof(*pxa_unit), GFP_KERNEL);
2528c2ecf20Sopenharmony_ci	if (!pxa_unit)
2538c2ecf20Sopenharmony_ci		return;
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	pxa_unit->apbc_base = of_iomap(np, 0);
2568c2ecf20Sopenharmony_ci	if (!pxa_unit->apbc_base) {
2578c2ecf20Sopenharmony_ci		pr_err("failed to map apbc registers\n");
2588c2ecf20Sopenharmony_ci		kfree(pxa_unit);
2598c2ecf20Sopenharmony_ci		return;
2608c2ecf20Sopenharmony_ci	}
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	mmp_clk_init(np, &pxa_unit->unit, PXA1928_APBC_NR_CLKS);
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	pxa1928_apb_periph_clk_init(pxa_unit);
2658c2ecf20Sopenharmony_ci	pxa1928_clk_reset_init(np, pxa_unit);
2668c2ecf20Sopenharmony_ci}
2678c2ecf20Sopenharmony_ciCLK_OF_DECLARE(pxa1928_apbc_clk, "marvell,pxa1928-apbc", pxa1928_apbc_clk_init);
268