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/of_address.h>
12 #include <linux/of_platform.h>
13 #include <linux/platform_device.h>
14 #include <linux/regmap.h>
16 #include "owl-common.h"
18 static const struct regmap_config owl_regmap_config
= {
22 .max_register
= 0x00cc,
26 static void owl_clk_set_regmap(const struct owl_clk_desc
*desc
,
27 struct regmap
*regmap
)
30 struct owl_clk_common
*clks
;
32 for (i
= 0; i
< desc
->num_clks
; i
++) {
37 clks
->regmap
= regmap
;
41 int owl_clk_regmap_init(struct platform_device
*pdev
,
42 struct owl_clk_desc
*desc
)
45 struct regmap
*regmap
;
48 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
49 base
= devm_ioremap_resource(&pdev
->dev
, res
);
53 regmap
= devm_regmap_init_mmio(&pdev
->dev
, base
, &owl_regmap_config
);
55 pr_err("failed to init regmap\n");
56 return PTR_ERR(regmap
);
59 owl_clk_set_regmap(desc
, regmap
);
60 desc
->regmap
= regmap
;
65 int owl_clk_probe(struct device
*dev
, struct clk_hw_onecell_data
*hw_clks
)
70 for (i
= 0; i
< hw_clks
->num
; i
++) {
74 if (IS_ERR_OR_NULL(hw
))
77 name
= hw
->init
->name
;
78 ret
= devm_clk_hw_register(dev
, hw
);
80 dev_err(dev
, "Couldn't register clock %d - %s\n",
86 ret
= devm_of_clk_add_hw_provider(dev
, of_clk_hw_onecell_get
, hw_clks
);
88 dev_err(dev
, "Failed to add clock provider\n");