| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
// |
| 3 |
// CS530x CODEC driver |
| 4 |
// |
| 5 |
// Copyright (C) 2025 Cirrus Logic, Inc. and |
| 6 |
// Cirrus Logic International Semiconductor Ltd. |
| 7 |
|
| 8 |
#include <linux/module.h> |
| 9 |
#include <linux/platform_device.h> |
| 10 |
#include <linux/spi/spi.h> |
| 11 |
|
| 12 |
#include "cs530x.h" |
| 13 |
|
| 14 |
static const struct of_device_id cs530x_of_match[] = { |
| 15 |
{ |
| 16 |
.compatible = "cirrus,cs4282", |
| 17 |
.data = (void *)CS4282, |
| 18 |
}, { |
| 19 |
.compatible = "cirrus,cs4302", |
| 20 |
.data = (void *)CS4302, |
| 21 |
}, { |
| 22 |
.compatible = "cirrus,cs4304", |
| 23 |
.data = (void *)CS4304, |
| 24 |
}, { |
| 25 |
.compatible = "cirrus,cs4308", |
| 26 |
.data = (void *)CS4308, |
| 27 |
}, { |
| 28 |
.compatible = "cirrus,cs5302", |
| 29 |
.data = (void *)CS5302, |
| 30 |
}, { |
| 31 |
.compatible = "cirrus,cs5304", |
| 32 |
.data = (void *)CS5304, |
| 33 |
}, { |
| 34 |
.compatible = "cirrus,cs5304", |
| 35 |
.data = (void *)CS5308, |
| 36 |
}, |
| 37 |
{} |
| 38 |
}; |
| 39 |
MODULE_DEVICE_TABLE(of, cs530x_of_match); |
| 40 |
|
| 41 |
static const struct spi_device_id cs530x_spi_id[] = { |
| 42 |
{ "cs4282", CS4282 }, |
| 43 |
{ "cs4302", CS4302 }, |
| 44 |
{ "cs4304", CS4304 }, |
| 45 |
{ "cs4308", CS4308 }, |
| 46 |
{ "cs5302", CS5302 }, |
| 47 |
{ "cs5304", CS5304 }, |
| 48 |
{ "cs5308", CS5308 }, |
| 49 |
{ } |
| 50 |
}; |
| 51 |
MODULE_DEVICE_TABLE(spi, cs530x_spi_id); |
| 52 |
|
| 53 |
static int cs530x_spi_probe(struct spi_device *spi) |
| 54 |
{ |
| 55 |
struct cs530x_priv *cs530x; |
| 56 |
struct device *dev = &spi->dev; |
| 57 |
int ret; |
| 58 |
|
| 59 |
cs530x = devm_kzalloc(dev, sizeof(struct cs530x_priv), GFP_KERNEL); |
| 60 |
if (cs530x == NULL) |
| 61 |
return -ENOMEM; |
| 62 |
|
| 63 |
spi_set_drvdata(spi, cs530x); |
| 64 |
|
| 65 |
cs530x->regmap = devm_regmap_init_spi(spi, &cs530x_regmap_spi); |
| 66 |
if (IS_ERR(cs530x->regmap)) { |
| 67 |
ret = PTR_ERR(cs530x->regmap); |
| 68 |
dev_err(dev, "Failed to allocate register map: %d\n", ret); |
| 69 |
return ret; |
| 70 |
} |
| 71 |
|
| 72 |
cs530x->devtype = (unsigned long)spi_get_device_match_data(spi); |
| 73 |
cs530x->dev = &spi->dev; |
| 74 |
|
| 75 |
return cs530x_probe(cs530x); |
| 76 |
} |
| 77 |
|
| 78 |
static struct spi_driver cs530x_spi_driver = { |
| 79 |
.driver = { |
| 80 |
.name = "cs530x", |
| 81 |
.of_match_table = cs530x_of_match, |
| 82 |
}, |
| 83 |
.id_table = cs530x_spi_id, |
| 84 |
.probe = cs530x_spi_probe, |
| 85 |
}; |
| 86 |
|
| 87 |
module_spi_driver(cs530x_spi_driver); |
| 88 |
|
| 89 |
MODULE_DESCRIPTION("SPI CS530X driver"); |
| 90 |
MODULE_IMPORT_NS("SND_SOC_CS530X"); |
| 91 |
MODULE_AUTHOR("Vitaly Rodionov <[email protected]>"); |
| 92 |
MODULE_LICENSE("GPL"); |