hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/mfd/motorola-cpcap.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Motorola CPCAP PMIC core driver
34 *
45 * Copyright (C) 2016 Tony Lindgren <tony@atomide.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #include <linux/device.h>
....@@ -18,6 +15,7 @@
1815 #include <linux/regmap.h>
1916 #include <linux/sysfs.h>
2017
18
+#include <linux/mfd/core.h>
2119 #include <linux/mfd/motorola-cpcap.h>
2220 #include <linux/spi/spi.h>
2321
....@@ -99,7 +97,7 @@
9997 .ack_base = CPCAP_REG_MI1,
10098 .mask_base = CPCAP_REG_MIM1,
10199 .use_ack = true,
102
- .ack_invert = true,
100
+ .clear_ack = true,
103101 },
104102 {
105103 .name = "cpcap-m2",
....@@ -108,7 +106,7 @@
108106 .ack_base = CPCAP_REG_MI2,
109107 .mask_base = CPCAP_REG_MIM2,
110108 .use_ack = true,
111
- .ack_invert = true,
109
+ .clear_ack = true,
112110 },
113111 {
114112 .name = "cpcap1-4",
....@@ -117,7 +115,7 @@
117115 .ack_base = CPCAP_REG_INT1,
118116 .mask_base = CPCAP_REG_INTM1,
119117 .use_ack = true,
120
- .ack_invert = true,
118
+ .clear_ack = true,
121119 },
122120 };
123121
....@@ -216,6 +214,75 @@
216214 .val_format_endian = REGMAP_ENDIAN_LITTLE,
217215 };
218216
217
+#ifdef CONFIG_PM_SLEEP
218
+static int cpcap_suspend(struct device *dev)
219
+{
220
+ struct spi_device *spi = to_spi_device(dev);
221
+
222
+ disable_irq(spi->irq);
223
+
224
+ return 0;
225
+}
226
+
227
+static int cpcap_resume(struct device *dev)
228
+{
229
+ struct spi_device *spi = to_spi_device(dev);
230
+
231
+ enable_irq(spi->irq);
232
+
233
+ return 0;
234
+}
235
+#endif
236
+
237
+static SIMPLE_DEV_PM_OPS(cpcap_pm, cpcap_suspend, cpcap_resume);
238
+
239
+static const struct mfd_cell cpcap_mfd_devices[] = {
240
+ {
241
+ .name = "cpcap_adc",
242
+ .of_compatible = "motorola,mapphone-cpcap-adc",
243
+ }, {
244
+ .name = "cpcap_battery",
245
+ .of_compatible = "motorola,cpcap-battery",
246
+ }, {
247
+ .name = "cpcap-charger",
248
+ .of_compatible = "motorola,mapphone-cpcap-charger",
249
+ }, {
250
+ .name = "cpcap-regulator",
251
+ .of_compatible = "motorola,mapphone-cpcap-regulator",
252
+ }, {
253
+ .name = "cpcap-rtc",
254
+ .of_compatible = "motorola,cpcap-rtc",
255
+ }, {
256
+ .name = "cpcap-pwrbutton",
257
+ .of_compatible = "motorola,cpcap-pwrbutton",
258
+ }, {
259
+ .name = "cpcap-usb-phy",
260
+ .of_compatible = "motorola,mapphone-cpcap-usb-phy",
261
+ }, {
262
+ .name = "cpcap-led",
263
+ .id = 0,
264
+ .of_compatible = "motorola,cpcap-led-red",
265
+ }, {
266
+ .name = "cpcap-led",
267
+ .id = 1,
268
+ .of_compatible = "motorola,cpcap-led-green",
269
+ }, {
270
+ .name = "cpcap-led",
271
+ .id = 2,
272
+ .of_compatible = "motorola,cpcap-led-blue",
273
+ }, {
274
+ .name = "cpcap-led",
275
+ .id = 3,
276
+ .of_compatible = "motorola,cpcap-led-adl",
277
+ }, {
278
+ .name = "cpcap-led",
279
+ .id = 4,
280
+ .of_compatible = "motorola,cpcap-led-cp",
281
+ }, {
282
+ .name = "cpcap-codec",
283
+ }
284
+};
285
+
219286 static int cpcap_probe(struct spi_device *spi)
220287 {
221288 const struct of_device_id *match;
....@@ -260,13 +327,19 @@
260327 if (ret)
261328 return ret;
262329
263
- return devm_of_platform_populate(&cpcap->spi->dev);
330
+ /* Parent SPI controller uses DMA, CPCAP and child devices do not */
331
+ spi->dev.coherent_dma_mask = 0;
332
+ spi->dev.dma_mask = &spi->dev.coherent_dma_mask;
333
+
334
+ return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices,
335
+ ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL);
264336 }
265337
266338 static struct spi_driver cpcap_driver = {
267339 .driver = {
268340 .name = "cpcap-core",
269341 .of_match_table = cpcap_of_match,
342
+ .pm = &cpcap_pm,
270343 },
271344 .probe = cpcap_probe,
272345 };