diff options
Diffstat (limited to 'arch/arm/mach-clps711x/clock.c')
-rw-r--r-- | arch/arm/mach-clps711x/clock.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c index 2c5137c582..4cb0f2bbfa 100644 --- a/arch/arm/mach-clps711x/clock.c +++ b/arch/arm/mach-clps711x/clock.c @@ -1,11 +1,5 @@ -/* - * Copyright (C) 2012-2016 Alexander Shiyan <shc_work@mail.ru> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - */ +// SPDX-License-Identifier: GPL-2.0-or-later +// SPDX-FileCopyrightText: Alexander Shiyan <shc_work@mail.ru> #include <common.h> #include <init.h> @@ -15,19 +9,21 @@ #include <linux/sizes.h> #include <dt-bindings/clock/clps711x-clock.h> -#include <mach/clps711x.h> +#include <mach/clps711x/clps711x.h> #define CLPS711X_OSC_FREQ 3686400 #define CLPS711X_EXT_FREQ 13000000 static struct clk *clks[CLPS711X_CLK_MAX]; +static struct clk_onecell_data clk_data; -static struct clk_div_table tdiv_tbl[] = { +static const struct clk_div_table tdiv_tbl[] = { { .val = 0, .div = 256, }, { .val = 1, .div = 1, }, + { } }; -static __init int clps711x_clk_init(void) +static int clps711x_clk_probe(struct device *dev) { unsigned int f_cpu, f_bus, f_uart, f_timer_ref, pll; u32 tmp; @@ -50,7 +46,7 @@ static __init int clps711x_clk_init(void) f_bus = 36864000 / 2; } - f_uart = f_bus / 10; + f_uart = DIV_ROUND_CLOSEST(f_bus, 10); if (tmp & SYSFLG2_CKMODE) { tmp = readw(SYSCON2); @@ -72,23 +68,26 @@ static __init int clps711x_clk_init(void) clks[CLPS711X_CLK_UART] = clk_fixed("uart", f_uart); clks[CLPS711X_CLK_TIMERREF] = clk_fixed("timer_ref", f_timer_ref); clks[CLPS711X_CLK_TIMER1] = clk_divider_table("timer1", "timer_ref", 0, - IOMEM(SYSCON1), 5, 1, tdiv_tbl, ARRAY_SIZE(tdiv_tbl)); + IOMEM(SYSCON1), 5, 1, tdiv_tbl, 0); clks[CLPS711X_CLK_TIMER2] = clk_divider_table("timer2", "timer_ref", 0, - IOMEM(SYSCON1), 7, 1, tdiv_tbl, ARRAY_SIZE(tdiv_tbl)); + IOMEM(SYSCON1), 7, 1, tdiv_tbl, 0); - clkdev_add_physbase(clks[CLPS711X_CLK_UART], UARTDR1, NULL); - clkdev_add_physbase(clks[CLPS711X_CLK_UART], UARTDR2, NULL); - clkdev_add_physbase(clks[CLPS711X_CLK_TIMER2], TC2D, NULL); + clk_data.clks = clks; + clk_data.clk_num = CLPS711X_CLK_MAX; + of_clk_add_provider(dev->of_node, of_clk_src_onecell_get, &clk_data); return 0; } -postcore_initcall(clps711x_clk_init); -static __init int clps711x_core_init(void) -{ - add_generic_device("clps711x-cs", DEVICE_ID_SINGLE, NULL, - TC2D, SZ_2, IORESOURCE_MEM, NULL); +static const struct of_device_id __maybe_unused clps711x_clk_dt_ids[] = { + { .compatible = "cirrus,ep7209-clk", }, + { } +}; +MODULE_DEVICE_TABLE(of, clps711x_clk_dt_ids); - return 0; -} -coredevice_initcall(clps711x_core_init); +static struct driver clps711x_clk_driver = { + .probe = clps711x_clk_probe, + .name = "clps711x-clk", + .of_compatible = DRV_OF_COMPAT(clps711x_clk_dt_ids), +}; +postcore_platform_driver(clps711x_clk_driver); |