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
);
98 void qcom_iris_disable(struct qcom_iris
*iris
)
100 clk_disable_unprepare(iris
->xo_clk
);
101 regulator_bulk_disable(iris
->num_vregs
, iris
->vregs
);
104 static int qcom_iris_probe(struct platform_device
*pdev
)
106 const struct iris_data
*data
;
107 struct qcom_wcnss
*wcnss
;
108 struct qcom_iris
*iris
;
112 iris
= devm_kzalloc(&pdev
->dev
, sizeof(struct qcom_iris
), GFP_KERNEL
);
116 data
= of_device_get_match_data(&pdev
->dev
);
117 wcnss
= dev_get_drvdata(pdev
->dev
.parent
);
119 iris
->xo_clk
= devm_clk_get(&pdev
->dev
, "xo");
120 if (IS_ERR(iris
->xo_clk
)) {
121 if (PTR_ERR(iris
->xo_clk
) != -EPROBE_DEFER
)
122 dev_err(&pdev
->dev
, "failed to acquire xo clk\n");
123 return PTR_ERR(iris
->xo_clk
);
126 iris
->num_vregs
= data
->num_vregs
;
127 iris
->vregs
= devm_kcalloc(&pdev
->dev
,
129 sizeof(struct regulator_bulk_data
),
134 for (i
= 0; i
< iris
->num_vregs
; i
++)
135 iris
->vregs
[i
].supply
= data
->vregs
[i
].name
;
137 ret
= devm_regulator_bulk_get(&pdev
->dev
, iris
->num_vregs
, iris
->vregs
);
139 dev_err(&pdev
->dev
, "failed to get regulators\n");
143 for (i
= 0; i
< iris
->num_vregs
; i
++) {
144 if (data
->vregs
[i
].max_voltage
)
145 regulator_set_voltage(iris
->vregs
[i
].consumer
,
146 data
->vregs
[i
].min_voltage
,
147 data
->vregs
[i
].max_voltage
);
149 if (data
->vregs
[i
].load_uA
)
150 regulator_set_load(iris
->vregs
[i
].consumer
,
151 data
->vregs
[i
].load_uA
);
154 qcom_wcnss_assign_iris(wcnss
, iris
, data
->use_48mhz_xo
);
159 static int qcom_iris_remove(struct platform_device
*pdev
)
161 struct qcom_wcnss
*wcnss
= dev_get_drvdata(pdev
->dev
.parent
);
163 qcom_wcnss_assign_iris(wcnss
, NULL
, false);
168 static const struct of_device_id iris_of_match
[] = {
169 { .compatible
= "qcom,wcn3620", .data
= &wcn3620_data
},
170 { .compatible
= "qcom,wcn3660", .data
= &wcn3660_data
},
171 { .compatible
= "qcom,wcn3680", .data
= &wcn3680_data
},
175 struct platform_driver qcom_iris_driver
= {
176 .probe
= qcom_iris_probe
,
177 .remove
= qcom_iris_remove
,
180 .of_match_table
= iris_of_match
,