1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8731-i2c.c -- WM8731 ALSA SoC Audio driver I2C code
5 * Copyright 2005 Openedhand Ltd.
6 * Copyright 2006-12 Wolfson Microelectronics, plc
8 * Author: Richard Purdie <richard@openedhand.com>
10 * Based on wm8753.c by Liam Girdwood
13 #include <linux/i2c.h>
14 #include <linux/module.h>
15 #include <linux/of_device.h>
20 static const struct of_device_id wm8731_of_match[] = {
21 { .compatible = "wlf,wm8731", },
24 MODULE_DEVICE_TABLE(of, wm8731_of_match);
26 static int wm8731_i2c_probe(struct i2c_client *i2c)
28 struct wm8731_priv *wm8731;
31 wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv),
36 i2c_set_clientdata(i2c, wm8731);
38 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
39 if (IS_ERR(wm8731->regmap)) {
40 ret = PTR_ERR(wm8731->regmap);
41 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
46 return wm8731_init(&i2c->dev, wm8731);
49 static const struct i2c_device_id wm8731_i2c_id[] = {
53 MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
55 static struct i2c_driver wm8731_i2c_driver = {
58 .of_match_table = wm8731_of_match,
60 .probe_new = wm8731_i2c_probe,
61 .id_table = wm8731_i2c_id,
64 module_i2c_driver(wm8731_i2c_driver);
66 MODULE_DESCRIPTION("ASoC WM8731 driver - I2C");
67 MODULE_AUTHOR("Richard Purdie");
68 MODULE_LICENSE("GPL");