mm/page_alloc: prevent merging between isolated and other pageblocks
[linux-2.6-block.git] / drivers / mfd / wm8350-i2c.c
CommitLineData
c661a0b9
MB
1/*
2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
3 *
c661a0b9
MB
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood
7 * linux@wolfsonmicro.com
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>
b7b142d9 18#include <linux/err.h>
c661a0b9
MB
19#include <linux/init.h>
20#include <linux/i2c.h>
21#include <linux/platform_device.h>
22#include <linux/mfd/wm8350/core.h>
b7b142d9 23#include <linux/regmap.h>
5a0e3ad6 24#include <linux/slab.h>
c661a0b9 25
c661a0b9
MB
26static int wm8350_i2c_probe(struct i2c_client *i2c,
27 const struct i2c_device_id *id)
28{
29 struct wm8350 *wm8350;
334a41ce 30 struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev);
c661a0b9
MB
31 int ret = 0;
32
55ee29d5 33 wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL);
e47a3bbe 34 if (wm8350 == NULL)
c661a0b9 35 return -ENOMEM;
c661a0b9 36
b7b142d9
MB
37 wm8350->regmap = devm_regmap_init_i2c(i2c, &wm8350_regmap);
38 if (IS_ERR(wm8350->regmap)) {
39 ret = PTR_ERR(wm8350->regmap);
40 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
41 ret);
42 return ret;
43 }
44
c661a0b9
MB
45 i2c_set_clientdata(i2c, wm8350);
46 wm8350->dev = &i2c->dev;
c661a0b9 47
334a41ce 48 return wm8350_device_init(wm8350, i2c->irq, pdata);
c661a0b9
MB
49}
50
51static int wm8350_i2c_remove(struct i2c_client *i2c)
52{
53 struct wm8350 *wm8350 = i2c_get_clientdata(i2c);
54
55 wm8350_device_exit(wm8350);
c661a0b9
MB
56
57 return 0;
58}
59
60static const struct i2c_device_id wm8350_i2c_id[] = {
6db1c9ba
LJ
61 { "wm8350", 0 },
62 { "wm8351", 0 },
63 { "wm8352", 0 },
64 { }
c661a0b9
MB
65};
66MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
67
68
69static struct i2c_driver wm8350_i2c_driver = {
70 .driver = {
71 .name = "wm8350",
c661a0b9
MB
72 },
73 .probe = wm8350_i2c_probe,
74 .remove = wm8350_i2c_remove,
75 .id_table = wm8350_i2c_id,
76};
77
78static int __init wm8350_i2c_init(void)
79{
80 return i2c_add_driver(&wm8350_i2c_driver);
81}
82/* init early so consumer devices can complete system boot */
83subsys_initcall(wm8350_i2c_init);
84
85static void __exit wm8350_i2c_exit(void)
86{
87 i2c_del_driver(&wm8350_i2c_driver);
88}
89module_exit(wm8350_i2c_exit);
90
91MODULE_DESCRIPTION("I2C support for the WM8350 AudioPlus PMIC");
92MODULE_LICENSE("GPL");