0001
0002
0003
0004
0005
0006
0007 #include <linux/clk-provider.h>
0008 #include <linux/of_device.h>
0009 #include <linux/platform_device.h>
0010 #include <linux/mfd/syscon.h>
0011 #include <linux/regmap.h>
0012 #include <linux/module.h>
0013
0014 #include "clk-regmap.h"
0015 #include "meson-eeclk.h"
0016
0017 int meson_eeclkc_probe(struct platform_device *pdev)
0018 {
0019 const struct meson_eeclkc_data *data;
0020 struct device *dev = &pdev->dev;
0021 struct regmap *map;
0022 int ret, i;
0023
0024 data = of_device_get_match_data(dev);
0025 if (!data)
0026 return -EINVAL;
0027
0028
0029 map = syscon_node_to_regmap(of_get_parent(dev->of_node));
0030 if (IS_ERR(map)) {
0031 dev_err(dev,
0032 "failed to get HHI regmap\n");
0033 return PTR_ERR(map);
0034 }
0035
0036 if (data->init_count)
0037 regmap_multi_reg_write(map, data->init_regs, data->init_count);
0038
0039
0040 for (i = 0; i < data->regmap_clk_num; i++)
0041 data->regmap_clks[i]->map = map;
0042
0043 for (i = 0; i < data->hw_onecell_data->num; i++) {
0044
0045 if (!data->hw_onecell_data->hws[i])
0046 continue;
0047
0048 ret = devm_clk_hw_register(dev, data->hw_onecell_data->hws[i]);
0049 if (ret) {
0050 dev_err(dev, "Clock registration failed\n");
0051 return ret;
0052 }
0053 }
0054
0055 return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
0056 data->hw_onecell_data);
0057 }
0058 EXPORT_SYMBOL_GPL(meson_eeclkc_probe);
0059 MODULE_LICENSE("GPL v2");