Skip to content

Commit 9ea280f

Browse files
Stefan Bindingbroonie
authored andcommitted
ASoC: cs35l56: Add Index based on ACPI HID or SDW ID to select regmap config
This is to prepare for further products using slightly different regmap configs. Signed-off-by: Stefan Binding <[email protected]> Reviewed-by: Richard Fitzgerald <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 02ca789 commit 9ea280f

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

sound/soc/codecs/cs35l56-i2c.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
static int cs35l56_i2c_probe(struct i2c_client *client)
1919
{
20+
unsigned int id = (u32)(uintptr_t)i2c_get_match_data(client);
2021
struct cs35l56_private *cs35l56;
2122
struct device *dev = &client->dev;
22-
const struct regmap_config *regmap_config = &cs35l56_regmap_i2c;
23+
const struct regmap_config *regmap_config;
2324
int ret;
2425

2526
cs35l56 = devm_kzalloc(dev, sizeof(struct cs35l56_private), GFP_KERNEL);
@@ -30,6 +31,15 @@ static int cs35l56_i2c_probe(struct i2c_client *client)
3031
cs35l56->base.can_hibernate = true;
3132

3233
i2c_set_clientdata(client, cs35l56);
34+
35+
switch (id) {
36+
case 0x3556:
37+
regmap_config = &cs35l56_regmap_i2c;
38+
break;
39+
default:
40+
return -ENODEV;
41+
}
42+
3343
cs35l56->base.regmap = devm_regmap_init_i2c(client, regmap_config);
3444
if (IS_ERR(cs35l56->base.regmap)) {
3545
ret = PTR_ERR(cs35l56->base.regmap);
@@ -57,14 +67,14 @@ static void cs35l56_i2c_remove(struct i2c_client *client)
5767
}
5868

5969
static const struct i2c_device_id cs35l56_id_i2c[] = {
60-
{ "cs35l56" },
70+
{ "cs35l56", 0x3556 },
6171
{}
6272
};
6373
MODULE_DEVICE_TABLE(i2c, cs35l56_id_i2c);
6474

6575
#ifdef CONFIG_ACPI
6676
static const struct acpi_device_id cs35l56_asoc_acpi_match[] = {
67-
{ "CSC355C", 0 },
77+
{ "CSC355C", 0x3556 },
6878
{},
6979
};
7080
MODULE_DEVICE_TABLE(acpi, cs35l56_asoc_acpi_match);

sound/soc/codecs/cs35l56-sdw.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ static int cs35l56_sdw_probe(struct sdw_slave *peripheral, const struct sdw_devi
509509
{
510510
struct device *dev = &peripheral->dev;
511511
struct cs35l56_private *cs35l56;
512+
const struct regmap_config *regmap_config;
512513
int ret;
513514

514515
cs35l56 = devm_kzalloc(dev, sizeof(*cs35l56), GFP_KERNEL);
@@ -521,8 +522,17 @@ static int cs35l56_sdw_probe(struct sdw_slave *peripheral, const struct sdw_devi
521522

522523
dev_set_drvdata(dev, cs35l56);
523524

525+
switch ((unsigned int)id->driver_data) {
526+
case 0x3556:
527+
case 0x3557:
528+
regmap_config = &cs35l56_regmap_sdw;
529+
break;
530+
default:
531+
return -ENODEV;
532+
}
533+
524534
cs35l56->base.regmap = devm_regmap_init(dev, &cs35l56_regmap_bus_sdw,
525-
peripheral, &cs35l56_regmap_sdw);
535+
peripheral, regmap_config);
526536
if (IS_ERR(cs35l56->base.regmap)) {
527537
ret = PTR_ERR(cs35l56->base.regmap);
528538
return dev_err_probe(dev, ret, "Failed to allocate register map\n");
@@ -562,8 +572,8 @@ static const struct dev_pm_ops cs35l56_sdw_pm = {
562572
};
563573

564574
static const struct sdw_device_id cs35l56_sdw_id[] = {
565-
SDW_SLAVE_ENTRY(0x01FA, 0x3556, 0),
566-
SDW_SLAVE_ENTRY(0x01FA, 0x3557, 0),
575+
SDW_SLAVE_ENTRY(0x01FA, 0x3556, 0x3556),
576+
SDW_SLAVE_ENTRY(0x01FA, 0x3557, 0x3557),
567577
{},
568578
};
569579
MODULE_DEVICE_TABLE(sdw, cs35l56_sdw_id);

0 commit comments

Comments
 (0)