xref: /openbmc/linux/sound/soc/codecs/wm8804-i2c.c (revision d2912cb1)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2bbed297dSCharles Keepax /*
3bbed297dSCharles Keepax  * wm8804-i2c.c  --  WM8804 S/PDIF transceiver driver - I2C
4bbed297dSCharles Keepax  *
5bbed297dSCharles Keepax  * Copyright 2015 Cirrus Logic Inc
6bbed297dSCharles Keepax  *
7bbed297dSCharles Keepax  * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
8bbed297dSCharles Keepax  */
9bbed297dSCharles Keepax 
10bbed297dSCharles Keepax #include <linux/init.h>
11bbed297dSCharles Keepax #include <linux/module.h>
12bbed297dSCharles Keepax #include <linux/i2c.h>
13960cdd50SPierre-Louis Bossart #include <linux/acpi.h>
14bbed297dSCharles Keepax 
15bbed297dSCharles Keepax #include "wm8804.h"
16bbed297dSCharles Keepax 
17bbed297dSCharles Keepax static int wm8804_i2c_probe(struct i2c_client *i2c,
18bbed297dSCharles Keepax 			    const struct i2c_device_id *id)
19bbed297dSCharles Keepax {
20bbed297dSCharles Keepax 	struct regmap *regmap;
21bbed297dSCharles Keepax 
22bbed297dSCharles Keepax 	regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config);
23bbed297dSCharles Keepax 	if (IS_ERR(regmap))
24bbed297dSCharles Keepax 		return PTR_ERR(regmap);
25bbed297dSCharles Keepax 
26bbed297dSCharles Keepax 	return wm8804_probe(&i2c->dev, regmap);
27bbed297dSCharles Keepax }
28bbed297dSCharles Keepax 
29bbed297dSCharles Keepax static int wm8804_i2c_remove(struct i2c_client *i2c)
30bbed297dSCharles Keepax {
31bbed297dSCharles Keepax 	wm8804_remove(&i2c->dev);
32bbed297dSCharles Keepax 	return 0;
33bbed297dSCharles Keepax }
34bbed297dSCharles Keepax 
35bbed297dSCharles Keepax static const struct i2c_device_id wm8804_i2c_id[] = {
36bbed297dSCharles Keepax 	{ "wm8804", 0 },
37bbed297dSCharles Keepax 	{ }
38bbed297dSCharles Keepax };
39bbed297dSCharles Keepax MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
40bbed297dSCharles Keepax 
41960cdd50SPierre-Louis Bossart #if defined(CONFIG_OF)
42bbed297dSCharles Keepax static const struct of_device_id wm8804_of_match[] = {
43bbed297dSCharles Keepax 	{ .compatible = "wlf,wm8804", },
44bbed297dSCharles Keepax 	{ }
45bbed297dSCharles Keepax };
46bbed297dSCharles Keepax MODULE_DEVICE_TABLE(of, wm8804_of_match);
47960cdd50SPierre-Louis Bossart #endif
48960cdd50SPierre-Louis Bossart 
49960cdd50SPierre-Louis Bossart #ifdef CONFIG_ACPI
50960cdd50SPierre-Louis Bossart static const struct acpi_device_id wm8804_acpi_match[] = {
51960cdd50SPierre-Louis Bossart 	{ "1AEC8804", 0 }, /* Wolfson PCI ID + part ID */
52960cdd50SPierre-Louis Bossart 	{ "10138804", 0 }, /* Cirrus Logic PCI ID + part ID */
53960cdd50SPierre-Louis Bossart 	{ },
54960cdd50SPierre-Louis Bossart };
55960cdd50SPierre-Louis Bossart MODULE_DEVICE_TABLE(acpi, wm8804_acpi_match);
56960cdd50SPierre-Louis Bossart #endif
57bbed297dSCharles Keepax 
58bbed297dSCharles Keepax static struct i2c_driver wm8804_i2c_driver = {
59bbed297dSCharles Keepax 	.driver = {
60bbed297dSCharles Keepax 		.name = "wm8804",
611a60667fSCharles Keepax 		.pm = &wm8804_pm,
62960cdd50SPierre-Louis Bossart 		.of_match_table = of_match_ptr(wm8804_of_match),
63960cdd50SPierre-Louis Bossart 		.acpi_match_table = ACPI_PTR(wm8804_acpi_match),
64bbed297dSCharles Keepax 	},
65bbed297dSCharles Keepax 	.probe = wm8804_i2c_probe,
66bbed297dSCharles Keepax 	.remove = wm8804_i2c_remove,
67bbed297dSCharles Keepax 	.id_table = wm8804_i2c_id
68bbed297dSCharles Keepax };
69bbed297dSCharles Keepax 
70bbed297dSCharles Keepax module_i2c_driver(wm8804_i2c_driver);
71bbed297dSCharles Keepax 
72bbed297dSCharles Keepax MODULE_DESCRIPTION("ASoC WM8804 driver - I2C");
73bbed297dSCharles Keepax MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
74bbed297dSCharles Keepax MODULE_LICENSE("GPL");
75