xref: /openbmc/linux/sound/soc/codecs/ssm2602-i2c.c (revision 1edd0337)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * SSM2602/SSM2603/SSM2604 I2C audio driver
4  *
5  * Copyright 2014 Analog Devices Inc.
6  */
7 
8 #include <linux/module.h>
9 #include <linux/i2c.h>
10 #include <linux/regmap.h>
11 
12 #include <sound/soc.h>
13 
14 #include "ssm2602.h"
15 
16 static const struct i2c_device_id ssm2602_i2c_id[];
17 
18 /*
19  * ssm2602 2 wire address is determined by GPIO5
20  * state during powerup.
21  *    low  = 0x1a
22  *    high = 0x1b
23  */
24 static int ssm2602_i2c_probe(struct i2c_client *client)
25 {
26 	const struct i2c_device_id *id = i2c_match_id(ssm2602_i2c_id, client);
27 	return ssm2602_probe(&client->dev, id->driver_data,
28 		devm_regmap_init_i2c(client, &ssm2602_regmap_config));
29 }
30 
31 static const struct i2c_device_id ssm2602_i2c_id[] = {
32 	{ "ssm2602", SSM2602 },
33 	{ "ssm2603", SSM2602 },
34 	{ "ssm2604", SSM2604 },
35 	{ }
36 };
37 MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
38 
39 static const struct of_device_id ssm2602_of_match[] = {
40 	{ .compatible = "adi,ssm2602", },
41 	{ .compatible = "adi,ssm2603", },
42 	{ .compatible = "adi,ssm2604", },
43 	{ }
44 };
45 MODULE_DEVICE_TABLE(of, ssm2602_of_match);
46 
47 static struct i2c_driver ssm2602_i2c_driver = {
48 	.driver = {
49 		.name = "ssm2602",
50 		.of_match_table = ssm2602_of_match,
51 	},
52 	.probe_new = ssm2602_i2c_probe,
53 	.id_table = ssm2602_i2c_id,
54 };
55 module_i2c_driver(ssm2602_i2c_driver);
56 
57 MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 I2C driver");
58 MODULE_AUTHOR("Cliff Cai");
59 MODULE_LICENSE("GPL");
60