xref: /openbmc/linux/sound/soc/codecs/ssm2602-i2c.c (revision 555b9ee1)
1c924dc68SLars-Peter Clausen /*
2c924dc68SLars-Peter Clausen  * SSM2602/SSM2603/SSM2604 I2C audio driver
3c924dc68SLars-Peter Clausen  *
4c924dc68SLars-Peter Clausen  * Copyright 2014 Analog Devices Inc.
5c924dc68SLars-Peter Clausen  *
6c924dc68SLars-Peter Clausen  * Licensed under the GPL-2.
7c924dc68SLars-Peter Clausen  */
8c924dc68SLars-Peter Clausen 
9c924dc68SLars-Peter Clausen #include <linux/module.h>
10c924dc68SLars-Peter Clausen #include <linux/i2c.h>
11c924dc68SLars-Peter Clausen #include <linux/regmap.h>
12c924dc68SLars-Peter Clausen 
13c924dc68SLars-Peter Clausen #include <sound/soc.h>
14c924dc68SLars-Peter Clausen 
15c924dc68SLars-Peter Clausen #include "ssm2602.h"
16c924dc68SLars-Peter Clausen 
17c924dc68SLars-Peter Clausen /*
18c924dc68SLars-Peter Clausen  * ssm2602 2 wire address is determined by GPIO5
19c924dc68SLars-Peter Clausen  * state during powerup.
20c924dc68SLars-Peter Clausen  *    low  = 0x1a
21c924dc68SLars-Peter Clausen  *    high = 0x1b
22c924dc68SLars-Peter Clausen  */
23c924dc68SLars-Peter Clausen static int ssm2602_i2c_probe(struct i2c_client *client,
24c924dc68SLars-Peter Clausen 			     const struct i2c_device_id *id)
25c924dc68SLars-Peter Clausen {
26c924dc68SLars-Peter Clausen 	return ssm2602_probe(&client->dev, id->driver_data,
27c924dc68SLars-Peter Clausen 		devm_regmap_init_i2c(client, &ssm2602_regmap_config));
28c924dc68SLars-Peter Clausen }
29c924dc68SLars-Peter Clausen 
30c924dc68SLars-Peter Clausen static int ssm2602_i2c_remove(struct i2c_client *client)
31c924dc68SLars-Peter Clausen {
32c924dc68SLars-Peter Clausen 	snd_soc_unregister_codec(&client->dev);
33c924dc68SLars-Peter Clausen 	return 0;
34c924dc68SLars-Peter Clausen }
35c924dc68SLars-Peter Clausen 
36c924dc68SLars-Peter Clausen static const struct i2c_device_id ssm2602_i2c_id[] = {
37c924dc68SLars-Peter Clausen 	{ "ssm2602", SSM2602 },
38c924dc68SLars-Peter Clausen 	{ "ssm2603", SSM2602 },
39c924dc68SLars-Peter Clausen 	{ "ssm2604", SSM2604 },
40c924dc68SLars-Peter Clausen 	{ }
41c924dc68SLars-Peter Clausen };
42c924dc68SLars-Peter Clausen MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
43c924dc68SLars-Peter Clausen 
44555b9ee1SStefan Kristiansson static const struct of_device_id ssm2602_of_match[] = {
45555b9ee1SStefan Kristiansson 	{ .compatible = "adi,ssm2602", },
46555b9ee1SStefan Kristiansson 	{ .compatible = "adi,ssm2603", },
47555b9ee1SStefan Kristiansson 	{ .compatible = "adi,ssm2604", },
48555b9ee1SStefan Kristiansson 	{ }
49555b9ee1SStefan Kristiansson };
50555b9ee1SStefan Kristiansson MODULE_DEVICE_TABLE(of, ssm2602_of_match);
51555b9ee1SStefan Kristiansson 
52c924dc68SLars-Peter Clausen static struct i2c_driver ssm2602_i2c_driver = {
53c924dc68SLars-Peter Clausen 	.driver = {
54c924dc68SLars-Peter Clausen 		.name = "ssm2602",
55c924dc68SLars-Peter Clausen 		.owner = THIS_MODULE,
56555b9ee1SStefan Kristiansson 		.of_match_table = ssm2602_of_match,
57c924dc68SLars-Peter Clausen 	},
58c924dc68SLars-Peter Clausen 	.probe = ssm2602_i2c_probe,
59c924dc68SLars-Peter Clausen 	.remove = ssm2602_i2c_remove,
60c924dc68SLars-Peter Clausen 	.id_table = ssm2602_i2c_id,
61c924dc68SLars-Peter Clausen };
62c924dc68SLars-Peter Clausen module_i2c_driver(ssm2602_i2c_driver);
63c924dc68SLars-Peter Clausen 
64c924dc68SLars-Peter Clausen MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 I2C driver");
65c924dc68SLars-Peter Clausen MODULE_AUTHOR("Cliff Cai");
66c924dc68SLars-Peter Clausen MODULE_LICENSE("GPL");
67