Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 1 | /* |
| 2 | * ALSA SoC TLV320AIC23 codec driver I2C interface |
| 3 | * |
| 4 | * Author: Arun KS, <arunks@mistralsolutions.com> |
| 5 | * Copyright: (C) 2008 Mistral Solutions Pvt Ltd., |
| 6 | * |
| 7 | * Based on sound/soc/codecs/wm8731.c by Richard Purdie |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/i2c.h> |
| 15 | #include <linux/module.h> |
Sachin Kamat | 0faabc4 | 2014-04-04 11:29:12 +0530 | [diff] [blame] | 16 | #include <linux/of.h> |
Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 17 | #include <linux/regmap.h> |
| 18 | #include <sound/soc.h> |
| 19 | |
| 20 | #include "tlv320aic23.h" |
| 21 | |
| 22 | static int tlv320aic23_i2c_probe(struct i2c_client *i2c, |
| 23 | const struct i2c_device_id *i2c_id) |
| 24 | { |
| 25 | struct regmap *regmap; |
| 26 | |
| 27 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 28 | return -EINVAL; |
| 29 | |
| 30 | regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap); |
| 31 | return tlv320aic23_probe(&i2c->dev, regmap); |
| 32 | } |
| 33 | |
Dmitry Torokhov | f580f8a | 2015-03-09 11:18:14 -0700 | [diff] [blame] | 34 | static int tlv320aic23_i2c_remove(struct i2c_client *i2c) |
Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 35 | { |
| 36 | snd_soc_unregister_codec(&i2c->dev); |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static const struct i2c_device_id tlv320aic23_id[] = { |
| 41 | {"tlv320aic23", 0}, |
| 42 | {} |
| 43 | }; |
| 44 | |
| 45 | MODULE_DEVICE_TABLE(i2c, tlv320aic23_id); |
| 46 | |
Stephen Warren | 3534b84 | 2014-03-31 12:38:17 -0600 | [diff] [blame] | 47 | static const struct of_device_id tlv320aic23_of_match[] = { |
| 48 | { .compatible = "ti,tlv320aic23", }, |
| 49 | { } |
| 50 | }; |
| 51 | MODULE_DEVICE_TABLE(of, tlv320aic23_of_match); |
| 52 | |
Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 53 | static struct i2c_driver tlv320aic23_i2c_driver = { |
| 54 | .driver = { |
| 55 | .name = "tlv320aic23-codec", |
Stephen Warren | 3534b84 | 2014-03-31 12:38:17 -0600 | [diff] [blame] | 56 | .of_match_table = of_match_ptr(tlv320aic23_of_match), |
Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 57 | }, |
| 58 | .probe = tlv320aic23_i2c_probe, |
Dmitry Torokhov | f580f8a | 2015-03-09 11:18:14 -0700 | [diff] [blame] | 59 | .remove = tlv320aic23_i2c_remove, |
Max Filippov | b3fc572 | 2014-03-06 14:04:41 +0400 | [diff] [blame] | 60 | .id_table = tlv320aic23_id, |
| 61 | }; |
| 62 | |
| 63 | module_i2c_driver(tlv320aic23_i2c_driver); |
| 64 | |
| 65 | MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver I2C"); |
| 66 | MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>"); |
| 67 | MODULE_LICENSE("GPL"); |