1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2018, The Linux Foundation. All rights reserved.
3
4 #include <linux/kernel.h>
5 #include <linux/init.h>
6 #include <linux/module.h>
7 #include <linux/platform_device.h>
8 #include <linux/err.h>
9 #include <linux/io.h>
10 #include <linux/of.h>
11 #include <linux/clk.h>
12 #include <linux/clk-provider.h>
13
14 static const struct clk_parent_data aux_parents[] = {
15 { .fw_name = "pll8_vote", .name = "pll8_vote" },
16 { .fw_name = "pxo", .name = "pxo_board" },
17 };
18
19 static const u32 aux_parent_map[] = {
20 3,
21 0,
22 };
23
24 static const struct of_device_id kpss_xcc_match_table[] = {
25 { .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
26 { .compatible = "qcom,kpss-gcc" },
27 {}
28 };
29 MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
30
kpss_xcc_driver_probe(struct platform_device * pdev)31 static int kpss_xcc_driver_probe(struct platform_device *pdev)
32 {
33 struct device *dev = &pdev->dev;
34 void __iomem *base;
35 struct clk_hw *hw;
36 const char *name;
37
38 base = devm_platform_ioremap_resource(pdev, 0);
39 if (IS_ERR(base))
40 return PTR_ERR(base);
41
42 if (device_get_match_data(&pdev->dev)) {
43 if (of_property_read_string_index(dev->of_node,
44 "clock-output-names",
45 0, &name))
46 return -ENODEV;
47 base += 0x14;
48 } else {
49 name = "acpu_l2_aux";
50 base += 0x28;
51 }
52
53 hw = devm_clk_hw_register_mux_parent_data_table(dev, name, aux_parents,
54 ARRAY_SIZE(aux_parents), 0,
55 base, 0, 0x3,
56 0, aux_parent_map, NULL);
57 if (IS_ERR(hw))
58 return PTR_ERR(hw);
59
60 return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, hw);
61 }
62
63 static struct platform_driver kpss_xcc_driver = {
64 .probe = kpss_xcc_driver_probe,
65 .driver = {
66 .name = "kpss-xcc",
67 .of_match_table = kpss_xcc_match_table,
68 },
69 };
70 module_platform_driver(kpss_xcc_driver);
71
72 MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
73 MODULE_LICENSE("GPL v2");
74 MODULE_ALIAS("platform:kpss-xcc");
75