1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // CS35L56 HDA audio driver I2C binding 4 // 5 // Copyright (C) 2023 Cirrus Logic, Inc. and 6 // Cirrus Logic International Semiconductor Ltd. 7 8 #include <linux/i2c.h> 9 #include <linux/module.h> 10 #include <linux/regmap.h> 11 12 #include "cs35l56_hda.h" 13 14 static int cs35l56_hda_i2c_probe(struct i2c_client *clt) 15 { 16 struct cs35l56_hda *cs35l56; 17 int ret; 18 19 cs35l56 = devm_kzalloc(&clt->dev, sizeof(*cs35l56), GFP_KERNEL); 20 if (!cs35l56) 21 return -ENOMEM; 22 23 cs35l56->base.dev = &clt->dev; 24 cs35l56->base.can_hibernate = true; 25 cs35l56->base.regmap = devm_regmap_init_i2c(clt, &cs35l56_regmap_i2c); 26 if (IS_ERR(cs35l56->base.regmap)) { 27 ret = PTR_ERR(cs35l56->base.regmap); 28 dev_err(cs35l56->base.dev, "Failed to allocate register map: %d\n", 29 ret); 30 return ret; 31 } 32 33 ret = cs35l56_hda_common_probe(cs35l56, clt->addr); 34 if (ret) 35 return ret; 36 ret = cs35l56_irq_request(&cs35l56->base, clt->irq); 37 if (ret < 0) 38 cs35l56_hda_remove(cs35l56->base.dev); 39 40 return ret; 41 } 42 43 static void cs35l56_hda_i2c_remove(struct i2c_client *clt) 44 { 45 cs35l56_hda_remove(&clt->dev); 46 } 47 48 static const struct i2c_device_id cs35l56_hda_i2c_id[] = { 49 { "cs35l56-hda", 0 }, 50 {} 51 }; 52 53 static struct i2c_driver cs35l56_hda_i2c_driver = { 54 .driver = { 55 .name = "cs35l56-hda", 56 .pm = &cs35l56_hda_pm_ops, 57 }, 58 .id_table = cs35l56_hda_i2c_id, 59 .probe = cs35l56_hda_i2c_probe, 60 .remove = cs35l56_hda_i2c_remove, 61 }; 62 module_i2c_driver(cs35l56_hda_i2c_driver); 63 64 MODULE_DESCRIPTION("HDA CS35L56 I2C driver"); 65 MODULE_IMPORT_NS(SND_HDA_SCODEC_CS35L56); 66 MODULE_IMPORT_NS(SND_SOC_CS35L56_SHARED); 67 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>"); 68 MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>"); 69 MODULE_LICENSE("GPL"); 70