Skip to content

Commit 2cbc8b4

Browse files
marcanjannau
authored andcommitted
mfd: Add a simple-mfd-spmi driver
This is the SPMI counterpart to simple-mfd-i2c. It merely exposes the SPMI register address space as an MFD device, such that different aspects of a device can be managed by separate drivers. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 542dad1 commit 2cbc8b4

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

drivers/mfd/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ config MFD_ACT8945A
5252
linear regulators, along with a complete ActivePath battery
5353
charger.
5454

55+
config MFD_APPLE_SPMI_PMU
56+
tristate "Apple SPMI PMUs"
57+
depends on SPMI
58+
depends on ARCH_APPLE || COMPILE_TEST
59+
default ARCH_APPLE
60+
select MFD_SIMPLE_MFD_SPMI
61+
help
62+
Say yes here to enable support for Apple PMUs attached via the
63+
SPMI bus. These can be found on Apple devices such as Apple
64+
Silicon Macs.
65+
66+
This driver itself only attaches to the core device, and relies
67+
on subsystem drivers for individual device functions. You must
68+
enable those for it to be useful.
69+
5570
config MFD_SUN4I_GPADC
5671
tristate "Allwinner sunxi platforms' GPADC MFD driver"
5772
select MFD_CORE
@@ -1324,6 +1339,19 @@ config MFD_SIMPLE_MFD_I2C
13241339
sub-devices represented by child nodes in Device Tree will be
13251340
subsequently registered.
13261341

1342+
config MFD_SIMPLE_MFD_SPMI
1343+
tristate
1344+
depends on SPMI
1345+
select MFD_CORE
1346+
select REGMAP_SPMI
1347+
help
1348+
This driver creates a single register map with the intention for it
1349+
to be shared by all sub-devices.
1350+
1351+
Once the register map has been successfully initialised, any
1352+
sub-devices represented by child nodes in Device Tree will be
1353+
subsequently registered.
1354+
13271355
config MFD_SL28CPLD
13281356
tristate "Kontron sl28cpld Board Management Controller"
13291357
depends on I2C

drivers/mfd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o
277277

278278
obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
279279
obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
280+
obj-$(CONFIG_MFD_SIMPLE_MFD_SPMI) += simple-mfd-spmi.o
280281
obj-$(CONFIG_MFD_SMPRO) += smpro-core.o
281282

282283
obj-$(CONFIG_MFD_INTEL_M10_BMC_CORE) += intel-m10-bmc-core.o

drivers/mfd/simple-mfd-spmi.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: GPL-2.0-only OR MIT
2+
/*
3+
* Simple MFD - SPMI
4+
*
5+
* Copyright The Asahi Linux Contributors
6+
*/
7+
8+
#include <linux/kernel.h>
9+
#include <linux/module.h>
10+
#include <linux/regmap.h>
11+
#include <linux/spmi.h>
12+
#include <linux/of_platform.h>
13+
14+
static const struct regmap_config spmi_regmap_config = {
15+
.reg_bits = 16,
16+
.val_bits = 8,
17+
.max_register = 0xffff,
18+
};
19+
20+
static int simple_spmi_probe(struct spmi_device *sdev)
21+
{
22+
struct regmap *regmap;
23+
24+
regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config);
25+
if (IS_ERR(regmap))
26+
return PTR_ERR(regmap);
27+
28+
return devm_of_platform_populate(&sdev->dev);
29+
}
30+
31+
static const struct of_device_id simple_spmi_id_table[] = {
32+
{ .compatible = "apple,spmi-pmu" },
33+
{}
34+
};
35+
MODULE_DEVICE_TABLE(of, simple_spmi_id_table);
36+
37+
static struct spmi_driver pmic_spmi_driver = {
38+
.probe = simple_spmi_probe,
39+
.driver = {
40+
.name = "simple-mfd-spmi",
41+
.owner = THIS_MODULE,
42+
.of_match_table = simple_spmi_id_table,
43+
},
44+
};
45+
module_spmi_driver(pmic_spmi_driver);
46+
47+
MODULE_LICENSE("Dual MIT/GPL");
48+
MODULE_DESCRIPTION("Simple MFD - SPMI driver");
49+
MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");

0 commit comments

Comments
 (0)