1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * wm8731-i2c.c -- WM8731 ALSA SoC Audio driver I2C code 4 * 5 * Copyright 2005 Openedhand Ltd. 6 * Copyright 2006-12 Wolfson Microelectronics, plc 7 * 8 * Author: Richard Purdie <richard@openedhand.com> 9 * 10 * Based on wm8753.c by Liam Girdwood 11 */ 12 13 #include <linux/i2c.h> 14 #include <linux/module.h> 15 #include <linux/of_device.h> 16 17 #include "wm8731.h" 18 19 20 static const struct of_device_id wm8731_of_match[] = { 21 { .compatible = "wlf,wm8731", }, 22 { } 23 }; 24 MODULE_DEVICE_TABLE(of, wm8731_of_match); 25 26 static int wm8731_i2c_probe(struct i2c_client *i2c, 27 const struct i2c_device_id *id) 28 { 29 struct wm8731_priv *wm8731; 30 int ret; 31 32 wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv), 33 GFP_KERNEL); 34 if (wm8731 == NULL) 35 return -ENOMEM; 36 37 i2c_set_clientdata(i2c, wm8731); 38 39 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap); 40 if (IS_ERR(wm8731->regmap)) { 41 ret = PTR_ERR(wm8731->regmap); 42 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 43 ret); 44 return ret; 45 } 46 47 return wm8731_init(&i2c->dev, wm8731); 48 } 49 50 static const struct i2c_device_id wm8731_i2c_id[] = { 51 { "wm8731", 0 }, 52 { } 53 }; 54 MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id); 55 56 static struct i2c_driver wm8731_i2c_driver = { 57 .driver = { 58 .name = "wm8731", 59 .of_match_table = wm8731_of_match, 60 }, 61 .probe = wm8731_i2c_probe, 62 .id_table = wm8731_i2c_id, 63 }; 64 65 module_i2c_driver(wm8731_i2c_driver); 66 67 MODULE_DESCRIPTION("ASoC WM8731 driver - I2C"); 68 MODULE_AUTHOR("Richard Purdie"); 69 MODULE_LICENSE("GPL"); 70