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