xref: /openbmc/linux/sound/soc/codecs/cs42l51-i2c.c (revision df8d014e)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2a1253ef6SBrian Austin /*
3a1253ef6SBrian Austin  * cs42l56.c -- CS42L51 ALSA SoC I2C audio driver
4a1253ef6SBrian Austin  *
5a1253ef6SBrian Austin  * Copyright 2014 CirrusLogic, Inc.
6a1253ef6SBrian Austin  *
7a1253ef6SBrian Austin  * Author: Brian Austin <brian.austin@cirrus.com>
8a1253ef6SBrian Austin  */
9a1253ef6SBrian Austin 
10a1253ef6SBrian Austin #include <linux/i2c.h>
11a1253ef6SBrian Austin #include <linux/module.h>
12a1253ef6SBrian Austin #include <sound/soc.h>
13a1253ef6SBrian Austin 
14a1253ef6SBrian Austin #include "cs42l51.h"
15a1253ef6SBrian Austin 
16a1253ef6SBrian Austin static struct i2c_device_id cs42l51_i2c_id[] = {
17a1253ef6SBrian Austin 	{"cs42l51", 0},
18a1253ef6SBrian Austin 	{}
19a1253ef6SBrian Austin };
20a1253ef6SBrian Austin MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
21a1253ef6SBrian Austin 
22*df8d014eSYang Yingliang static const struct of_device_id cs42l51_of_match[] = {
23e51df4f8SThomas Petazzoni 	{ .compatible = "cirrus,cs42l51", },
24e51df4f8SThomas Petazzoni 	{ }
25e51df4f8SThomas Petazzoni };
26e51df4f8SThomas Petazzoni MODULE_DEVICE_TABLE(of, cs42l51_of_match);
27e51df4f8SThomas Petazzoni 
cs42l51_i2c_probe(struct i2c_client * i2c)284a404345SStephen Kitt static int cs42l51_i2c_probe(struct i2c_client *i2c)
29a1253ef6SBrian Austin {
30a1253ef6SBrian Austin 	struct regmap_config config;
31a1253ef6SBrian Austin 
32a1253ef6SBrian Austin 	config = cs42l51_regmap;
33a1253ef6SBrian Austin 
34a1253ef6SBrian Austin 	return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config));
35a1253ef6SBrian Austin }
36a1253ef6SBrian Austin 
cs42l51_i2c_remove(struct i2c_client * i2c)37ed5c2f5fSUwe Kleine-König static void cs42l51_i2c_remove(struct i2c_client *i2c)
38f77b6ea7SOlivier Moysan {
3973d4c313SUwe Kleine-König 	cs42l51_remove(&i2c->dev);
40f77b6ea7SOlivier Moysan }
41f77b6ea7SOlivier Moysan 
4275a71482SOlivier Moysan static const struct dev_pm_ops cs42l51_pm_ops = {
4375a71482SOlivier Moysan 	SET_SYSTEM_SLEEP_PM_OPS(cs42l51_suspend, cs42l51_resume)
4475a71482SOlivier Moysan };
4575a71482SOlivier Moysan 
46a1253ef6SBrian Austin static struct i2c_driver cs42l51_i2c_driver = {
47a1253ef6SBrian Austin 	.driver = {
48a1253ef6SBrian Austin 		.name = "cs42l51",
492cb1e025SThomas Petazzoni 		.of_match_table = cs42l51_of_match,
5075a71482SOlivier Moysan 		.pm = &cs42l51_pm_ops,
51a1253ef6SBrian Austin 	},
529abcd240SUwe Kleine-König 	.probe = cs42l51_i2c_probe,
53f77b6ea7SOlivier Moysan 	.remove = cs42l51_i2c_remove,
54a1253ef6SBrian Austin 	.id_table = cs42l51_i2c_id,
55a1253ef6SBrian Austin };
56a1253ef6SBrian Austin 
57a1253ef6SBrian Austin module_i2c_driver(cs42l51_i2c_driver);
58a1253ef6SBrian Austin 
59a1253ef6SBrian Austin MODULE_DESCRIPTION("ASoC CS42L51 I2C Driver");
60a1253ef6SBrian Austin MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
61a1253ef6SBrian Austin MODULE_LICENSE("GPL");
62