Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // CS35l41 HDA I2C driver
0004 //
0005 // Copyright 2021 Cirrus Logic, Inc.
0006 //
0007 // Author: Lucas Tanure <tanureal@opensource.cirrus.com>
0008 
0009 #include <linux/mod_devicetable.h>
0010 #include <linux/module.h>
0011 #include <linux/i2c.h>
0012 
0013 #include "cs35l41_hda.h"
0014 
0015 static int cs35l41_hda_i2c_probe(struct i2c_client *clt, const struct i2c_device_id *id)
0016 {
0017     const char *device_name;
0018 
0019     /*
0020      * Compare against the device name so it works for SPI, normal ACPI
0021      * and for ACPI by serial-multi-instantiate matching cases.
0022      */
0023     if (strstr(dev_name(&clt->dev), "CLSA0100"))
0024         device_name = "CLSA0100";
0025     else if (strstr(dev_name(&clt->dev), "CLSA0101"))
0026         device_name = "CLSA0101";
0027     else if (strstr(dev_name(&clt->dev), "CSC3551"))
0028         device_name = "CSC3551";
0029     else
0030         return -ENODEV;
0031 
0032     return cs35l41_hda_probe(&clt->dev, device_name, clt->addr, clt->irq,
0033                  devm_regmap_init_i2c(clt, &cs35l41_regmap_i2c));
0034 }
0035 
0036 static int cs35l41_hda_i2c_remove(struct i2c_client *clt)
0037 {
0038     cs35l41_hda_remove(&clt->dev);
0039 
0040     return 0;
0041 }
0042 
0043 static const struct i2c_device_id cs35l41_hda_i2c_id[] = {
0044     { "cs35l41-hda", 0 },
0045     {}
0046 };
0047 
0048 static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
0049     {"CLSA0100", 0 },
0050     {"CLSA0101", 0 },
0051     {"CSC3551", 0 },
0052     {}
0053 };
0054 MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
0055 
0056 static struct i2c_driver cs35l41_i2c_driver = {
0057     .driver = {
0058         .name       = "cs35l41-hda",
0059         .acpi_match_table = cs35l41_acpi_hda_match,
0060         .pm     = &cs35l41_hda_pm_ops,
0061     },
0062     .id_table   = cs35l41_hda_i2c_id,
0063     .probe      = cs35l41_hda_i2c_probe,
0064     .remove     = cs35l41_hda_i2c_remove,
0065 };
0066 module_i2c_driver(cs35l41_i2c_driver);
0067 
0068 MODULE_DESCRIPTION("HDA CS35L41 driver");
0069 MODULE_IMPORT_NS(SND_HDA_SCODEC_CS35L41);
0070 MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>");
0071 MODULE_LICENSE("GPL");