2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood
7 * linux@wolfsonmicro.com
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
16 #include <linux/err.h>
17 #include <linux/init.h>
18 #include <linux/i2c.h>
19 #include <linux/platform_device.h>
20 #include <linux/mfd/wm8350/core.h>
21 #include <linux/regmap.h>
22 #include <linux/slab.h>
24 static int wm8350_i2c_probe(struct i2c_client
*i2c
,
25 const struct i2c_device_id
*id
)
27 struct wm8350
*wm8350
;
28 struct wm8350_platform_data
*pdata
= dev_get_platdata(&i2c
->dev
);
31 wm8350
= devm_kzalloc(&i2c
->dev
, sizeof(struct wm8350
), GFP_KERNEL
);
35 wm8350
->regmap
= devm_regmap_init_i2c(i2c
, &wm8350_regmap
);
36 if (IS_ERR(wm8350
->regmap
)) {
37 ret
= PTR_ERR(wm8350
->regmap
);
38 dev_err(&i2c
->dev
, "Failed to allocate register map: %d\n",
43 i2c_set_clientdata(i2c
, wm8350
);
44 wm8350
->dev
= &i2c
->dev
;
46 return wm8350_device_init(wm8350
, i2c
->irq
, pdata
);
49 static const struct i2c_device_id wm8350_i2c_id
[] = {
56 static struct i2c_driver wm8350_i2c_driver
= {
59 .suppress_bind_attrs
= true,
61 .probe
= wm8350_i2c_probe
,
62 .id_table
= wm8350_i2c_id
,
65 static int __init
wm8350_i2c_init(void)
67 return i2c_add_driver(&wm8350_i2c_driver
);
69 /* init early so consumer devices can complete system boot */
70 subsys_initcall(wm8350_i2c_init
);