122066226SMark Brown /* 222066226SMark Brown * Driver for the PCM512x CODECs 322066226SMark Brown * 4da924c3aSMark 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> 20b84f48d1SPierre-Louis Bossart #include <linux/acpi.h> 2122066226SMark Brown 2222066226SMark Brown #include "pcm512x.h" 2322066226SMark Brown 2422066226SMark Brown static int pcm512x_i2c_probe(struct i2c_client *i2c, 2522066226SMark Brown const struct i2c_device_id *id) 2622066226SMark Brown { 2722066226SMark Brown struct regmap *regmap; 28681a1956SPeter Rosin struct regmap_config config = pcm512x_regmap; 2922066226SMark Brown 30681a1956SPeter Rosin /* msb needs to be set to enable auto-increment of addresses */ 31681a1956SPeter Rosin config.read_flag_mask = 0x80; 32681a1956SPeter Rosin config.write_flag_mask = 0x80; 33681a1956SPeter Rosin 34681a1956SPeter Rosin regmap = devm_regmap_init_i2c(i2c, &config); 3522066226SMark Brown if (IS_ERR(regmap)) 3622066226SMark Brown return PTR_ERR(regmap); 3722066226SMark Brown 3822066226SMark Brown return pcm512x_probe(&i2c->dev, regmap); 3922066226SMark Brown } 4022066226SMark Brown 4122066226SMark Brown static int pcm512x_i2c_remove(struct i2c_client *i2c) 4222066226SMark Brown { 4322066226SMark Brown pcm512x_remove(&i2c->dev); 4422066226SMark Brown return 0; 4522066226SMark Brown } 4622066226SMark Brown 4722066226SMark Brown static const struct i2c_device_id pcm512x_i2c_id[] = { 4822066226SMark Brown { "pcm5121", }, 4922066226SMark Brown { "pcm5122", }, 50ba5295e5SPeter Rosin { "pcm5141", }, 51ba5295e5SPeter Rosin { "pcm5142", }, 5222066226SMark Brown { } 5322066226SMark Brown }; 5422066226SMark Brown MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); 5522066226SMark Brown 56b84f48d1SPierre-Louis Bossart #if defined(CONFIG_OF) 5722066226SMark Brown static const struct of_device_id pcm512x_of_match[] = { 5822066226SMark Brown { .compatible = "ti,pcm5121", }, 5922066226SMark Brown { .compatible = "ti,pcm5122", }, 60ba5295e5SPeter Rosin { .compatible = "ti,pcm5141", }, 61ba5295e5SPeter Rosin { .compatible = "ti,pcm5142", }, 6222066226SMark Brown { } 6322066226SMark Brown }; 6422066226SMark Brown MODULE_DEVICE_TABLE(of, pcm512x_of_match); 65b84f48d1SPierre-Louis Bossart #endif 66b84f48d1SPierre-Louis Bossart 67b84f48d1SPierre-Louis Bossart #ifdef CONFIG_ACPI 68b84f48d1SPierre-Louis Bossart static const struct acpi_device_id pcm512x_acpi_match[] = { 69b84f48d1SPierre-Louis Bossart { "104C5121", 0 }, 70b84f48d1SPierre-Louis Bossart { "104C5122", 0 }, 71b84f48d1SPierre-Louis Bossart { "104C5141", 0 }, 72b84f48d1SPierre-Louis Bossart { "104C5142", 0 }, 73b84f48d1SPierre-Louis Bossart { }, 74b84f48d1SPierre-Louis Bossart }; 75b84f48d1SPierre-Louis Bossart MODULE_DEVICE_TABLE(acpi, pcm512x_acpi_match); 76b84f48d1SPierre-Louis Bossart #endif 7722066226SMark Brown 7822066226SMark Brown static struct i2c_driver pcm512x_i2c_driver = { 7922066226SMark Brown .probe = pcm512x_i2c_probe, 8022066226SMark Brown .remove = pcm512x_i2c_remove, 8122066226SMark Brown .id_table = pcm512x_i2c_id, 8222066226SMark Brown .driver = { 8322066226SMark Brown .name = "pcm512x", 84b84f48d1SPierre-Louis Bossart .of_match_table = of_match_ptr(pcm512x_of_match), 85b84f48d1SPierre-Louis Bossart .acpi_match_table = ACPI_PTR(pcm512x_acpi_match), 8622066226SMark Brown .pm = &pcm512x_pm_ops, 8722066226SMark Brown }, 8822066226SMark Brown }; 8922066226SMark Brown 9022066226SMark Brown module_i2c_driver(pcm512x_i2c_driver); 9122066226SMark Brown 9222066226SMark Brown MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C"); 93da924c3aSMark Brown MODULE_AUTHOR("Mark Brown <broonie@kernel.org>"); 9422066226SMark Brown MODULE_LICENSE("GPL v2"); 95