xref: /linux/drivers/clk/qcom/kpss-xcc.c (revision c3db5128e80e1437cb08d0d41aeb7163004897e7)
13ddc3564SStephen Boyd // SPDX-License-Identifier: GPL-2.0
23ddc3564SStephen Boyd // Copyright (c) 2018, The Linux Foundation. All rights reserved.
33ddc3564SStephen Boyd 
43ddc3564SStephen Boyd #include <linux/kernel.h>
53ddc3564SStephen Boyd #include <linux/init.h>
63ddc3564SStephen Boyd #include <linux/module.h>
73ddc3564SStephen Boyd #include <linux/platform_device.h>
83ddc3564SStephen Boyd #include <linux/err.h>
93ddc3564SStephen Boyd #include <linux/io.h>
103ddc3564SStephen Boyd #include <linux/of.h>
113ddc3564SStephen Boyd #include <linux/of_device.h>
123ddc3564SStephen Boyd #include <linux/clk.h>
133ddc3564SStephen Boyd #include <linux/clk-provider.h>
143ddc3564SStephen Boyd 
15*c3db5128SChristian Marangi static const struct clk_parent_data aux_parents[] = {
16*c3db5128SChristian Marangi 	{ .fw_name = "pll8_vote", .name = "pll8_vote" },
17*c3db5128SChristian Marangi 	{ .fw_name = "pxo", .name = "pxo_board" },
183ddc3564SStephen Boyd };
193ddc3564SStephen Boyd 
20eac03cb0SJonathan Neuschäfer static const u32 aux_parent_map[] = {
213ddc3564SStephen Boyd 	3,
223ddc3564SStephen Boyd 	0,
233ddc3564SStephen Boyd };
243ddc3564SStephen Boyd 
253ddc3564SStephen Boyd static const struct of_device_id kpss_xcc_match_table[] = {
263ddc3564SStephen Boyd 	{ .compatible = "qcom,kpss-acc-v1", .data = (void *)1UL },
273ddc3564SStephen Boyd 	{ .compatible = "qcom,kpss-gcc" },
283ddc3564SStephen Boyd 	{}
293ddc3564SStephen Boyd };
303ddc3564SStephen Boyd MODULE_DEVICE_TABLE(of, kpss_xcc_match_table);
313ddc3564SStephen Boyd 
323ddc3564SStephen Boyd static int kpss_xcc_driver_probe(struct platform_device *pdev)
333ddc3564SStephen Boyd {
343ddc3564SStephen Boyd 	const struct of_device_id *id;
353ddc3564SStephen Boyd 	void __iomem *base;
36*c3db5128SChristian Marangi 	struct clk_hw *hw;
373ddc3564SStephen Boyd 	const char *name;
383ddc3564SStephen Boyd 
393ddc3564SStephen Boyd 	id = of_match_device(kpss_xcc_match_table, &pdev->dev);
403ddc3564SStephen Boyd 	if (!id)
413ddc3564SStephen Boyd 		return -ENODEV;
423ddc3564SStephen Boyd 
4317c774abSCai Huoqing 	base = devm_platform_ioremap_resource(pdev, 0);
443ddc3564SStephen Boyd 	if (IS_ERR(base))
453ddc3564SStephen Boyd 		return PTR_ERR(base);
463ddc3564SStephen Boyd 
473ddc3564SStephen Boyd 	if (id->data) {
483ddc3564SStephen Boyd 		if (of_property_read_string_index(pdev->dev.of_node,
493ddc3564SStephen Boyd 						  "clock-output-names",
503ddc3564SStephen Boyd 						  0, &name))
513ddc3564SStephen Boyd 			return -ENODEV;
523ddc3564SStephen Boyd 		base += 0x14;
533ddc3564SStephen Boyd 	} else {
543ddc3564SStephen Boyd 		name = "acpu_l2_aux";
553ddc3564SStephen Boyd 		base += 0x28;
563ddc3564SStephen Boyd 	}
573ddc3564SStephen Boyd 
58*c3db5128SChristian Marangi 	hw = devm_clk_hw_register_mux_parent_data_table(&pdev->dev, name, aux_parents,
59*c3db5128SChristian Marangi 							ARRAY_SIZE(aux_parents), 0,
60*c3db5128SChristian Marangi 							base, 0, 0x3,
613ddc3564SStephen Boyd 							0, aux_parent_map, NULL);
623ddc3564SStephen Boyd 
63*c3db5128SChristian Marangi 	return PTR_ERR_OR_ZERO(hw);
643ddc3564SStephen Boyd }
653ddc3564SStephen Boyd 
663ddc3564SStephen Boyd static struct platform_driver kpss_xcc_driver = {
673ddc3564SStephen Boyd 	.probe = kpss_xcc_driver_probe,
683ddc3564SStephen Boyd 	.driver = {
693ddc3564SStephen Boyd 		.name = "kpss-xcc",
703ddc3564SStephen Boyd 		.of_match_table = kpss_xcc_match_table,
713ddc3564SStephen Boyd 	},
723ddc3564SStephen Boyd };
733ddc3564SStephen Boyd module_platform_driver(kpss_xcc_driver);
743ddc3564SStephen Boyd 
753ddc3564SStephen Boyd MODULE_DESCRIPTION("Krait Processor Sub System (KPSS) Clock Driver");
763ddc3564SStephen Boyd MODULE_LICENSE("GPL v2");
773ddc3564SStephen Boyd MODULE_ALIAS("platform:kpss-xcc");
78