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>
8 #include <linux/of_device.h>
9 #include <linux/platform_device.h>
10 #include <linux/mfd/syscon.h>
11 #include <linux/regmap.h>
13 #include "clk-input.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
;
25 data
= of_device_get_match_data(dev
);
29 /* Get the hhi system controller node */
30 map
= syscon_node_to_regmap(of_get_parent(dev
->of_node
));
33 "failed to get HHI regmap\n");
38 regmap_multi_reg_write(map
, data
->init_regs
, data
->init_count
);
40 input
= meson_clk_hw_register_input(dev
, "xtal", IN_PREFIX
"xtal", 0);
43 if (ret
!= -EPROBE_DEFER
)
44 dev_err(dev
, "failed to get input clock");
48 /* Populate regmap for the regmap backed clocks */
49 for (i
= 0; i
< data
->regmap_clk_num
; i
++)
50 data
->regmap_clks
[i
]->map
= map
;
52 for (i
= 0; i
< data
->hw_onecell_data
->num
; i
++) {
53 /* array might be sparse */
54 if (!data
->hw_onecell_data
->hws
[i
])
57 ret
= devm_clk_hw_register(dev
, data
->hw_onecell_data
->hws
[i
]);
59 dev_err(dev
, "Clock registration failed\n");
64 return devm_of_clk_add_hw_provider(dev
, of_clk_hw_onecell_get
,
65 data
->hw_onecell_data
);