xref: /linux/drivers/clk/qcom/lpasscc-sc8280xp.c (revision 170aafe35cb98e0f3fbacb446ea86389fbce22ea)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2022, Linaro Limited
4  */
5 
6 #include <linux/clk-provider.h>
7 #include <linux/err.h>
8 #include <linux/kernel.h>
9 #include <linux/mod_devicetable.h>
10 #include <linux/module.h>
11 #include <linux/of.h>
12 #include <linux/platform_device.h>
13 #include <linux/regmap.h>
14 
15 #include <dt-bindings/clock/qcom,sc8280xp-lpasscc.h>
16 
17 #include "common.h"
18 #include "reset.h"
19 
20 static const struct qcom_reset_map lpass_audiocc_sc8280xp_resets[] = {
21 	[LPASS_AUDIO_SWR_RX_CGCR] =  { 0xa0, 1 },
22 	[LPASS_AUDIO_SWR_WSA_CGCR] = { 0xb0, 1 },
23 	[LPASS_AUDIO_SWR_WSA2_CGCR] =  { 0xd8, 1 },
24 };
25 
26 static const struct regmap_config lpass_audiocc_sc8280xp_regmap_config = {
27 	.reg_bits = 32,
28 	.reg_stride = 4,
29 	.val_bits = 32,
30 	.name = "lpass-audio-csr",
31 	.max_register = 0x1000,
32 };
33 
34 static const struct qcom_cc_desc lpass_audiocc_sc8280xp_reset_desc = {
35 	.config = &lpass_audiocc_sc8280xp_regmap_config,
36 	.resets = lpass_audiocc_sc8280xp_resets,
37 	.num_resets = ARRAY_SIZE(lpass_audiocc_sc8280xp_resets),
38 };
39 
40 static const struct qcom_reset_map lpasscc_sc8280xp_resets[] = {
41 	[LPASS_AUDIO_SWR_TX_CGCR] = { 0xc010, 1 },
42 };
43 
44 static const struct regmap_config lpasscc_sc8280xp_regmap_config = {
45 	.reg_bits = 32,
46 	.reg_stride = 4,
47 	.val_bits = 32,
48 	.name = "lpass-tcsr",
49 	.max_register = 0x12000,
50 };
51 
52 static const struct qcom_cc_desc lpasscc_sc8280xp_reset_desc = {
53 	.config = &lpasscc_sc8280xp_regmap_config,
54 	.resets = lpasscc_sc8280xp_resets,
55 	.num_resets = ARRAY_SIZE(lpasscc_sc8280xp_resets),
56 };
57 
58 static const struct of_device_id lpasscc_sc8280xp_match_table[] = {
59 	{
60 		.compatible = "qcom,sc8280xp-lpassaudiocc",
61 		.data = &lpass_audiocc_sc8280xp_reset_desc,
62 	}, {
63 		.compatible = "qcom,sc8280xp-lpasscc",
64 		.data = &lpasscc_sc8280xp_reset_desc,
65 	},
66 	{ }
67 };
68 MODULE_DEVICE_TABLE(of, lpasscc_sc8280xp_match_table);
69 
70 static int lpasscc_sc8280xp_probe(struct platform_device *pdev)
71 {
72 	const struct qcom_cc_desc *desc = of_device_get_match_data(&pdev->dev);
73 
74 	return qcom_cc_probe_by_index(pdev, 0, desc);
75 }
76 
77 static struct platform_driver lpasscc_sc8280xp_driver = {
78 	.probe = lpasscc_sc8280xp_probe,
79 	.driver = {
80 		.name = "lpasscc-sc8280xp",
81 		.of_match_table = lpasscc_sc8280xp_match_table,
82 	},
83 };
84 
85 module_platform_driver(lpasscc_sc8280xp_driver);
86 
87 MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org>");
88 MODULE_DESCRIPTION("QTI LPASSCC SC8280XP Driver");
89 MODULE_LICENSE("GPL");
90