11802d0beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
222066226SMark Brown /*
322066226SMark Brown * Driver for the PCM512x CODECs
422066226SMark Brown *
5da924c3aSMark Brown * Author: Mark Brown <broonie@kernel.org>
622066226SMark Brown * Copyright 2014 Linaro Ltd
722066226SMark Brown */
822066226SMark Brown
922066226SMark Brown #include <linux/init.h>
1022066226SMark Brown #include <linux/module.h>
1122066226SMark Brown #include <linux/i2c.h>
12b84f48d1SPierre-Louis Bossart #include <linux/acpi.h>
1322066226SMark Brown
1422066226SMark Brown #include "pcm512x.h"
1522066226SMark Brown
pcm512x_i2c_probe(struct i2c_client * i2c)167f7d7214SStephen Kitt static int pcm512x_i2c_probe(struct i2c_client *i2c)
1722066226SMark Brown {
1822066226SMark Brown struct regmap *regmap;
19681a1956SPeter Rosin struct regmap_config config = pcm512x_regmap;
2022066226SMark Brown
21681a1956SPeter Rosin /* msb needs to be set to enable auto-increment of addresses */
22681a1956SPeter Rosin config.read_flag_mask = 0x80;
23681a1956SPeter Rosin config.write_flag_mask = 0x80;
24681a1956SPeter Rosin
25681a1956SPeter Rosin regmap = devm_regmap_init_i2c(i2c, &config);
2622066226SMark Brown if (IS_ERR(regmap))
2722066226SMark Brown return PTR_ERR(regmap);
2822066226SMark Brown
2922066226SMark Brown return pcm512x_probe(&i2c->dev, regmap);
3022066226SMark Brown }
3122066226SMark Brown
pcm512x_i2c_remove(struct i2c_client * i2c)32ed5c2f5fSUwe Kleine-König static void pcm512x_i2c_remove(struct i2c_client *i2c)
3322066226SMark Brown {
3422066226SMark Brown pcm512x_remove(&i2c->dev);
3522066226SMark Brown }
3622066226SMark Brown
3722066226SMark Brown static const struct i2c_device_id pcm512x_i2c_id[] = {
3822066226SMark Brown { "pcm5121", },
3922066226SMark Brown { "pcm5122", },
40ba5295e5SPeter Rosin { "pcm5141", },
41ba5295e5SPeter Rosin { "pcm5142", },
42*9c9b172fSChristian Hewitt { "pcm5242", },
431f817805SJoerg Schambacher { "tas5754", },
441f817805SJoerg Schambacher { "tas5756", },
4522066226SMark Brown { }
4622066226SMark Brown };
4722066226SMark Brown MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
4822066226SMark Brown
49b84f48d1SPierre-Louis Bossart #if defined(CONFIG_OF)
5022066226SMark Brown static const struct of_device_id pcm512x_of_match[] = {
5122066226SMark Brown { .compatible = "ti,pcm5121", },
5222066226SMark Brown { .compatible = "ti,pcm5122", },
53ba5295e5SPeter Rosin { .compatible = "ti,pcm5141", },
54ba5295e5SPeter Rosin { .compatible = "ti,pcm5142", },
55*9c9b172fSChristian Hewitt { .compatible = "ti,pcm5242", },
561f817805SJoerg Schambacher { .compatible = "ti,tas5754", },
571f817805SJoerg Schambacher { .compatible = "ti,tas5756", },
5822066226SMark Brown { }
5922066226SMark Brown };
6022066226SMark Brown MODULE_DEVICE_TABLE(of, pcm512x_of_match);
61b84f48d1SPierre-Louis Bossart #endif
62b84f48d1SPierre-Louis Bossart
63b84f48d1SPierre-Louis Bossart #ifdef CONFIG_ACPI
64b84f48d1SPierre-Louis Bossart static const struct acpi_device_id pcm512x_acpi_match[] = {
65b84f48d1SPierre-Louis Bossart { "104C5121", 0 },
66b84f48d1SPierre-Louis Bossart { "104C5122", 0 },
67b84f48d1SPierre-Louis Bossart { "104C5141", 0 },
68b84f48d1SPierre-Louis Bossart { "104C5142", 0 },
69b84f48d1SPierre-Louis Bossart { },
70b84f48d1SPierre-Louis Bossart };
71b84f48d1SPierre-Louis Bossart MODULE_DEVICE_TABLE(acpi, pcm512x_acpi_match);
72b84f48d1SPierre-Louis Bossart #endif
7322066226SMark Brown
7422066226SMark Brown static struct i2c_driver pcm512x_i2c_driver = {
759abcd240SUwe Kleine-König .probe = pcm512x_i2c_probe,
7622066226SMark Brown .remove = pcm512x_i2c_remove,
7722066226SMark Brown .id_table = pcm512x_i2c_id,
7822066226SMark Brown .driver = {
7922066226SMark Brown .name = "pcm512x",
80b84f48d1SPierre-Louis Bossart .of_match_table = of_match_ptr(pcm512x_of_match),
81b84f48d1SPierre-Louis Bossart .acpi_match_table = ACPI_PTR(pcm512x_acpi_match),
8222066226SMark Brown .pm = &pcm512x_pm_ops,
8322066226SMark Brown },
8422066226SMark Brown };
8522066226SMark Brown
8622066226SMark Brown module_i2c_driver(pcm512x_i2c_driver);
8722066226SMark Brown
8822066226SMark Brown MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
89da924c3aSMark Brown MODULE_AUTHOR("Mark Brown <broonie@kernel.org>");
9022066226SMark Brown MODULE_LICENSE("GPL v2");
91