15 #include <linux/module.h>
18 #include <linux/i2c.h>
19 #include <linux/kernel.h>
24 #include <linux/slab.h>
26 static bool wm8400_volatile(
struct device *
dev,
unsigned int reg)
68 .
name =
"wm8400-codec",
69 .platform_data = wm8400,
70 .pdata_size =
sizeof(*wm8400),
94 dev_err(wm8400->
dev,
"Chip ID register read failed\n");
98 dev_err(wm8400->
dev,
"Device is not a WM8400, ID is %x\n",
105 dev_err(wm8400->
dev,
"ID register read failed: %d\n", ret);
109 dev_info(wm8400->
dev,
"WM8400 revision %x\n", reg);
111 ret = wm8400_register_codec(wm8400);
113 dev_err(wm8400->
dev,
"Failed to register codec\n");
120 dev_err(wm8400->
dev,
"Platform init failed: %d\n",
125 dev_warn(wm8400->
dev,
"No platform initialisation supplied\n");
134 static void wm8400_release(
struct wm8400 *wm8400)
139 static const struct regmap_config wm8400_regmap_config = {
144 .volatile_reg = wm8400_volatile,
159 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
160 static int wm8400_i2c_probe(
struct i2c_client *i2c,
163 struct wm8400 *wm8400;
167 if (wm8400 ==
NULL) {
173 if (IS_ERR(wm8400->
regmap)) {
174 ret = PTR_ERR(wm8400->
regmap);
179 i2c_set_clientdata(i2c, wm8400);
181 ret = wm8400_init(wm8400, i2c->
dev.platform_data);
191 static int wm8400_i2c_remove(
struct i2c_client *i2c)
193 struct wm8400 *wm8400 = i2c_get_clientdata(i2c);
195 wm8400_release(wm8400);
206 static struct i2c_driver wm8400_i2c_driver = {
211 .probe = wm8400_i2c_probe,
212 .remove = wm8400_i2c_remove,
213 .id_table = wm8400_i2c_id,
217 static int __init wm8400_module_init(
void)
221 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
222 ret = i2c_add_driver(&wm8400_i2c_driver);
224 pr_err(
"Failed to register I2C driver: %d\n", ret);
231 static void __exit wm8400_module_exit(
void)
233 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)