1 // SPDX-License-Identifier: GPL-2.0+
3 // OWL common clock driver
5 // Copyright (c) 2014 Actions Semi Inc.
6 // Author: David Liu <liuwei@actions-semi.com>
8 // Copyright (c) 2018 Linaro Ltd.
9 // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
11 #include <linux/platform_device.h>
12 #include <linux/regmap.h>
14 #include "owl-common.h"
16 static const struct regmap_config owl_regmap_config
= {
20 .max_register
= 0x00cc,
24 static void owl_clk_set_regmap(const struct owl_clk_desc
*desc
,
25 struct regmap
*regmap
)
28 struct owl_clk_common
*clks
;
30 for (i
= 0; i
< desc
->num_clks
; i
++) {
35 clks
->regmap
= regmap
;
39 int owl_clk_regmap_init(struct platform_device
*pdev
,
40 struct owl_clk_desc
*desc
)
43 struct regmap
*regmap
;
45 base
= devm_platform_ioremap_resource(pdev
, 0);
49 regmap
= devm_regmap_init_mmio(&pdev
->dev
, base
, &owl_regmap_config
);
51 pr_err("failed to init regmap\n");
52 return PTR_ERR(regmap
);
55 owl_clk_set_regmap(desc
, regmap
);
56 desc
->regmap
= regmap
;
61 int owl_clk_probe(struct device
*dev
, struct clk_hw_onecell_data
*hw_clks
)
66 for (i
= 0; i
< hw_clks
->num
; i
++) {
70 if (IS_ERR_OR_NULL(hw
))
73 name
= hw
->init
->name
;
74 ret
= devm_clk_hw_register(dev
, hw
);
76 dev_err(dev
, "Couldn't register clock %d - %s\n",
82 ret
= devm_of_clk_add_hw_provider(dev
, of_clk_hw_onecell_get
, hw_clks
);
84 dev_err(dev
, "Failed to add clock provider\n");