xref: /linux/sound/soc/codecs/pcm512x-i2c.c (revision da924c3a0d3f45bf8c46e83a7aa1b75b86f1e7a0)
122066226SMark Brown /*
222066226SMark Brown  * Driver for the PCM512x CODECs
322066226SMark Brown  *
4*da924c3aSMark Brown  * Author:	Mark Brown <broonie@kernel.org>
522066226SMark Brown  *		Copyright 2014 Linaro Ltd
622066226SMark Brown  *
722066226SMark Brown  * This program is free software; you can redistribute it and/or
822066226SMark Brown  * modify it under the terms of the GNU General Public License
922066226SMark Brown  * version 2 as published by the Free Software Foundation.
1022066226SMark Brown  *
1122066226SMark Brown  * This program is distributed in the hope that it will be useful, but
1222066226SMark Brown  * WITHOUT ANY WARRANTY; without even the implied warranty of
1322066226SMark Brown  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1422066226SMark Brown  * General Public License for more details.
1522066226SMark Brown  */
1622066226SMark Brown 
1722066226SMark Brown #include <linux/init.h>
1822066226SMark Brown #include <linux/module.h>
1922066226SMark Brown #include <linux/i2c.h>
2022066226SMark Brown 
2122066226SMark Brown #include "pcm512x.h"
2222066226SMark Brown 
2322066226SMark Brown static int pcm512x_i2c_probe(struct i2c_client *i2c,
2422066226SMark Brown 			     const struct i2c_device_id *id)
2522066226SMark Brown {
2622066226SMark Brown 	struct regmap *regmap;
27681a1956SPeter Rosin 	struct regmap_config config = pcm512x_regmap;
2822066226SMark Brown 
29681a1956SPeter Rosin 	/* msb needs to be set to enable auto-increment of addresses */
30681a1956SPeter Rosin 	config.read_flag_mask = 0x80;
31681a1956SPeter Rosin 	config.write_flag_mask = 0x80;
32681a1956SPeter Rosin 
33681a1956SPeter Rosin 	regmap = devm_regmap_init_i2c(i2c, &config);
3422066226SMark Brown 	if (IS_ERR(regmap))
3522066226SMark Brown 		return PTR_ERR(regmap);
3622066226SMark Brown 
3722066226SMark Brown 	return pcm512x_probe(&i2c->dev, regmap);
3822066226SMark Brown }
3922066226SMark Brown 
4022066226SMark Brown static int pcm512x_i2c_remove(struct i2c_client *i2c)
4122066226SMark Brown {
4222066226SMark Brown 	pcm512x_remove(&i2c->dev);
4322066226SMark Brown 	return 0;
4422066226SMark Brown }
4522066226SMark Brown 
4622066226SMark Brown static const struct i2c_device_id pcm512x_i2c_id[] = {
4722066226SMark Brown 	{ "pcm5121", },
4822066226SMark Brown 	{ "pcm5122", },
49ba5295e5SPeter Rosin 	{ "pcm5141", },
50ba5295e5SPeter Rosin 	{ "pcm5142", },
5122066226SMark Brown 	{ }
5222066226SMark Brown };
5322066226SMark Brown MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
5422066226SMark Brown 
5522066226SMark Brown static const struct of_device_id pcm512x_of_match[] = {
5622066226SMark Brown 	{ .compatible = "ti,pcm5121", },
5722066226SMark Brown 	{ .compatible = "ti,pcm5122", },
58ba5295e5SPeter Rosin 	{ .compatible = "ti,pcm5141", },
59ba5295e5SPeter Rosin 	{ .compatible = "ti,pcm5142", },
6022066226SMark Brown 	{ }
6122066226SMark Brown };
6222066226SMark Brown MODULE_DEVICE_TABLE(of, pcm512x_of_match);
6322066226SMark Brown 
6422066226SMark Brown static struct i2c_driver pcm512x_i2c_driver = {
6522066226SMark Brown 	.probe 		= pcm512x_i2c_probe,
6622066226SMark Brown 	.remove 	= pcm512x_i2c_remove,
6722066226SMark Brown 	.id_table	= pcm512x_i2c_id,
6822066226SMark Brown 	.driver		= {
6922066226SMark Brown 		.name	= "pcm512x",
7022066226SMark Brown 		.of_match_table = pcm512x_of_match,
7122066226SMark Brown 		.pm     = &pcm512x_pm_ops,
7222066226SMark Brown 	},
7322066226SMark Brown };
7422066226SMark Brown 
7522066226SMark Brown module_i2c_driver(pcm512x_i2c_driver);
7622066226SMark Brown 
7722066226SMark Brown MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
78*da924c3aSMark Brown MODULE_AUTHOR("Mark Brown <broonie@kernel.org>");
7922066226SMark Brown MODULE_LICENSE("GPL v2");
80