xref: /openbmc/linux/sound/soc/codecs/cs42l51-i2c.c (revision 2cb1e025)
1a1253ef6SBrian Austin /*
2a1253ef6SBrian Austin  * cs42l56.c -- CS42L51 ALSA SoC I2C audio driver
3a1253ef6SBrian Austin  *
4a1253ef6SBrian Austin  * Copyright 2014 CirrusLogic, Inc.
5a1253ef6SBrian Austin  *
6a1253ef6SBrian Austin  * Author: Brian Austin <brian.austin@cirrus.com>
7a1253ef6SBrian Austin  *
8a1253ef6SBrian Austin  * This program is free software; you can redistribute it and/or modify
9a1253ef6SBrian Austin  * it under the terms of the GNU General Public License version 2 as
10a1253ef6SBrian Austin  * published by the Free Software Foundation.
11a1253ef6SBrian Austin  *
12a1253ef6SBrian Austin  */
13a1253ef6SBrian Austin 
14a1253ef6SBrian Austin #include <linux/i2c.h>
15a1253ef6SBrian Austin #include <linux/module.h>
16a1253ef6SBrian Austin #include <sound/soc.h>
17a1253ef6SBrian Austin 
18a1253ef6SBrian Austin #include "cs42l51.h"
19a1253ef6SBrian Austin 
20a1253ef6SBrian Austin static struct i2c_device_id cs42l51_i2c_id[] = {
21a1253ef6SBrian Austin 	{"cs42l51", 0},
22a1253ef6SBrian Austin 	{}
23a1253ef6SBrian Austin };
24a1253ef6SBrian Austin MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
25a1253ef6SBrian Austin 
26a1253ef6SBrian Austin static int cs42l51_i2c_probe(struct i2c_client *i2c,
27a1253ef6SBrian Austin 			     const struct i2c_device_id *id)
28a1253ef6SBrian Austin {
29a1253ef6SBrian Austin 	struct regmap_config config;
30a1253ef6SBrian Austin 
31a1253ef6SBrian Austin 	config = cs42l51_regmap;
32a1253ef6SBrian Austin 	config.val_bits = 8;
33a1253ef6SBrian Austin 	config.reg_bits = 8;
34a1253ef6SBrian Austin 
35a1253ef6SBrian Austin 	return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config));
36a1253ef6SBrian Austin }
37a1253ef6SBrian Austin 
38a1253ef6SBrian Austin static int cs42l51_i2c_remove(struct i2c_client *i2c)
39a1253ef6SBrian Austin {
40a1253ef6SBrian Austin 	snd_soc_unregister_codec(&i2c->dev);
41a1253ef6SBrian Austin 
42a1253ef6SBrian Austin 	return 0;
43a1253ef6SBrian Austin }
44a1253ef6SBrian Austin 
45a1253ef6SBrian Austin static struct i2c_driver cs42l51_i2c_driver = {
46a1253ef6SBrian Austin 	.driver = {
47a1253ef6SBrian Austin 		.name = "cs42l51",
48a1253ef6SBrian Austin 		.owner = THIS_MODULE,
492cb1e025SThomas Petazzoni 		.of_match_table = cs42l51_of_match,
50a1253ef6SBrian Austin 	},
51a1253ef6SBrian Austin 	.probe = cs42l51_i2c_probe,
52a1253ef6SBrian Austin 	.remove = cs42l51_i2c_remove,
53a1253ef6SBrian Austin 	.id_table = cs42l51_i2c_id,
54a1253ef6SBrian Austin };
55a1253ef6SBrian Austin 
56a1253ef6SBrian Austin module_i2c_driver(cs42l51_i2c_driver);
57a1253ef6SBrian Austin 
58a1253ef6SBrian Austin MODULE_DESCRIPTION("ASoC CS42L51 I2C Driver");
59a1253ef6SBrian Austin MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
60a1253ef6SBrian Austin MODULE_LICENSE("GPL");
61