xref: /openbmc/linux/sound/soc/codecs/pcm3060-i2c.c (revision 6ee47d4a)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * PCM3060 I2C driver
4  *
5  * Copyright (C) 2018 Kirill Marinushkin <kmarinushkin@birdec.tech>
6  */
7 
8 #include <linux/i2c.h>
9 #include <linux/module.h>
10 #include <sound/soc.h>
11 
12 #include "pcm3060.h"
13 
14 static int pcm3060_i2c_probe(struct i2c_client *i2c,
15 			     const struct i2c_device_id *id)
16 {
17 	struct pcm3060_priv *priv;
18 
19 	priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
20 	if (!priv)
21 		return -ENOMEM;
22 
23 	i2c_set_clientdata(i2c, priv);
24 
25 	priv->regmap = devm_regmap_init_i2c(i2c, &pcm3060_regmap);
26 	if (IS_ERR(priv->regmap))
27 		return PTR_ERR(priv->regmap);
28 
29 	return pcm3060_probe(&i2c->dev);
30 }
31 
32 static const struct i2c_device_id pcm3060_i2c_id[] = {
33 	{ .name = "pcm3060" },
34 	{ },
35 };
36 MODULE_DEVICE_TABLE(i2c, pcm3060_i2c_id);
37 
38 #ifdef CONFIG_OF
39 static const struct of_device_id pcm3060_of_match[] = {
40 	{ .compatible = "ti,pcm3060" },
41 	{ },
42 };
43 MODULE_DEVICE_TABLE(of, pcm3060_of_match);
44 #endif /* CONFIG_OF */
45 
46 static struct i2c_driver pcm3060_i2c_driver = {
47 	.driver = {
48 		.name = "pcm3060",
49 #ifdef CONFIG_OF
50 		.of_match_table = pcm3060_of_match,
51 #endif /* CONFIG_OF */
52 	},
53 	.id_table = pcm3060_i2c_id,
54 	.probe = pcm3060_i2c_probe,
55 };
56 
57 module_i2c_driver(pcm3060_i2c_driver);
58 
59 MODULE_DESCRIPTION("PCM3060 I2C driver");
60 MODULE_AUTHOR("Kirill Marinushkin <kmarinushkin@birdec.tech>");
61 MODULE_LICENSE("GPL v2");
62