mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 12:17:12 +09:00
rk3368 codec : add support for codec es8316
Signed-off-by: smj <smj@rock-chips.com>
This commit is contained in:
@@ -43,6 +43,7 @@ config SND_SOC_ALL_CODECS
|
||||
select SND_SOC_DFBMCS320
|
||||
select SND_SOC_ISABELLE if I2C
|
||||
select SND_SOC_ES8323 if SND_SOC_I2C_AND_SPI
|
||||
select SND_SOC_ES8316 if I2C
|
||||
select SND_SOC_ES8323_PCM if SND_SOC_I2C_AND_SPI
|
||||
select SND_SOC_JZ4740_CODEC
|
||||
select SND_SOC_LM4857 if I2C
|
||||
@@ -290,6 +291,9 @@ config SND_SOC_DMIC
|
||||
config SND_SOC_ES8323
|
||||
tristate
|
||||
|
||||
config SND_SOC_ES8316
|
||||
tristate
|
||||
|
||||
config SND_SOC_ISABELLE
|
||||
tristate
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ snd-soc-dfbmcs320-objs := dfbmcs320.o
|
||||
snd-soc-jz4740-codec-objs := jz4740.o
|
||||
snd-soc-dmic-objs := dmic.o
|
||||
snd-soc-es8323-objs := es8323.o
|
||||
snd-soc-es8316-objs := es8316.o
|
||||
snd-soc-es8323-pcm-objs := es8323_pcm.o
|
||||
snd-soc-isabelle-objs := isabelle.o
|
||||
snd-soc-l3-objs := l3.o
|
||||
@@ -183,6 +184,7 @@ obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
|
||||
obj-$(CONFIG_SND_SOC_DFBMCS320) += snd-soc-dfbmcs320.o
|
||||
obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
|
||||
obj-$(CONFIG_SND_SOC_ES8323) += snd-soc-es8323.o
|
||||
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
|
||||
obj-$(CONFIG_SND_SOC_ES8323_PCM) += snd-soc-es8323-pcm.o
|
||||
obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o
|
||||
obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o
|
||||
|
||||
1197
sound/soc/codecs/es8316.c
Normal file
1197
sound/soc/codecs/es8316.c
Normal file
File diff suppressed because it is too large
Load Diff
117
sound/soc/codecs/es8316.h
Normal file
117
sound/soc/codecs/es8316.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright Everest Semiconductor Co.,Ltd
|
||||
*
|
||||
* Author: David Yang <yangxiaohua@everest-semi.com>
|
||||
*
|
||||
* Based on ES8323.h
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ES8316_H
|
||||
#define _ES8316_H
|
||||
|
||||
/* ES8316 register space */
|
||||
/*
|
||||
* RESET Control
|
||||
*/
|
||||
#define ES8316_RESET_REG00 0x00
|
||||
/*
|
||||
* Clock Managerment
|
||||
*/
|
||||
#define ES8316_CLKMGR_CLKSW_REG01 0x01
|
||||
#define ES8316_CLKMGR_CLKSEL_REG02 0x02
|
||||
#define ES8316_CLKMGR_ADCOSR_REG03 0x03
|
||||
#define ES8316_CLKMGR_ADCDIV1_REG04 0x04
|
||||
#define ES8316_CLKMGR_ADCDIV2_REG05 0x05
|
||||
#define ES8316_CLKMGR_DACDIV1_REG06 0x06
|
||||
#define ES8316_CLKMGR_DACDIV2_REG07 0x07
|
||||
#define ES8316_CLKMGR_CPDIV_REG08 0x08
|
||||
/*
|
||||
* SDP Control
|
||||
*/
|
||||
#define ES8316_SDP_MS_BCKDIV_REG09 0x09
|
||||
#define ES8316_SDP_ADCFMT_REG0A 0x0a
|
||||
#define ES8316_SDP_DACFMT_REG0B 0x0b
|
||||
/*
|
||||
* System Control
|
||||
*/
|
||||
#define ES8316_SYS_VMIDSEL_REG0C 0x0c
|
||||
#define ES8316_SYS_PDN_REG0D 0x0d
|
||||
#define ES8316_SYS_LP1_REG0E 0x0e
|
||||
#define ES8316_SYS_LP2_REG0F 0x0f
|
||||
#define ES8316_SYS_VMIDLOW_REG10 0x10
|
||||
#define ES8316_SYS_VSEL_REG11 0x11
|
||||
#define ES8316_SYS_REF_REG12 0x12
|
||||
/*
|
||||
* HP Mixer
|
||||
*/
|
||||
#define ES8316_HPMIX_SEL_REG13 0x13
|
||||
#define ES8316_HPMIX_SWITCH_REG14 0x14
|
||||
#define ES8316_HPMIX_PDN_REG15 0x15
|
||||
#define ES8316_HPMIX_VOL_REG16 0x16
|
||||
/*
|
||||
* Charge Pump Headphone driver
|
||||
*/
|
||||
#define ES8316_CPHP_OUTEN_REG17 0x17
|
||||
#define ES8316_CPHP_ICAL_VOL_REG18 0x18
|
||||
#define ES8316_CPHP_PDN1_REG19 0x19
|
||||
#define ES8316_CPHP_PDN2_REG1A 0x1a
|
||||
#define ES8316_CPHP_LDOCTL_REG1B 0x1b
|
||||
/*
|
||||
* Calibration
|
||||
*/
|
||||
#define ES8316_CAL_TYPE_REG1C 0x1c
|
||||
#define ES8316_CAL_SET_REG1D 0x1d
|
||||
#define ES8316_CAL_HPLIV_REG1E 0x1e
|
||||
#define ES8316_CAL_HPRIV_REG1F 0x1f
|
||||
#define ES8316_CAL_HPLMV_REG20 0x20
|
||||
#define ES8316_CAL_HPRMV_REG21 0x21
|
||||
/*
|
||||
* ADC Control
|
||||
*/
|
||||
#define ES8316_ADC_PDN_LINSEL_REG22 0x22
|
||||
#define ES8316_ADC_PGAGAIN_REG23 0x23
|
||||
#define ES8316_ADC_D2SEPGA_REG24 0x24
|
||||
#define ES8316_ADC_DMIC_REG25 0x25
|
||||
#define ES8316_ADC_MUTE_REG26 0x26
|
||||
#define ES8316_ADC_VOLUME_REG27 0x27
|
||||
#define ES8316_ADC_ALC1_REG29 0x29
|
||||
#define ES8316_ADC_ALC2_REG2A 0x2a
|
||||
#define ES8316_ADC_ALC3_REG2B 0x2b
|
||||
#define ES8316_ADC_ALC4_REG2C 0x2c
|
||||
#define ES8316_ADC_ALC5_REG2D 0x2d
|
||||
#define ES8316_ADC_ALC6_REG2E 0x2e
|
||||
/*
|
||||
* DAC Control
|
||||
*/
|
||||
#define ES8316_DAC_PDN_REG2F 0x2f
|
||||
#define ES8316_DAC_SET1_REG30 0x30
|
||||
#define ES8316_DAC_SET2_REG31 0x31
|
||||
#define ES8316_DAC_SET3_REG32 0x32
|
||||
#define ES8316_DAC_VOLL_REG33 0x33
|
||||
#define ES8316_DAC_VOLR_REG34 0x34
|
||||
/*
|
||||
* GPIO
|
||||
*/
|
||||
#define ES8316_GPIO_SEL_REG4D 0x4D
|
||||
#define ES8316_GPIO_DEBUNCE_INT_REG4E 0x4E
|
||||
#define ES8316_GPIO_FLAG 0x4F
|
||||
/*
|
||||
* TEST MODE
|
||||
*/
|
||||
#define ES8316_TESTMODE_REG50 0x50
|
||||
#define ES8316_TEST1_REG51 0x51
|
||||
#define ES8316_TEST2_REG52 0x52
|
||||
#define ES8316_TEST3_REG53 0x53
|
||||
|
||||
#define ES8316_IFACE ES8316_SDP_MS_BCKDIV_REG09
|
||||
#define ES8316_ADC_IFACE ES8316_SDP_ADCFMT_REG0A
|
||||
#define ES8316_DAC_IFACE ES8316_SDP_DACFMT_REG0B
|
||||
|
||||
#define ES8316_REGNUM 84
|
||||
|
||||
#endif
|
||||
@@ -59,6 +59,15 @@ config SND_RK_SOC_ES8323
|
||||
Say Y if you want to add support for SoC audio on rockchip
|
||||
with the ES8323.
|
||||
|
||||
config SND_RK_SOC_ES8316
|
||||
tristate "SoC I2S Audio support for rockchip - ES8316"
|
||||
depends on SND_RK_SOC
|
||||
select SND_RK_SOC_I2S
|
||||
select SND_SOC_ES8316
|
||||
help
|
||||
Say Y if you want to add support for SoC audio on rockchip
|
||||
with the ES8316.
|
||||
|
||||
config SND_SOC_ES8323_PCM
|
||||
tristate "SoC I2S Audio support for rockchip - ES8323 for PCM modem"
|
||||
depends on SND_RK_SOC
|
||||
|
||||
@@ -35,6 +35,7 @@ snd-soc-rk616-objs := rk_rk616.o
|
||||
snd-soc-aic3262-objs := rk_aic3262.o
|
||||
snd-soc-rk2928-objs := rk2928-card.o
|
||||
snd-soc-es8323-objs := rk_es8323.o
|
||||
snd-soc-es8316-objs := rk_es8316.o
|
||||
snd-soc-rk3026-objs := rk_rk3026.o
|
||||
snd-soc-rk3190-objs := rk_rk3190.o
|
||||
snd-soc-spdif-card-objs := rk_spdif_card.o
|
||||
@@ -67,6 +68,7 @@ obj-$(CONFIG_SND_RK_SOC_RK610) += snd-soc-rk610.o
|
||||
obj-$(CONFIG_SND_RK_SOC_RK616) += snd-soc-rk616.o
|
||||
obj-$(CONFIG_SND_RK_SOC_RK2928) += snd-soc-rk2928.o
|
||||
obj-$(CONFIG_SND_RK_SOC_ES8323) += snd-soc-es8323.o
|
||||
obj-$(CONFIG_SND_RK_SOC_ES8316) += snd-soc-es8316.o
|
||||
obj-$(CONFIG_SND_RK_SOC_RK3026) += snd-soc-rk3026.o
|
||||
obj-$(CONFIG_SND_RK_SOC_RK3190) += snd-soc-rk3190.o
|
||||
obj-$(CONFIG_SND_RK_SOC_RT5512) += snd-soc-rt5512.o
|
||||
|
||||
203
sound/soc/rockchip/rk_es8316.c
Normal file
203
sound/soc/rockchip/rk_es8316.c
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* rk29_es8316.c -- SoC audio for rockchip
|
||||
*
|
||||
* Driver for rockchip es8316 audio
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
|
||||
#include "../codecs/es8316.h"
|
||||
#include "card_info.h"
|
||||
#include "rk_pcm.h"
|
||||
#include "rk_i2s.h"
|
||||
|
||||
|
||||
#ifdef CONFIG_MACH_RK_FAC
|
||||
#include <plat/config.h>
|
||||
/*extern int codec_type;*/
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#define DBG(x...) printk(x)
|
||||
#else
|
||||
#define DBG(x...)
|
||||
#endif
|
||||
|
||||
static int rk29_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
unsigned int pll_out = 0, dai_fmt = rtd->card->dai_link->dai_fmt;
|
||||
int ret;
|
||||
|
||||
DBG("Enter::%s----%d\n", __func__, __LINE__);
|
||||
|
||||
/* set codec DAI configuration */
|
||||
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
|
||||
if (ret < 0) {
|
||||
DBG("%s():failed to set the format for codec side\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* set cpu DAI configuration */
|
||||
ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
|
||||
if (ret < 0) {
|
||||
DBG("%s():failed to set the format for cpu side\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (params_rate(params)) {
|
||||
case 8000:
|
||||
case 16000:
|
||||
case 24000:
|
||||
case 32000:
|
||||
case 48000:
|
||||
pll_out = 12288000;
|
||||
break;
|
||||
case 11025:
|
||||
case 22050:
|
||||
case 44100:
|
||||
pll_out = 11289600;
|
||||
break;
|
||||
default:
|
||||
DBG("Enter:%s, %d, Error rate=%d\n",
|
||||
__func__, __LINE__, params_rate(params));
|
||||
return -EINVAL;
|
||||
}
|
||||
DBG("Enter:%s, %d, rate=%d\n", __func__, __LINE__, params_rate(params));
|
||||
|
||||
if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
|
||||
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,
|
||||
(pll_out/4)/params_rate(params)-1);
|
||||
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
|
||||
}
|
||||
|
||||
DBG("Enter:%s, %d, LRCK=%d\n", __func__, __LINE__,
|
||||
(pll_out/4)/params_rate(params));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget rk29_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_LINE("Audio Out", NULL),
|
||||
SND_SOC_DAPM_MIC("Micn", NULL),
|
||||
SND_SOC_DAPM_MIC("Micp", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route audio_map[] = {
|
||||
{"Audio Out", NULL, "LOUT1"},
|
||||
{"Audio Out", NULL, "ROUT1"},
|
||||
{"Micn", NULL, "RINPUT1"},
|
||||
{"Micp", NULL, "LINPUT1"},
|
||||
};
|
||||
|
||||
/*
|
||||
* Logic for a es8316 as connected on a rockchip board.
|
||||
*/
|
||||
static int rk29_es8316_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
int ret;
|
||||
|
||||
DBG("Enter::%s----%d\n", __func__, __LINE__);
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, 0,
|
||||
11289600, SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
DBG(KERN_ERR "Failed to set es8316 SYSCLK: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_ops rk29_ops = {
|
||||
.hw_params = rk29_hw_params,
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_link rk29_dai = {
|
||||
.name = "ES8316",
|
||||
.stream_name = "ES8316 PCM",
|
||||
.codec_name = "ES8316.v01a",
|
||||
.platform_name = "rockchip-audio",
|
||||
.cpu_dai_name = "rk29_i2s.0",
|
||||
.codec_dai_name = "ES8316 HiFi",
|
||||
.init = rk29_es8316_init,
|
||||
.ops = &rk29_ops,
|
||||
};
|
||||
|
||||
static struct snd_soc_card rockchip_es8316_snd_card = {
|
||||
.name = "RK_ES8316",
|
||||
.dai_link = &rk29_dai,
|
||||
.num_links = 1,
|
||||
};
|
||||
|
||||
static int rockchip_es8316_audio_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_card *card = &rockchip_es8316_snd_card;
|
||||
|
||||
card->dev = &pdev->dev;
|
||||
|
||||
ret = rockchip_of_get_sound_card_info(card);
|
||||
if (ret) {
|
||||
DBG("%s() get sound card info failed:%d\n", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_register_card(card);
|
||||
if (ret)
|
||||
DBG("%s() register card failed:%d\n", __func__, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rockchip_es8316_audio_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||
|
||||
snd_soc_unregister_card(card);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id rockchip_es8316_of_match[] = {
|
||||
{ .compatible = "rockchip-es8316", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rockchip_es8316_of_match);
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static struct platform_driver rockchip_es8316_audio_driver = {
|
||||
.driver = {
|
||||
.name = "rockchip-es8316",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &snd_soc_pm_ops,
|
||||
.of_match_table = of_match_ptr(rockchip_es8316_of_match),
|
||||
},
|
||||
.probe = rockchip_es8316_audio_probe,
|
||||
.remove = rockchip_es8316_audio_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(rockchip_es8316_audio_driver);
|
||||
|
||||
/* Module information */
|
||||
MODULE_AUTHOR("rockchip");
|
||||
MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
Reference in New Issue
Block a user