Skip to content

Commit bb03ffb

Browse files
Todd BrochLee Jones
authored andcommitted
mfd: cros_ec: Instantiate sub-devices from device tree
If the EC device tree node has sub-nodes, try to instantiate them as MFD sub-devices. We can configure the EC features provided by the board. Signed-off-by: Todd Broch <tbroch@chromium.org> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent e7b707f commit bb03ffb

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎drivers/mfd/cros_ec.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* battery charging and regulator control, firmware update.
1818
*/
1919

20+
#include <linux/of_platform.h>
2021
#include <linux/interrupt.h>
2122
#include <linux/slab.h>
2223
#include <linux/module.h>
@@ -108,19 +109,9 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
108109
EXPORT_SYMBOL(cros_ec_cmd_xfer);
109110

110111
static const struct mfd_cell cros_devs[] = {
111-
{
112-
.name = "cros-ec-keyb",
113-
.id = 1,
114-
.of_compatible = "google,cros-ec-keyb",
115-
},
116-
{
117-
.name = "cros-ec-i2c-tunnel",
118-
.id = 2,
119-
.of_compatible = "google,cros-ec-i2c-tunnel",
120-
},
121112
{
122113
.name = "cros-ec-ctl",
123-
.id = 3,
114+
.id = PLATFORM_DEVID_AUTO,
124115
},
125116
};
126117

@@ -150,6 +141,15 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
150141
return err;
151142
}
152143

144+
if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
145+
err = of_platform_populate(dev->of_node, NULL, NULL, dev);
146+
if (err) {
147+
mfd_remove_devices(dev);
148+
dev_err(dev, "Failed to register sub-devices\n");
149+
return err;
150+
}
151+
}
152+
153153
dev_info(dev, "Chrome EC device registered\n");
154154

155155
return 0;

0 commit comments

Comments
 (0)