ad3a056982
[ Upstream commit 89ab396d712f7c91fe94f55cff23460426f5fc81 ] We should hold the reference returned by of_get_parent() and use it to call of_node_put() for refcount balance. Fixes:88e2da8124
("clk: meson: aoclk: refactor common code into dedicated file") Fixes:6682bd4d44
("clk: meson: factorise meson64 peripheral clock controller drivers") Fixes:bb6eddd1d2
("clk: meson: meson8b: use the HHI syscon if available") Signed-off-by: Liang He <windhl@126.com> Link: https://lore.kernel.org/r/20220628141038.168383-1-windhl@126.com Reviewed-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2019 BayLibre, SAS.
|
|
* Author: Jerome Brunet <jbrunet@baylibre.com>
|
|
*/
|
|
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/mfd/syscon.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "clk-regmap.h"
|
|
#include "meson-eeclk.h"
|
|
|
|
int meson_eeclkc_probe(struct platform_device *pdev)
|
|
{
|
|
const struct meson_eeclkc_data *data;
|
|
struct device *dev = &pdev->dev;
|
|
struct device_node *np;
|
|
struct regmap *map;
|
|
int ret, i;
|
|
|
|
data = of_device_get_match_data(dev);
|
|
if (!data)
|
|
return -EINVAL;
|
|
|
|
/* Get the hhi system controller node */
|
|
np = of_get_parent(dev->of_node);
|
|
map = syscon_node_to_regmap(np);
|
|
of_node_put(np);
|
|
if (IS_ERR(map)) {
|
|
dev_err(dev,
|
|
"failed to get HHI regmap\n");
|
|
return PTR_ERR(map);
|
|
}
|
|
|
|
if (data->init_count)
|
|
regmap_multi_reg_write(map, data->init_regs, data->init_count);
|
|
|
|
/* Populate regmap for the regmap backed clocks */
|
|
for (i = 0; i < data->regmap_clk_num; i++)
|
|
data->regmap_clks[i]->map = map;
|
|
|
|
for (i = 0; i < data->hw_onecell_data->num; i++) {
|
|
/* array might be sparse */
|
|
if (!data->hw_onecell_data->hws[i])
|
|
continue;
|
|
|
|
ret = devm_clk_hw_register(dev, data->hw_onecell_data->hws[i]);
|
|
if (ret) {
|
|
dev_err(dev, "Clock registration failed\n");
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
|
|
data->hw_onecell_data);
|
|
}
|