watchdog/core: Rename some softlockup_* functions
[linux/fpc-iii.git] / drivers / remoteproc / qcom_wcnss_iris.c
blobe842be58e8c7799a59b4d36b3f186f0c8631a664
1 /*
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"
27 struct qcom_iris {
28 struct device *dev;
30 struct clk *xo_clk;
32 struct regulator_bulk_data *vregs;
33 size_t num_vregs;
36 struct iris_data {
37 const struct wcnss_vreg_info *vregs;
38 size_t num_vregs;
40 bool use_48mhz_xo;
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 },
50 .num_vregs = 4,
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 },
61 .num_vregs = 4,
62 .use_48mhz_xo = true,
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 },
72 .num_vregs = 4,
73 .use_48mhz_xo = true,
76 int qcom_iris_enable(struct qcom_iris *iris)
78 int ret;
80 ret = regulator_bulk_enable(iris->num_vregs, iris->vregs);
81 if (ret)
82 return ret;
84 ret = clk_prepare_enable(iris->xo_clk);
85 if (ret) {
86 dev_err(iris->dev, "failed to enable xo clk\n");
87 goto disable_regulators;
90 return 0;
92 disable_regulators:
93 regulator_bulk_disable(iris->num_vregs, iris->vregs);
95 return ret;
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;
109 int ret;
110 int i;
112 iris = devm_kzalloc(&pdev->dev, sizeof(struct qcom_iris), GFP_KERNEL);
113 if (!iris)
114 return -ENOMEM;
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,
128 iris->num_vregs,
129 sizeof(struct regulator_bulk_data),
130 GFP_KERNEL);
131 if (!iris->vregs)
132 return -ENOMEM;
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);
138 if (ret) {
139 dev_err(&pdev->dev, "failed to get regulators\n");
140 return ret;
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);
156 return 0;
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);
165 return 0;
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 },
174 MODULE_DEVICE_TABLE(of, iris_of_match);
176 struct platform_driver qcom_iris_driver = {
177 .probe = qcom_iris_probe,
178 .remove = qcom_iris_remove,
179 .driver = {
180 .name = "qcom-iris",
181 .of_match_table = iris_of_match,