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