1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019 BayLibre, SAS.
4 * Author: Jerome Brunet <jbrunet@baylibre.com>
7 #include <linux/clk-provider.h>
9 #include <linux/platform_device.h>
10 #include <linux/mfd/syscon.h>
11 #include <linux/regmap.h>
12 #include <linux/module.h>
14 #include "clk-regmap.h"
15 #include "meson-eeclk.h"
17 int meson_eeclkc_probe(struct platform_device
*pdev
)
19 const struct meson_eeclkc_data
*data
;
20 struct device
*dev
= &pdev
->dev
;
21 struct device_node
*np
;
25 data
= of_device_get_match_data(dev
);
29 /* Get the hhi system controller node */
30 np
= of_get_parent(dev
->of_node
);
31 map
= syscon_node_to_regmap(np
);
35 "failed to get HHI regmap\n");
40 regmap_multi_reg_write(map
, data
->init_regs
, data
->init_count
);
42 /* Populate regmap for the regmap backed clocks */
43 for (i
= 0; i
< data
->regmap_clk_num
; i
++)
44 data
->regmap_clks
[i
]->map
= map
;
46 for (i
= 0; i
< data
->hw_clks
.num
; i
++) {
47 /* array might be sparse */
48 if (!data
->hw_clks
.hws
[i
])
51 ret
= devm_clk_hw_register(dev
, data
->hw_clks
.hws
[i
]);
53 dev_err(dev
, "Clock registration failed\n");
58 return devm_of_clk_add_hw_provider(dev
, meson_clk_hw_get
, (void *)&data
->hw_clks
);
60 EXPORT_SYMBOL_NS_GPL(meson_eeclkc_probe
, CLK_MESON
);
62 MODULE_DESCRIPTION("Amlogic Main Clock Controller Helpers");
63 MODULE_LICENSE("GPL");
64 MODULE_IMPORT_NS(CLK_MESON
);