1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Driver for ADAU1361/ADAU1461/ADAU1761/ADAU1961 codec
4  *
5  * Copyright 2014 Analog Devices Inc.
6  *  Author: Lars-Peter Clausen <lars@metafoo.de>
7  */
8 
9 #include <linux/i2c.h>
10 #include <linux/mod_devicetable.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
13 #include <sound/soc.h>
14 
15 #include "adau1761.h"
16 
adau1761_i2c_probe(struct i2c_client * client,const struct i2c_device_id * id)17 static int adau1761_i2c_probe(struct i2c_client *client,
18 	const struct i2c_device_id *id)
19 {
20 	struct regmap_config config;
21 
22 	config = adau1761_regmap_config;
23 	config.val_bits = 8;
24 	config.reg_bits = 16;
25 
26 	return adau1761_probe(&client->dev,
27 		devm_regmap_init_i2c(client, &config),
28 		id->driver_data, NULL);
29 }
30 
adau1761_i2c_remove(struct i2c_client * client)31 static int adau1761_i2c_remove(struct i2c_client *client)
32 {
33 	adau17x1_remove(&client->dev);
34 	return 0;
35 }
36 
37 static const struct i2c_device_id adau1761_i2c_ids[] = {
38 	{ "adau1361", ADAU1361 },
39 	{ "adau1461", ADAU1761 },
40 	{ "adau1761", ADAU1761 },
41 	{ "adau1961", ADAU1361 },
42 	{ }
43 };
44 MODULE_DEVICE_TABLE(i2c, adau1761_i2c_ids);
45 
46 #if defined(CONFIG_OF)
47 static const struct of_device_id adau1761_i2c_dt_ids[] = {
48 	{ .compatible = "adi,adau1361", },
49 	{ .compatible = "adi,adau1461", },
50 	{ .compatible = "adi,adau1761", },
51 	{ .compatible = "adi,adau1961", },
52 	{ },
53 };
54 MODULE_DEVICE_TABLE(of, adau1761_i2c_dt_ids);
55 #endif
56 
57 static struct i2c_driver adau1761_i2c_driver = {
58 	.driver = {
59 		.name = "adau1761",
60 		.of_match_table = of_match_ptr(adau1761_i2c_dt_ids),
61 	},
62 	.probe = adau1761_i2c_probe,
63 	.remove = adau1761_i2c_remove,
64 	.id_table = adau1761_i2c_ids,
65 };
66 module_i2c_driver(adau1761_i2c_driver);
67 
68 MODULE_DESCRIPTION("ASoC ADAU1361/ADAU1461/ADAU1761/ADAU1961 CODEC I2C driver");
69 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
70 MODULE_LICENSE("GPL");
71