xref: /openbmc/linux/sound/soc/codecs/pcm3168a-i2c.c (revision aaf9128a)
1 /*
2  * PCM3168A codec i2c driver
3  *
4  * Copyright (C) 2015 Imagination Technologies Ltd.
5  *
6  * Author: Damien Horsley <Damien.Horsley@imgtec.com>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms and conditions of the GNU General Public License,
10  * version 2, as published by the Free Software Foundation.
11  */
12 
13 #include <linux/i2c.h>
14 #include <linux/init.h>
15 #include <linux/module.h>
16 
17 #include <sound/soc.h>
18 
19 #include "pcm3168a.h"
20 
21 static int pcm3168a_i2c_probe(struct i2c_client *i2c,
22 			     const struct i2c_device_id *id)
23 {
24 	struct regmap *regmap;
25 
26 	regmap = devm_regmap_init_i2c(i2c, &pcm3168a_regmap);
27 	if (IS_ERR(regmap))
28 		return PTR_ERR(regmap);
29 
30 	return pcm3168a_probe(&i2c->dev, regmap);
31 }
32 
33 static int pcm3168a_i2c_remove(struct i2c_client *i2c)
34 {
35 	pcm3168a_remove(&i2c->dev);
36 
37 	return 0;
38 }
39 
40 static const struct i2c_device_id pcm3168a_i2c_id[] = {
41 	{ "pcm3168a", },
42 	{ }
43 };
44 MODULE_DEVICE_TABLE(i2c, pcm3168a_i2c_id);
45 
46 static const struct of_device_id pcm3168a_of_match[] = {
47 	{ .compatible = "ti,pcm3168a", },
48 	{ }
49 };
50 MODULE_DEVICE_TABLE(of, pcm3168a_of_match);
51 
52 static struct i2c_driver pcm3168a_i2c_driver = {
53 	.probe		= pcm3168a_i2c_probe,
54 	.remove		= pcm3168a_i2c_remove,
55 	.id_table	= pcm3168a_i2c_id,
56 	.driver		= {
57 		.name	= "pcm3168a",
58 		.of_match_table = pcm3168a_of_match,
59 		.pm		= &pcm3168a_pm_ops,
60 	},
61 };
62 module_i2c_driver(pcm3168a_i2c_driver);
63 
64 MODULE_DESCRIPTION("PCM3168A I2C codec driver");
65 MODULE_AUTHOR("Damien Horsley <Damien.Horsley@imgtec.com>");
66 MODULE_LICENSE("GPL v2");
67