| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
// |
| 3 |
// CS35L56 HDA audio driver SPI binding |
| 4 |
// |
| 5 |
// Copyright (C) 2023 Cirrus Logic, Inc. and |
| 6 |
// Cirrus Logic International Semiconductor Ltd. |
| 7 |
|
| 8 |
#include <linux/module.h> |
| 9 |
#include <linux/regmap.h> |
| 10 |
#include <linux/spi/spi.h> |
| 11 |
|
| 12 |
#include "cs35l56_hda.h" |
| 13 |
|
| 14 |
static int cs35l56_hda_spi_probe(struct spi_device *spi) |
| 15 |
{ |
| 16 |
const struct spi_device_id *id = spi_get_device_id(spi); |
| 17 |
struct cs35l56_hda *cs35l56; |
| 18 |
int ret; |
| 19 |
|
| 20 |
cs35l56 = devm_kzalloc(&spi->dev, sizeof(*cs35l56), GFP_KERNEL); |
| 21 |
if (!cs35l56) |
| 22 |
return -ENOMEM; |
| 23 |
|
| 24 |
cs35l56->base.dev = &spi->dev; |
| 25 |
ret = cs35l56_init_config_for_spi(&cs35l56->base, spi); |
| 26 |
if (ret) |
| 27 |
return ret; |
| 28 |
|
| 29 |
#ifdef CS35L56_WAKE_HOLD_TIME_US |
| 30 |
cs35l56->base.can_hibernate = true; |
| 31 |
#endif |
| 32 |
|
| 33 |
cs35l56->base.regmap = devm_regmap_init_spi(spi, &cs35l56_regmap_spi); |
| 34 |
if (IS_ERR(cs35l56->base.regmap)) { |
| 35 |
ret = PTR_ERR(cs35l56->base.regmap); |
| 36 |
dev_err(cs35l56->base.dev, "Failed to allocate register map: %d\n", |
| 37 |
ret); |
| 38 |
return ret; |
| 39 |
} |
| 40 |
|
| 41 |
ret = cs35l56_hda_common_probe(cs35l56, id->driver_data, spi_get_chipselect(spi, 0)); |
| 42 |
if (ret) |
| 43 |
return ret; |
| 44 |
ret = cs35l56_irq_request(&cs35l56->base, spi->irq); |
| 45 |
if (ret < 0) |
| 46 |
cs35l56_hda_remove(cs35l56->base.dev); |
| 47 |
|
| 48 |
return ret; |
| 49 |
} |
| 50 |
|
| 51 |
static void cs35l56_hda_spi_remove(struct spi_device *spi) |
| 52 |
{ |
| 53 |
cs35l56_hda_remove(&spi->dev); |
| 54 |
} |
| 55 |
|
| 56 |
static const struct spi_device_id cs35l56_hda_spi_id[] = { |
| 57 |
{ "cs35l54-hda", 0x3554 }, |
| 58 |
{ "cs35l56-hda", 0x3556 }, |
| 59 |
{ "cs35l57-hda", 0x3557 }, |
| 60 |
{} |
| 61 |
}; |
| 62 |
|
| 63 |
static const struct acpi_device_id cs35l56_acpi_hda_match[] = { |
| 64 |
{ "CSC3554", 0 }, |
| 65 |
{ "CSC3556", 0 }, |
| 66 |
{ "CSC3557", 0 }, |
| 67 |
{} |
| 68 |
}; |
| 69 |
MODULE_DEVICE_TABLE(acpi, cs35l56_acpi_hda_match); |
| 70 |
|
| 71 |
static struct spi_driver cs35l56_hda_spi_driver = { |
| 72 |
.driver = { |
| 73 |
.name = "cs35l56-hda", |
| 74 |
.acpi_match_table = cs35l56_acpi_hda_match, |
| 75 |
.pm = &cs35l56_hda_pm_ops, |
| 76 |
}, |
| 77 |
.id_table = cs35l56_hda_spi_id, |
| 78 |
.probe = cs35l56_hda_spi_probe, |
| 79 |
.remove = cs35l56_hda_spi_remove, |
| 80 |
}; |
| 81 |
module_spi_driver(cs35l56_hda_spi_driver); |
| 82 |
|
| 83 |
MODULE_DESCRIPTION("HDA CS35L56 SPI driver"); |
| 84 |
MODULE_IMPORT_NS("SND_HDA_SCODEC_CS35L56"); |
| 85 |
MODULE_IMPORT_NS("SND_SOC_CS35L56_SHARED"); |
| 86 |
MODULE_AUTHOR("Richard Fitzgerald <[email protected]>"); |
| 87 |
MODULE_AUTHOR("Simon Trimmer <[email protected]>"); |
| 88 |
MODULE_LICENSE("GPL"); |