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