Skip to content

Commit ad18392

Browse files
povikbroonie
authored andcommitted
ASoC: tas2764: Extend driver to SN012776
SN012776 is a speaker amp chip found in Apple's 2021 laptops. It appears similar and more-or-less compatible to TAS2764. Extend the TAS2764 driver with some SN012776 specifics and configure the chip assuming it's in one of the Apple machines. Reviewed-by: Neal Gompa <[email protected]> Signed-off-by: Martin Povišer <[email protected]> Signed-off-by: James Calligeros <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ce92339 commit ad18392

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

sound/soc/codecs/tas2764.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/regulator/consumer.h>
1515
#include <linux/regmap.h>
1616
#include <linux/of.h>
17+
#include <linux/of_device.h>
1718
#include <linux/slab.h>
1819
#include <sound/soc.h>
1920
#include <sound/pcm.h>
@@ -23,14 +24,20 @@
2324

2425
#include "tas2764.h"
2526

27+
enum tas2764_devid {
28+
DEVID_TAS2764 = 0,
29+
DEVID_SN012776 = 1
30+
};
31+
2632
struct tas2764_priv {
2733
struct snd_soc_component *component;
2834
struct gpio_desc *reset_gpio;
2935
struct gpio_desc *sdz_gpio;
3036
struct regmap *regmap;
3137
struct device *dev;
3238
int irq;
33-
39+
enum tas2764_devid devid;
40+
3441
int v_sense_slot;
3542
int i_sense_slot;
3643

@@ -533,10 +540,16 @@ static struct snd_soc_dai_driver tas2764_dai_driver[] = {
533540
},
534541
};
535542

543+
static uint8_t sn012776_bop_presets[] = {
544+
0x01, 0x32, 0x02, 0x22, 0x83, 0x2d, 0x80, 0x02, 0x06,
545+
0x32, 0x46, 0x30, 0x02, 0x06, 0x38, 0x40, 0x30, 0x02,
546+
0x06, 0x3e, 0x37, 0x30, 0xff, 0xe6
547+
};
548+
536549
static int tas2764_codec_probe(struct snd_soc_component *component)
537550
{
538551
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
539-
int ret;
552+
int ret, i;
540553

541554
tas2764->component = component;
542555

@@ -585,6 +598,27 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
585598
if (ret < 0)
586599
return ret;
587600

601+
switch (tas2764->devid) {
602+
case DEVID_SN012776:
603+
ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
604+
TAS2764_PWR_CTRL_BOP_SRC,
605+
TAS2764_PWR_CTRL_BOP_SRC);
606+
if (ret < 0)
607+
return ret;
608+
609+
for (i = 0; i < ARRAY_SIZE(sn012776_bop_presets); i++) {
610+
ret = snd_soc_component_write(component,
611+
TAS2764_BOP_CFG0 + i,
612+
sn012776_bop_presets[i]);
613+
614+
if (ret < 0)
615+
return ret;
616+
}
617+
break;
618+
default:
619+
break;
620+
}
621+
588622
return 0;
589623
}
590624

@@ -716,6 +750,8 @@ static int tas2764_i2c_probe(struct i2c_client *client)
716750
if (!tas2764)
717751
return -ENOMEM;
718752

753+
tas2764->devid = (enum tas2764_devid)of_device_get_match_data(&client->dev);
754+
719755
tas2764->dev = &client->dev;
720756
tas2764->irq = client->irq;
721757
i2c_set_clientdata(client, tas2764);
@@ -752,7 +788,8 @@ MODULE_DEVICE_TABLE(i2c, tas2764_i2c_id);
752788

753789
#if defined(CONFIG_OF)
754790
static const struct of_device_id tas2764_of_match[] = {
755-
{ .compatible = "ti,tas2764" },
791+
{ .compatible = "ti,tas2764", .data = (void *)DEVID_TAS2764 },
792+
{ .compatible = "ti,sn012776", .data = (void *)DEVID_SN012776 },
756793
{},
757794
};
758795
MODULE_DEVICE_TABLE(of, tas2764_of_match);

sound/soc/codecs/tas2764.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define TAS2764_PWR_CTRL_ACTIVE 0x0
3030
#define TAS2764_PWR_CTRL_MUTE BIT(0)
3131
#define TAS2764_PWR_CTRL_SHUTDOWN BIT(1)
32+
#define TAS2764_PWR_CTRL_BOP_SRC BIT(7)
3233

3334
#define TAS2764_VSENSE_POWER_EN 3
3435
#define TAS2764_ISENSE_POWER_EN 4
@@ -116,4 +117,6 @@
116117
#define TAS2764_INT_CLK_CFG TAS2764_REG(0x0, 0x5c)
117118
#define TAS2764_INT_CLK_CFG_IRQZ_CLR BIT(2)
118119

120+
#define TAS2764_BOP_CFG0 TAS2764_REG(0X0, 0x1d)
121+
119122
#endif /* __TAS2764__ */

0 commit comments

Comments
 (0)