Lines Matching +full:s2mps11 +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0+
3 // clk-s2mps11.c - Clock driver for S2MPS11.
12 #include <linux/clk-provider.h>
14 #include <linux/mfd/samsung/s2mps11.h>
20 #include <dt-bindings/clock/samsung,s2mps11.h>
26 struct clk *clk; member
39 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); in s2mps11_clk_prepare() local
41 return regmap_update_bits(s2mps11->iodev->regmap_pmic, in s2mps11_clk_prepare()
42 s2mps11->reg, in s2mps11_clk_prepare()
43 s2mps11->mask, s2mps11->mask); in s2mps11_clk_prepare()
48 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); in s2mps11_clk_unprepare() local
50 regmap_update_bits(s2mps11->iodev->regmap_pmic, s2mps11->reg, in s2mps11_clk_unprepare()
51 s2mps11->mask, ~s2mps11->mask); in s2mps11_clk_unprepare()
58 struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); in s2mps11_clk_is_prepared() local
60 ret = regmap_read(s2mps11->iodev->regmap_pmic, in s2mps11_clk_is_prepared()
61 s2mps11->reg, &val); in s2mps11_clk_is_prepared()
63 return -EINVAL; in s2mps11_clk_is_prepared()
65 return val & s2mps11->mask; in s2mps11_clk_is_prepared()
81 /* This s2mps11_clks_init tructure is common to s2mps11, s2mps13 and s2mps14 */
100 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); in s2mps11_clk_parse_dt()
104 if (!iodev->dev->of_node) in s2mps11_clk_parse_dt()
105 return ERR_PTR(-EINVAL); in s2mps11_clk_parse_dt()
107 clk_np = of_get_child_by_name(iodev->dev->of_node, "clocks"); in s2mps11_clk_parse_dt()
109 dev_err(&pdev->dev, "could not find clock sub-node\n"); in s2mps11_clk_parse_dt()
110 return ERR_PTR(-EINVAL); in s2mps11_clk_parse_dt()
114 of_property_read_string_index(clk_np, "clock-output-names", i, in s2mps11_clk_parse_dt()
122 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); in s2mps11_clk_probe()
127 enum sec_device_type hwid = platform_get_device_id(pdev)->driver_data; in s2mps11_clk_probe()
129 s2mps11_clks = devm_kcalloc(&pdev->dev, S2MPS11_CLKS_NUM, in s2mps11_clk_probe()
132 return -ENOMEM; in s2mps11_clk_probe()
134 clk_data = devm_kzalloc(&pdev->dev, in s2mps11_clk_probe()
138 return -ENOMEM; in s2mps11_clk_probe()
154 dev_err(&pdev->dev, "Invalid device type\n"); in s2mps11_clk_probe()
155 return -EINVAL; in s2mps11_clk_probe()
159 s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev, s2mps11_clks_init); in s2mps11_clk_probe()
160 if (IS_ERR(s2mps11_clks->clk_np)) in s2mps11_clk_probe()
161 return PTR_ERR(s2mps11_clks->clk_np); in s2mps11_clk_probe()
171 s2mps11_clks[i].clk = devm_clk_register(&pdev->dev, in s2mps11_clk_probe()
173 if (IS_ERR(s2mps11_clks[i].clk)) { in s2mps11_clk_probe()
174 dev_err(&pdev->dev, "Fail to register : %s\n", in s2mps11_clk_probe()
176 ret = PTR_ERR(s2mps11_clks[i].clk); in s2mps11_clk_probe()
183 ret = -ENOMEM; in s2mps11_clk_probe()
186 clk_data->hws[i] = &s2mps11_clks[i].hw; in s2mps11_clk_probe()
189 clk_data->num = S2MPS11_CLKS_NUM; in s2mps11_clk_probe()
190 of_clk_add_hw_provider(s2mps11_clks->clk_np, of_clk_hw_onecell_get, in s2mps11_clk_probe()
199 while (--i >= 0) in s2mps11_clk_probe()
223 { "s2mps11-clk", S2MPS11X},
224 { "s2mps13-clk", S2MPS13X},
225 { "s2mps14-clk", S2MPS14X},
226 { "s5m8767-clk", S5M8767X},
243 .compatible = "samsung,s2mps11-clk",
246 .compatible = "samsung,s2mps13-clk",
249 .compatible = "samsung,s2mps14-clk",
252 .compatible = "samsung,s5m8767-clk",
263 .name = "s2mps11-clk",
271 MODULE_DESCRIPTION("S2MPS11 Clock Driver");