Blame view
drivers/mfd/wm8350-i2c.c
2.19 KB
c661a0b92
|
1 2 3 |
/* * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC * |
c661a0b92
|
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
* Copyright 2007, 2008 Wolfson Microelectronics PLC. * * Author: Liam Girdwood * linux@wolfsonmicro.com * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * */ #include <linux/module.h> #include <linux/moduleparam.h> |
b7b142d9f
|
18 |
#include <linux/err.h> |
c661a0b92
|
19 20 21 22 |
#include <linux/init.h> #include <linux/i2c.h> #include <linux/platform_device.h> #include <linux/mfd/wm8350/core.h> |
b7b142d9f
|
23 |
#include <linux/regmap.h> |
5a0e3ad6a
|
24 |
#include <linux/slab.h> |
c661a0b92
|
25 |
|
c661a0b92
|
26 27 28 29 |
static int wm8350_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8350 *wm8350; |
334a41ce9
|
30 |
struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev); |
c661a0b92
|
31 |
int ret = 0; |
55ee29d5f
|
32 |
wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); |
e47a3bbe4
|
33 |
if (wm8350 == NULL) |
c661a0b92
|
34 |
return -ENOMEM; |
c661a0b92
|
35 |
|
b7b142d9f
|
36 37 38 39 40 41 42 43 |
wm8350->regmap = devm_regmap_init_i2c(i2c, &wm8350_regmap); if (IS_ERR(wm8350->regmap)) { ret = PTR_ERR(wm8350->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d ", ret); return ret; } |
c661a0b92
|
44 45 |
i2c_set_clientdata(i2c, wm8350); wm8350->dev = &i2c->dev; |
c661a0b92
|
46 |
|
334a41ce9
|
47 |
return wm8350_device_init(wm8350, i2c->irq, pdata); |
c661a0b92
|
48 49 50 51 52 53 54 |
} static int wm8350_i2c_remove(struct i2c_client *i2c) { struct wm8350 *wm8350 = i2c_get_clientdata(i2c); wm8350_device_exit(wm8350); |
c661a0b92
|
55 56 57 58 59 |
return 0; } static const struct i2c_device_id wm8350_i2c_id[] = { |
6db1c9ba9
|
60 61 62 63 |
{ "wm8350", 0 }, { "wm8351", 0 }, { "wm8352", 0 }, { } |
c661a0b92
|
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
}; MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id); static struct i2c_driver wm8350_i2c_driver = { .driver = { .name = "wm8350", .owner = THIS_MODULE, }, .probe = wm8350_i2c_probe, .remove = wm8350_i2c_remove, .id_table = wm8350_i2c_id, }; static int __init wm8350_i2c_init(void) { return i2c_add_driver(&wm8350_i2c_driver); } /* init early so consumer devices can complete system boot */ subsys_initcall(wm8350_i2c_init); static void __exit wm8350_i2c_exit(void) { i2c_del_driver(&wm8350_i2c_driver); } module_exit(wm8350_i2c_exit); MODULE_DESCRIPTION("I2C support for the WM8350 AudioPlus PMIC"); MODULE_LICENSE("GPL"); |