forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/drivers/regulator/arizona-micsupp.c
....@@ -1,15 +1,10 @@
1
-/*
2
- * arizona-micsupp.c -- Microphone supply for Arizona devices
3
- *
4
- * Copyright 2012 Wolfson Microelectronics PLC.
5
- *
6
- * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
12
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// arizona-micsupp.c -- Microphone supply for Arizona devices
4
+//
5
+// Copyright 2012 Wolfson Microelectronics PLC.
6
+//
7
+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
....@@ -21,7 +16,6 @@
2116 #include <linux/regulator/driver.h>
2217 #include <linux/regulator/machine.h>
2318 #include <linux/regulator/of_regulator.h>
24
-#include <linux/gpio.h>
2519 #include <linux/slab.h>
2620 #include <linux/workqueue.h>
2721 #include <sound/soc.h>
....@@ -29,6 +23,10 @@
2923 #include <linux/mfd/arizona/core.h>
3024 #include <linux/mfd/arizona/pdata.h>
3125 #include <linux/mfd/arizona/registers.h>
26
+
27
+#include <linux/mfd/madera/core.h>
28
+#include <linux/mfd/madera/pdata.h>
29
+#include <linux/mfd/madera/registers.h>
3230
3331 #include <linux/regulator/arizona-micsupp.h>
3432
....@@ -127,7 +125,7 @@
127125 .set_bypass = arizona_micsupp_set_bypass,
128126 };
129127
130
-static const struct regulator_linear_range arizona_micsupp_ranges[] = {
128
+static const struct linear_range arizona_micsupp_ranges[] = {
131129 REGULATOR_LINEAR_RANGE(1700000, 0, 0x1e, 50000),
132130 REGULATOR_LINEAR_RANGE(3300000, 0x1f, 0x1f, 0),
133131 };
....@@ -154,7 +152,7 @@
154152 .owner = THIS_MODULE,
155153 };
156154
157
-static const struct regulator_linear_range arizona_micsupp_ext_ranges[] = {
155
+static const struct linear_range arizona_micsupp_ext_ranges[] = {
158156 REGULATOR_LINEAR_RANGE(900000, 0, 0x14, 25000),
159157 REGULATOR_LINEAR_RANGE(1500000, 0x15, 0x27, 100000),
160158 };
....@@ -203,6 +201,28 @@
203201 },
204202
205203 .num_consumer_supplies = 1,
204
+};
205
+
206
+static const struct regulator_desc madera_micsupp = {
207
+ .name = "MICVDD",
208
+ .supply_name = "CPVDD1",
209
+ .type = REGULATOR_VOLTAGE,
210
+ .n_voltages = 40,
211
+ .ops = &arizona_micsupp_ops,
212
+
213
+ .vsel_reg = MADERA_LDO2_CONTROL_1,
214
+ .vsel_mask = MADERA_LDO2_VSEL_MASK,
215
+ .enable_reg = MADERA_MIC_CHARGE_PUMP_1,
216
+ .enable_mask = MADERA_CPMIC_ENA,
217
+ .bypass_reg = MADERA_MIC_CHARGE_PUMP_1,
218
+ .bypass_mask = MADERA_CPMIC_BYPASS,
219
+
220
+ .linear_ranges = arizona_micsupp_ext_ranges,
221
+ .n_linear_ranges = ARRAY_SIZE(arizona_micsupp_ext_ranges),
222
+
223
+ .enable_time = 3000,
224
+
225
+ .owner = THIS_MODULE,
206226 };
207227
208228 static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
....@@ -321,6 +341,24 @@
321341 &arizona->pdata.micvdd);
322342 }
323343
344
+static int madera_micsupp_probe(struct platform_device *pdev)
345
+{
346
+ struct madera *madera = dev_get_drvdata(pdev->dev.parent);
347
+ struct arizona_micsupp *micsupp;
348
+
349
+ micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL);
350
+ if (!micsupp)
351
+ return -ENOMEM;
352
+
353
+ micsupp->regmap = madera->regmap;
354
+ micsupp->dapm = &madera->dapm;
355
+ micsupp->dev = madera->dev;
356
+ micsupp->init_data = arizona_micsupp_ext_default;
357
+
358
+ return arizona_micsupp_common_init(pdev, micsupp, &madera_micsupp,
359
+ &madera->pdata.micvdd);
360
+}
361
+
324362 static struct platform_driver arizona_micsupp_driver = {
325363 .probe = arizona_micsupp_probe,
326364 .driver = {
....@@ -328,10 +366,35 @@
328366 },
329367 };
330368
331
-module_platform_driver(arizona_micsupp_driver);
369
+static struct platform_driver madera_micsupp_driver = {
370
+ .probe = madera_micsupp_probe,
371
+ .driver = {
372
+ .name = "madera-micsupp",
373
+ },
374
+};
375
+
376
+static struct platform_driver * const arizona_micsupp_drivers[] = {
377
+ &arizona_micsupp_driver,
378
+ &madera_micsupp_driver,
379
+};
380
+
381
+static int __init arizona_micsupp_init(void)
382
+{
383
+ return platform_register_drivers(arizona_micsupp_drivers,
384
+ ARRAY_SIZE(arizona_micsupp_drivers));
385
+}
386
+module_init(arizona_micsupp_init);
387
+
388
+static void __exit arizona_micsupp_exit(void)
389
+{
390
+ platform_unregister_drivers(arizona_micsupp_drivers,
391
+ ARRAY_SIZE(arizona_micsupp_drivers));
392
+}
393
+module_exit(arizona_micsupp_exit);
332394
333395 /* Module information */
334396 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
335397 MODULE_DESCRIPTION("Arizona microphone supply driver");
336398 MODULE_LICENSE("GPL");
337399 MODULE_ALIAS("platform:arizona-micsupp");
400
+MODULE_ALIAS("platform:madera-micsupp");