Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Texas Instruments PCM186x Universal Audio ADC - I2C
0004  *
0005  * Copyright (C) 2015-2017 Texas Instruments Incorporated - https://www.ti.com
0006  *  Andreas Dannenberg <dannenberg@ti.com>
0007  *  Andrew F. Davis <afd@ti.com>
0008  */
0009 
0010 #include <linux/init.h>
0011 #include <linux/module.h>
0012 #include <linux/i2c.h>
0013 
0014 #include "pcm186x.h"
0015 
0016 static const struct of_device_id pcm186x_of_match[] = {
0017     { .compatible = "ti,pcm1862", .data = (void *)PCM1862 },
0018     { .compatible = "ti,pcm1863", .data = (void *)PCM1863 },
0019     { .compatible = "ti,pcm1864", .data = (void *)PCM1864 },
0020     { .compatible = "ti,pcm1865", .data = (void *)PCM1865 },
0021     { }
0022 };
0023 MODULE_DEVICE_TABLE(of, pcm186x_of_match);
0024 
0025 static const struct i2c_device_id pcm186x_i2c_id[] = {
0026     { "pcm1862", PCM1862 },
0027     { "pcm1863", PCM1863 },
0028     { "pcm1864", PCM1864 },
0029     { "pcm1865", PCM1865 },
0030     { }
0031 };
0032 MODULE_DEVICE_TABLE(i2c, pcm186x_i2c_id);
0033 
0034 static int pcm186x_i2c_probe(struct i2c_client *i2c)
0035 {
0036     const struct i2c_device_id *id = i2c_match_id(pcm186x_i2c_id, i2c);
0037     const enum pcm186x_type type = (enum pcm186x_type)id->driver_data;
0038     int irq = i2c->irq;
0039     struct regmap *regmap;
0040 
0041     regmap = devm_regmap_init_i2c(i2c, &pcm186x_regmap);
0042     if (IS_ERR(regmap))
0043         return PTR_ERR(regmap);
0044 
0045     return pcm186x_probe(&i2c->dev, type, irq, regmap);
0046 }
0047 
0048 static struct i2c_driver pcm186x_i2c_driver = {
0049     .probe_new  = pcm186x_i2c_probe,
0050     .id_table   = pcm186x_i2c_id,
0051     .driver     = {
0052         .name   = "pcm186x",
0053         .of_match_table = pcm186x_of_match,
0054     },
0055 };
0056 module_i2c_driver(pcm186x_i2c_driver);
0057 
0058 MODULE_AUTHOR("Andreas Dannenberg <dannenberg@ti.com>");
0059 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
0060 MODULE_DESCRIPTION("PCM186x Universal Audio ADC I2C Interface Driver");
0061 MODULE_LICENSE("GPL v2");