|
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>
|
|
23 | 24 |
|
24 | 25 | #include "tas2764.h"
|
25 | 26 |
|
| 27 | +enum tas2764_devid { |
| 28 | + DEVID_TAS2764 = 0, |
| 29 | + DEVID_SN012776 = 1 |
| 30 | +}; |
| 31 | + |
26 | 32 | struct tas2764_priv {
|
27 | 33 | struct snd_soc_component *component;
|
28 | 34 | struct gpio_desc *reset_gpio;
|
29 | 35 | struct gpio_desc *sdz_gpio;
|
30 | 36 | struct regmap *regmap;
|
31 | 37 | struct device *dev;
|
32 | 38 | int irq;
|
33 |
| - |
| 39 | + enum tas2764_devid devid; |
| 40 | + |
34 | 41 | int v_sense_slot;
|
35 | 42 | int i_sense_slot;
|
36 | 43 |
|
@@ -533,10 +540,16 @@ static struct snd_soc_dai_driver tas2764_dai_driver[] = {
|
533 | 540 | },
|
534 | 541 | };
|
535 | 542 |
|
| 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 | + |
536 | 549 | static int tas2764_codec_probe(struct snd_soc_component *component)
|
537 | 550 | {
|
538 | 551 | struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
|
539 |
| - int ret; |
| 552 | + int ret, i; |
540 | 553 |
|
541 | 554 | tas2764->component = component;
|
542 | 555 |
|
@@ -585,6 +598,27 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
|
585 | 598 | if (ret < 0)
|
586 | 599 | return ret;
|
587 | 600 |
|
| 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 | + |
588 | 622 | return 0;
|
589 | 623 | }
|
590 | 624 |
|
@@ -716,6 +750,8 @@ static int tas2764_i2c_probe(struct i2c_client *client)
|
716 | 750 | if (!tas2764)
|
717 | 751 | return -ENOMEM;
|
718 | 752 |
|
| 753 | + tas2764->devid = (enum tas2764_devid)of_device_get_match_data(&client->dev); |
| 754 | + |
719 | 755 | tas2764->dev = &client->dev;
|
720 | 756 | tas2764->irq = client->irq;
|
721 | 757 | i2c_set_clientdata(client, tas2764);
|
@@ -752,7 +788,8 @@ MODULE_DEVICE_TABLE(i2c, tas2764_i2c_id);
|
752 | 788 |
|
753 | 789 | #if defined(CONFIG_OF)
|
754 | 790 | 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 }, |
756 | 793 | {},
|
757 | 794 | };
|
758 | 795 | MODULE_DEVICE_TABLE(of, tas2764_of_match);
|
|
0 commit comments