Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Driver for the PCM512x CODECs
0004  *
0005  * Author:  Mark Brown <broonie@kernel.org>
0006  *      Copyright 2014 Linaro Ltd
0007  */
0008 
0009 #include <linux/init.h>
0010 #include <linux/module.h>
0011 #include <linux/i2c.h>
0012 #include <linux/acpi.h>
0013 
0014 #include "pcm512x.h"
0015 
0016 static int pcm512x_i2c_probe(struct i2c_client *i2c)
0017 {
0018     struct regmap *regmap;
0019     struct regmap_config config = pcm512x_regmap;
0020 
0021     /* msb needs to be set to enable auto-increment of addresses */
0022     config.read_flag_mask = 0x80;
0023     config.write_flag_mask = 0x80;
0024 
0025     regmap = devm_regmap_init_i2c(i2c, &config);
0026     if (IS_ERR(regmap))
0027         return PTR_ERR(regmap);
0028 
0029     return pcm512x_probe(&i2c->dev, regmap);
0030 }
0031 
0032 static int pcm512x_i2c_remove(struct i2c_client *i2c)
0033 {
0034     pcm512x_remove(&i2c->dev);
0035     return 0;
0036 }
0037 
0038 static const struct i2c_device_id pcm512x_i2c_id[] = {
0039     { "pcm5121", },
0040     { "pcm5122", },
0041     { "pcm5141", },
0042     { "pcm5142", },
0043     { }
0044 };
0045 MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
0046 
0047 #if defined(CONFIG_OF)
0048 static const struct of_device_id pcm512x_of_match[] = {
0049     { .compatible = "ti,pcm5121", },
0050     { .compatible = "ti,pcm5122", },
0051     { .compatible = "ti,pcm5141", },
0052     { .compatible = "ti,pcm5142", },
0053     { }
0054 };
0055 MODULE_DEVICE_TABLE(of, pcm512x_of_match);
0056 #endif
0057 
0058 #ifdef CONFIG_ACPI
0059 static const struct acpi_device_id pcm512x_acpi_match[] = {
0060     { "104C5121", 0 },
0061     { "104C5122", 0 },
0062     { "104C5141", 0 },
0063     { "104C5142", 0 },
0064     { },
0065 };
0066 MODULE_DEVICE_TABLE(acpi, pcm512x_acpi_match);
0067 #endif
0068 
0069 static struct i2c_driver pcm512x_i2c_driver = {
0070     .probe_new  = pcm512x_i2c_probe,
0071     .remove     = pcm512x_i2c_remove,
0072     .id_table   = pcm512x_i2c_id,
0073     .driver     = {
0074         .name   = "pcm512x",
0075         .of_match_table = of_match_ptr(pcm512x_of_match),
0076         .acpi_match_table = ACPI_PTR(pcm512x_acpi_match),
0077         .pm     = &pcm512x_pm_ops,
0078     },
0079 };
0080 
0081 module_i2c_driver(pcm512x_i2c_driver);
0082 
0083 MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
0084 MODULE_AUTHOR("Mark Brown <broonie@kernel.org>");
0085 MODULE_LICENSE("GPL v2");