From 6c8702e6ff3d16d03581b8a89b2bd6f29410f047 Mon Sep 17 00:00:00 2001 From: Elaine Zhang Date: Thu, 16 Jul 2020 17:39:53 +0800 Subject: [PATCH] clk: rockchip: rk3288: support driver build as tristate module Signed-off-by: Elaine Zhang Change-Id: If93da1b970a5932b7ed64a857ec3e178bf6ae755 --- drivers/clk/rockchip/Kconfig | 2 +- drivers/clk/rockchip/clk-rk3288.c | 54 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/clk/rockchip/Kconfig b/drivers/clk/rockchip/Kconfig index 682bd852ee07..551729985ce8 100644 --- a/drivers/clk/rockchip/Kconfig +++ b/drivers/clk/rockchip/Kconfig @@ -59,7 +59,7 @@ config CLK_RK322X Build the driver for RK322x Clock Driver. config CLK_RK3288 - bool "Rockchip RK3288 clock controller support" + tristate "Rockchip RK3288 clock controller support" depends on ARM || COMPILE_TEST default y help diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index 8771d0b4c485..54bcdf68ab0f 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c @@ -6,8 +6,10 @@ #include #include +#include #include #include +#include #include #include #include "clk.h" @@ -1012,3 +1014,55 @@ static void __init rk3288w_clk_init(struct device_node *np) rk3288_common_init(np, RK3288W_CRU); } CLK_OF_DECLARE(rk3288w_cru, "rockchip,rk3288w-cru", rk3288w_clk_init); + +struct clk_rk3288_inits { + void (*inits)(struct device_node *np); +}; + +static const struct clk_rk3288_inits clk_rk3288_init = { + .inits = rk3288_clk_init, +}; + +static const struct clk_rk3288_inits clk_rk3288w_init = { + .inits = rk3288w_clk_init, +}; + +static const struct of_device_id clk_rk3288_match_table[] = { + { + .compatible = "rockchip,rk3288-cru", + .data = &clk_rk3288_init, + }, { + .compatible = "rockchip,rk3288w-cru", + .data = &clk_rk3288w_init, + }, + { } +}; +MODULE_DEVICE_TABLE(of, clk_rk3288_match_table); + +static int __init clk_rk3288_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *match; + const struct clk_rk3288_inits *init_data; + + match = of_match_device(clk_rk3288_match_table, &pdev->dev); + if (!match || !match->data) + return -EINVAL; + + init_data = match->data; + if (init_data->inits) + init_data->inits(np); + + return 0; +} + +static struct platform_driver clk_rk3288_driver = { + .driver = { + .name = "clk-rk3288", + .of_match_table = clk_rk3288_match_table, + }, +}; +builtin_platform_driver_probe(clk_rk3288_driver, clk_rk3288_probe); + +MODULE_DESCRIPTION("Rockchip RK3288 Clock Driver"); +MODULE_LICENSE("GPL");