Commit | Line | Data |
---|---|---|
22066226 MB |
1 | /* |
2 | * Driver for the PCM512x CODECs | |
3 | * | |
4 | * Author: Mark Brown <broonie@linaro.org> | |
5 | * Copyright 2014 Linaro Ltd | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License | |
9 | * version 2 as published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | */ | |
16 | ||
17 | #include <linux/init.h> | |
18 | #include <linux/module.h> | |
19 | #include <linux/i2c.h> | |
20 | ||
21 | #include "pcm512x.h" | |
22 | ||
23 | static int pcm512x_i2c_probe(struct i2c_client *i2c, | |
24 | const struct i2c_device_id *id) | |
25 | { | |
26 | struct regmap *regmap; | |
681a1956 | 27 | struct regmap_config config = pcm512x_regmap; |
22066226 | 28 | |
681a1956 PR |
29 | /* msb needs to be set to enable auto-increment of addresses */ |
30 | config.read_flag_mask = 0x80; | |
31 | config.write_flag_mask = 0x80; | |
32 | ||
33 | regmap = devm_regmap_init_i2c(i2c, &config); | |
22066226 MB |
34 | if (IS_ERR(regmap)) |
35 | return PTR_ERR(regmap); | |
36 | ||
37 | return pcm512x_probe(&i2c->dev, regmap); | |
38 | } | |
39 | ||
40 | static int pcm512x_i2c_remove(struct i2c_client *i2c) | |
41 | { | |
42 | pcm512x_remove(&i2c->dev); | |
43 | return 0; | |
44 | } | |
45 | ||
46 | static const struct i2c_device_id pcm512x_i2c_id[] = { | |
47 | { "pcm5121", }, | |
48 | { "pcm5122", }, | |
ba5295e5 PR |
49 | { "pcm5141", }, |
50 | { "pcm5142", }, | |
22066226 MB |
51 | { } |
52 | }; | |
53 | MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); | |
54 | ||
55 | static const struct of_device_id pcm512x_of_match[] = { | |
56 | { .compatible = "ti,pcm5121", }, | |
57 | { .compatible = "ti,pcm5122", }, | |
ba5295e5 PR |
58 | { .compatible = "ti,pcm5141", }, |
59 | { .compatible = "ti,pcm5142", }, | |
22066226 MB |
60 | { } |
61 | }; | |
62 | MODULE_DEVICE_TABLE(of, pcm512x_of_match); | |
63 | ||
64 | static struct i2c_driver pcm512x_i2c_driver = { | |
65 | .probe = pcm512x_i2c_probe, | |
66 | .remove = pcm512x_i2c_remove, | |
67 | .id_table = pcm512x_i2c_id, | |
68 | .driver = { | |
69 | .name = "pcm512x", | |
22066226 MB |
70 | .of_match_table = pcm512x_of_match, |
71 | .pm = &pcm512x_pm_ops, | |
72 | }, | |
73 | }; | |
74 | ||
75 | module_i2c_driver(pcm512x_i2c_driver); | |
76 | ||
77 | MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C"); | |
78 | MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); | |
79 | MODULE_LICENSE("GPL v2"); |