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
)
21 struct wm8350
*wm8350
;
22 struct wm8350_platform_data
*pdata
= dev_get_platdata(&i2c
->dev
);
25 wm8350
= devm_kzalloc(&i2c
->dev
, sizeof(struct wm8350
), GFP_KERNEL
);
29 wm8350
->regmap
= devm_regmap_init_i2c(i2c
, &wm8350_regmap
);
30 if (IS_ERR(wm8350
->regmap
)) {
31 ret
= PTR_ERR(wm8350
->regmap
);
32 dev_err(&i2c
->dev
, "Failed to allocate register map: %d\n",
37 i2c_set_clientdata(i2c
, wm8350
);
38 wm8350
->dev
= &i2c
->dev
;
40 return wm8350_device_init(wm8350
, i2c
->irq
, pdata
);
43 static const struct i2c_device_id wm8350_i2c_id
[] = {
50 static struct i2c_driver wm8350_i2c_driver
= {
53 .suppress_bind_attrs
= true,
55 .probe
= wm8350_i2c_probe
,
56 .id_table
= wm8350_i2c_id
,
59 static int __init
wm8350_i2c_init(void)
61 return i2c_add_driver(&wm8350_i2c_driver
);
63 /* init early so consumer devices can complete system boot */
64 subsys_initcall(wm8350_i2c_init
);