]> Git Repo - linux.git/blob - drivers/mfd/wm8350-i2c.c
mfd: Add tps65910 device tree bindings documentation
[linux.git] / drivers / mfd / wm8350-i2c.c
1 /*
2  * wm8350-i2c.c  --  Generic I2C driver for Wolfson WM8350 PMIC
3  *
4  * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5  *
6  * Author: Liam Girdwood
7  *         [email protected]
8  *
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.
13  *
14  */
15
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/err.h>
19 #include <linux/init.h>
20 #include <linux/i2c.h>
21 #include <linux/platform_device.h>
22 #include <linux/mfd/wm8350/core.h>
23 #include <linux/regmap.h>
24 #include <linux/slab.h>
25
26 static const struct regmap_config wm8350_regmap = {
27         .reg_bits = 8,
28         .val_bits = 16,
29 };
30
31 static int wm8350_i2c_probe(struct i2c_client *i2c,
32                             const struct i2c_device_id *id)
33 {
34         struct wm8350 *wm8350;
35         int ret = 0;
36
37         wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL);
38         if (wm8350 == NULL)
39                 return -ENOMEM;
40
41         wm8350->regmap = devm_regmap_init_i2c(i2c, &wm8350_regmap);
42         if (IS_ERR(wm8350->regmap)) {
43                 ret = PTR_ERR(wm8350->regmap);
44                 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
45                         ret);
46                 return ret;
47         }
48
49         i2c_set_clientdata(i2c, wm8350);
50         wm8350->dev = &i2c->dev;
51
52         ret = wm8350_device_init(wm8350, i2c->irq, i2c->dev.platform_data);
53         if (ret < 0)
54                 goto err;
55
56         return ret;
57
58 err:
59         regmap_exit(wm8350->regmap);
60         return ret;
61 }
62
63 static int wm8350_i2c_remove(struct i2c_client *i2c)
64 {
65         struct wm8350 *wm8350 = i2c_get_clientdata(i2c);
66
67         wm8350_device_exit(wm8350);
68
69         return 0;
70 }
71
72 static const struct i2c_device_id wm8350_i2c_id[] = {
73        { "wm8350", 0 },
74        { "wm8351", 0 },
75        { "wm8352", 0 },
76        { }
77 };
78 MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
79
80
81 static struct i2c_driver wm8350_i2c_driver = {
82         .driver = {
83                    .name = "wm8350",
84                    .owner = THIS_MODULE,
85         },
86         .probe = wm8350_i2c_probe,
87         .remove = wm8350_i2c_remove,
88         .id_table = wm8350_i2c_id,
89 };
90
91 static int __init wm8350_i2c_init(void)
92 {
93         return i2c_add_driver(&wm8350_i2c_driver);
94 }
95 /* init early so consumer devices can complete system boot */
96 subsys_initcall(wm8350_i2c_init);
97
98 static void __exit wm8350_i2c_exit(void)
99 {
100         i2c_del_driver(&wm8350_i2c_driver);
101 }
102 module_exit(wm8350_i2c_exit);
103
104 MODULE_DESCRIPTION("I2C support for the WM8350 AudioPlus PMIC");
105 MODULE_LICENSE("GPL");
This page took 0.038255 seconds and 4 git commands to generate.