Skip to content

Commit 5ec436d

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 7af219b commit 5ec436d

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

drivers/mfd/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ config MFD_ACT8945A
6464
linear regulators, along with a complete ActivePath battery
6565
charger.
6666

67+
config MFD_APPLE_SPMI_PMU
68+
tristate "Apple SPMI PMUs"
69+
depends on SPMI
70+
depends on ARCH_APPLE || COMPILE_TEST
71+
default ARCH_APPLE
72+
select MFD_SIMPLE_MFD_SPMI
73+
help
74+
Say yes here to enable support for Apple PMUs attached via the
75+
SPMI bus. These can be found on Apple devices such as Apple
76+
Silicon Macs.
77+
78+
This driver itself only attaches to the core device, and relies
79+
on subsystem drivers for individual device functions. You must
80+
enable those for it to be useful.
81+
6782
config MFD_SUN4I_GPADC
6883
tristate "Allwinner sunxi platforms' GPADC MFD driver"
6984
select MFD_CORE
@@ -1348,6 +1363,19 @@ config MFD_SIMPLE_MFD_I2C
13481363
sub-devices represented by child nodes in Device Tree will be
13491364
subsequently registered.
13501365

1366+
config MFD_SIMPLE_MFD_SPMI
1367+
tristate
1368+
depends on SPMI
1369+
select MFD_CORE
1370+
select REGMAP_SPMI
1371+
help
1372+
This driver creates a single register map with the intention for it
1373+
to be shared by all sub-devices.
1374+
1375+
Once the register map has been successfully initialised, any
1376+
sub-devices represented by child nodes in Device Tree will be
1377+
subsequently registered.
1378+
13511379
config MFD_SL28CPLD
13521380
tristate "Kontron sl28cpld Board Management Controller"
13531381
depends on I2C

drivers/mfd/Makefile

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

280280
obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
281281
obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
282+
obj-$(CONFIG_MFD_SIMPLE_MFD_SPMI) += simple-mfd-spmi.o
282283
obj-$(CONFIG_MFD_SMPRO) += smpro-core.o
283284

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

drivers/mfd/simple-mfd-spmi.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
.of_match_table = simple_spmi_id_table,
42+
},
43+
};
44+
module_spmi_driver(pmic_spmi_driver);
45+
46+
MODULE_LICENSE("Dual MIT/GPL");
47+
MODULE_DESCRIPTION("Simple MFD - SPMI driver");
48+
MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");

0 commit comments

Comments
 (0)