| 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 |
const struct i2c_device_id *id = i2c_client_get_device_id(clt); |
| 17 |
struct cs35l56_hda *cs35l56; |
| 18 |
int ret; |
| 19 |
|
| 20 |
cs35l56 = devm_kzalloc(&clt->dev, sizeof(*cs35l56), GFP_KERNEL); |
| 21 |
if (!cs35l56) |
| 22 |
return -ENOMEM; |
| 23 |
|
| 24 |
cs35l56->base.dev = &clt->dev; |
| 25 |
|
| 26 |
#ifdef CS35L56_WAKE_HOLD_TIME_US |
| 27 |
cs35l56->base.can_hibernate = true; |
| 28 |
#endif |
| 29 |
|
| 30 |
cs35l56->base.regmap = devm_regmap_init_i2c(clt, &cs35l56_regmap_i2c); |
| 31 |
if (IS_ERR(cs35l56->base.regmap)) { |
| 32 |
ret = PTR_ERR(cs35l56->base.regmap); |
| 33 |
dev_err(cs35l56->base.dev, "Failed to allocate register map: %d\n", |
| 34 |
ret); |
| 35 |
return ret; |
| 36 |
} |
| 37 |
|
| 38 |
ret = cs35l56_hda_common_probe(cs35l56, id->driver_data, clt->addr); |
| 39 |
if (ret) |
| 40 |
return ret; |
| 41 |
ret = cs35l56_irq_request(&cs35l56->base, clt->irq); |
| 42 |
if (ret < 0) |
| 43 |
cs35l56_hda_remove(cs35l56->base.dev); |
| 44 |
|
| 45 |
return ret; |
| 46 |
} |
| 47 |
|
| 48 |
static void cs35l56_hda_i2c_remove(struct i2c_client *clt) |
| 49 |
{ |
| 50 |
cs35l56_hda_remove(&clt->dev); |
| 51 |
} |
| 52 |
|
| 53 |
static const struct i2c_device_id cs35l56_hda_i2c_id[] = { |
| 54 |
{ "cs35l54-hda", 0x3554 }, |
| 55 |
{ "cs35l56-hda", 0x3556 }, |
| 56 |
{ "cs35l57-hda", 0x3557 }, |
| 57 |
{} |
| 58 |
}; |
| 59 |
|
| 60 |
static const struct acpi_device_id cs35l56_acpi_hda_match[] = { |
| 61 |
{ "CSC3554", 0 }, |
| 62 |
{ "CSC3556", 0 }, |
| 63 |
{ "CSC3557", 0 }, |
| 64 |
{} |
| 65 |
}; |
| 66 |
MODULE_DEVICE_TABLE(acpi, cs35l56_acpi_hda_match); |
| 67 |
|
| 68 |
static struct i2c_driver cs35l56_hda_i2c_driver = { |
| 69 |
.driver = { |
| 70 |
.name = "cs35l56-hda", |
| 71 |
.acpi_match_table = cs35l56_acpi_hda_match, |
| 72 |
.pm = &cs35l56_hda_pm_ops, |
| 73 |
}, |
| 74 |
.id_table = cs35l56_hda_i2c_id, |
| 75 |
.probe = cs35l56_hda_i2c_probe, |
| 76 |
.remove = cs35l56_hda_i2c_remove, |
| 77 |
}; |
| 78 |
module_i2c_driver(cs35l56_hda_i2c_driver); |
| 79 |
|
| 80 |
MODULE_DESCRIPTION("HDA CS35L56 I2C driver"); |
| 81 |
MODULE_IMPORT_NS("SND_HDA_SCODEC_CS35L56"); |
| 82 |
MODULE_IMPORT_NS("SND_SOC_CS35L56_SHARED"); |
| 83 |
MODULE_AUTHOR("Richard Fitzgerald <[email protected]>"); |
| 84 |
MODULE_AUTHOR("Simon Trimmer <[email protected]>"); |
| 85 |
MODULE_LICENSE("GPL"); |