1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // CS35l41 HDA I2C driver 4 // 5 // Copyright 2021 Cirrus Logic, Inc. 6 // 7 // Author: Lucas Tanure <tanureal@opensource.cirrus.com> 8 9 #include <linux/module.h> 10 #include <linux/i2c.h> 11 12 #include "cs35l41_hda.h" 13 14 static int cs35l41_hda_i2c_probe(struct i2c_client *clt) 15 { 16 const char *device_name; 17 18 /* 19 * Compare against the device name so it works for SPI, normal ACPI 20 * and for ACPI by serial-multi-instantiate matching cases. 21 */ 22 if (strstr(dev_name(&clt->dev), "CLSA0100")) 23 device_name = "CLSA0100"; 24 else if (strstr(dev_name(&clt->dev), "CLSA0101")) 25 device_name = "CLSA0101"; 26 else if (strstr(dev_name(&clt->dev), "CSC3551")) 27 device_name = "CSC3551"; 28 else 29 return -ENODEV; 30 31 return cs35l41_hda_probe(&clt->dev, device_name, clt->addr, clt->irq, 32 devm_regmap_init_i2c(clt, &cs35l41_regmap_i2c), I2C); 33 } 34 35 static void cs35l41_hda_i2c_remove(struct i2c_client *clt) 36 { 37 cs35l41_hda_remove(&clt->dev); 38 } 39 40 static const struct i2c_device_id cs35l41_hda_i2c_id[] = { 41 { .name = "cs35l41-hda" }, 42 { } 43 }; 44 45 static const struct acpi_device_id cs35l41_acpi_hda_match[] = { 46 {"CLSA0100", 0 }, 47 {"CLSA0101", 0 }, 48 {"CSC3551", 0 }, 49 {} 50 }; 51 MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match); 52 53 static struct i2c_driver cs35l41_i2c_driver = { 54 .driver = { 55 .name = "cs35l41-hda", 56 .acpi_match_table = cs35l41_acpi_hda_match, 57 .pm = &cs35l41_hda_pm_ops, 58 }, 59 .id_table = cs35l41_hda_i2c_id, 60 .probe = cs35l41_hda_i2c_probe, 61 .remove = cs35l41_hda_i2c_remove, 62 }; 63 module_i2c_driver(cs35l41_i2c_driver); 64 65 MODULE_DESCRIPTION("HDA CS35L41 driver"); 66 MODULE_IMPORT_NS("SND_HDA_SCODEC_CS35L41"); 67 MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>"); 68 MODULE_LICENSE("GPL"); 69