1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
5 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
7 * Author: Liam Girdwood
8 * linux@wolfsonmicro.com
11 #include <linux/err.h>
12 #include <linux/init.h>
13 #include <linux/i2c.h>
14 #include <linux/platform_device.h>
15 #include <linux/mfd/wm8350/core.h>
16 #include <linux/regmap.h>
17 #include <linux/slab.h>
19 static int wm8350_i2c_probe(struct i2c_client
*i2c
,
20 const struct i2c_device_id
*id
)
22 struct wm8350
*wm8350
;
23 struct wm8350_platform_data
*pdata
= dev_get_platdata(&i2c
->dev
);
26 wm8350
= devm_kzalloc(&i2c
->dev
, sizeof(struct wm8350
), GFP_KERNEL
);
30 wm8350
->regmap
= devm_regmap_init_i2c(i2c
, &wm8350_regmap
);
31 if (IS_ERR(wm8350
->regmap
)) {
32 ret
= PTR_ERR(wm8350
->regmap
);
33 dev_err(&i2c
->dev
, "Failed to allocate register map: %d\n",
38 i2c_set_clientdata(i2c
, wm8350
);
39 wm8350
->dev
= &i2c
->dev
;
41 return wm8350_device_init(wm8350
, i2c
->irq
, pdata
);
44 static const struct i2c_device_id wm8350_i2c_id
[] = {
51 static struct i2c_driver wm8350_i2c_driver
= {
54 .suppress_bind_attrs
= true,
56 .probe
= wm8350_i2c_probe
,
57 .id_table
= wm8350_i2c_id
,
60 static int __init
wm8350_i2c_init(void)
62 return i2c_add_driver(&wm8350_i2c_driver
);
64 /* init early so consumer devices can complete system boot */
65 subsys_initcall(wm8350_i2c_init
);