122066226SMark Brown /* 222066226SMark Brown * Driver for the PCM512x CODECs 322066226SMark Brown * 422066226SMark Brown * Author: Mark Brown <broonie@linaro.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; 27*681a1956SPeter Rosin struct regmap_config config = pcm512x_regmap; 2822066226SMark Brown 29*681a1956SPeter Rosin /* msb needs to be set to enable auto-increment of addresses */ 30*681a1956SPeter Rosin config.read_flag_mask = 0x80; 31*681a1956SPeter Rosin config.write_flag_mask = 0x80; 32*681a1956SPeter Rosin 33*681a1956SPeter 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", }, 4922066226SMark Brown { } 5022066226SMark Brown }; 5122066226SMark Brown MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); 5222066226SMark Brown 5322066226SMark Brown static const struct of_device_id pcm512x_of_match[] = { 5422066226SMark Brown { .compatible = "ti,pcm5121", }, 5522066226SMark Brown { .compatible = "ti,pcm5122", }, 5622066226SMark Brown { } 5722066226SMark Brown }; 5822066226SMark Brown MODULE_DEVICE_TABLE(of, pcm512x_of_match); 5922066226SMark Brown 6022066226SMark Brown static struct i2c_driver pcm512x_i2c_driver = { 6122066226SMark Brown .probe = pcm512x_i2c_probe, 6222066226SMark Brown .remove = pcm512x_i2c_remove, 6322066226SMark Brown .id_table = pcm512x_i2c_id, 6422066226SMark Brown .driver = { 6522066226SMark Brown .name = "pcm512x", 6622066226SMark Brown .owner = THIS_MODULE, 6722066226SMark Brown .of_match_table = pcm512x_of_match, 6822066226SMark Brown .pm = &pcm512x_pm_ops, 6922066226SMark Brown }, 7022066226SMark Brown }; 7122066226SMark Brown 7222066226SMark Brown module_i2c_driver(pcm512x_i2c_driver); 7322066226SMark Brown 7422066226SMark Brown MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C"); 7522066226SMark Brown MODULE_AUTHOR("Mark Brown <broonie@linaro.org>"); 7622066226SMark Brown MODULE_LICENSE("GPL v2"); 77