1 // SPDX-License-Identifier: GPL-2.0-only
5 * This driver creates a single register map with the intention for it to be
6 * shared by all sub-devices. Children can use their parent's device structure
7 * (dev.parent) in order to reference it.
9 * Once the register map has been successfully initialised, any sub-devices
10 * represented by child nodes in Device Tree will be subsequently registered.
13 #include <linux/i2c.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/of_platform.h>
17 #include <linux/regmap.h>
19 static const struct regmap_config simple_regmap_config
= {
24 static int simple_mfd_i2c_probe(struct i2c_client
*i2c
)
26 const struct regmap_config
*config
;
27 struct regmap
*regmap
;
29 config
= device_get_match_data(&i2c
->dev
);
31 config
= &simple_regmap_config
;
33 regmap
= devm_regmap_init_i2c(i2c
, config
);
35 return PTR_ERR(regmap
);
37 return devm_of_platform_populate(&i2c
->dev
);
40 static const struct of_device_id simple_mfd_i2c_of_match
[] = {
41 { .compatible
= "kontron,sl28cpld" },
44 MODULE_DEVICE_TABLE(of
, simple_mfd_i2c_of_match
);
46 static struct i2c_driver simple_mfd_i2c_driver
= {
47 .probe_new
= simple_mfd_i2c_probe
,
49 .name
= "simple-mfd-i2c",
50 .of_match_table
= simple_mfd_i2c_of_match
,
53 module_i2c_driver(simple_mfd_i2c_driver
);
55 MODULE_AUTHOR("Michael Walle <michael@walle.cc>");
56 MODULE_DESCRIPTION("Simple MFD - I2C driver");
57 MODULE_LICENSE("GPL v2");