aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/rt5677.h45
-rw-r--r--sound/soc/codecs/rt5677.c80
-rw-r--r--sound/soc/codecs/rt5677.h30
3 files changed, 67 insertions, 88 deletions
diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h
deleted file mode 100644
index a6207043ac3c..000000000000
--- a/include/sound/rt5677.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * linux/sound/rt5677.h -- Platform data for RT5677
3 *
4 * Copyright 2013 Realtek Semiconductor Corp.
5 * Author: Oder Chiou <oder_chiou@realtek.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __LINUX_SND_RT5677_H
13#define __LINUX_SND_RT5677_H
14
15enum rt5677_dmic2_clk {
16 RT5677_DMIC_CLK1 = 0,
17 RT5677_DMIC_CLK2 = 1,
18};
19
20
21struct rt5677_platform_data {
22 /* IN1/IN2/LOUT1/LOUT2/LOUT3 can optionally be differential */
23 bool in1_diff;
24 bool in2_diff;
25 bool lout1_diff;
26 bool lout2_diff;
27 bool lout3_diff;
28 /* DMIC2 clock source selection */
29 enum rt5677_dmic2_clk dmic2_clk_pin;
30
31 /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */
32 u8 gpio_config[6];
33
34 /* jd1 can select 0 ~ 3 as OFF, GPIO1, GPIO2 and GPIO3 respectively */
35 unsigned int jd1_gpio;
36 /* jd2 and jd3 can select 0 ~ 3 as
37 OFF, GPIO4, GPIO5 and GPIO6 respectively */
38 unsigned int jd2_gpio;
39 unsigned int jd3_gpio;
40
41 /* Set MICBIAS1 VDD 1v8 or 3v3 */
42 bool micbias1_vdd_3v3;
43};
44
45#endif
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 6f629278d982..9875c8d05b5c 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/firmware.h> 23#include <linux/firmware.h>
24#include <linux/of_device.h>
24#include <linux/property.h> 25#include <linux/property.h>
25#include <sound/core.h> 26#include <sound/core.h>
26#include <sound/pcm.h> 27#include <sound/pcm.h>
@@ -779,9 +780,7 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
779 return 0; 780 return 0;
780} 781}
781 782
782static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
783static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0); 783static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
784static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
785static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0); 784static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
786static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 785static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
787static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0); 786static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
@@ -4624,35 +4623,27 @@ static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset)
4624 struct regmap_irq_chip_data *data = rt5677->irq_data; 4623 struct regmap_irq_chip_data *data = rt5677->irq_data;
4625 int irq; 4624 int irq;
4626 4625
4627 if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) { 4626 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) ||
4628 if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || 4627 (rt5677->pdata.jd1_gpio == 2 &&
4629 (rt5677->pdata.jd1_gpio == 2 && 4628 offset == RT5677_GPIO2) ||
4630 offset == RT5677_GPIO2) || 4629 (rt5677->pdata.jd1_gpio == 3 &&
4631 (rt5677->pdata.jd1_gpio == 3 && 4630 offset == RT5677_GPIO3)) {
4632 offset == RT5677_GPIO3)) { 4631 irq = RT5677_IRQ_JD1;
4633 irq = RT5677_IRQ_JD1; 4632 } else if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) ||
4634 } else { 4633 (rt5677->pdata.jd2_gpio == 2 &&
4635 return -ENXIO; 4634 offset == RT5677_GPIO5) ||
4636 } 4635 (rt5677->pdata.jd2_gpio == 3 &&
4637 } 4636 offset == RT5677_GPIO6)) {
4638 4637 irq = RT5677_IRQ_JD2;
4639 if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) { 4638 } else if ((rt5677->pdata.jd3_gpio == 1 &&
4640 if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) || 4639 offset == RT5677_GPIO4) ||
4641 (rt5677->pdata.jd2_gpio == 2 && 4640 (rt5677->pdata.jd3_gpio == 2 &&
4642 offset == RT5677_GPIO5) || 4641 offset == RT5677_GPIO5) ||
4643 (rt5677->pdata.jd2_gpio == 3 && 4642 (rt5677->pdata.jd3_gpio == 3 &&
4644 offset == RT5677_GPIO6)) { 4643 offset == RT5677_GPIO6)) {
4645 irq = RT5677_IRQ_JD2; 4644 irq = RT5677_IRQ_JD3;
4646 } else if ((rt5677->pdata.jd3_gpio == 1 && 4645 } else {
4647 offset == RT5677_GPIO4) || 4646 return -ENXIO;
4648 (rt5677->pdata.jd3_gpio == 2 &&
4649 offset == RT5677_GPIO5) ||
4650 (rt5677->pdata.jd3_gpio == 3 &&
4651 offset == RT5677_GPIO6)) {
4652 irq = RT5677_IRQ_JD3;
4653 } else {
4654 return -ENXIO;
4655 }
4656 } 4647 }
4657 4648
4658 return regmap_irq_get_virq(data, irq); 4649 return regmap_irq_get_virq(data, irq);
@@ -5021,24 +5012,21 @@ static const struct regmap_config rt5677_regmap = {
5021static const struct i2c_device_id rt5677_i2c_id[] = { 5012static const struct i2c_device_id rt5677_i2c_id[] = {
5022 { "rt5677", RT5677 }, 5013 { "rt5677", RT5677 },
5023 { "rt5676", RT5676 }, 5014 { "rt5676", RT5676 },
5024 { "RT5677CE:00", RT5677 },
5025 { } 5015 { }
5026}; 5016};
5027MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 5017MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
5028 5018
5029static const struct of_device_id rt5677_of_match[] = { 5019static const struct of_device_id rt5677_of_match[] = {
5030 { .compatible = "realtek,rt5677", }, 5020 { .compatible = "realtek,rt5677", RT5677 },
5031 { } 5021 { }
5032}; 5022};
5033MODULE_DEVICE_TABLE(of, rt5677_of_match); 5023MODULE_DEVICE_TABLE(of, rt5677_of_match);
5034 5024
5035#ifdef CONFIG_ACPI
5036static const struct acpi_device_id rt5677_acpi_match[] = { 5025static const struct acpi_device_id rt5677_acpi_match[] = {
5037 { "RT5677CE", RT5677 }, 5026 { "RT5677CE", RT5677 },
5038 { } 5027 { }
5039}; 5028};
5040MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); 5029MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match);
5041#endif
5042 5030
5043static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677, 5031static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677,
5044 struct device *dev) 5032 struct device *dev)
@@ -5148,7 +5136,6 @@ static void rt5677_free_irq(struct i2c_client *i2c)
5148static int rt5677_i2c_probe(struct i2c_client *i2c, 5136static int rt5677_i2c_probe(struct i2c_client *i2c,
5149 const struct i2c_device_id *id) 5137 const struct i2c_device_id *id)
5150{ 5138{
5151 struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev);
5152 struct rt5677_priv *rt5677; 5139 struct rt5677_priv *rt5677;
5153 int ret; 5140 int ret;
5154 unsigned int val; 5141 unsigned int val;
@@ -5160,16 +5147,25 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
5160 5147
5161 i2c_set_clientdata(i2c, rt5677); 5148 i2c_set_clientdata(i2c, rt5677);
5162 5149
5163 rt5677->type = id->driver_data; 5150 if (i2c->dev.of_node) {
5151 const struct of_device_id *match_id;
5152
5153 match_id = of_match_device(rt5677_of_match, &i2c->dev);
5154 if (match_id)
5155 rt5677->type = (enum rt5677_type)match_id->data;
5164 5156
5165 if (pdata)
5166 rt5677->pdata = *pdata;
5167 else if (i2c->dev.of_node)
5168 rt5677_read_device_properties(rt5677, &i2c->dev); 5157 rt5677_read_device_properties(rt5677, &i2c->dev);
5169 else if (ACPI_HANDLE(&i2c->dev)) 5158 } else if (ACPI_HANDLE(&i2c->dev)) {
5159 const struct acpi_device_id *acpi_id;
5160
5161 acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev);
5162 if (acpi_id)
5163 rt5677->type = (enum rt5677_type)acpi_id->driver_data;
5164
5170 rt5677_read_acpi_properties(rt5677, &i2c->dev); 5165 rt5677_read_acpi_properties(rt5677, &i2c->dev);
5171 else 5166 } else {
5172 return -EINVAL; 5167 return -EINVAL;
5168 }
5173 5169
5174 /* pow-ldo2 and reset are optional. The codec pins may be statically 5170 /* pow-ldo2 and reset are optional. The codec pins may be statically
5175 * connected on the board without gpios. If the gpio device property 5171 * connected on the board without gpios. If the gpio device property
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h
index d46855a42c40..97239973edc4 100644
--- a/sound/soc/codecs/rt5677.h
+++ b/sound/soc/codecs/rt5677.h
@@ -12,7 +12,6 @@
12#ifndef __RT5677_H__ 12#ifndef __RT5677_H__
13#define __RT5677_H__ 13#define __RT5677_H__
14 14
15#include <sound/rt5677.h>
16#include <linux/gpio/driver.h> 15#include <linux/gpio/driver.h>
17#include <linux/gpio/consumer.h> 16#include <linux/gpio/consumer.h>
18 17
@@ -1761,6 +1760,35 @@ enum {
1761 RT5677_I2S4_SOURCE = (0x1 << 18), 1760 RT5677_I2S4_SOURCE = (0x1 << 18),
1762}; 1761};
1763 1762
1763enum rt5677_dmic2_clk {
1764 RT5677_DMIC_CLK1 = 0,
1765 RT5677_DMIC_CLK2 = 1,
1766};
1767
1768struct rt5677_platform_data {
1769 /* IN1/IN2/LOUT1/LOUT2/LOUT3 can optionally be differential */
1770 bool in1_diff;
1771 bool in2_diff;
1772 bool lout1_diff;
1773 bool lout2_diff;
1774 bool lout3_diff;
1775 /* DMIC2 clock source selection */
1776 enum rt5677_dmic2_clk dmic2_clk_pin;
1777
1778 /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */
1779 u8 gpio_config[6];
1780
1781 /* jd1 can select 0 ~ 3 as OFF, GPIO1, GPIO2 and GPIO3 respectively */
1782 unsigned int jd1_gpio;
1783 /* jd2 and jd3 can select 0 ~ 3 as
1784 OFF, GPIO4, GPIO5 and GPIO6 respectively */
1785 unsigned int jd2_gpio;
1786 unsigned int jd3_gpio;
1787
1788 /* Set MICBIAS1 VDD 1v8 or 3v3 */
1789 bool micbias1_vdd_3v3;
1790};
1791
1764struct rt5677_priv { 1792struct rt5677_priv {
1765 struct snd_soc_codec *codec; 1793 struct snd_soc_codec *codec;
1766 struct rt5677_platform_data pdata; 1794 struct rt5677_platform_data pdata;