mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-10 07:50:04 +00:00
a96cbb146a
The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Acked-by: Dinh Nguyen <dinguyen@kernel.org> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> # samsung Acked-by: Heiko Stuebner <heiko@sntech.de> #rockchip Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # versaclock5 Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230718143156.1066339-1-robh@kernel.org Acked-by: Abel Vesa <abel.vesa@linaro.org> #imx Signed-off-by: Stephen Boyd <sboyd@kernel.org>
113 lines
2.5 KiB
C
113 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
//
|
|
// Spreadtrum clock infrastructure
|
|
//
|
|
// Copyright (C) 2017 Spreadtrum, Inc.
|
|
// Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
|
|
|
|
#include <linux/mfd/syscon.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "common.h"
|
|
|
|
static const struct regmap_config sprdclk_regmap_config = {
|
|
.reg_bits = 32,
|
|
.reg_stride = 4,
|
|
.val_bits = 32,
|
|
.fast_io = true,
|
|
};
|
|
|
|
static void sprd_clk_set_regmap(const struct sprd_clk_desc *desc,
|
|
struct regmap *regmap)
|
|
{
|
|
int i;
|
|
struct sprd_clk_common *cclk;
|
|
|
|
for (i = 0; i < desc->num_clk_clks; i++) {
|
|
cclk = desc->clk_clks[i];
|
|
if (!cclk)
|
|
continue;
|
|
|
|
cclk->regmap = regmap;
|
|
}
|
|
}
|
|
|
|
int sprd_clk_regmap_init(struct platform_device *pdev,
|
|
const struct sprd_clk_desc *desc)
|
|
{
|
|
void __iomem *base;
|
|
struct device *dev = &pdev->dev;
|
|
struct device_node *node = dev->of_node, *np;
|
|
struct regmap *regmap;
|
|
struct resource *res;
|
|
struct regmap_config reg_config = sprdclk_regmap_config;
|
|
|
|
if (of_property_present(node, "sprd,syscon")) {
|
|
regmap = syscon_regmap_lookup_by_phandle(node, "sprd,syscon");
|
|
if (IS_ERR(regmap)) {
|
|
pr_err("%s: failed to get syscon regmap\n", __func__);
|
|
return PTR_ERR(regmap);
|
|
}
|
|
} else if (of_device_is_compatible(np = of_get_parent(node), "syscon") ||
|
|
(of_node_put(np), 0)) {
|
|
regmap = device_node_to_regmap(np);
|
|
of_node_put(np);
|
|
if (IS_ERR(regmap)) {
|
|
dev_err(dev, "failed to get regmap from its parent.\n");
|
|
return PTR_ERR(regmap);
|
|
}
|
|
} else {
|
|
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
|
if (IS_ERR(base))
|
|
return PTR_ERR(base);
|
|
|
|
reg_config.max_register = resource_size(res) - reg_config.reg_stride;
|
|
|
|
regmap = devm_regmap_init_mmio(&pdev->dev, base,
|
|
®_config);
|
|
if (IS_ERR(regmap)) {
|
|
pr_err("failed to init regmap\n");
|
|
return PTR_ERR(regmap);
|
|
}
|
|
}
|
|
|
|
sprd_clk_set_regmap(desc, regmap);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(sprd_clk_regmap_init);
|
|
|
|
int sprd_clk_probe(struct device *dev, struct clk_hw_onecell_data *clkhw)
|
|
{
|
|
int i, ret;
|
|
struct clk_hw *hw;
|
|
|
|
for (i = 0; i < clkhw->num; i++) {
|
|
const char *name;
|
|
|
|
hw = clkhw->hws[i];
|
|
if (!hw)
|
|
continue;
|
|
|
|
name = hw->init->name;
|
|
ret = devm_clk_hw_register(dev, hw);
|
|
if (ret) {
|
|
dev_err(dev, "Couldn't register clock %d - %s\n",
|
|
i, name);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clkhw);
|
|
if (ret)
|
|
dev_err(dev, "Failed to add clock provider\n");
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(sprd_clk_probe);
|
|
|
|
MODULE_LICENSE("GPL v2");
|