2 * Qualcomm Wireless Connectivity Subsystem Iris driver
4 * Copyright (C) 2016 Linaro Ltd
5 * Copyright (C) 2014 Sony Mobile Communications AB
6 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/clk.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/of_device.h>
22 #include <linux/platform_device.h>
23 #include <linux/regulator/consumer.h>
25 #include "qcom_wcnss.h"
32 struct regulator_bulk_data
*vregs
;
37 const struct wcnss_vreg_info
*vregs
;
43 static const struct iris_data wcn3620_data
= {
44 .vregs
= (struct wcnss_vreg_info
[]) {
45 { "vddxo", 1800000, 1800000, 10000 },
46 { "vddrfa", 1300000, 1300000, 100000 },
47 { "vddpa", 3300000, 3300000, 515000 },
48 { "vdddig", 1800000, 1800000, 10000 },
51 .use_48mhz_xo
= false,
54 static const struct iris_data wcn3660_data
= {
55 .vregs
= (struct wcnss_vreg_info
[]) {
56 { "vddxo", 1800000, 1800000, 10000 },
57 { "vddrfa", 1300000, 1300000, 100000 },
58 { "vddpa", 2900000, 3000000, 515000 },
59 { "vdddig", 1200000, 1225000, 10000 },
65 static const struct iris_data wcn3680_data
= {
66 .vregs
= (struct wcnss_vreg_info
[]) {
67 { "vddxo", 1800000, 1800000, 10000 },
68 { "vddrfa", 1300000, 1300000, 100000 },
69 { "vddpa", 3300000, 3300000, 515000 },
70 { "vdddig", 1800000, 1800000, 10000 },
76 int qcom_iris_enable(struct qcom_iris
*iris
)
80 ret
= regulator_bulk_enable(iris
->num_vregs
, iris
->vregs
);
84 ret
= clk_prepare_enable(iris
->xo_clk
);
86 dev_err(iris
->dev
, "failed to enable xo clk\n");
87 goto disable_regulators
;
93 regulator_bulk_disable(iris
->num_vregs
, iris
->vregs
);
97 EXPORT_SYMBOL_GPL(qcom_iris_enable
);
99 void qcom_iris_disable(struct qcom_iris
*iris
)
101 clk_disable_unprepare(iris
->xo_clk
);
102 regulator_bulk_disable(iris
->num_vregs
, iris
->vregs
);
104 EXPORT_SYMBOL_GPL(qcom_iris_disable
);
106 static int qcom_iris_probe(struct platform_device
*pdev
)
108 const struct iris_data
*data
;
109 struct qcom_wcnss
*wcnss
;
110 struct qcom_iris
*iris
;
114 iris
= devm_kzalloc(&pdev
->dev
, sizeof(struct qcom_iris
), GFP_KERNEL
);
118 data
= of_device_get_match_data(&pdev
->dev
);
119 wcnss
= dev_get_drvdata(pdev
->dev
.parent
);
121 iris
->xo_clk
= devm_clk_get(&pdev
->dev
, "xo");
122 if (IS_ERR(iris
->xo_clk
)) {
123 if (PTR_ERR(iris
->xo_clk
) != -EPROBE_DEFER
)
124 dev_err(&pdev
->dev
, "failed to acquire xo clk\n");
125 return PTR_ERR(iris
->xo_clk
);
128 iris
->num_vregs
= data
->num_vregs
;
129 iris
->vregs
= devm_kcalloc(&pdev
->dev
,
131 sizeof(struct regulator_bulk_data
),
136 for (i
= 0; i
< iris
->num_vregs
; i
++)
137 iris
->vregs
[i
].supply
= data
->vregs
[i
].name
;
139 ret
= devm_regulator_bulk_get(&pdev
->dev
, iris
->num_vregs
, iris
->vregs
);
141 dev_err(&pdev
->dev
, "failed to get regulators\n");
145 for (i
= 0; i
< iris
->num_vregs
; i
++) {
146 if (data
->vregs
[i
].max_voltage
)
147 regulator_set_voltage(iris
->vregs
[i
].consumer
,
148 data
->vregs
[i
].min_voltage
,
149 data
->vregs
[i
].max_voltage
);
151 if (data
->vregs
[i
].load_uA
)
152 regulator_set_load(iris
->vregs
[i
].consumer
,
153 data
->vregs
[i
].load_uA
);
156 qcom_wcnss_assign_iris(wcnss
, iris
, data
->use_48mhz_xo
);
161 static int qcom_iris_remove(struct platform_device
*pdev
)
163 struct qcom_wcnss
*wcnss
= dev_get_drvdata(pdev
->dev
.parent
);
165 qcom_wcnss_assign_iris(wcnss
, NULL
, false);
170 static const struct of_device_id iris_of_match
[] = {
171 { .compatible
= "qcom,wcn3620", .data
= &wcn3620_data
},
172 { .compatible
= "qcom,wcn3660", .data
= &wcn3660_data
},
173 { .compatible
= "qcom,wcn3680", .data
= &wcn3680_data
},
177 static struct platform_driver wcnss_driver
= {
178 .probe
= qcom_iris_probe
,
179 .remove
= qcom_iris_remove
,
182 .of_match_table
= iris_of_match
,
186 module_platform_driver(wcnss_driver
);
187 MODULE_DESCRIPTION("Qualcomm Wireless Subsystem Iris driver");
188 MODULE_LICENSE("GPL v2");