Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <neal@gompa.dev>
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Link: https://patch.msgid.link/20250227-apple-codec-changes-v3-3-cbb130030acf@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Martin Povišer and committed by
Mark Brown
ad183929 ce923393

+43 -3
+40 -3
sound/soc/codecs/tas2764.c
··· 14 14 #include <linux/regulator/consumer.h> 15 15 #include <linux/regmap.h> 16 16 #include <linux/of.h> 17 + #include <linux/of_device.h> 17 18 #include <linux/slab.h> 18 19 #include <sound/soc.h> 19 20 #include <sound/pcm.h> ··· 24 23 25 24 #include "tas2764.h" 26 25 26 + enum tas2764_devid { 27 + DEVID_TAS2764 = 0, 28 + DEVID_SN012776 = 1 29 + }; 30 + 27 31 struct tas2764_priv { 28 32 struct snd_soc_component *component; 29 33 struct gpio_desc *reset_gpio; ··· 36 30 struct regmap *regmap; 37 31 struct device *dev; 38 32 int irq; 39 - 33 + enum tas2764_devid devid; 34 + 40 35 int v_sense_slot; 41 36 int i_sense_slot; 42 37 ··· 540 533 }, 541 534 }; 542 535 536 + static uint8_t sn012776_bop_presets[] = { 537 + 0x01, 0x32, 0x02, 0x22, 0x83, 0x2d, 0x80, 0x02, 0x06, 538 + 0x32, 0x46, 0x30, 0x02, 0x06, 0x38, 0x40, 0x30, 0x02, 539 + 0x06, 0x3e, 0x37, 0x30, 0xff, 0xe6 540 + }; 541 + 543 542 static int tas2764_codec_probe(struct snd_soc_component *component) 544 543 { 545 544 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); 546 - int ret; 545 + int ret, i; 547 546 548 547 tas2764->component = component; 549 548 ··· 597 584 TAS2764_TDM_CFG6_ISNS_ENABLE, 0); 598 585 if (ret < 0) 599 586 return ret; 587 + 588 + switch (tas2764->devid) { 589 + case DEVID_SN012776: 590 + ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL, 591 + TAS2764_PWR_CTRL_BOP_SRC, 592 + TAS2764_PWR_CTRL_BOP_SRC); 593 + if (ret < 0) 594 + return ret; 595 + 596 + for (i = 0; i < ARRAY_SIZE(sn012776_bop_presets); i++) { 597 + ret = snd_soc_component_write(component, 598 + TAS2764_BOP_CFG0 + i, 599 + sn012776_bop_presets[i]); 600 + 601 + if (ret < 0) 602 + return ret; 603 + } 604 + break; 605 + default: 606 + break; 607 + } 600 608 601 609 return 0; 602 610 } ··· 750 716 if (!tas2764) 751 717 return -ENOMEM; 752 718 719 + tas2764->devid = (enum tas2764_devid)of_device_get_match_data(&client->dev); 720 + 753 721 tas2764->dev = &client->dev; 754 722 tas2764->irq = client->irq; 755 723 i2c_set_clientdata(client, tas2764); ··· 788 752 789 753 #if defined(CONFIG_OF) 790 754 static const struct of_device_id tas2764_of_match[] = { 791 - { .compatible = "ti,tas2764" }, 755 + { .compatible = "ti,tas2764", .data = (void *)DEVID_TAS2764 }, 756 + { .compatible = "ti,sn012776", .data = (void *)DEVID_SN012776 }, 792 757 {}, 793 758 }; 794 759 MODULE_DEVICE_TABLE(of, tas2764_of_match);
+3
sound/soc/codecs/tas2764.h
··· 29 29 #define TAS2764_PWR_CTRL_ACTIVE 0x0 30 30 #define TAS2764_PWR_CTRL_MUTE BIT(0) 31 31 #define TAS2764_PWR_CTRL_SHUTDOWN BIT(1) 32 + #define TAS2764_PWR_CTRL_BOP_SRC BIT(7) 32 33 33 34 #define TAS2764_VSENSE_POWER_EN 3 34 35 #define TAS2764_ISENSE_POWER_EN 4 ··· 116 115 /* Clock/IRQ Settings */ 117 116 #define TAS2764_INT_CLK_CFG TAS2764_REG(0x0, 0x5c) 118 117 #define TAS2764_INT_CLK_CFG_IRQZ_CLR BIT(2) 118 + 119 + #define TAS2764_BOP_CFG0 TAS2764_REG(0X0, 0x1d) 119 120 120 121 #endif /* __TAS2764__ */